3 // Copyright (C) 2003 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.
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
29 #ifndef MED_Structures_HeaderFile
30 #define MED_Structures_HeaderFile
32 #include "MED_Common.hxx"
37 //---------------------------------------------------------------
38 //! Defines a type for managing sequence of strings
39 typedef TVector<char> TString;
41 //! Extract a substring from the sequence of the strings
42 std::string GetString(TInt theId, TInt theStep,
43 const TString& theString);
45 //! Set a substring in the sequence of the strings
46 void SetString(TInt theId, TInt theStep,
48 const std::string& theValue);
50 //---------------------------------------------------------------
51 //! Define a parent class for all MEDWrapper classes
58 //---------------------------------------------------------------
59 //! Define a parent class for all named MED entities
60 struct TNameInfo: virtual TBase
62 TString myName; //!< Keeps its name
63 virtual std::string GetName() const = 0; //!< Gets its name
64 virtual void SetName(const std::string& theValue) = 0; //!< Set a new name
68 //---------------------------------------------------------------
69 //! Define a parent class for all MED entities that contains a sequence of numbers
71 It defines through corresponding enumeration (EModeSwitch) how the sequence
72 should be interpreted in C or Fortran mode (eFULL_INTERLACE or eNON_INTERLACE).
74 struct TModeSwitchInfo: virtual TBase
76 //! To construct instance of the class by default
78 myModeSwitch(eFULL_INTERLACE)
81 //! To construct instance of the class
82 TModeSwitchInfo(EModeSwitch theModeSwitch):
83 myModeSwitch(theModeSwitch)
86 EModeSwitch myModeSwitch; //!< Keeps the
87 EModeSwitch GetModeSwitch() const { return myModeSwitch;}
91 //---------------------------------------------------------------
92 //! Define a base class which represents MED Mesh entity
93 struct TMeshInfo: virtual TNameInfo
95 TInt myDim; //!< Dimension of the mesh (0, 1, 2 or 3)
96 TInt GetDim() const { return myDim;} //!< Gets dimension of the mesh
98 EMaillage myType; //!< Type of the mesh
99 EMaillage GetType() const { return myType;} //!< Gets type of the mesh
101 TString myDesc; //!< Description of the mesh
102 virtual std::string GetDesc() const = 0; //!< Get description for the mesh
103 virtual void SetDesc(const std::string& theValue) = 0; //!< Sets description for the mesh
107 //---------------------------------------------------------------
108 typedef TVector<TInt> TIntVector;
109 typedef TSlice<TIntVector> TIntVecSlice;
110 typedef TCSlice<TIntVector> TCIntVecSlice;
112 typedef TIntVector TFamAttr;
114 //! Define a base class which represents MED Family entity
115 struct TFamilyInfo: virtual TNameInfo
117 PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
118 //! Get a reference to corresponding MED Mesh
119 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
121 TInt myId; //!< An unique index of the MED FAMILY
122 TInt GetId() const { return myId;} //!< Gets number of the MED FAMILY
123 void SetId(TInt theId) { myId = theId;} //! Define number of the MED FAMILY
125 TInt myNbGroup; //!< Defines number MED Groups connected to
126 //! Gets number of MED GROUPS the MED FAMILY is bound to
127 TInt GetNbGroup() const { return myNbGroup;}
129 //! Contains sequence of the names for the MED Groups connected to
130 TString myGroupNames;
131 //! Gets name of a bound MED GROUP by its number
132 virtual std::string GetGroupName(TInt theId) const = 0;
133 //! Sets name of the defined MED GROUP by its number
134 virtual void SetGroupName(TInt theId, const std::string& theValue) = 0;
136 TInt myNbAttr; //!< Defines number of the MED Family attributes
137 //! Gets number of attached attributes for the MED FAMILY
138 TInt GetNbAttr() const { return myNbAttr;}
140 //! Defines sequence of the indexes of the MED Family attributes
142 //! Get MED FAMILY attribute by its number
143 TInt GetAttrId(TInt theId) const;
144 //! Set MED FAMILY attribute by its number
145 void SetAttrId(TInt theId, TInt theVal);
147 //! Defines sequence of the values of the MED Family attributes
149 //! Get MED FAMILY attribute by its number
150 TInt GetAttrVal(TInt theId) const;
151 //! Set MED FAMILY attribute by its number
152 void SetAttrVal(TInt theId, TInt theVal);
154 //! Defines sequence of the names of the MED Family attributes
156 //! Get value of the MED FAMILY attribute by its number
157 virtual std::string GetAttrDesc(TInt theId) const = 0;
158 //! Set value of the MED FAMILY attribute by its number
159 virtual void SetAttrDesc(TInt theId, const std::string& theValue) = 0;
163 //---------------------------------------------------------------
164 typedef TIntVector TElemNum;
166 //! Define a parent class for all MED entities that describes mesh entites such as nodes and cells.
167 struct TElemInfo: virtual TBase
169 PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
170 //! Get a reference to corresponding MED Mesh
171 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
173 TInt myNbElem; //<! Number of corresponding mesh entities
174 TInt GetNbElem() const { return myNbElem;} //! Get number of mesh elements
176 //! Defines sequence MED Family indexes for corresponding mesh entites
178 //! Get number of a MED FAMILY by order number of the mesh element
179 TInt GetFamNum(TInt theId) const;
180 //! Set number of a MED FAMILY for the mesh element with the order number
181 void SetFamNum(TInt theId, TInt theVal);
183 //! Defines if the mesh elements are indexed
184 EBooleen myIsElemNum;
185 //! Let know if the mesh elements are indexed
186 EBooleen IsElemNum() const { return myIsElemNum;}
188 //! Contains sequence of the indexes for the mesh elements
190 //! Get a reference number of the mesh element by its order number
191 TInt GetElemNum(TInt theId) const;
192 //! Set a reference number for the mesh element by its order number
193 void SetElemNum(TInt theId, TInt theVal);
195 //! Defines if the mesh elements are named
196 EBooleen myIsElemNames;
197 //! Let know if the mesh elements havew names
198 EBooleen IsElemNames() const { return myIsElemNames;}
200 //! Contains sequence of the names for the mesh elements
202 //! Get name of the mesh element by its order number
203 virtual std::string GetElemName(TInt theId) const = 0;
204 //! Set name of the mesh element by its order number
205 virtual void SetElemName(TInt theId, const std::string& theValue) = 0;
209 //---------------------------------------------------------------
210 typedef TVector<TFloat> TFloatVector;
211 typedef TSlice<TFloatVector> TFloatVecSlice;
212 typedef TCSlice<TFloatVector> TCFloatVecSlice;
214 typedef TFloatVector TNodeCoord;
215 typedef TFloatVecSlice TCoordSlice;
216 typedef TCFloatVecSlice TCCoordSlice;
218 //! Define a base class which represents MED Nodes entity
221 virtual TModeSwitchInfo
223 TNodeCoord myCoord; //!< Contains all nodal coordinates
225 //! Gives coordinates for mesh node by its number (const version)
226 TCCoordSlice GetCoordSlice(TInt theId) const;
227 //! Gives coordinates for mesh node by its number
228 TCoordSlice GetCoordSlice(TInt theId);
230 ERepere mySystem; //!< Defines, which coordinate system is used
231 //! Get which coordinate system is used for the node describing
232 ERepere GetSystem() const { return mySystem;}
233 //! Set coordinate system to be used for the node describing
234 void SetSystem(ERepere theSystem) { mySystem = theSystem;}
236 TString myCoordNames; //!< Contains names for the coordinate dimensions
237 //! Get name of the coordinate dimension by its order number
238 virtual std::string GetCoordName(TInt theId) const = 0;
239 //! Set name of the coordinate dimension by its order number
240 virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
242 TString myCoordUnits; //!< Contains units for the coordinate dimensions
243 //! Get name of unit for the coordinate dimension by its order number
244 virtual std::string GetCoordUnit(TInt theId) const = 0;
245 //! Set name of unit for the coordinate dimension by its order number
246 virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
250 //---------------------------------------------------------------
251 typedef TIntVecSlice TConnSlice;
252 typedef TCIntVecSlice TCConnSlice;
254 //! Define a base class which represents MED Cells entity
257 virtual TModeSwitchInfo
259 EEntiteMaillage myEntity; //!< Defines the MED Entity where the mesh cells belongs to
260 //! Let known what MED ENTITY the cells belong to
261 EEntiteMaillage GetEntity() const { return myEntity;}
263 EGeometrieElement myGeom; //!< Defines the MED Geometric type of the instance
264 //! Let known what MED geometrical type the cells belong to
265 EGeometrieElement GetGeom() const { return myGeom;}
267 EConnectivite myConnMode; //!< Defines connectivity mode
268 //! Let known in what connectivity the cells are writen
269 EConnectivite GetConnMode() const { return myConnMode;}
271 virtual TInt GetConnDim() const = 0; //!< Gives step in the connectivity sequence
273 TElemNum myConn; //!< Defines sequence which describe connectivity for ech of mesh cell
275 //! Gives connectivities for mesh cell by its number (const version)
276 TCConnSlice GetConnSlice(TInt theElemId) const;
277 //! Gives connectivities for mesh cell by its number
278 TConnSlice GetConnSlice(TInt theElemId);
281 //---------------------------------------------------------------
282 //! Define a base class which represents MED Polygon entity
283 struct TPolygoneInfo:
286 //! Defines the MED Entity where the polygons belongs to
287 EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
288 //! Let known what MED ENTITY the MED Polygons belong to
289 EEntiteMaillage GetEntity() const { return myEntity;}
291 //! Defines the MED Geometric type of the instance
292 EGeometrieElement myGeom; // ePOLYGONE
293 //! Let known what MED geometrical type the MED Polygons belong to
294 EGeometrieElement GetGeom() const { return ePOLYGONE;}
296 //! Defines connectivity mode
297 EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
298 //! Let known in what connectivity the cells are writen
299 EConnectivite GetConnMode() const { return myConnMode;}
301 TElemNum myConn; //!< Table de connectivities
302 TElemNum myIndex; //!< Table de indexes
304 //! Gives number of the connectivities for the defined polygon
305 TInt GetNbConn(TInt theElemId) const;
307 //! Gives connectivities for polygon by its number (const version)
308 TCConnSlice GetConnSlice(TInt theElemId) const;
309 //! Gives connectivities for polygon by its number
310 TConnSlice GetConnSlice(TInt theElemId);
313 //---------------------------------------------------------------
314 typedef TVector<TCConnSlice> TCConnSliceArr;
315 typedef TVector<TConnSlice> TConnSliceArr;
317 //! Define a base class which represents MED Polyedre entity
318 struct TPolyedreInfo:
321 //! Defines the MED Entity where the polyedres belongs to
322 EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
323 //! Let known what MED ENTITY the MED Polyedres belong to
324 EEntiteMaillage GetEntity() const { return myEntity;}
326 //! Defines the MED Geometric type of the instance
327 EGeometrieElement myGeom; // ePOLYEDRE
328 //! Let known what MED geometrical type the MED Polyedres belong to
329 EGeometrieElement GetGeom() const { return ePOLYEDRE;}
331 //! Defines connectivity mode
332 EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
333 //! Let known in what connectivity the cells are writen
334 EConnectivite GetConnMode() const { return myConnMode;}
336 TElemNum myConn; //!< Table de connectivities
337 TElemNum myFaces; //!< Table de faces indexes
338 TElemNum myIndex; //!< Table de indexes
340 //! Gives number of the faces for the defined polyedre (const version)
341 TInt GetNbFaces(TInt theElemId) const;
342 //! Gives number of the nodes for the defined polyedre
343 TInt GetNbNodes(TInt theElemId) const;
345 //! Gives sequence of the face connectivities for polyedre by its number (const version)
346 TCConnSliceArr GetConnSliceArr(TInt theElemId) const;
347 //! Gives sequence of the face connectivities for polyedre by its number
348 TConnSliceArr GetConnSliceArr(TInt theElemId);
351 //---------------------------------------------------------------
352 //! Define a base class which represents MED Field entity
356 PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
357 //! Get a reference to corresponding MED Mesh
358 const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
360 ETypeChamp myType; //!< Defines type of the MED Field
361 //! Let known what type of the MED FIELD is used
362 ETypeChamp GetType() const { return myType;}
364 TInt myNbComp; //!< Defines number of components stored in the field
365 //! Get number of components for the MED FIELD
366 TInt GetNbComp() const { return myNbComp;}
368 EBooleen myIsLocal; //!< Defines if the MED Field is local
369 //! Let known is the MED FIELD is local or not
370 EBooleen GetIsLocal() const { return myIsLocal;}
372 TInt myNbRef; //!< Defines number of refereces of the field
373 //! Let known number of references for the MED FIELD
374 TInt GetNbRef() const { return myNbRef;}
376 TString myCompNames; //!< Contains names for each of MED Field components
377 //! Get name of the component by its order number
378 virtual std::string GetCompName(TInt theId) const = 0;
379 //! Set name for the component by its order number
380 virtual void SetCompName(TInt theId, const std::string& theValue) = 0;
382 TString myUnitNames; //!< Contains units for each of MED Field components
383 //! Get unit of the component by its order number
384 virtual std::string GetUnitName(TInt theId) const = 0;
385 //! Set unit for the component by its order number
386 virtual void SetUnitName(TInt theId, const std::string& theValue) = 0;
390 //---------------------------------------------------------------
391 //! Get dimension of the Gauss coordinates for the defined type of mesh cell
393 GetDimGaussCoord(EGeometrieElement theGeom);
395 //! Get number of referenced nodes for the defined type of mesh cell
397 GetNbRefCoord(EGeometrieElement theGeom);
399 typedef TFloatVector TWeight;
401 //! The class represents MED Gauss entity
404 virtual TModeSwitchInfo
406 typedef boost::tuple<EGeometrieElement,std::string> TKey;
407 typedef boost::tuple<TKey,TInt> TInfo;
411 operator()(const TKey& theLeft, const TKey& theRight) const;
414 operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const;
417 //! Defines, which geometrical type the MED Gauss entity belongs to
418 EGeometrieElement myGeom;
419 //! Let known what MED geometrical type the MED GAUSS entity belong to
420 EGeometrieElement GetGeom() const { return myGeom;}
422 //! Contains coordinates for the refereced nodes
423 TNodeCoord myRefCoord;
425 //! Gives coordinates for the referenced node by its number
426 TCCoordSlice GetRefCoordSlice(TInt theId) const;
427 //! Gives coordinates for the referenced node by its number
428 TCoordSlice GetRefCoordSlice(TInt theId);
430 //! Contains coordinates for the Gauss points
431 TNodeCoord myGaussCoord;
433 //! Gives coordinates for the Gauss points by its number
434 TCCoordSlice GetGaussCoordSlice(TInt theId) const;
435 //! Gives coordinates for the Gauss points by its number
436 TCoordSlice GetGaussCoordSlice(TInt theId);
438 //! Contains wheights for the Gauss points
441 //! Gives number of the referenced nodes
442 TInt GetNbRef() const { return GetNbRefCoord(GetGeom());}
444 //! Gives dimension of the referenced nodes
445 TInt GetDim() const { return GetDimGaussCoord(GetGeom());}
447 //! Gives number of the Gauss Points
448 TInt GetNbGauss() const { return myGaussCoord.size()/GetDim();}
452 //---------------------------------------------------------------
453 typedef std::map<EGeometrieElement,PGaussInfo> TGeom2Gauss;
454 typedef std::map<EGeometrieElement,TInt> TGeom2NbGauss;
456 //! Define a base class which represents MED TimeStamp
457 struct TTimeStampInfo:
460 PFieldInfo myFieldInfo; //!< A reference to correspondig MED Field
461 //! Get a reference to corresponding MED Field
462 const PFieldInfo& GetFieldInfo() const { return myFieldInfo;}
464 //! Defines the MED Entity where the MED TimeStamp belongs to
465 EEntiteMaillage myEntity;
466 //! Let known to what MED Entity the MED TimeStamp belong to
467 EEntiteMaillage GetEntity() const { return myEntity;}
469 //! Keeps map of number of cells per geometric type where the MED TimeStamp belongs to
470 TGeom2Size myGeom2Size;
471 //! Get map of number of cells per geometric type where the MED TimeStamp belongs to
472 const TGeom2Size& GetGeom2Size() const { return myGeom2Size;}
474 TGeom2NbGauss myGeom2NbGauss; //!< Keeps number of the Gauss Points for the MED TimeStamp
475 TInt GetNbGauss(EGeometrieElement theGeom) const; //!< Gives number of the Gauss Points for the MED TimeStamp
477 TInt myNumDt; //!< Keeps number in time for the MED TimeStamp
478 TInt GetNumDt() const { return myNumDt;} //!< Defines number in time for the MED TimeStamp
480 TInt myNumOrd; //!< Keeps number for the MED TimeStamp
481 TInt GetNumOrd() const { return myNumOrd;} //!< Defines number for the MED TimeStamp
483 TFloat myDt; //!< Keeps time for the MED TimeStamp
484 TFloat GetDt() const { return myDt;} //!< Defines time for the MED TimeStamp
486 //! Keeps map of MED Gauss entityes per geometric type
487 TGeom2Gauss myGeom2Gauss;
488 //! Gets a map of MED Gauss entityes per geometric type
489 const TGeom2Gauss& GetGeom2Gauss() const { return myGeom2Gauss;}
491 TString myUnitDt; //!< Defines unit for the time for the MED TimeStamp
492 //! Get unit of time for the MED TimeStamp
493 virtual std::string GetUnitDt() const = 0;
494 //! Set unit of time for the MED TimeStamp
495 virtual void SetUnitDt(const std::string& theValue) = 0;
499 //---------------------------------------------------------------
500 //! The class represents MED Profile entity
504 typedef std::string TKey;
505 typedef boost::tuple<TKey,TInt> TInfo;
507 EModeProfil myMode; //!< Keeps mode for the MED Profile
508 //! Let known what mode of MED Profile is used
509 EModeProfil GetMode() const { return myMode;}
510 //! Set mode for the MED Profile
511 void SetMode(EModeProfil theMode) { myMode = theMode;}
513 TElemNum myElemNum; //!< Keeps sequence of cell by its number which belong to the profile
514 //! Get number of mesh elelemts by its order number
515 TInt GetElemNum(TInt theId) const;
516 //! Set number of mesh elelemts by its order number
517 void SetElemNum(TInt theId, TInt theVal);
519 //! Let known is the MED Profile defined
520 bool IsPresent() const { return GetName() != "";}
522 //! Let known size of the MED Profile
523 TInt GetSize() const { return myElemNum.size();}
527 //---------------------------------------------------------------
528 typedef TFloatVector TValue;
529 typedef TSlice<TValue> TValueSlice;
530 typedef TCSlice<TValue> TCValueSlice;
532 typedef TVector<TCValueSlice> TCValueSliceArr;
533 typedef TVector<TValueSlice> TValueSliceArr;
535 //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
537 virtual TModeSwitchInfo
546 //! Initialize the class
551 EModeSwitch theMode = eFULL_INTERLACE);
553 //! Iteration through Gauss Points by their components
555 GetGaussValueSliceArr(TInt theElemId) const;
557 //! Iteration through Gauss Points by their components
559 GetGaussValueSliceArr(TInt theElemId);
561 //! Iteration through components by corresponding Gauss Points
563 GetCompValueSliceArr(TInt theElemId) const;
565 //! Iteration through components by corresponding Gauss Points
567 GetCompValueSliceArr(TInt theElemId);
571 //---------------------------------------------------------------
572 typedef std::map<EGeometrieElement,TMeshValue> TGeom2Value;
573 typedef std::map<EGeometrieElement,PProfileInfo> TGeom2Profile;
575 //! The class implements a container for MED TimeStamp values
576 struct TTimeStampVal:
577 virtual TModeSwitchInfo
579 PTimeStampInfo myTimeStampInfo; //!< A reference to correspondig MED TimeStamp
580 //!< Get a reference to correspondig MED TimeStamp
581 const PTimeStampInfo& GetTimeStampInfo() const { return myTimeStampInfo;}
583 //! Keeps map of MED Profiles per geometric type
584 TGeom2Profile myGeom2Profile;
585 //! Gets a map of MED Profiles per geometric type
586 const TGeom2Profile& GetGeom2Profile() const { return myGeom2Profile;}
588 TGeom2Value myGeom2Value;
590 //! Keeps map of MED TimeStamp values per geometric type (const version)
591 const TMeshValue& GetMeshValue(EGeometrieElement theGeom) const;
593 //! Keeps map of MED TimeStamp values per geometric type
594 TMeshValue& GetMeshValue(EGeometrieElement theGeom);