OOFEM 3.0
Loading...
Searching...
No Matches
oofeggraphiccontext.C
Go to the documentation of this file.
1/*
2 *
3 * ##### ##### ###### ###### ### ###
4 * ## ## ## ## ## ## ## ### ##
5 * ## ## ## ## #### #### ## # ##
6 * ## ## ## ## ## ## ## ##
7 * ## ## ## ## ## ## ## ##
8 * ##### ##### ## ###### ## ##
9 *
10 *
11 * OOFEM : Object Oriented Finite Element Code
12 *
13 * Copyright (C) 1993 - 2025 Borek Patzak
14 *
15 *
16 *
17 * Czech Technical University, Faculty of Civil Engineering,
18 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
35#include "oofeggraphiccontext.h"
36#include "engngm.h"
37#include "element.h"
38#include "material.h"
39#include "range.h"
40#include "mathfem.h"
41#include "oofemtxtinputrecord.h"
42// for Range class definition outputmanager.h included
43#include "outputmanager.h"
44
45namespace oofem {
46EngngModel *oofegGraphicContext :: emodel = NULL;
47EFringeTable oofegGraphicContext :: ft;
48EPixel oofegGraphicContext :: meshFillColor;
49EPixel oofegGraphicContext :: remoteMeshFillColor;
50EPixel oofegGraphicContext :: edgeColor;
51EPixel oofegGraphicContext :: remoteEdgeColor;
52EPixel oofegGraphicContext :: nodeColor;
53EPixel oofegGraphicContext :: bcicColor;
54EPixel oofegGraphicContext :: bcForceColor;
55EPixel oofegGraphicContext :: deformedElementColor;
56EPixel oofegGraphicContext :: crackPatternColor;
57EPixel oofegGraphicContext :: activeCrackColor;
58EPixel oofegGraphicContext :: yieldPlotColors [ OOFEG_YIELD_STEPS ];
59EPixel oofegGraphicContext :: crossSectionColor;
60EPixel oofegGraphicContext :: standardSparseProfileColor, oofegGraphicContext :: extendedSparseProfileColor;
61EPixel oofegGraphicContext :: geometryColor;
62int oofegGraphicContext :: activeStep = -1;
63int oofegGraphicContext :: activeStepVersion = 0;
64double oofegGraphicContext :: defScale = 1.0;
65double oofegGraphicContext :: zprofilescale = 0.0;
66int oofegGraphicContext :: activeEigVal = 1;
67int oofegGraphicContext :: activeYieldStep;
68IntArray oofegGraphicContext :: matRegFilter;
69std :: list< Range > oofegGraphicContext :: element_filter;
70SmootherType oofegGraphicContext :: smootherType;
71ScalarAlgorithmType oofegGraphicContext :: scalarAlgo = SA_ISO_SURF;
72int oofegGraphicContext :: intVarDefGeoFlag = 0;
73int oofegGraphicContext :: sparseProfileMode;
74int oofegGraphicContext :: activeProblem = 0;
75int oofegGraphicContext :: activeDomain = 0;
76ScaleMode oofegGraphicContext :: smode;
77double oofegGraphicContext :: emin, oofegGraphicContext :: emax;
78int oofegGraphicContext :: scaleInitFlag;
79
80InternalStateMode oofegGraphicContext :: varMode = ISM_recovered;
81bool oofegGraphicContext :: staticVarsInitFlag = 0;
82
83
84oofegGraphicContext :: oofegGraphicContext()
85{
86 isActiveFlag = false;
88}
89
90
91void
92oofegGraphicContext :: init(EngngModel *d)
93{
94 if ( staticVarsInitFlag == 0 ) {
95 BOOLEAN suc;
96 int i, nmat;
97
98 emodel = d;
99 meshFillColor = ColorGetPixelFromString(const_cast< char * >("black"), & suc);
100 remoteMeshFillColor = ColorGetPixelFromString(const_cast< char * >("DarkGray"), & suc);
101 edgeColor = ColorGetPixelFromString(const_cast< char * >("black"), & suc);
102 edgeColor = ColorGetPixelFromString(const_cast< char * >("DarkGray"), & suc);
103 deformedElementColor = ColorGetPixelFromString(const_cast< char * >("BlueViolet"), & suc);
104 nodeColor = ColorGetPixelFromString(const_cast< char * >("black"), & suc);
105 bcicColor = ColorGetPixelFromString(const_cast< char * >("orange"), & suc);
106 bcForceColor = ColorGetPixelFromString(const_cast< char * >("red"), & suc);
107 crackPatternColor = ColorGetPixelFromString(const_cast< char * >("gray66"), & suc);
108 activeCrackColor = ColorGetPixelFromString(const_cast< char * >("red2"), & suc);
109 standardSparseProfileColor = ColorGetPixelFromString(const_cast< char * >("blue"), & suc);
110 extendedSparseProfileColor = ColorGetPixelFromString(const_cast< char * >("red"), & suc);
111 geometryColor = ColorGetPixelFromString(const_cast< char * >("yellow"), & suc);
112
113 yieldPlotColors [ 0 ] = ColorGetPixelFromString(const_cast< char * >("pink"), & suc);
114 yieldPlotColors [ 1 ] = ColorGetPixelFromString(const_cast< char * >("PaleVioletRed"), & suc);
115 yieldPlotColors [ 2 ] = ColorGetPixelFromString(const_cast< char * >("maroon"), & suc);
116
117 crossSectionColor = ColorGetPixelFromString(const_cast< char * >("blue"), & suc);
118
119 activeDomain = 1;
120
121 ft = ColorCreateFringeTable();
122
123 nmat = 0;
124 for ( int id = 1; id <= d->giveNumberOfDomains(); id++ ) {
125 nmat = max( nmat, d->giveDomain(id)->giveNumberOfRegions() );
126 }
127
128 // ft = ColorCreateFringeTable();
129 matRegFilter.resize(nmat);
130 for ( i = 1; i <= nmat; i++ ) {
131 matRegFilter.at(i) = 1;
132 }
133
135 }
136}
137
138oofegGraphicContext :: ~oofegGraphicContext()
139{ }
140
141EPixel
142oofegGraphicContext :: GR_giveColorFromUserColorTable(EPixel *table, int tableSize, double relVal)
143{
144 //
145 // returns color from given color table of size tableSize,
146 // relVal is relative number (0..1) saying which color to return
147 //
148 if ( relVal > 1 ) {
149 relVal = 1.;
150 }
151
152 if ( relVal < 0 ) {
153 relVal = 0.;
154 }
155
156 int indx = ( int ) floor(relVal * tableSize + 0.5);
157 return table [ indx - 1 ];
158}
159
160int
161oofegGraphicContext :: testElementGraphicActivity(Element *e)
162{
163 int matFilterState = ( this->getMaterialModelFilterState( e->giveRegionNumber() ) );
164 int elemFiltState = 0;
165 if ( element_filter.empty() ) {
166 return matFilterState;
167 } else {
168 for ( Range &range: this->element_filter ) {
169 if ( range.test( e->giveNumber() ) ) {
170 elemFiltState = 1;
171 break;
172 }
173 }
174
175 return ( matFilterState && elemFiltState );
176 }
177}
178
179int
180oofegGraphicContext :: getMaterialModelFilterState(int i)
181{
182 if ( ( i <= 0 ) || ( i > matRegFilter.giveSize() ) ) {
183 return 0;
184 }
185
186 return matRegFilter.at(i);
187}
188
189void
190oofegGraphicContext :: setMaterialModelFilterState(int i, int state)
191{
192 if ( ( i <= 0 ) || ( i > matRegFilter.giveSize() ) ) {
193 return;
194 }
195
196 matRegFilter.at(i) = state;
197}
198
199void
200oofegGraphicContext :: setElementFilterState(char *initString)
201{
202 OOFEMTXTInputRecord parser(0, std :: string(initString));
203 element_filter.clear();
204 parser.giveField(element_filter, "element_filter");
205}
206
207int
208oofegGraphicContext :: setActiveProblem(int a)
209{
210 EngngModel *slave = emodel->giveSlaveProblem(a);
211 int nmat = 0;
212 for ( int id = 1; id <= slave->giveNumberOfDomains(); id++ ) {
213 nmat = max( nmat, slave->giveDomain(id)->giveNumberOfMaterialModels() );
214 }
215
216 // ft = ColorCreateFringeTable();
217 matRegFilter.resize(nmat);
218 for ( int i = 1; i <= nmat; i++ ) {
219 matRegFilter.at(i) = 1;
220 }
221
222 activeProblem = a;
223 return a;
224}
225
227oofegGraphicContext :: getActiveProblem() {
228 if ( activeProblem ) {
229 return emodel->giveSlaveProblem(activeProblem);
230 } else {
231 return emodel;
232 }
233}
234
235
236void
237oofegGraphicContext :: updateFringeTableMinMax(double *s, int size)
238{
239 if ( this->getScaleMode() == SM_Autoscale ) {
240 double smin = this->getScaleMin();
241 double smax = this->getScaleMax();
242
243 for ( int i = 0; i < size; i++ ) {
244 if ( scaleInitFlag ) {
245 smin = smax = s [ i ];
246 scaleInitFlag = 0;
247 } else {
248 if ( smax < s [ i ] ) {
249 smax = s [ i ];
250 }
251
252 if ( smin > s [ i ] ) {
253 smin = s [ i ];
254 }
255 }
256 }
257
258 setScaleVals(smin, smax);
259 if ( fabs(smax - smin) < 1.e-12 ) {
260 smax += 1.e-12;
261 }
262
263 ColorSetupFringeTableByMinMax(this->getFringeTable(), ( FPNum ) smin, ( FPNum ) smax);
264 }
265}
266} // end namespace oofem
int giveNumberOfMaterialModels() const
Returns number of material models in domain.
Definition domain.h:465
int giveNumberOfRegions() const
Returns number of regions. Currently regions corresponds to cross section models.
Definition domain.h:475
int giveRegionNumber()
Definition element.C:546
int giveNumberOfDomains()
Returns number of domains in problem.
Definition engngm.h:365
Domain * giveDomain(int n)
Definition engngm.C:1936
int giveNumber() const
Definition femcmpnn.h:104
void giveField(int &answer, InputFieldType id) override
Reads the integer field value.
static EPixel yieldPlotColors[OOFEG_YIELD_STEPS]
static std ::list< Range > element_filter
void setScaleVals(double smin, double smax)
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
InternalStateMode
Determines the mode of internal variable.
#define OOFEG_YIELD_STEPS

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011