1 // Copyright (C) 2007-2015 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_Common.hxx"
27 #include "MED_Utilities.hxx"
30 #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
69 //---------------------------------------------------------------
70 //! Define a parent class for all named MED entities
71 struct MEDWRAPPER_EXPORT TNameInfo: virtual TBase
73 TString myName; //!< Keeps its name
74 virtual std::string GetName() const = 0; //!< Gets its name
75 virtual void SetName(const std::string& theValue) = 0; //!< Set a new name
76 virtual void SetName(const TString& theValue) = 0; //!< Set a new name
80 //---------------------------------------------------------------
81 //! Define a parent class for all MED entities that contains a sequence of numbers
83 It defines through corresponding enumeration (EModeSwitch) how the sequence
84 should be interpreted in C or Fortran mode (eFULL_INTERLACE or eNON_INTERLACE).
86 struct MEDWRAPPER_EXPORT TModeSwitchInfo: virtual TBase
88 //! To construct instance of the class by default
90 myModeSwitch(eFULL_INTERLACE)
93 //! To construct instance of the class
94 TModeSwitchInfo(EModeSwitch theModeSwitch):
95 myModeSwitch(theModeSwitch)
98 EModeSwitch myModeSwitch; //!< Keeps the
99 EModeSwitch GetModeSwitch() const { return myModeSwitch;}
103 //---------------------------------------------------------------
104 //! Define a base class which represents MED Mesh entity
105 struct MEDWRAPPER_EXPORT TMeshInfo: virtual TNameInfo
107 TInt myDim; //!< Dimension of the mesh (0, 1, 2 or 3)
108 TInt GetDim() const { return myDim;} //!< Gets dimension of the mesh
111 TInt GetSpaceDim() const { return mySpaceDim; }
113 EMaillage myType; //!< Type of the mesh
114 EMaillage GetType() const { return myType;} //!< Gets type of the mesh
116 TString myDesc; //!< Description of the mesh
117 virtual std::string GetDesc() const = 0; //!< Get description for the mesh
118 virtual void SetDesc(const std::string& theValue) = 0; //!< Sets description for the mesh
124 //---------------------------------------------------------------
125 typedef TVector<TInt> TIntVector;
126 typedef TSlice<TInt> TIntVecSlice;
127 typedef TCSlice<TInt> TCIntVecSlice;
129 typedef TIntVector TFamAttr;
131 //! Define a base class which represents MED Family entity
132 struct MEDWRAPPER_EXPORT TFamilyInfo: virtual TNameInfo
134 PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
135 //! Get a reference to corresponding MED Mesh
136 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
138 TInt myId; //!< An unique index of the MED FAMILY
139 TInt GetId() const { return myId;} //!< Gets number of the MED FAMILY
140 void SetId(TInt theId) { myId = theId;} //! Define number of the MED FAMILY
142 TInt myNbGroup; //!< Defines number MED Groups connected to
143 //! Gets number of MED GROUPS the MED FAMILY is bound to
144 TInt GetNbGroup() const { return myNbGroup;}
146 //! Contains sequence of the names for the MED Groups connected to
147 TString myGroupNames;
148 //! Gets name of a bound MED GROUP by its number
149 virtual std::string GetGroupName(TInt theId) const = 0;
150 //! Sets name of the defined MED GROUP by its number
151 virtual void SetGroupName(TInt theId, const std::string& theValue) = 0;
153 TInt myNbAttr; //!< Defines number of the MED Family attributes
154 //! Gets number of attached attributes for the MED FAMILY
155 TInt GetNbAttr() const { return myNbAttr;}
157 //! Defines sequence of the indexes of the MED Family attributes
159 //! Get MED FAMILY attribute by its number
160 TInt GetAttrId(TInt theId) const;
161 //! Set MED FAMILY attribute by its number
162 void SetAttrId(TInt theId, TInt theVal);
164 //! Defines sequence of the values of the MED Family attributes
166 //! Get MED FAMILY attribute by its number
167 TInt GetAttrVal(TInt theId) const;
168 //! Set MED FAMILY attribute by its number
169 void SetAttrVal(TInt theId, TInt theVal);
171 //! Defines sequence of the names of the MED Family attributes
173 //! Get value of the MED FAMILY attribute by its number
174 virtual std::string GetAttrDesc(TInt theId) const = 0;
175 //! Set value of the MED FAMILY attribute by its number
176 virtual void SetAttrDesc(TInt theId, const std::string& theValue) = 0;
180 //---------------------------------------------------------------
181 typedef TIntVector TElemNum;
182 typedef SharedPtr<TElemNum> PElemNum;
184 //! Define a parent class for all MED entities that describes mesh entites such as nodes and cells.
185 struct MEDWRAPPER_EXPORT TElemInfo: virtual TBase
187 PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
188 //! Get a reference to corresponding MED Mesh
189 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
191 TInt myNbElem; //<! Number of corresponding mesh entities
192 TInt GetNbElem() const { return myNbElem;} //! Get number of mesh elements
194 //! Defines sequence MED Family indexes for corresponding mesh entites
196 //! Get number of a MED FAMILY by order number of the mesh element
197 TInt GetFamNum(TInt theId) const;
198 //! Set number of a MED FAMILY for the mesh element with the order number
199 void SetFamNum(TInt theId, TInt theVal);
201 //! Defines if the mesh elements are indexed
202 EBooleen myIsElemNum;
203 //! Let know if the mesh elements are indexed
204 EBooleen IsElemNum() const { return myIsElemNum;}
206 //! Defines if the mesh elements family are indexed
208 //! Let know if the mesh elements family are indexed
209 EBooleen IsFamNum() const { return myIsFamNum;}
212 //! Contains sequence of the indexes for the mesh elements
214 //! Get a reference number of the mesh element by its order number
215 TInt GetElemNum(TInt theId) const;
216 //! Set a reference number for the mesh element by its order number
217 void SetElemNum(TInt theId, TInt theVal);
219 //! Defines if the mesh elements are named
220 EBooleen myIsElemNames;
221 //! Let know if the mesh elements havew names
222 EBooleen IsElemNames() const { return myIsElemNames;}
224 //! Contains sequence of the names for the mesh elements
226 //! Get name of the mesh element by its order number
227 virtual std::string GetElemName(TInt theId) const = 0;
228 //! Set name of the mesh element by its order number
229 virtual void SetElemName(TInt theId, const std::string& theValue) = 0;
233 //---------------------------------------------------------------
234 typedef TVector<TFloat> TFloatVector;
235 typedef TSlice<TFloat> TFloatVecSlice;
236 typedef TCSlice<TFloat> TCFloatVecSlice;
238 typedef TFloatVector TNodeCoord;
239 typedef SharedPtr<TNodeCoord> PNodeCoord;
241 typedef TFloatVecSlice TCoordSlice;
242 typedef TCFloatVecSlice TCCoordSlice;
244 //! Define a base class which represents MED Nodes entity
245 struct MEDWRAPPER_EXPORT TNodeInfo:
247 virtual TModeSwitchInfo
249 PNodeCoord myCoord; //!< Contains all nodal coordinates
251 //! Gives coordinates for mesh node by its number (const version)
252 TCCoordSlice GetCoordSlice(TInt theId) const;
253 //! Gives coordinates for mesh node by its number
254 TCoordSlice GetCoordSlice(TInt theId);
256 ERepere mySystem; //!< Defines, which coordinate system is used
257 //! Get which coordinate system is used for the node describing
258 ERepere GetSystem() const { return mySystem;}
259 //! Set coordinate system to be used for the node describing
260 void SetSystem(ERepere theSystem) { mySystem = theSystem;}
262 TString myCoordNames; //!< Contains names for the coordinate dimensions
263 //! Get name of the coordinate dimension by its order number
264 virtual std::string GetCoordName(TInt theId) const = 0;
265 //! Set name of the coordinate dimension by its order number
266 virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
268 TString myCoordUnits; //!< Contains units for the coordinate dimensions
269 //! Get name of unit for the coordinate dimension by its order number
270 virtual std::string GetCoordUnit(TInt theId) const = 0;
271 //! Set name of unit for the coordinate dimension by its order number
272 virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
276 //---------------------------------------------------------------
277 typedef TIntVecSlice TConnSlice;
278 typedef TCIntVecSlice TCConnSlice;
280 //! Define a base class which represents MED Cells entity
281 struct MEDWRAPPER_EXPORT TCellInfo:
283 virtual TModeSwitchInfo
285 EEntiteMaillage myEntity; //!< Defines the MED Entity where the mesh cells belongs to
286 //! Let known what MED ENTITY the cells belong to
287 EEntiteMaillage GetEntity() const { return myEntity;}
289 EGeometrieElement myGeom; //!< Defines the MED Geometric type of the instance
290 //! Let known what MED geometrical type the cells belong to
291 EGeometrieElement GetGeom() const { return myGeom;}
293 EConnectivite myConnMode; //!< Defines connectivity mode
294 //! Let known in what connectivity the cells are writen
295 EConnectivite GetConnMode() const { return myConnMode;}
297 virtual TInt GetConnDim() const = 0; //!< Gives step in the connectivity sequence
299 PElemNum myConn; //!< Defines sequence which describe connectivity for each of mesh cell
301 //! Gives connectivities for mesh cell by its number (const version)
302 TCConnSlice GetConnSlice(TInt theElemId) const;
303 //! Gives connectivities for mesh cell by its number
304 TConnSlice GetConnSlice(TInt theElemId);
307 //---------------------------------------------------------------
308 //! Define a base class which represents MED Polygon entity
309 struct MEDWRAPPER_EXPORT TPolygoneInfo:
312 //! Defines the MED Entity where the polygons belongs to
313 EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
314 //! Let known what MED ENTITY the MED Polygons belong to
315 EEntiteMaillage GetEntity() const { return myEntity;}
317 //! Defines the MED Geometric type of the instance
318 EGeometrieElement myGeom; // ePOLYGONE
319 //! Let known what MED geometrical type the MED Polygons belong to
320 EGeometrieElement GetGeom() const { return ePOLYGONE;}
322 //! Defines connectivity mode
323 EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
324 //! Let known in what connectivity the cells are writen
325 EConnectivite GetConnMode() const { return myConnMode;}
327 PElemNum myConn; //!< Table de connectivities
328 PElemNum myIndex; //!< Table de indexes
330 //! Gives number of the connectivities for the defined polygon
331 TInt GetNbConn(TInt theElemId) const;
333 //! Gives connectivities for polygon by its number (const version)
334 TCConnSlice GetConnSlice(TInt theElemId) const;
335 //! Gives connectivities for polygon by its number
336 TConnSlice GetConnSlice(TInt theElemId);
339 //---------------------------------------------------------------
340 //! Define a class representing MED_BALL structure element.
342 // This could be a generic class for any structure element
343 // holding any number of contant and variable attributes
344 // but it's too hard to implement
346 struct MEDWRAPPER_EXPORT TBallInfo:
349 TFloatVector myDiameters;
352 //---------------------------------------------------------------
353 typedef TVector<TCConnSlice> TCConnSliceArr;
354 typedef TVector<TConnSlice> TConnSliceArr;
356 //! Define a base class which represents MED Polyedre entity
357 struct MEDWRAPPER_EXPORT TPolyedreInfo:
360 //! Defines the MED Entity where the polyedres belongs to
361 EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
362 //! Let known what MED ENTITY the MED Polyedres belong to
363 EEntiteMaillage GetEntity() const { return myEntity;}
365 //! Defines the MED Geometric type of the instance
366 EGeometrieElement myGeom; // ePOLYEDRE
367 //! Let known what MED geometrical type the MED Polyedres belong to
368 EGeometrieElement GetGeom() const { return ePOLYEDRE;}
370 //! Defines connectivity mode
371 EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
372 //! Let known in what connectivity the cells are writen
373 EConnectivite GetConnMode() const { return myConnMode;}
375 PElemNum myConn; //!< Table de connectivities
376 PElemNum myFaces; //!< Table de faces indexes
377 PElemNum myIndex; //!< Table de indexes
379 //! Gives number of the faces for the defined polyedre (const version)
380 TInt GetNbFaces(TInt theElemId) const;
381 //! Gives number of the nodes for the defined polyedre
382 TInt GetNbNodes(TInt theElemId) const;
384 //! Gives sequence of the face connectivities for polyedre by its number (const version)
385 TCConnSliceArr GetConnSliceArr(TInt theElemId) const;
386 //! Gives sequence of the face connectivities for polyedre by its number
387 TConnSliceArr GetConnSliceArr(TInt theElemId);
390 //---------------------------------------------------------------
391 //! Define a base class which represents MED Field entity
392 struct MEDWRAPPER_EXPORT TFieldInfo:
395 PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
396 //! Get a reference to corresponding MED Mesh
397 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
399 ETypeChamp myType; //!< Defines type of the MED Field
400 //! Let known what type of the MED FIELD is used
401 ETypeChamp GetType() const { return myType;}
403 TInt myNbComp; //!< Defines number of components stored in the field
404 //! Get number of components for the MED FIELD
405 TInt GetNbComp() const { return myNbComp;}
407 EBooleen myIsLocal; //!< Defines if the MED Field is local
408 //! Let known is the MED FIELD is local or not
409 EBooleen GetIsLocal() const { return myIsLocal;}
411 TInt myNbRef; //!< Defines number of refereces of the field
412 //! Let known number of references for the MED FIELD
413 TInt GetNbRef() const { return myNbRef;}
415 TString myCompNames; //!< Contains names for each of MED Field components
416 //! Get name of the component by its order number
417 virtual std::string GetCompName(TInt theId) const = 0;
418 //! Set name for the component by its order number
419 virtual void SetCompName(TInt theId, const std::string& theValue) = 0;
421 TString myUnitNames; //!< Contains units for each of MED Field components
422 //! Get unit of the component by its order number
423 virtual std::string GetUnitName(TInt theId) const = 0;
424 //! Set unit for the component by its order number
425 virtual void SetUnitName(TInt theId, const std::string& theValue) = 0;
430 //---------------------------------------------------------------
431 //! Get dimension of the Gauss coordinates for the defined type of mesh cell
434 GetDimGaussCoord(EGeometrieElement theGeom);
436 //! Get number of referenced nodes for the defined type of mesh cell
439 GetNbRefCoord(EGeometrieElement theGeom);
441 typedef TFloatVector TWeight;
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 //! Let known 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());}
494 //---------------------------------------------------------------
495 typedef std::map<EGeometrieElement,PGaussInfo> TGeom2Gauss;
496 typedef std::map<EGeometrieElement,TInt> TGeom2NbGauss;
498 //! Define a base class which represents MED TimeStamp
499 struct MEDWRAPPER_EXPORT TTimeStampInfo:
502 PFieldInfo myFieldInfo; //!< A reference to correspondig 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 //! Let known 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;
541 //---------------------------------------------------------------
542 //! The class represents MED Profile entity
543 struct MEDWRAPPER_EXPORT TProfileInfo:
546 typedef std::string TKey;
547 typedef boost::tuple<TKey,TInt> TInfo;
549 EModeProfil myMode; //!< Keeps mode for the MED Profile
550 //! Let known what mode of MED Profile is used
551 EModeProfil GetMode() const { return myMode;}
552 //! Set mode for the MED Profile
553 void SetMode(EModeProfil theMode) { myMode = theMode;}
555 PElemNum myElemNum; //!< Keeps sequence of cell by its number which belong to the profile
556 //! Get number of mesh elelemts by its order number
557 TInt GetElemNum(TInt theId) const;
558 //! Set number of mesh elelemts by its order number
559 void SetElemNum(TInt theId, TInt theVal);
561 //! Let known is the MED Profile defined
562 bool IsPresent() const { return GetName() != "";}
564 //! Let known size of the MED Profile
565 TInt GetSize() const { return (TInt)myElemNum->size();}
569 //---------------------------------------------------------------
570 //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
571 struct MEDWRAPPER_EXPORT TMeshValueBase:
572 virtual TModeSwitchInfo
581 //! Initialize the class
583 Allocate(TInt theNbElem,
586 EModeSwitch theMode = eFULL_INTERLACE);
588 //! Returns size of the value container
592 //! Returns MED interpetation of the value size
596 //! Returns number of Gauss Points bounded with the value
600 //! Returns step inside of the data array
604 //! Returns bare pointer on the internal value representation
610 //---------------------------------------------------------------
611 //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
612 template<class TValueType>
614 virtual TMeshValueBase
616 typedef TValueType TValue;
617 typedef typename TValueType::value_type TElement;
619 typedef TSlice<TElement> TValueSlice;
620 typedef TCSlice<TElement> TCValueSlice;
622 typedef TVector<TCValueSlice> TCValueSliceArr;
623 typedef TVector<TValueSlice> TValueSliceArr;
627 //! Initialize the class
629 Allocate(TInt theNbElem,
632 EModeSwitch theMode = eFULL_INTERLACE)
634 TMeshValueBase::Allocate(theNbElem, theNbGauss, theNbComp, theMode);
635 myValue.resize(theNbElem * this->GetStep());
638 //! Returns bare pointer on the internal value representation
643 return (unsigned char*)&myValue[0];
646 //! Returns bare pointer on the internal value representation
654 //! Returns bare pointer on the internal value representation
662 //! Iteration through Gauss Points by their components
664 GetGaussValueSliceArr(TInt theElemId) const
666 TCValueSliceArr aValueSliceArr(myNbGauss);
667 if(GetModeSwitch() == eFULL_INTERLACE){
668 TInt anId = theElemId * myStep;
669 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
670 aValueSliceArr[aGaussId] =
671 TCValueSlice(myValue, std::slice(anId, myNbComp, 1));
676 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
677 aValueSliceArr[aGaussId] =
678 TCValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
681 return aValueSliceArr;
684 //! Iteration through Gauss Points by their components
686 GetGaussValueSliceArr(TInt theElemId)
688 TValueSliceArr aValueSliceArr(myNbGauss);
689 if(GetModeSwitch() == eFULL_INTERLACE){
690 TInt anId = theElemId*myStep;
691 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
692 aValueSliceArr[aGaussId] =
693 TValueSlice(myValue, std::slice(anId, myNbComp, 1));
698 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
699 aValueSliceArr[aGaussId] =
700 TValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
703 return aValueSliceArr;
706 //! Iteration through components by corresponding Gauss Points
708 GetCompValueSliceArr(TInt theElemId) const
710 TCValueSliceArr aValueSliceArr(myNbComp);
711 if(GetModeSwitch() == eFULL_INTERLACE){
712 TInt anId = theElemId*myStep;
713 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
714 aValueSliceArr[aCompId] =
715 TCValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
720 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
721 aValueSliceArr[aCompId] =
722 TCValueSlice(myValue, std::slice(theElemId, myNbGauss, myStep));
725 return aValueSliceArr;
728 //! Iteration through components by corresponding Gauss Points
730 GetCompValueSliceArr(TInt theElemId)
732 if(GetModeSwitch() == eFULL_INTERLACE){
733 TValueSliceArr aValueSliceArr(myNbComp);
734 TInt anId = theElemId*myStep;
735 for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
736 aValueSliceArr[aCompId] =
737 TValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
740 return aValueSliceArr;
743 TValueSliceArr aValueSliceArr(myNbGauss);
744 for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
745 aValueSliceArr[aGaussId] =
746 TValueSlice(myValue,std::slice(theElemId, myNbComp, myStep));
748 return aValueSliceArr;
753 typedef TTMeshValue<TFloatVector> TFloatMeshValue;
754 typedef TTMeshValue<TIntVector> TIntMeshValue;
756 //---------------------------------------------------------------
757 // Backward compatibility declarations
758 typedef TFloatVector TValue;
759 typedef TSlice<TFloat> TValueSlice;
760 typedef TCSlice<TFloat> TCValueSlice;
762 typedef TVector<TCValueSlice> TCValueSliceArr;
763 typedef TVector<TValueSlice> TValueSliceArr;
765 typedef TFloatMeshValue TMeshValue;
766 typedef std::map<EGeometrieElement,TMeshValue> TGeom2Value;
768 //---------------------------------------------------------------
769 typedef std::map<EGeometrieElement,PProfileInfo> TGeom2Profile;
770 typedef std::set<EGeometrieElement> TGeom;
772 //! The class is a base class for MED TimeStamp values holder
773 struct MEDWRAPPER_EXPORT TTimeStampValueBase:
774 virtual TModeSwitchInfo
776 //! A reference to correspondig MED TimeStamp
777 PTimeStampInfo myTimeStampInfo;
778 //!< Get a reference to correspondig 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;
822 //---------------------------------------------------------------
823 //! The class implements a container for MED TimeStamp values
824 template<class TMeshValueType>
825 struct TTimeStampValue:
826 virtual TTimeStampValueBase
828 typedef TMeshValueType TTMeshValue;
829 typedef SharedPtr<TMeshValueType> PTMeshValue;
830 typedef typename TMeshValueType::TElement TElement;
831 typedef std::map<EGeometrieElement, PTMeshValue> TTGeom2Value;
833 ETypeChamp myTypeChamp; //<! Keeps type of the champ
835 //! Gets type of the champ
843 //! Keeps map of MED TimeStamp values per geometric type (const version)
844 TTGeom2Value myGeom2Value;
847 GetGeom2Value() const
852 //! Gets MED TimeStamp values for the given geometric type (const version)
854 GetMeshValuePtr(EGeometrieElement theGeom) const
856 typename TTGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
857 if(anIter == myGeom2Value.end())
858 EXCEPTION(std::runtime_error,"TTimeStampValue::GetMeshValuePtr - myGeom2Value.find(theGeom) fails");
859 return anIter->second;
862 //! Gets MED TimeStamp values for the given geometric type
864 GetMeshValuePtr(EGeometrieElement theGeom)
866 myGeomSet.insert(theGeom);
867 if(myGeom2Value.find(theGeom) == myGeom2Value.end()){
868 myGeom2Value[theGeom] = PTMeshValue(new TTMeshValue());
869 return myGeom2Value[theGeom];
871 return myGeom2Value[theGeom];
874 //! Gets MED TimeStamp values for the given geometric type (const version)
876 GetMeshValue(EGeometrieElement theGeom) const
878 return *(this->GetMeshValuePtr(theGeom));
881 //! Gets MED TimeStamp values for the given geometric type
883 GetMeshValue(EGeometrieElement theGeom)
885 return *(this->GetMeshValuePtr(theGeom));
890 //---------------------------------------------------------------
891 typedef TTimeStampValue<TFloatMeshValue> TFloatTimeStampValue;
892 typedef SharedPtr<TFloatTimeStampValue> PFloatTimeStampValue;
894 PFloatTimeStampValue MEDWRAPPER_EXPORT
895 CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
897 typedef TTimeStampValue<TIntMeshValue> TIntTimeStampValue;
898 typedef SharedPtr<TIntTimeStampValue> PIntTimeStampValue;
900 PIntTimeStampValue MEDWRAPPER_EXPORT
901 CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
904 //---------------------------------------------------------------
905 template<class TMeshValueTypeFrom, class TMeshValueTypeTo>
907 CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueTypeFrom> > theTimeStampValueFrom,
908 SharedPtr<TTimeStampValue<TMeshValueTypeTo> > theTimeStampValueTo)
910 typedef TTimeStampValue<TMeshValueTypeFrom> TimeStampValueTypeFrom;
911 typedef TTimeStampValue<TMeshValueTypeTo> TimeStampValueTypeTo;
912 typedef typename TMeshValueTypeTo::TElement TElementTo;
914 typename TimeStampValueTypeFrom::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
915 typename TimeStampValueTypeFrom::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
916 for(; anIter != aGeom2Value.end(); anIter++){
917 const EGeometrieElement& aGeom = anIter->first;
918 const typename TimeStampValueTypeFrom::TTMeshValue& aMeshValue = *anIter->second;
919 typename TimeStampValueTypeTo::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
920 aMeshValue2.Allocate(aMeshValue.myNbElem,
921 aMeshValue.myNbGauss,
923 aMeshValue.myModeSwitch);
924 const typename TimeStampValueTypeFrom::TTMeshValue::TValue& aValue = aMeshValue.myValue;
925 typename TimeStampValueTypeTo::TTMeshValue::TValue& aValue2 = aMeshValue2.myValue;
926 TInt aSize = aValue.size();
927 for(TInt anId = 0; anId < aSize; anId++)
928 aValue2[anId] = TElementTo(aValue[anId]);
932 template<class TMeshValueType>
934 CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueFrom,
935 SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueTo)
937 typedef TTimeStampValue<TMeshValueType> TimeStampValueType;
938 typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
939 typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
940 for(; anIter != aGeom2Value.end(); anIter++){
941 const EGeometrieElement& aGeom = anIter->first;
942 const typename TimeStampValueType::TTMeshValue& aMeshValue = *anIter->second;
943 typename TimeStampValueType::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
944 aMeshValue2 = aMeshValue;
948 //---------------------------------------------------------------
951 CopyTimeStampValueBase(const PTimeStampValueBase& theValueFrom,
952 const PTimeStampValueBase& theValueTo)
954 if(theValueFrom->GetTypeChamp() == theValueTo->GetTypeChamp()){
955 if(theValueFrom->GetTypeChamp() == eFLOAT64)
956 CopyTimeStampValue<TFloatMeshValue>(theValueFrom, theValueTo);
957 else if(theValueFrom->GetTypeChamp() == eINT)
958 CopyTimeStampValue<TIntMeshValue>(theValueFrom, theValueTo);
960 if(theValueFrom->GetTypeChamp() == eFLOAT64 && theValueTo->GetTypeChamp() == eINT)
961 CopyTimeStampValue<TFloatMeshValue, TIntMeshValue>(theValueFrom, theValueTo);
962 else if(theValueFrom->GetTypeChamp() == eINT && theValueTo->GetTypeChamp() == eFLOAT64)
963 CopyTimeStampValue<TIntMeshValue, TFloatMeshValue>(theValueFrom, theValueTo);
968 //---------------------------------------------------------------
969 // Backward compatibility declarations
970 typedef TFloatTimeStampValue TTimeStampVal;
971 typedef PFloatTimeStampValue PTimeStampVal;
973 //---------------------------------------------------------------
974 typedef std::map<TInt,TFloatVector> TIndexes;
975 typedef std::map<TInt,TString> TNames;
977 //! Define a base class which represents MED Grille (structured mesh)
978 struct MEDWRAPPER_EXPORT TGrilleInfo:
979 virtual TModeSwitchInfo
982 PMeshInfo myMeshInfo;
983 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
985 TNodeCoord myCoord; //!< Contains all nodal coordinates, now used only for eGRILLE_STANDARD
986 //! Gives coordinates for mesh nodes (const version)
987 const TNodeCoord& GetNodeCoord() const;
988 TNodeCoord& GetNodeCoord();
989 //! Gives coordinates for mesh node by its number, array index from 0
990 TNodeCoord GetCoord(TInt theId);
991 //! Gives ids of nodes for mesh cell or sub-cell by its number, array index from 0
992 TIntVector GetConn(TInt theId, const bool isSub=false);
994 EGrilleType myGrilleType; //!< Defines grille type (eGRILLE_CARTESIENNE,eGRILLE_POLAIRE,eGRILLE_STANDARD)
995 //!Gets grille type (const version)
996 const EGrilleType& GetGrilleType() const;
998 EGrilleType GetGrilleType();
1000 void SetGrilleType(EGrilleType theGrilleType);
1004 TString myCoordNames; //!< Contains names for the coordinate dimensions
1005 //! Get name of the coordinate dimension by its order number
1006 virtual std::string GetCoordName(TInt theId) const = 0 ;
1007 //! Set name of the coordinate dimension by its order number
1008 virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
1010 TString myCoordUnits; //!< Contains units for the coordinate dimensions
1011 //! Get name of unit for the coordinate dimension by its order number
1012 virtual std::string GetCoordUnit(TInt theId) const = 0;
1013 //! Set name of unit for the coordinate dimension by its order number
1014 virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
1017 //! Map of index of axes and Table of indexes for certain axe, now used for eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1019 //!Gets a map of Tables (const version)
1020 const TIndexes& GetMapOfIndexes() const ;
1021 //!Gets a map of Tables
1022 TIndexes& GetMapOfIndexes();
1023 //!Gets a Table of indexes for certain axe(const version)
1024 const TFloatVector& GetIndexes(TInt theAxisNumber) const;
1025 //!Gets a Table of indexes for certain axe
1026 TFloatVector& GetIndexes(TInt theAxisNumber);
1027 //!Gets a number of indices per axe
1028 TInt GetNbIndexes(TInt theAxisNumber);
1030 TInt GetNbNodes();//! Return count of all points
1031 TInt GetNbCells();//! Return count of all cells
1032 TInt GetNbSubCells();//! Return count of all entities of <mesh dimension-1>
1033 EGeometrieElement GetGeom();//! Return geometry of cells (calculated from mesh dimension)
1034 EGeometrieElement GetSubGeom();//! Return geometry of subcells (calculated from mesh dimension)
1035 EEntiteMaillage GetEntity();//! Return entity (eMAILLE)
1036 EEntiteMaillage GetSubEntity();//! Return sub entity
1039 *Vector of grille structure (Example: {3,4,5}, 3 nodes in X axe, 4 nodes in Y axe, ...)
1041 TIntVector myGrilleStructure;
1042 //!Gets grille structure(const version)
1043 const TIntVector& GetGrilleStructure() const;
1044 //!Gets grille structure
1045 TIntVector GetGrilleStructure();
1046 //!Sets the grille structure of theAxis axe to theNb.
1047 void SetGrilleStructure(TInt theAxis,TInt theNb);
1050 *Defines sequence MED Family indexes for corresponding mesh entites
1053 //! Get number of a MED FAMILY by order number of the mesh element
1054 TInt GetFamNum(TInt theId) const;
1055 //! Set number of a MED FAMILY for the mesh element with the order number
1056 void SetFamNum(TInt theId, TInt theVal);
1059 *Defines sequence MED Family indexes for sub entites
1061 TElemNum myFamSubNum;
1062 //! Get number of a MED FAMILY by order number of sub element
1063 TInt GetFamSubNum(TInt theId) const;
1064 //! Set number of a MED FAMILY for theId-th sub element
1065 void SetFamSubNum(TInt theId, TInt theVal);
1068 *Defines sequence MED Family indexes for corresponding mesh nodes
1070 TElemNum myFamNumNode;
1071 //! Get number of a MED FAMILY by order number of the mesh node
1072 TInt GetFamNumNode(TInt theId) const;
1073 //! Set number of a MED FAMILY for the mesh node with the order number
1074 void SetFamNumNode(TInt theId, TInt theVal);