1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef MED_Structures_HeaderFile
24 #define MED_Structures_HeaderFile
26 #include "MED_WrapperDef.hxx"
27 #include "MED_Common.hxx"
28 #include "MED_Utilities.hxx"
31 #pragma warning(disable:4251)
36 //---------------------------------------------------------------
37 //! Defines a type for managing sequence of strings
38 typedef TVector<char> TString;
39 typedef SharedPtr<TString> PString;
41 //! Extract a substring from the sequence of the strings
44 GetString(TInt theId, TInt theStep,
45 const TString& theString);
47 //! Set a substring in the sequence of the strings
50 SetString(TInt theId, TInt theStep,
52 const std::string& theValue);
54 //! Set a substring in the sequence of the strings
57 SetString(TInt theId, TInt theStep,
59 const TString& theValue);
61 //---------------------------------------------------------------
62 //! Define a parent class for all MEDWrapper classes
63 struct MEDWRAPPER_EXPORT TBase
68 //---------------------------------------------------------------
69 //! Define a parent class for all named MED entities
70 struct MEDWRAPPER_EXPORT TNameInfo: virtual TBase
72 TString myName; //!< Keeps its name
73 virtual std::string GetName() const = 0; //!< Gets its name
74 virtual void SetName(const std::string& theValue) = 0; //!< Set a new name
75 virtual void SetName(const TString& theValue) = 0; //!< Set a new name
78 //---------------------------------------------------------------
79 //! Define a parent class for all MED entities that contains a sequence of numbers
81 It defines through corresponding enumeration (EModeSwitch) how the sequence
82 should be interpreted in C or Fortran mode (eFULL_INTERLACE or eNON_INTERLACE).
84 struct MEDWRAPPER_EXPORT TModeSwitchInfo: virtual TBase
86 //! To construct instance of the class by default
88 myModeSwitch(eFULL_INTERLACE)
91 //! To construct instance of the class
92 TModeSwitchInfo(EModeSwitch theModeSwitch):
93 myModeSwitch(theModeSwitch)
96 EModeSwitch myModeSwitch; //!< Keeps the
97 EModeSwitch GetModeSwitch() const { return myModeSwitch;}
100 //---------------------------------------------------------------
101 //! Define a base class which represents MED Mesh entity
102 struct MEDWRAPPER_EXPORT TMeshInfo: virtual TNameInfo
104 TInt myDim; //!< Dimension of the mesh (0, 1, 2 or 3)
105 TInt GetDim() const { return myDim;} //!< Gets dimension of the mesh
108 TInt GetSpaceDim() const { return mySpaceDim; }
110 EMaillage myType; //!< Type of the mesh
111 EMaillage GetType() const { return myType;} //!< Gets type of the mesh
113 TString myDesc; //!< Description of the mesh
114 virtual std::string GetDesc() const = 0; //!< Get description for the mesh
115 virtual void SetDesc(const std::string& theValue) = 0; //!< Sets description for the mesh
118 //---------------------------------------------------------------
119 typedef TVector<TInt> TIntVector;
120 typedef TSlice<TInt> TIntVecSlice;
121 typedef TCSlice<TInt> TCIntVecSlice;
123 typedef TIntVector TFamAttr;
125 //! Define a base class which represents MED Family entity
126 struct MEDWRAPPER_EXPORT TFamilyInfo: virtual TNameInfo
128 PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
129 //! Get a reference to corresponding MED Mesh
130 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
132 TInt myId; //!< An unique index of the MED FAMILY
133 TInt GetId() const { return myId;} //!< Gets number of the MED FAMILY
134 void SetId(TInt theId) { myId = theId;} //! Define number of the MED FAMILY
136 TInt myNbGroup; //!< Defines number MED Groups connected to
137 //! Gets number of MED GROUPS the MED FAMILY is bound to
138 TInt GetNbGroup() const { return myNbGroup;}
140 //! Contains sequence of the names for the MED Groups connected to
141 TString myGroupNames;
142 //! Gets name of a bound MED GROUP by its number
143 virtual std::string GetGroupName(TInt theId) const = 0;
144 //! Sets name of the defined MED GROUP by its number
145 virtual void SetGroupName(TInt theId, const std::string& theValue) = 0;
147 TInt myNbAttr; //!< Defines number of the MED Family attributes
148 //! Gets number of attached attributes for the MED FAMILY
149 TInt GetNbAttr() const { return myNbAttr;}
151 //! Defines sequence of the indexes of the MED Family attributes
153 //! Get MED FAMILY attribute by its number
154 TInt GetAttrId(TInt theId) const;
155 //! Set MED FAMILY attribute by its number
156 void SetAttrId(TInt theId, TInt theVal);
158 //! Defines sequence of the values of the MED Family attributes
160 //! Get MED FAMILY attribute by its number
161 TInt GetAttrVal(TInt theId) const;
162 //! Set MED FAMILY attribute by its number
163 void SetAttrVal(TInt theId, TInt theVal);
165 //! Defines sequence of the names of the MED Family attributes
167 //! Get value of the MED FAMILY attribute by its number
168 virtual std::string GetAttrDesc(TInt theId) const = 0;
169 //! Set value of the MED FAMILY attribute by its number
170 virtual void SetAttrDesc(TInt theId, const std::string& theValue) = 0;
173 //---------------------------------------------------------------
174 typedef TIntVector TElemNum;
175 typedef SharedPtr<TElemNum> PElemNum;
177 //! Define a parent class for all MED entities that describes mesh entites such as nodes and cells.
178 struct MEDWRAPPER_EXPORT TElemInfo: virtual TBase
180 PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
181 //! Get a reference to corresponding MED Mesh
182 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
184 TInt myNbElem; //<! Number of corresponding mesh entities
185 TInt GetNbElem() const { return myNbElem;} //! Get number of mesh elements
187 //! Defines sequence MED Family indexes for corresponding mesh entites
189 //! Get number of a MED FAMILY by order number of the mesh element
190 TInt GetFamNum(TInt theId) const;
191 //! Set number of a MED FAMILY for the mesh element with the order number
192 void SetFamNum(TInt theId, TInt theVal);
194 //! Defines if the mesh elements are indexed
195 EBooleen myIsElemNum;
196 //! Let know if the mesh elements are indexed
197 EBooleen IsElemNum() const { return myIsElemNum;}
199 //! Defines if the mesh elements family are indexed
201 //! Let know if the mesh elements family are indexed
202 EBooleen IsFamNum() const { return myIsFamNum;}
205 //! Contains sequence of the indexes for the mesh elements
207 //! Get a reference number of the mesh element by its order number
208 TInt GetElemNum(TInt theId) const;
209 //! Set a reference number for the mesh element by its order number
210 void SetElemNum(TInt theId, TInt theVal);
212 //! Defines if the mesh elements are named
213 EBooleen myIsElemNames;
214 //! Let know if the mesh elements havew names
215 EBooleen IsElemNames() const { return myIsElemNames;}
217 //! Contains sequence of the names for the mesh elements
219 //! Get name of the mesh element by its order number
220 virtual std::string GetElemName(TInt theId) const = 0;
221 //! Set name of the mesh element by its order number
222 virtual void SetElemName(TInt theId, const std::string& theValue) = 0;
225 //---------------------------------------------------------------
226 typedef TVector<TFloat> TFloatVector;
227 typedef TSlice<TFloat> TFloatVecSlice;
228 typedef TCSlice<TFloat> TCFloatVecSlice;
230 typedef TFloatVector TNodeCoord;
231 typedef SharedPtr<TNodeCoord> PNodeCoord;
233 typedef TFloatVecSlice TCoordSlice;
234 typedef TCFloatVecSlice TCCoordSlice;
236 //! Define a base class which represents MED Nodes entity
237 struct MEDWRAPPER_EXPORT TNodeInfo:
239 virtual TModeSwitchInfo
241 PNodeCoord myCoord; //!< Contains all nodal coordinates
243 //! Gives coordinates for mesh node by its number (const version)
244 TCCoordSlice GetCoordSlice(TInt theId) const;
245 //! Gives coordinates for mesh node by its number
246 TCoordSlice GetCoordSlice(TInt theId);
248 ERepere mySystem; //!< Defines, which coordinate system is used
249 //! Get which coordinate system is used for the node describing
250 ERepere GetSystem() const { return mySystem;}
251 //! Set coordinate system to be used for the node describing
252 void SetSystem(ERepere theSystem) { mySystem = theSystem;}
254 TString myCoordNames; //!< Contains names for the coordinate dimensions
255 //! Get name of the coordinate dimension by its order number
256 virtual std::string GetCoordName(TInt theId) const = 0;
257 //! Set name of the coordinate dimension by its order number
258 virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
260 TString myCoordUnits; //!< Contains units for the coordinate dimensions
261 //! Get name of unit for the coordinate dimension by its order number
262 virtual std::string GetCoordUnit(TInt theId) const = 0;
263 //! Set name of unit for the coordinate dimension by its order number
264 virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
267 //---------------------------------------------------------------
268 typedef TIntVecSlice TConnSlice;
269 typedef TCIntVecSlice TCConnSlice;
271 //! Define a base class which represents MED Cells entity
272 struct MEDWRAPPER_EXPORT TCellInfo:
274 virtual TModeSwitchInfo
276 EEntiteMaillage myEntity; //!< Defines the MED Entity where the mesh cells belongs to
277 //! Let known what MED ENTITY the cells belong to
278 EEntiteMaillage GetEntity() const { return myEntity;}
280 EGeometrieElement myGeom; //!< Defines the MED Geometric type of the instance
281 //! Let known what MED geometrical type the cells belong to
282 EGeometrieElement GetGeom() const { return myGeom;}
284 EConnectivite myConnMode; //!< Defines connectivity mode
285 //! Let known in what connectivity the cells are writen
286 EConnectivite GetConnMode() const { return myConnMode;}
288 virtual TInt GetConnDim() const = 0; //!< Gives step in the connectivity sequence
290 PElemNum myConn; //!< Defines sequence which describe connectivity for each of mesh cell
292 //! Gives connectivities for mesh cell by its number (const version)
293 TCConnSlice GetConnSlice(TInt theElemId) const;
294 //! Gives connectivities for mesh cell by its number
295 TConnSlice GetConnSlice(TInt theElemId);
298 //---------------------------------------------------------------
299 //! Define a base class which represents MED Polygon entity
300 struct MEDWRAPPER_EXPORT TPolygoneInfo:
303 //! Defines the MED Entity where the polygons belongs to
304 EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
305 //! Let known what MED ENTITY the MED Polygons belong to
306 EEntiteMaillage GetEntity() const { return myEntity;}
308 //! Defines the MED Geometric type of the instance
309 EGeometrieElement myGeom; // ePOLYGONE
310 //! Let known what MED geometrical type the MED Polygons belong to
311 EGeometrieElement GetGeom() const { return ePOLYGONE;}
313 //! Defines connectivity mode
314 EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
315 //! Let known in what connectivity the cells are writen
316 EConnectivite GetConnMode() const { return myConnMode;}
318 PElemNum myConn; //!< Table de connectivities
319 PElemNum myIndex; //!< Table de indexes
321 //! Gives number of the connectivities for the defined polygon
322 TInt GetNbConn(TInt theElemId) const;
324 //! Gives connectivities for polygon by its number (const version)
325 TCConnSlice GetConnSlice(TInt theElemId) const;
326 //! Gives connectivities for polygon by its number
327 TConnSlice GetConnSlice(TInt theElemId);
330 //---------------------------------------------------------------
331 //! Define a class representing MED_BALL structure element.
333 // This could be a generic class for any structure element
334 // holding any number of contant and variable attributes
335 // but it's too hard to implement
337 struct MEDWRAPPER_EXPORT TBallInfo:
340 TFloatVector myDiameters;
343 //---------------------------------------------------------------
344 typedef TVector<TCConnSlice> TCConnSliceArr;
345 typedef TVector<TConnSlice> TConnSliceArr;
347 //! Define a base class which represents MED Polyedre entity
348 struct MEDWRAPPER_EXPORT TPolyedreInfo:
351 //! Defines the MED Entity where the polyedres belongs to
352 EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
353 //! Let known what MED ENTITY the MED Polyedres belong to
354 EEntiteMaillage GetEntity() const { return myEntity;}
356 //! Defines the MED Geometric type of the instance
357 EGeometrieElement myGeom; // ePOLYEDRE
358 //! Let known what MED geometrical type the MED Polyedres belong to
359 EGeometrieElement GetGeom() const { return ePOLYEDRE;}
361 //! Defines connectivity mode
362 EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
363 //! Let known in what connectivity the cells are writen
364 EConnectivite GetConnMode() const { return myConnMode;}
366 PElemNum myConn; //!< Table de connectivities
367 PElemNum myFaces; //!< Table de faces indexes
368 PElemNum myIndex; //!< Table de indexes
370 //! Gives number of the faces for the defined polyedre (const version)
371 TInt GetNbFaces(TInt theElemId) const;
372 //! Gives number of the nodes for the defined polyedre
373 TInt GetNbNodes(TInt theElemId) const;
375 //! Gives sequence of the face connectivities for polyedre by its number (const version)
376 TCConnSliceArr GetConnSliceArr(TInt theElemId) const;
377 //! Gives sequence of the face connectivities for polyedre by its number
378 TConnSliceArr GetConnSliceArr(TInt theElemId);
381 //---------------------------------------------------------------
382 //! Define a base class which represents MED Field entity
383 struct MEDWRAPPER_EXPORT TFieldInfo:
386 PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
387 //! Get a reference to corresponding MED Mesh
388 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
390 ETypeChamp myType; //!< Defines type of the MED Field
391 //! Let known what type of the MED FIELD is used
392 ETypeChamp GetType() const { return myType;}
394 TInt myNbComp; //!< Defines number of components stored in the field
395 //! Get number of components for the MED FIELD
396 TInt GetNbComp() const { return myNbComp;}
398 EBooleen myIsLocal; //!< Defines if the MED Field is local
399 //! Let known is the MED FIELD is local or not
400 EBooleen GetIsLocal() const { return myIsLocal;}
402 TInt myNbRef; //!< Defines number of refereces of the field
403 //! Let known number of references for the MED FIELD
404 TInt GetNbRef() const { return myNbRef;}
406 TString myCompNames; //!< Contains names for each of MED Field components
407 //! Get name of the component by its order number
408 virtual std::string GetCompName(TInt theId) const = 0;
409 //! Set name for the component by its order number
410 virtual void SetCompName(TInt theId, const std::string& theValue) = 0;
412 TString myUnitNames; //!< Contains units for each of MED Field components
413 //! Get unit of the component by its order number
414 virtual std::string GetUnitName(TInt theId) const = 0;
415 //! Set unit for the component by its order number
416 virtual void SetUnitName(TInt theId, const std::string& theValue) = 0;
419 //---------------------------------------------------------------
420 //! Get dimension of the Gauss coordinates for the defined type of mesh cell
423 GetDimGaussCoord(EGeometrieElement theGeom);
425 //! Get number of referenced nodes for the defined type of mesh cell
428 GetNbRefCoord(EGeometrieElement theGeom);
430 typedef TFloatVector TWeight;
432 //! The class represents MED Gauss entity
433 struct MEDWRAPPER_EXPORT TGaussInfo:
435 virtual TModeSwitchInfo
437 typedef boost::tuple<EGeometrieElement,std::string> TKey;
438 typedef boost::tuple<TKey,TInt> TInfo;
439 struct MEDWRAPPER_EXPORT TLess
442 operator()(const TKey& theLeft, const TKey& theRight) const;
445 operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const;
448 //! Defines, which geometrical type the MED Gauss entity belongs to
449 EGeometrieElement myGeom;
450 //! Let known what MED geometrical type the MED GAUSS entity belong to
451 EGeometrieElement GetGeom() const { return myGeom;}
453 //! Contains coordinates for the refereced nodes
454 TNodeCoord myRefCoord;
456 //! Gives coordinates for the referenced node by its number
457 TCCoordSlice GetRefCoordSlice(TInt theId) const;
458 //! Gives coordinates for the referenced node by its number
459 TCoordSlice GetRefCoordSlice(TInt theId);
461 //! Contains coordinates for the Gauss points
462 TNodeCoord myGaussCoord;
464 //! Gives coordinates for the Gauss points by its number
465 TCCoordSlice GetGaussCoordSlice(TInt theId) const;
466 //! Gives coordinates for the Gauss points by its number
467 TCoordSlice GetGaussCoordSlice(TInt theId);
469 //! Contains wheights for the Gauss points
472 //! Gives number of the referenced nodes
473 TInt GetNbRef() const { return GetNbRefCoord(GetGeom());}
475 //! Gives dimension of the referenced nodes
476 TInt GetDim() const { return GetDimGaussCoord(GetGeom());}
478 //! Gives number of the Gauss Points
479 TInt GetNbGauss() const { return (TInt)(myGaussCoord.size()/GetDim());}
482 //---------------------------------------------------------------
483 typedef std::map<EGeometrieElement,PGaussInfo> TGeom2Gauss;
484 typedef std::map<EGeometrieElement,TInt> TGeom2NbGauss;
486 //! Define a base class which represents MED TimeStamp
487 struct MEDWRAPPER_EXPORT TTimeStampInfo:
490 PFieldInfo myFieldInfo; //!< A reference to correspondig MED Field
491 //! Get a reference to corresponding MED Field
492 const PFieldInfo& GetFieldInfo() const { return myFieldInfo;}
494 //! Defines the MED Entity where the MED TimeStamp belongs to
495 EEntiteMaillage myEntity;
496 //! Let known to what MED Entity the MED TimeStamp belong to
497 EEntiteMaillage GetEntity() const { return myEntity;}
499 //! Keeps map of number of cells per geometric type where the MED TimeStamp belongs to
500 TGeom2Size myGeom2Size;
501 //! Get map of number of cells per geometric type where the MED TimeStamp belongs to
502 const TGeom2Size& GetGeom2Size() const { return myGeom2Size;}
504 TGeom2NbGauss myGeom2NbGauss; //!< Keeps number of the Gauss Points for the MED TimeStamp
505 TInt GetNbGauss(EGeometrieElement theGeom) const; //!< Gives number of the Gauss Points for the MED TimeStamp
507 TInt myNumDt; //!< Keeps number in time for the MED TimeStamp
508 TInt GetNumDt() const { return myNumDt;} //!< Defines number in time for the MED TimeStamp
510 TInt myNumOrd; //!< Keeps number for the MED TimeStamp
511 TInt GetNumOrd() const { return myNumOrd;} //!< Defines number for the MED TimeStamp
513 TFloat myDt; //!< Keeps time for the MED TimeStamp
514 TFloat GetDt() const { return myDt;} //!< Defines time for the MED TimeStamp
516 //! Keeps map of MED Gauss entityes per geometric type
517 TGeom2Gauss myGeom2Gauss;
518 //! Gets a map of MED Gauss entityes per geometric type
519 const TGeom2Gauss& GetGeom2Gauss() const { return myGeom2Gauss;}
521 TString myUnitDt; //!< Defines unit for the time for the MED TimeStamp
522 //! Get unit of time for the MED TimeStamp
523 virtual std::string GetUnitDt() const = 0;
524 //! Set unit of time for the MED TimeStamp
525 virtual void SetUnitDt(const std::string& theValue) = 0;
528 //---------------------------------------------------------------
529 //! The class represents MED Profile entity
530 struct MEDWRAPPER_EXPORT TProfileInfo:
533 typedef std::string TKey;
534 typedef boost::tuple<TKey,TInt> TInfo;
536 EModeProfil myMode; //!< Keeps mode for the MED Profile
537 //! Let known what mode of MED Profile is used
538 EModeProfil GetMode() const { return myMode;}
539 //! Set mode for the MED Profile
540 void SetMode(EModeProfil theMode) { myMode = theMode;}
542 PElemNum myElemNum; //!< Keeps sequence of cell by its number which belong to the profile
543 //! Get number of mesh elelemts by its order number
544 TInt GetElemNum(TInt theId) const;
545 //! Set number of mesh elelemts by its order number
546 void SetElemNum(TInt theId, TInt theVal);
548 //! Let known is the MED Profile defined
549 bool IsPresent() const { return GetName() != "";}
551 //! Let known size of the MED Profile
552 TInt GetSize() const { return (TInt)myElemNum->size();}
555 //---------------------------------------------------------------
556 //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
557 struct MEDWRAPPER_EXPORT TMeshValueBase:
558 virtual TModeSwitchInfo
567 //! Initialize the class
569 Allocate(TInt theNbElem,
572 EModeSwitch theMode = eFULL_INTERLACE);
574 //! Returns size of the value container
578 //! Returns MED interpetation of the value size
582 //! Returns number of Gauss Points bounded with the value
586 //! Returns step inside of the data array
590 //! Returns bare pointer on the internal value representation
596 //---------------------------------------------------------------
597 //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
598 template<class TValueType>
600 virtual TMeshValueBase
602 typedef TValueType TValue;
603 typedef typename TValueType::value_type TElement;
605 typedef TSlice<TElement> TValueSlice;
606 typedef TCSlice<TElement> TCValueSlice;
608 typedef TVector<TCValueSlice> TCValueSliceArr;
609 typedef TVector<TValueSlice> TValueSliceArr;
613 //! Initialize the class
615 Allocate(TInt theNbElem,
618 EModeSwitch theMode = eFULL_INTERLACE)
620 TMeshValueBase::Allocate(theNbElem, theNbGauss, theNbComp, theMode);
621 myValue.resize(theNbElem * this->GetStep());
624 //! Returns bare pointer on the internal value representation
629 return (unsigned char*)&myValue[0];
632 //! Returns bare pointer on the internal value representation
640 //! Returns bare pointer on the internal value representation
648 //! Iteration through Gauss Points by their components
650 GetGaussValueSliceArr(TInt theElemId) const
652 TCValueSliceArr aValueSliceArr(myNbGauss);
653 if(GetModeSwitch() == eFULL_INTERLACE){
654 TInt anId = theElemId * myStep;
655 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
656 aValueSliceArr[aGaussId] =
657 TCValueSlice(myValue, std::slice(anId, myNbComp, 1));
662 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
663 aValueSliceArr[aGaussId] =
664 TCValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
667 return aValueSliceArr;
670 //! Iteration through Gauss Points by their components
672 GetGaussValueSliceArr(TInt theElemId)
674 TValueSliceArr aValueSliceArr(myNbGauss);
675 if(GetModeSwitch() == eFULL_INTERLACE){
676 TInt anId = theElemId*myStep;
677 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
678 aValueSliceArr[aGaussId] =
679 TValueSlice(myValue, std::slice(anId, myNbComp, 1));
684 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
685 aValueSliceArr[aGaussId] =
686 TValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
689 return aValueSliceArr;
692 //! Iteration through components by corresponding Gauss Points
694 GetCompValueSliceArr(TInt theElemId) const
696 TCValueSliceArr aValueSliceArr(myNbComp);
697 if(GetModeSwitch() == eFULL_INTERLACE){
698 TInt anId = theElemId*myStep;
699 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
700 aValueSliceArr[aCompId] =
701 TCValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
706 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
707 aValueSliceArr[aCompId] =
708 TCValueSlice(myValue, std::slice(theElemId, myNbGauss, myStep));
711 return aValueSliceArr;
714 //! Iteration through components by corresponding Gauss Points
716 GetCompValueSliceArr(TInt theElemId)
718 if(GetModeSwitch() == eFULL_INTERLACE){
719 TValueSliceArr aValueSliceArr(myNbComp);
720 TInt anId = theElemId*myStep;
721 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
722 aValueSliceArr[aCompId] =
723 TValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
726 return aValueSliceArr;
729 TValueSliceArr aValueSliceArr(myNbGauss);
730 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
731 aValueSliceArr[aGaussId] =
732 TValueSlice(myValue,std::slice(theElemId, myNbComp, myStep));
734 return aValueSliceArr;
739 typedef TTMeshValue<TFloatVector> TFloatMeshValue;
740 typedef TTMeshValue<TIntVector> TIntMeshValue;
742 //---------------------------------------------------------------
743 // Backward compatibility declarations
744 typedef TFloatVector TValue;
745 typedef TSlice<TFloat> TValueSlice;
746 typedef TCSlice<TFloat> TCValueSlice;
748 typedef TVector<TCValueSlice> TCValueSliceArr;
749 typedef TVector<TValueSlice> TValueSliceArr;
751 typedef TFloatMeshValue TMeshValue;
752 typedef std::map<EGeometrieElement,TMeshValue> TGeom2Value;
754 //---------------------------------------------------------------
755 typedef std::map<EGeometrieElement,PProfileInfo> TGeom2Profile;
756 typedef std::set<EGeometrieElement> TGeom;
758 //! The class is a base class for MED TimeStamp values holder
759 struct MEDWRAPPER_EXPORT TTimeStampValueBase:
760 virtual TModeSwitchInfo
762 //! A reference to correspondig MED TimeStamp
763 PTimeStampInfo myTimeStampInfo;
764 //!< Get a reference to correspondig MED TimeStamp
765 const PTimeStampInfo& GetTimeStampInfo() const { return myTimeStampInfo;}
767 //! Keeps set of MED EGeometrieElement which contains values for the timestamp
769 const TGeomSet& GetGeomSet() const { return myGeomSet;}
771 //! Keeps map of MED Profiles per geometric type
772 TGeom2Profile myGeom2Profile;
773 //! Gets a map of MED Profiles per geometric type
774 const TGeom2Profile& GetGeom2Profile() const { return myGeom2Profile;}
776 //! Gets type of the champ
779 GetTypeChamp() const = 0;
781 //! Allocates values for the given geometry
784 AllocateValue(EGeometrieElement theGeom,
788 EModeSwitch theMode = eFULL_INTERLACE) = 0;
792 GetValueSize(EGeometrieElement theGeom) const = 0;
796 GetNbVal(EGeometrieElement theGeom) const = 0;
800 GetNbGauss(EGeometrieElement theGeom) const = 0;
804 GetValuePtr(EGeometrieElement theGeom) = 0;
807 //---------------------------------------------------------------
808 //! The class implements a container for MED TimeStamp values
809 template<class TMeshValueType>
810 struct TTimeStampValue:
811 virtual TTimeStampValueBase
813 typedef TMeshValueType TTMeshValue;
814 typedef SharedPtr<TMeshValueType> PTMeshValue;
815 typedef typename TMeshValueType::TElement TElement;
816 typedef std::map<EGeometrieElement, PTMeshValue> TTGeom2Value;
818 ETypeChamp myTypeChamp; //<! Keeps type of the champ
820 //! Gets type of the champ
828 //! Keeps map of MED TimeStamp values per geometric type (const version)
829 TTGeom2Value myGeom2Value;
832 GetGeom2Value() const
837 //! Gets MED TimeStamp values for the given geometric type (const version)
839 GetMeshValuePtr(EGeometrieElement theGeom) const
841 typename TTGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
842 if(anIter == myGeom2Value.end())
843 EXCEPTION(std::runtime_error,"TTimeStampValue::GetMeshValuePtr - myGeom2Value.find(theGeom) fails");
844 return anIter->second;
847 //! Gets MED TimeStamp values for the given geometric type
849 GetMeshValuePtr(EGeometrieElement theGeom)
851 myGeomSet.insert(theGeom);
852 if(myGeom2Value.find(theGeom) == myGeom2Value.end()){
853 myGeom2Value[theGeom] = PTMeshValue(new TTMeshValue());
854 return myGeom2Value[theGeom];
856 return myGeom2Value[theGeom];
859 //! Gets MED TimeStamp values for the given geometric type (const version)
861 GetMeshValue(EGeometrieElement theGeom) const
863 return *(this->GetMeshValuePtr(theGeom));
866 //! Gets MED TimeStamp values for the given geometric type
868 GetMeshValue(EGeometrieElement theGeom)
870 return *(this->GetMeshValuePtr(theGeom));
874 //---------------------------------------------------------------
875 typedef TTimeStampValue<TFloatMeshValue> TFloatTimeStampValue;
876 typedef SharedPtr<TFloatTimeStampValue> PFloatTimeStampValue;
878 PFloatTimeStampValue MEDWRAPPER_EXPORT
879 CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
881 typedef TTimeStampValue<TIntMeshValue> TIntTimeStampValue;
882 typedef SharedPtr<TIntTimeStampValue> PIntTimeStampValue;
884 PIntTimeStampValue MEDWRAPPER_EXPORT
885 CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
887 //---------------------------------------------------------------
888 template<class TMeshValueTypeFrom, class TMeshValueTypeTo>
890 CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueTypeFrom> > theTimeStampValueFrom,
891 SharedPtr<TTimeStampValue<TMeshValueTypeTo> > theTimeStampValueTo)
893 typedef TTimeStampValue<TMeshValueTypeFrom> TimeStampValueTypeFrom;
894 typedef TTimeStampValue<TMeshValueTypeTo> TimeStampValueTypeTo;
895 typedef typename TMeshValueTypeTo::TElement TElementTo;
897 typename TimeStampValueTypeFrom::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
898 typename TimeStampValueTypeFrom::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
899 for(; anIter != aGeom2Value.end(); anIter++){
900 const EGeometrieElement& aGeom = anIter->first;
901 const typename TimeStampValueTypeFrom::TTMeshValue& aMeshValue = *anIter->second;
902 typename TimeStampValueTypeTo::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
903 aMeshValue2.Allocate(aMeshValue.myNbElem,
904 aMeshValue.myNbGauss,
906 aMeshValue.myModeSwitch);
907 const typename TimeStampValueTypeFrom::TTMeshValue::TValue& aValue = aMeshValue.myValue;
908 typename TimeStampValueTypeTo::TTMeshValue::TValue& aValue2 = aMeshValue2.myValue;
909 TInt aSize = aValue.size();
910 for(TInt anId = 0; anId < aSize; anId++)
911 aValue2[anId] = TElementTo(aValue[anId]);
915 template<class TMeshValueType>
917 CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueFrom,
918 SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueTo)
920 typedef TTimeStampValue<TMeshValueType> TimeStampValueType;
921 typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
922 typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
923 for(; anIter != aGeom2Value.end(); anIter++){
924 const EGeometrieElement& aGeom = anIter->first;
925 const typename TimeStampValueType::TTMeshValue& aMeshValue = *anIter->second;
926 typename TimeStampValueType::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
927 aMeshValue2 = aMeshValue;
931 //---------------------------------------------------------------
934 CopyTimeStampValueBase(const PTimeStampValueBase& theValueFrom,
935 const PTimeStampValueBase& theValueTo)
937 if(theValueFrom->GetTypeChamp() == theValueTo->GetTypeChamp()){
938 if(theValueFrom->GetTypeChamp() == eFLOAT64)
939 CopyTimeStampValue<TFloatMeshValue>(theValueFrom, theValueTo);
940 else if(theValueFrom->GetTypeChamp() == eINT)
941 CopyTimeStampValue<TIntMeshValue>(theValueFrom, theValueTo);
943 if(theValueFrom->GetTypeChamp() == eFLOAT64 && theValueTo->GetTypeChamp() == eINT)
944 CopyTimeStampValue<TFloatMeshValue, TIntMeshValue>(theValueFrom, theValueTo);
945 else if(theValueFrom->GetTypeChamp() == eINT && theValueTo->GetTypeChamp() == eFLOAT64)
946 CopyTimeStampValue<TIntMeshValue, TFloatMeshValue>(theValueFrom, theValueTo);
950 //---------------------------------------------------------------
951 // Backward compatibility declarations
952 typedef TFloatTimeStampValue TTimeStampVal;
953 typedef PFloatTimeStampValue PTimeStampVal;
955 //---------------------------------------------------------------
956 typedef std::map<TInt,TFloatVector> TIndexes;
957 typedef std::map<TInt,TString> TNames;
959 //! Define a base class which represents MED Grille (structured mesh)
960 struct MEDWRAPPER_EXPORT TGrilleInfo:
961 virtual TModeSwitchInfo
963 PMeshInfo myMeshInfo;
964 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
966 TNodeCoord myCoord; //!< Contains all nodal coordinates, now used only for eGRILLE_STANDARD
967 //! Gives coordinates for mesh nodes (const version)
968 const TNodeCoord& GetNodeCoord() const;
969 TNodeCoord& GetNodeCoord();
970 //! Gives coordinates for mesh node by its number, array index from 0
971 TNodeCoord GetCoord(TInt theId);
972 //! Gives ids of nodes for mesh cell or sub-cell by its number, array index from 0
973 TIntVector GetConn(TInt theId, const bool isSub=false);
975 EGrilleType myGrilleType; //!< Defines grille type (eGRILLE_CARTESIENNE,eGRILLE_POLAIRE,eGRILLE_STANDARD)
976 //!Gets grille type (const version)
977 const EGrilleType& GetGrilleType() const;
979 EGrilleType GetGrilleType();
981 void SetGrilleType(EGrilleType theGrilleType);
983 TString myCoordNames; //!< Contains names for the coordinate dimensions
984 //! Get name of the coordinate dimension by its order number
985 virtual std::string GetCoordName(TInt theId) const = 0 ;
986 //! Set name of the coordinate dimension by its order number
987 virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
989 TString myCoordUnits; //!< Contains units for the coordinate dimensions
990 //! Get name of unit for the coordinate dimension by its order number
991 virtual std::string GetCoordUnit(TInt theId) const = 0;
992 //! Set name of unit for the coordinate dimension by its order number
993 virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
995 //! Map of index of axes and Table of indexes for certain axe, now used for eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
997 //!Gets a map of Tables (const version)
998 const TIndexes& GetMapOfIndexes() const ;
999 //!Gets a map of Tables
1000 TIndexes& GetMapOfIndexes();
1001 //!Gets a Table of indexes for certain axe(const version)
1002 const TFloatVector& GetIndexes(TInt theAxisNumber) const;
1003 //!Gets a Table of indexes for certain axe
1004 TFloatVector& GetIndexes(TInt theAxisNumber);
1005 //!Gets a number of indices per axe
1006 TInt GetNbIndexes(TInt theAxisNumber);
1008 TInt GetNbNodes();//! Return count of all points
1009 TInt GetNbCells();//! Return count of all cells
1010 TInt GetNbSubCells();//! Return count of all entities of <mesh dimension-1>
1011 EGeometrieElement GetGeom();//! Return geometry of cells (calculated from mesh dimension)
1012 EGeometrieElement GetSubGeom();//! Return geometry of subcells (calculated from mesh dimension)
1013 EEntiteMaillage GetEntity();//! Return entity (eMAILLE)
1014 EEntiteMaillage GetSubEntity();//! Return sub entity
1017 *Vector of grille structure (Example: {3,4,5}, 3 nodes in X axe, 4 nodes in Y axe, ...)
1019 TIntVector myGrilleStructure;
1020 //!Gets grille structure(const version)
1021 const TIntVector& GetGrilleStructure() const;
1022 //!Gets grille structure
1023 TIntVector GetGrilleStructure();
1024 //!Sets the grille structure of theAxis axe to theNb.
1025 void SetGrilleStructure(TInt theAxis,TInt theNb);
1028 *Defines sequence MED Family indexes for corresponding mesh entites
1031 //! Get number of a MED FAMILY by order number of the mesh element
1032 TInt GetFamNum(TInt theId) const;
1033 //! Set number of a MED FAMILY for the mesh element with the order number
1034 void SetFamNum(TInt theId, TInt theVal);
1037 *Defines sequence MED Family indexes for sub entites
1039 TElemNum myFamSubNum;
1040 //! Get number of a MED FAMILY by order number of sub element
1041 TInt GetFamSubNum(TInt theId) const;
1042 //! Set number of a MED FAMILY for theId-th sub element
1043 void SetFamSubNum(TInt theId, TInt theVal);
1046 *Defines sequence MED Family indexes for corresponding mesh nodes
1048 TElemNum myFamNumNode;
1049 //! Get number of a MED FAMILY by order number of the mesh node
1050 TInt GetFamNumNode(TInt theId) const;
1051 //! Set number of a MED FAMILY for the mesh node with the order number
1052 void SetFamNumNode(TInt theId, TInt theVal);
1056 #endif // MED_Structures_HeaderFile