OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 2013 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 
45 namespace oofem {
46 EngngModel *oofegGraphicContext :: emodel = NULL;
47 EFringeTable oofegGraphicContext :: ft;
69 std :: list< Range > oofegGraphicContext :: element_filter;
79 
82 
83 
85 {
86  isActiveFlag = false;
88 }
89 
90 
91 void
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)->giveNumberOfMaterialModels() );
126  }
127 
128  // ft = ColorCreateFringeTable();
129  matRegFilter.resize(nmat);
130  for ( i = 1; i <= nmat; i++ ) {
131  matRegFilter.at(i) = 1;
132  }
133 
134  staticVarsInitFlag = 1;
135  }
136 }
137 
139 { }
140 
141 EPixel
142 oofegGraphicContext :: 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 
160 int
162 {
163  int matFilterState = ( this->getMaterialModelFilterState( e->giveMaterial()->giveNumber() ) );
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 
179 int
181 {
182  if ( ( i <= 0 ) || ( i > matRegFilter.giveSize() ) ) {
183  return 0;
184  }
185 
186  return matRegFilter.at(i);
187 }
188 
189 void
191 {
192  if ( ( i <= 0 ) || ( i > matRegFilter.giveSize() ) ) {
193  return;
194  }
195 
196  matRegFilter.at(i) = state;
197 }
198 
199 void
201 {
202  OOFEMTXTInputRecord parser(0, std :: string(initString));
203  element_filter.clear();
204  parser.giveField(element_filter, "element_filter");
205 }
206 
207 int
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 
226 EngngModel *
228  if ( activeProblem ) {
230  } else {
231  return emodel;
232  }
233 }
234 
235 
236 void
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
virtual EngngModel * giveSlaveProblem(int i)
Returns i-th slave problem.
Definition: engngm.h:1082
int getMaterialModelFilterState(int i)
Returns the state of material model (region) filter for particular mod.el.
int testElementGraphicActivity(Element *)
Test if particular element passed fulfills various filtering criteria for its graphics output...
int max(int i, int j)
Returns bigger value form two given decimals.
Definition: mathfem.h:71
void setMaterialModelFilterState(int i, int state)
Sets the state of material model (region) filter for particular model.
Abstract base class for all finite elements.
Definition: element.h:145
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
#define OOFEG_YIELD_STEPS
static std::list< Range > element_filter
static ScalarAlgorithmType scalarAlgo
Class Range is an abstraction for interval of integer numbers.
Definition: range.h:50
int giveNumberOfMaterialModels() const
Returns number of material models in domain.
Definition: domain.h:436
static SmootherType smootherType
static InternalStateMode varMode
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
Class representing the Input Record for OOFEM txt input file format.
void setScaleVals(double smin, double smax)
virtual IRResultType giveField(int &answer, InputFieldType id)
Reads the integer field value.
int giveNumberOfDomains()
Returns number of domains in problem.
Definition: engngm.h:342
void setElementFilterState(char *initString)
Sets the state of element filter for particular model.
void updateFringeTableMinMax(double *s, int size)
EPixel GR_giveColorFromUserColorTable(EPixel *table, int tableSize, double relVal)
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
int giveSize() const
Definition: intarray.h:203
static EPixel yieldPlotColors[OOFEG_YIELD_STEPS]
the oofem namespace is to define a context or scope in which all oofem names are defined.
Domain * giveDomain(int n)
Service for accessing particular problem domain.
Definition: engngm.C:1720
int giveNumber() const
Definition: femcmpnn.h:107
InternalStateMode
Determines the mode of internal variable.
virtual Material * giveMaterial()
Definition: element.C:484

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:30 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011