1 // Copyright (C) 2007-2020 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"
29 #include "MED_SliceArray.hxx"
31 #include <boost/tuple/tuple.hpp>
34 #pragma warning(disable:4251)
39 //---------------------------------------------------------------
40 //! Defines a type for managing sequence of strings
41 typedef TVector<char> TString;
42 typedef SharedPtr<TString> PString;
44 //---------------------------------------------------------------
45 //! Extract a substring from the sequence of the strings
50 const TString& theString);
52 //---------------------------------------------------------------
53 //! Set a substring in the sequence of the strings
59 const std::string& theValue);
61 //---------------------------------------------------------------
62 //! Set a substring in the sequence of the strings
68 const TString& theValue);
70 //---------------------------------------------------------------
71 //! Define a parent class for all MEDWrapper classes
72 struct MEDWRAPPER_EXPORT TBase
77 //---------------------------------------------------------------
78 //! Define a parent class for all named MED entities
79 struct MEDWRAPPER_EXPORT TNameInfo: virtual TBase
81 TString myName; //!< Keeps its name
82 virtual std::string GetName() const = 0; //!< Gets its name
83 virtual void SetName(const std::string& theValue) = 0; //!< Set a new name
84 virtual void SetName(const TString& theValue) = 0; //!< Set a new name
87 //---------------------------------------------------------------
88 //! Define a parent class for all MED entities that contains a sequence of numbers
90 It defines through corresponding enumeration (EModeSwitch) how the sequence
91 should be interpreted in C or Fortran mode (eFULL_INTERLACE or eNON_INTERLACE).
93 struct MEDWRAPPER_EXPORT TModeSwitchInfo: virtual TBase
95 //! To construct instance of the class by default
97 myModeSwitch(eFULL_INTERLACE)
100 //! To construct instance of the class
101 TModeSwitchInfo(EModeSwitch theModeSwitch):
102 myModeSwitch(theModeSwitch)
105 EModeSwitch myModeSwitch; //!< Keeps the interlace mode
106 EModeSwitch GetModeSwitch() const { return myModeSwitch; }
109 //---------------------------------------------------------------
110 //! Define a base class which represents MED Mesh entity
111 struct MEDWRAPPER_EXPORT TMeshInfo: virtual TNameInfo
113 TInt myDim; //!< Dimension of the mesh (0, 1, 2 or 3)
114 TInt GetDim() const { return myDim; } //!< Gets dimension of the mesh
117 TInt GetSpaceDim() const { return mySpaceDim; }
119 EMaillage myType; //!< Type of the mesh
120 EMaillage GetType() const { return myType; } //!< Gets type of the mesh
122 TString myDesc; //!< Description of the mesh
123 virtual std::string GetDesc() const = 0; //!< Get description for the mesh
124 virtual void SetDesc(const std::string& theValue) = 0; //!< Sets description for the mesh
127 //---------------------------------------------------------------
128 typedef TSlice<TInt> TIntVecSlice;
129 typedef TCSlice<TInt> TCIntVecSlice;
130 typedef TIntVector TFamAttr;
132 //---------------------------------------------------------------
133 //! Define a base class which represents MED Family entity
134 struct MEDWRAPPER_EXPORT TFamilyInfo: virtual TNameInfo
136 PMeshInfo myMeshInfo; //!< A reference to corresponding MED Mesh
137 //! Get a reference to corresponding MED Mesh
138 const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
140 TInt myId; //!< An unique index of the MED FAMILY
141 TInt GetId() const { return myId; } //!< Gets number of the MED FAMILY
142 void SetId(TInt theId) { myId = theId; } //! Define number of the MED FAMILY
144 TInt myNbGroup; //!< Defines number MED Groups connected to
145 //! Gets number of MED GROUPS the MED FAMILY is bound to
146 TInt GetNbGroup() const { return myNbGroup; }
148 //! Contains sequence of the names for the MED Groups connected to
149 TString myGroupNames;
150 //! Gets name of a bound MED GROUP by its number
151 virtual std::string GetGroupName(TInt theId) const = 0;
152 //! Sets name of the defined MED GROUP by its number
153 virtual void SetGroupName(TInt theId, const std::string& theValue) = 0;
155 TInt myNbAttr; //!< Defines number of the MED Family attributes
156 //! Gets number of attached attributes for the MED FAMILY
157 TInt GetNbAttr() const { return myNbAttr; }
159 //! Defines sequence of the indexes of the MED Family attributes
161 //! Get MED FAMILY attribute by its number
162 TInt GetAttrId(TInt theId) const;
163 //! Set MED FAMILY attribute by its number
164 void SetAttrId(TInt theId, TInt theVal);
166 //! Defines sequence of the values of the MED Family attributes
168 //! Get MED FAMILY attribute by its number
169 TInt GetAttrVal(TInt theId) const;
170 //! Set MED FAMILY attribute by its number
171 void SetAttrVal(TInt theId, TInt theVal);
173 //! Defines sequence of the names of the MED Family attributes
175 //! Get value of the MED FAMILY attribute by its number
176 virtual std::string GetAttrDesc(TInt theId) const = 0;
177 //! Set value of the MED FAMILY attribute by its number
178 virtual void SetAttrDesc(TInt theId, const std::string& theValue) = 0;
181 //---------------------------------------------------------------
182 typedef TIntVector TElemNum;
183 typedef SharedPtr<TElemNum> PElemNum;
185 //---------------------------------------------------------------
186 //! Define a parent class for all MED entities that describes mesh entities such as nodes and cells.
187 struct MEDWRAPPER_EXPORT TElemInfo: virtual TBase
189 PMeshInfo myMeshInfo; //!< A reference to corresponding MED Mesh
190 //! Get a reference to corresponding MED Mesh
191 const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
193 TInt myNbElem; //<! Number of corresponding mesh entities
194 TInt GetNbElem() const { return myNbElem; } //! Get number of mesh elements
196 //! Defines sequence MED Family indexes for corresponding mesh entities
198 //! Get number of a MED FAMILY by order number of the mesh element
199 TInt GetFamNum(TInt theId) const;
200 //! Set number of a MED FAMILY for the mesh element with the order number
201 void SetFamNum(TInt theId, TInt theVal);
203 //! Defines if the mesh elements are indexed
204 EBooleen myIsElemNum;
205 //! Let know if the mesh elements are indexed
206 EBooleen IsElemNum() const { return myIsElemNum; }
208 //! Defines if the mesh elements family are indexed
210 //! Let know if the mesh elements family are indexed
211 EBooleen IsFamNum() const { return myIsFamNum; }
213 //! Contains sequence of the indexes for the mesh elements
215 //! Get a reference number of the mesh element by its order number
216 TInt GetElemNum(TInt theId) const;
217 //! Set a reference number for the mesh element by its order number
218 void SetElemNum(TInt theId, TInt theVal);
220 //! Defines if the mesh elements are named
221 EBooleen myIsElemNames;
222 //! Let know if the mesh elements have names
223 EBooleen IsElemNames() const { return myIsElemNames; }
225 //! Contains sequence of the names for the mesh elements
227 //! Get name of the mesh element by its order number
228 virtual std::string GetElemName(TInt theId) const = 0;
229 //! Set name of the mesh element by its order number
230 virtual void SetElemName(TInt theId, const std::string& theValue) = 0;
233 //---------------------------------------------------------------
234 typedef TSlice<TFloat> TFloatVecSlice;
235 typedef TCSlice<TFloat> TCFloatVecSlice;
236 typedef TFloatVector TNodeCoord;
237 typedef SharedPtr<TNodeCoord> PNodeCoord;
238 typedef TFloatVecSlice TCoordSlice;
239 typedef TCFloatVecSlice TCCoordSlice;
241 //---------------------------------------------------------------
242 //! Define a base class which represents MED Nodes entity
243 struct MEDWRAPPER_EXPORT TNodeInfo:
245 virtual TModeSwitchInfo
247 PNodeCoord myCoord; //!< Contains all nodal coordinates
249 //! Gives coordinates for mesh node by its number (const version)
250 TCCoordSlice GetCoordSlice(TInt theId) const;
251 //! Gives coordinates for mesh node by its number
252 TCoordSlice GetCoordSlice(TInt theId);
254 ERepere mySystem; //!< Defines, which coordinate system is used
255 //! Get which coordinate system is used for the node describing
256 ERepere GetSystem() const { return mySystem; }
257 //! Set coordinate system to be used for the node describing
258 void SetSystem(ERepere theSystem) { mySystem = theSystem; }
260 TString myCoordNames; //!< Contains names for the coordinate dimensions
261 //! Get name of the coordinate dimension by its order number
262 virtual std::string GetCoordName(TInt theId) const = 0;
263 //! Set name of the coordinate dimension by its order number
264 virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
266 TString myCoordUnits; //!< Contains units for the coordinate dimensions
267 //! Get name of unit for the coordinate dimension by its order number
268 virtual std::string GetCoordUnit(TInt theId) const = 0;
269 //! Set name of unit for the coordinate dimension by its order number
270 virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
273 //---------------------------------------------------------------
274 typedef TIntVecSlice TConnSlice;
275 typedef TCIntVecSlice TCConnSlice;
277 //---------------------------------------------------------------
278 //! Define a base class which represents MED Cells entity
279 struct MEDWRAPPER_EXPORT TCellInfo:
281 virtual TModeSwitchInfo
283 EEntiteMaillage myEntity; //!< Defines the MED Entity where the mesh cells belongs to
284 //! Find out what MED ENTITY the cells belong to
285 EEntiteMaillage GetEntity() const { return myEntity; }
287 EGeometrieElement myGeom; //!< Defines the MED Geometric type of the instance
288 //! Find out what MED geometrical type the cells belong to
289 EGeometrieElement GetGeom() const { return myGeom; }
291 EConnectivite myConnMode; //!< Defines connectivity mode
292 //! Find out in what connectivity the cells are written
293 EConnectivite GetConnMode() const { return myConnMode; }
295 virtual TInt GetConnDim() const = 0; //!< Gives step in the connectivity sequence
297 PElemNum myConn; //!< Defines sequence which describe connectivity for each of mesh cell
299 //! Gives connectivities for mesh cell by its number (const version)
300 TCConnSlice GetConnSlice(TInt theElemId) const;
301 //! Gives connectivities for mesh cell by its number
302 TConnSlice GetConnSlice(TInt theElemId);
305 //---------------------------------------------------------------
306 //! Define a base class which represents MED Polygon entity
307 struct MEDWRAPPER_EXPORT TPolygoneInfo:
310 //! Defines the MED Entity where the polygons belongs to
311 EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
312 //! Find out what MED ENTITY the MED Polygons belong to
313 EEntiteMaillage GetEntity() const { return myEntity; }
315 //! Defines the MED Geometric type of the instance
316 EGeometrieElement myGeom; // ePOLYGONE
317 //! Find out what MED geometrical type the MED Polygons belong to
318 EGeometrieElement GetGeom() const { return ePOLYGONE; }
320 //! Defines connectivity mode
321 EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
322 //! Find out in what connectivity the cells are written
323 EConnectivite GetConnMode() const { return myConnMode; }
325 PElemNum myConn; //!< Table de connectivities
326 PElemNum myIndex; //!< Table de indexes
328 //! Gives number of the connectivities for the defined polygon
329 TInt GetNbConn(TInt theElemId) const;
331 //! Gives connectivities for polygon by its number (const version)
332 TCConnSlice GetConnSlice(TInt theElemId) const;
333 //! Gives connectivities for polygon by its number
334 TConnSlice GetConnSlice(TInt theElemId);
337 //---------------------------------------------------------------
338 //! Define a class representing MED_BALL structure element.
340 This could be a generic class for any structure element
341 holding any number of constant and variable attributes
342 but it's too hard to implement
344 struct MEDWRAPPER_EXPORT TBallInfo:
347 TFloatVector myDiameters;
350 //---------------------------------------------------------------
351 typedef TVector<TCConnSlice> TCConnSliceArr;
352 typedef TVector<TConnSlice> TConnSliceArr;
354 //---------------------------------------------------------------
355 //! Define a base class which represents MED Polyedre entity
356 struct MEDWRAPPER_EXPORT TPolyedreInfo:
359 //! Defines the MED Entity where the polyedres belongs to
360 EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
361 //! Find out what MED ENTITY the MED Polyedres belong to
362 EEntiteMaillage GetEntity() const { return myEntity; }
364 //! Defines the MED Geometric type of the instance
365 EGeometrieElement myGeom; // ePOLYEDRE
366 //! Find out what MED geometrical type the MED Polyedres belong to
367 EGeometrieElement GetGeom() const { return ePOLYEDRE; }
369 //! Defines connectivity mode
370 EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
371 //! Find out in what connectivity the cells are written
372 EConnectivite GetConnMode() const { return myConnMode; }
374 PElemNum myConn; //!< Table de connectivities
375 PElemNum myFaces; //!< Table de faces indexes
376 PElemNum myIndex; //!< Table de indexes
378 //! Gives number of the faces for the defined polyedre (const version)
379 TInt GetNbFaces(TInt theElemId) const;
380 //! Gives number of the nodes for the defined polyedre
381 TInt GetNbNodes(TInt theElemId) const;
383 //! Gives sequence of the face connectivities for polyedre by its number (const version)
384 TCConnSliceArr GetConnSliceArr(TInt theElemId) const;
385 //! Gives sequence of the face connectivities for polyedre by its number
386 TConnSliceArr GetConnSliceArr(TInt theElemId);
389 //---------------------------------------------------------------
390 //! Define a base class which represents MED Field entity
391 struct MEDWRAPPER_EXPORT TFieldInfo:
394 PMeshInfo myMeshInfo; //!< A reference to corresponding MED Mesh
395 //! Get a reference to corresponding MED Mesh
396 const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
398 ETypeChamp myType; //!< Defines type of MED Field
399 //! Find out what type of MED FIELD is used
400 ETypeChamp GetType() const { return myType; }
402 TInt myNbComp; //!< Defines number of components stored in the field
403 //! Get number of components for MED FIELD
404 TInt GetNbComp() const { return myNbComp; }
406 EBooleen myIsLocal; //!< Defines if the MED Field is local
407 //! Find out if MED FIELD is local or not
408 EBooleen GetIsLocal() const { return myIsLocal; }
410 TInt myNbRef; //!< Defines number of references of the field
411 //! Find out number of references for the MED FIELD
412 TInt GetNbRef() const { return myNbRef; }
414 TString myCompNames; //!< Contains names for each of MED Field components
415 //! Get name of the component by its order number
416 virtual std::string GetCompName(TInt theId) const = 0;
417 //! Set name for the component by its order number
418 virtual void SetCompName(TInt theId, const std::string& theValue) = 0;
420 TString myUnitNames; //!< Contains units for each of MED Field components
421 //! Get unit of the component by its order number
422 virtual std::string GetUnitName(TInt theId) const = 0;
423 //! Set unit for the component by its order number
424 virtual void SetUnitName(TInt theId, const std::string& theValue) = 0;
427 //---------------------------------------------------------------
428 //! Get dimension of the Gauss coordinates for the defined type of mesh cell
431 GetDimGaussCoord(EGeometrieElement theGeom);
433 //---------------------------------------------------------------
434 //! Get number of referenced nodes for the defined type of mesh cell
437 GetNbRefCoord(EGeometrieElement theGeom);
439 //---------------------------------------------------------------
440 typedef TFloatVector TWeight;
442 //---------------------------------------------------------------
443 //! The class represents MED Gauss entity
444 struct MEDWRAPPER_EXPORT TGaussInfo:
446 virtual TModeSwitchInfo
448 typedef boost::tuple<EGeometrieElement,std::string> TKey;
449 typedef boost::tuple<TKey,TInt> TInfo;
450 struct MEDWRAPPER_EXPORT TLess
453 operator()(const TKey& theLeft, const TKey& theRight) const;
456 operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const;
459 //! Defines, which geometrical type the MED Gauss entity belongs to
460 EGeometrieElement myGeom;
461 //! Find out what MED geometrical type the MED GAUSS entity belong to
462 EGeometrieElement GetGeom() const { return myGeom; }
464 //! Contains coordinates for the refereced nodes
465 TNodeCoord myRefCoord;
467 //! Gives coordinates for the referenced node by its number
468 TCCoordSlice GetRefCoordSlice(TInt theId) const;
469 //! Gives coordinates for the referenced node by its number
470 TCoordSlice GetRefCoordSlice(TInt theId);
472 //! Contains coordinates for the Gauss points
473 TNodeCoord myGaussCoord;
475 //! Gives coordinates for the Gauss points by its number
476 TCCoordSlice GetGaussCoordSlice(TInt theId) const;
477 //! Gives coordinates for the Gauss points by its number
478 TCoordSlice GetGaussCoordSlice(TInt theId);
480 //! Contains wheights for the Gauss points
483 //! Gives number of the referenced nodes
484 TInt GetNbRef() const { return GetNbRefCoord(GetGeom()); }
486 //! Gives dimension of the referenced nodes
487 TInt GetDim() const { return GetDimGaussCoord(GetGeom()); }
489 //! Gives number of the Gauss Points
490 TInt GetNbGauss() const { return (TInt)(myGaussCoord.size() / GetDim()); }
493 //---------------------------------------------------------------
494 typedef std::map<EGeometrieElement,PGaussInfo> TGeom2Gauss;
495 typedef std::map<EGeometrieElement,TInt> TGeom2NbGauss;
497 //---------------------------------------------------------------
498 //! Define a base class which represents MED TimeStamp
499 struct MEDWRAPPER_EXPORT TTimeStampInfo:
502 PFieldInfo myFieldInfo; //!< A reference to corresponding MED Field
503 //! Get a reference to corresponding MED Field
504 const PFieldInfo& GetFieldInfo() const { return myFieldInfo; }
506 //! Defines the MED Entity where the MED TimeStamp belongs to
507 EEntiteMaillage myEntity;
508 //! Find out to what MED Entity the MED TimeStamp belong to
509 EEntiteMaillage GetEntity() const { return myEntity; }
511 //! Keeps map of number of cells per geometric type where the MED TimeStamp belongs to
512 TGeom2Size myGeom2Size;
513 //! Get map of number of cells per geometric type where the MED TimeStamp belongs to
514 const TGeom2Size& GetGeom2Size() const { return myGeom2Size; }
516 TGeom2NbGauss myGeom2NbGauss; //!< Keeps number of the Gauss Points for the MED TimeStamp
517 TInt GetNbGauss(EGeometrieElement theGeom) const; //!< Gives number of the Gauss Points for the MED TimeStamp
519 TInt myNumDt; //!< Keeps number in time for the MED TimeStamp
520 TInt GetNumDt() const { return myNumDt; } //!< Defines number in time for the MED TimeStamp
522 TInt myNumOrd; //!< Keeps number for the MED TimeStamp
523 TInt GetNumOrd() const { return myNumOrd; } //!< Defines number for the MED TimeStamp
525 TFloat myDt; //!< Keeps time for the MED TimeStamp
526 TFloat GetDt() const { return myDt; } //!< Defines time for the MED TimeStamp
528 //! Keeps map of MED Gauss entityes per geometric type
529 TGeom2Gauss myGeom2Gauss;
530 //! Gets a map of MED Gauss entityes per geometric type
531 const TGeom2Gauss& GetGeom2Gauss() const { return myGeom2Gauss; }
533 TString myUnitDt; //!< Defines unit for the time for the MED TimeStamp
534 //! Get unit of time for the MED TimeStamp
535 virtual std::string GetUnitDt() const = 0;
536 //! Set unit of time for the MED TimeStamp
537 virtual void SetUnitDt(const std::string& theValue) = 0;
540 //---------------------------------------------------------------
541 //! The class represents MED Profile entity
542 struct MEDWRAPPER_EXPORT TProfileInfo:
545 typedef std::string TKey;
546 typedef boost::tuple<TKey,TInt> TInfo;
548 EModeProfil myMode; //!< Keeps mode for the MED Profile
549 //! Find out what mode of MED Profile is used
550 EModeProfil GetMode() const { return myMode; }
551 //! Set mode for the MED Profile
552 void SetMode(EModeProfil theMode) { myMode = theMode; }
554 PElemNum myElemNum; //!< Keeps sequence of cell by its number which belong to the profile
555 //! Get number of mesh elelemts by its order number
556 TInt GetElemNum(TInt theId) const;
557 //! Set number of mesh elelemts by its order number
558 void SetElemNum(TInt theId, TInt theVal);
560 //! Find out if the MED Profile defined
561 bool IsPresent() const { return GetName() != ""; }
563 //! Find out size of the MED Profile
564 TInt GetSize() const { return (TInt)myElemNum->size(); }
567 //---------------------------------------------------------------
568 //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
569 struct MEDWRAPPER_EXPORT TMeshValueBase:
570 virtual TModeSwitchInfo
579 //! Initialize the class
581 Allocate(TInt theNbElem,
584 EModeSwitch theMode = eFULL_INTERLACE);
586 //! Returns size of the value container
590 //! Returns MED interpretation of the value size
594 //! Returns number of Gauss Points bounded with the value
598 //! Returns step inside of the data array
602 //! Returns bare pointer on the internal value representation
608 //---------------------------------------------------------------
609 //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
610 template<class TValueType>
612 virtual TMeshValueBase
614 typedef TValueType TValue;
615 typedef typename TValueType::value_type TElement;
617 typedef TSlice<TElement> TValueSlice;
618 typedef TCSlice<TElement> TCValueSlice;
620 typedef TVector<TCValueSlice> TCValueSliceArr;
621 typedef TVector<TValueSlice> TValueSliceArr;
625 //! Initialize the class
627 Allocate(TInt theNbElem,
630 EModeSwitch theMode = eFULL_INTERLACE)
632 TMeshValueBase::Allocate(theNbElem, theNbGauss, theNbComp, theMode);
633 myValue.resize(theNbElem * this->GetStep());
636 //! Returns bare pointer on the internal value representation
641 return (unsigned char*)&myValue[0];
644 //! Returns bare pointer on the internal value representation
652 //! Returns bare pointer on the internal value representation
660 //! Iteration through Gauss Points by their components
662 GetGaussValueSliceArr(TInt theElemId) const
664 TCValueSliceArr aValueSliceArr(myNbGauss);
665 if(GetModeSwitch() == eFULL_INTERLACE){
666 TInt anId = theElemId * myStep;
667 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
668 aValueSliceArr[aGaussId] =
669 TCValueSlice(myValue, std::slice(anId, myNbComp, 1));
674 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
675 aValueSliceArr[aGaussId] =
676 TCValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
679 return aValueSliceArr;
682 //! Iteration through Gauss Points by their components
684 GetGaussValueSliceArr(TInt theElemId)
686 TValueSliceArr aValueSliceArr(myNbGauss);
687 if(GetModeSwitch() == eFULL_INTERLACE){
688 TInt anId = theElemId*myStep;
689 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
690 aValueSliceArr[aGaussId] =
691 TValueSlice(myValue, std::slice(anId, myNbComp, 1));
696 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
697 aValueSliceArr[aGaussId] =
698 TValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
701 return aValueSliceArr;
704 //! Iteration through components by corresponding Gauss Points
706 GetCompValueSliceArr(TInt theElemId) const
708 TCValueSliceArr aValueSliceArr(myNbComp);
709 if(GetModeSwitch() == eFULL_INTERLACE){
710 TInt anId = theElemId*myStep;
711 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
712 aValueSliceArr[aCompId] =
713 TCValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
718 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
719 aValueSliceArr[aCompId] =
720 TCValueSlice(myValue, std::slice(theElemId, myNbGauss, myStep));
723 return aValueSliceArr;
726 //! Iteration through components by corresponding Gauss Points
728 GetCompValueSliceArr(TInt theElemId)
730 if(GetModeSwitch() == eFULL_INTERLACE){
731 TValueSliceArr aValueSliceArr(myNbComp);
732 TInt anId = theElemId*myStep;
733 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
734 aValueSliceArr[aCompId] =
735 TValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
738 return aValueSliceArr;
741 TValueSliceArr aValueSliceArr(myNbGauss);
742 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
743 aValueSliceArr[aGaussId] =
744 TValueSlice(myValue,std::slice(theElemId, myNbComp, myStep));
746 return aValueSliceArr;
751 //---------------------------------------------------------------
752 typedef TTMeshValue<TFloatVector> TFloatMeshValue;
753 typedef TTMeshValue<TIntVector> TIntMeshValue;
755 //---------------------------------------------------------------
756 // Backward compatibility declarations
757 typedef TFloatVector TValue;
758 typedef TSlice<TFloat> TValueSlice;
759 typedef TCSlice<TFloat> TCValueSlice;
761 typedef TVector<TCValueSlice> TCValueSliceArr;
762 typedef TVector<TValueSlice> TValueSliceArr;
764 typedef TFloatMeshValue TMeshValue;
765 typedef std::map<EGeometrieElement,TMeshValue> TGeom2Value;
767 //---------------------------------------------------------------
768 typedef std::map<EGeometrieElement,PProfileInfo> TGeom2Profile;
769 typedef std::set<EGeometrieElement> TGeom;
771 //---------------------------------------------------------------
772 //! The class is a base class for MED TimeStamp values holder
773 struct MEDWRAPPER_EXPORT TTimeStampValueBase:
774 virtual TModeSwitchInfo
776 //! A reference to corresponding MED TimeStamp
777 PTimeStampInfo myTimeStampInfo;
778 //!< Get a reference to corresponding MED TimeStamp
779 const PTimeStampInfo& GetTimeStampInfo() const { return myTimeStampInfo; }
781 //! Keeps set of MED EGeometrieElement which contains values for the timestamp
783 const TGeomSet& GetGeomSet() const { return myGeomSet; }
785 //! Keeps map of MED Profiles per geometric type
786 TGeom2Profile myGeom2Profile;
787 //! Gets a map of MED Profiles per geometric type
788 const TGeom2Profile& GetGeom2Profile() const { return myGeom2Profile; }
790 //! Gets type of the champ
793 GetTypeChamp() const = 0;
795 //! Allocates values for the given geometry
798 AllocateValue(EGeometrieElement theGeom,
802 EModeSwitch theMode = eFULL_INTERLACE) = 0;
806 GetValueSize(EGeometrieElement theGeom) const = 0;
810 GetNbVal(EGeometrieElement theGeom) const = 0;
814 GetNbGauss(EGeometrieElement theGeom) const = 0;
818 GetValuePtr(EGeometrieElement theGeom) = 0;
821 //---------------------------------------------------------------
822 //! The class implements a container for MED TimeStamp values
823 template<class TMeshValueType>
824 struct TTimeStampValue:
825 virtual TTimeStampValueBase
827 typedef TMeshValueType TTMeshValue;
828 typedef SharedPtr<TMeshValueType> PTMeshValue;
829 typedef typename TMeshValueType::TElement TElement;
830 typedef std::map<EGeometrieElement, PTMeshValue> TTGeom2Value;
832 ETypeChamp myTypeChamp; //<! Keeps type of the champ
834 //! Gets type of the champ
842 //! Keeps map of MED TimeStamp values per geometric type (const version)
843 TTGeom2Value myGeom2Value;
846 GetGeom2Value() const
851 //! Gets MED TimeStamp values for the given geometric type (const version)
853 GetMeshValuePtr(EGeometrieElement theGeom) const
855 typename TTGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
856 if(anIter == myGeom2Value.end())
857 EXCEPTION(std::runtime_error,"TTimeStampValue::GetMeshValuePtr - myGeom2Value.find(theGeom) fails");
858 return anIter->second;
861 //! Gets MED TimeStamp values for the given geometric type
863 GetMeshValuePtr(EGeometrieElement theGeom)
865 myGeomSet.insert(theGeom);
866 if(myGeom2Value.find(theGeom) == myGeom2Value.end()){
867 myGeom2Value[theGeom] = PTMeshValue(new TTMeshValue());
868 return myGeom2Value[theGeom];
870 return myGeom2Value[theGeom];
873 //! Gets MED TimeStamp values for the given geometric type (const version)
875 GetMeshValue(EGeometrieElement theGeom) const
877 return *(this->GetMeshValuePtr(theGeom));
880 //! Gets MED TimeStamp values for the given geometric type
882 GetMeshValue(EGeometrieElement theGeom)
884 return *(this->GetMeshValuePtr(theGeom));
888 //---------------------------------------------------------------
889 typedef TTimeStampValue<TFloatMeshValue> TFloatTimeStampValue;
890 typedef SharedPtr<TFloatTimeStampValue> PFloatTimeStampValue;
892 PFloatTimeStampValue MEDWRAPPER_EXPORT
893 CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
895 typedef TTimeStampValue<TIntMeshValue> TIntTimeStampValue;
896 typedef SharedPtr<TIntTimeStampValue> PIntTimeStampValue;
898 PIntTimeStampValue MEDWRAPPER_EXPORT
899 CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
901 //---------------------------------------------------------------
902 template<class TMeshValueTypeFrom, class TMeshValueTypeTo>
904 CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueTypeFrom> > theTimeStampValueFrom,
905 SharedPtr<TTimeStampValue<TMeshValueTypeTo> > theTimeStampValueTo)
907 typedef TTimeStampValue<TMeshValueTypeFrom> TimeStampValueTypeFrom;
908 typedef TTimeStampValue<TMeshValueTypeTo> TimeStampValueTypeTo;
909 typedef typename TMeshValueTypeTo::TElement TElementTo;
911 typename TimeStampValueTypeFrom::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
912 typename TimeStampValueTypeFrom::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
913 for(; anIter != aGeom2Value.end(); anIter++){
914 const EGeometrieElement& aGeom = anIter->first;
915 const typename TimeStampValueTypeFrom::TTMeshValue& aMeshValue = *anIter->second;
916 typename TimeStampValueTypeTo::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
917 aMeshValue2.Allocate(aMeshValue.myNbElem,
918 aMeshValue.myNbGauss,
920 aMeshValue.myModeSwitch);
921 const typename TimeStampValueTypeFrom::TTMeshValue::TValue& aValue = aMeshValue.myValue;
922 typename TimeStampValueTypeTo::TTMeshValue::TValue& aValue2 = aMeshValue2.myValue;
923 TInt aSize = aValue.size();
924 for(TInt anId = 0; anId < aSize; anId++)
925 aValue2[anId] = TElementTo(aValue[anId]);
929 //---------------------------------------------------------------
930 template<class TMeshValueType>
932 CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueFrom,
933 SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueTo)
935 typedef TTimeStampValue<TMeshValueType> TimeStampValueType;
936 typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
937 typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
938 for(; anIter != aGeom2Value.end(); anIter++){
939 const EGeometrieElement& aGeom = anIter->first;
940 const typename TimeStampValueType::TTMeshValue& aMeshValue = *anIter->second;
941 typename TimeStampValueType::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
942 aMeshValue2 = aMeshValue;
946 //---------------------------------------------------------------
949 CopyTimeStampValueBase(const PTimeStampValueBase& theValueFrom,
950 const PTimeStampValueBase& theValueTo)
952 if(theValueFrom->GetTypeChamp() == theValueTo->GetTypeChamp()){
953 if(theValueFrom->GetTypeChamp() == eFLOAT64)
954 CopyTimeStampValue<TFloatMeshValue>(theValueFrom, theValueTo);
955 else if(theValueFrom->GetTypeChamp() == eINT)
956 CopyTimeStampValue<TIntMeshValue>(theValueFrom, theValueTo);
958 if(theValueFrom->GetTypeChamp() == eFLOAT64 && theValueTo->GetTypeChamp() == eINT)
959 CopyTimeStampValue<TFloatMeshValue, TIntMeshValue>(theValueFrom, theValueTo);
960 else if(theValueFrom->GetTypeChamp() == eINT && theValueTo->GetTypeChamp() == eFLOAT64)
961 CopyTimeStampValue<TIntMeshValue, TFloatMeshValue>(theValueFrom, theValueTo);
965 //---------------------------------------------------------------
966 // Backward compatibility declarations
967 typedef TFloatTimeStampValue TTimeStampVal;
968 typedef PFloatTimeStampValue PTimeStampVal;
970 //---------------------------------------------------------------
971 typedef std::map<TInt,TFloatVector> TIndexes;
972 typedef std::map<TInt,TString> TNames;
974 //---------------------------------------------------------------
975 //! Define a base class which represents MED Grille (structured mesh)
976 struct MEDWRAPPER_EXPORT TGrilleInfo:
977 virtual TModeSwitchInfo
979 PMeshInfo myMeshInfo;
980 const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
982 TNodeCoord myCoord; //!< Contains all nodal coordinates, now used only for eGRILLE_STANDARD
983 //! Gives coordinates for mesh nodes (const version)
984 const TNodeCoord& GetNodeCoord() const;
985 TNodeCoord& GetNodeCoord();
986 //! Gives coordinates for mesh node by its number, array index from 0
987 TNodeCoord GetCoord(TInt theId);
988 //! Gives ids of nodes for mesh cell or sub-cell by its number, array index from 0
989 TIntVector GetConn(TInt theId, const bool isSub=false);
991 EGrilleType myGrilleType; //!< Defines grille type (eGRILLE_CARTESIENNE,eGRILLE_POLAIRE,eGRILLE_STANDARD)
992 //!Gets grille type (const version)
993 const EGrilleType& GetGrilleType() const;
995 EGrilleType GetGrilleType();
997 void SetGrilleType(EGrilleType theGrilleType);
999 TString myCoordNames; //!< Contains names for the coordinate dimensions
1000 //! Get name of the coordinate dimension by its order number
1001 virtual std::string GetCoordName(TInt theId) const = 0 ;
1002 //! Set name of the coordinate dimension by its order number
1003 virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
1005 TString myCoordUnits; //!< Contains units for the coordinate dimensions
1006 //! Get name of unit for the coordinate dimension by its order number
1007 virtual std::string GetCoordUnit(TInt theId) const = 0;
1008 //! Set name of unit for the coordinate dimension by its order number
1009 virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
1011 //! Map of index of axes and Table of indexes for certain axe, now used for eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1013 //!Gets a map of Tables (const version)
1014 const TIndexes& GetMapOfIndexes() const ;
1015 //!Gets a map of Tables
1016 TIndexes& GetMapOfIndexes();
1017 //!Gets a Table of indexes for certain axe(const version)
1018 const TFloatVector& GetIndexes(TInt theAxisNumber) const;
1019 //!Gets a Table of indexes for certain axe
1020 TFloatVector& GetIndexes(TInt theAxisNumber);
1021 //!Gets a number of indices per axe
1022 TInt GetNbIndexes(TInt theAxisNumber);
1024 TInt GetNbNodes();//! Return count of all points
1025 TInt GetNbCells();//! Return count of all cells
1026 TInt GetNbSubCells();//! Return count of all entities of <mesh dimension-1>
1027 EGeometrieElement GetGeom();//! Return geometry of cells (calculated from mesh dimension)
1028 EGeometrieElement GetSubGeom();//! Return geometry of subcells (calculated from mesh dimension)
1029 EEntiteMaillage GetEntity();//! Return entity (eMAILLE)
1030 EEntiteMaillage GetSubEntity();//! Return sub entity
1033 *Vector of grille structure (Example: {3,4,5}, 3 nodes in X axe, 4 nodes in Y axe, ...)
1035 TIntVector myGrilleStructure;
1036 //!Gets grille structure(const version)
1037 const TIntVector& GetGrilleStructure() const;
1038 //!Gets grille structure
1039 TIntVector GetGrilleStructure();
1040 //!Sets the grille structure of theAxis axe to theNb.
1041 void SetGrilleStructure(TInt theAxis,TInt theNb);
1044 *Defines sequence MED Family indexes for corresponding mesh entities
1047 //! Get number of a MED FAMILY by order number of the mesh element
1048 TInt GetFamNum(TInt theId) const;
1049 //! Set number of a MED FAMILY for the mesh element with the order number
1050 void SetFamNum(TInt theId, TInt theVal);
1053 *Defines sequence MED Family indexes for sub entities
1055 TElemNum myFamSubNum;
1056 //! Get number of a MED FAMILY by order number of sub element
1057 TInt GetFamSubNum(TInt theId) const;
1058 //! Set number of a MED FAMILY for theId-th sub element
1059 void SetFamSubNum(TInt theId, TInt theVal);
1062 *Defines sequence MED Family indexes for corresponding mesh nodes
1064 TElemNum myFamNumNode;
1065 //! Get number of a MED FAMILY by order number of the mesh node
1066 TInt GetFamNumNode(TInt theId) const;
1067 //! Set number of a MED FAMILY for the mesh node with the order number
1068 void SetFamNumNode(TInt theId, TInt theVal);
1072 #endif // MED_Structures_HeaderFile