src/MEDWrapper/Base/MED_Structures.hxx

Go to the documentation of this file.
00001 //  
00002 //
00003 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
00005 // 
00006 //  This library is free software; you can redistribute it and/or 
00007 //  modify it under the terms of the GNU Lesser General Public 
00008 //  License as published by the Free Software Foundation; either 
00009 //  version 2.1 of the License. 
00010 // 
00011 //  This library is distributed in the hope that it will be useful, 
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00014 //  Lesser General Public License for more details. 
00015 // 
00016 //  You should have received a copy of the GNU Lesser General Public 
00017 //  License along with this library; if not, write to the Free Software 
00018 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
00019 // 
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //
00023 //
00024 //  File   : 
00025 //  Author : 
00026 //  Module : 
00027 //  $Header: /home/server/cvs/MED/MED_SRC/src/MEDWrapper/Base/MED_Structures.hxx,v 1.5.2.2 2006/07/13 13:49:01 enk Exp $
00028 
00029 #ifndef MED_Structures_HeaderFile
00030 #define MED_Structures_HeaderFile
00031 
00032 #include "MED_Common.hxx"
00033 
00034 namespace MED
00035 {
00036 
00037   //---------------------------------------------------------------
00039   typedef TVector<char> TString; 
00040 
00042   std::string GetString(TInt theId, TInt theStep, 
00043                const TString& theString);
00044 
00046   void SetString(TInt theId, TInt theStep, 
00047            TString& theString, 
00048            const std::string& theValue);
00049 
00050   //---------------------------------------------------------------
00052   struct TBase
00053   {
00054     virtual ~TBase() {} 
00055   };
00056 
00057 
00058   //---------------------------------------------------------------
00060   struct TNameInfo: virtual TBase
00061   {
00062     TString myName; 
00063     virtual std::string GetName() const = 0; 
00064     virtual void SetName(const std::string& theValue) = 0; 
00065   };
00066 
00067 
00068   //---------------------------------------------------------------
00070 
00074   struct TModeSwitchInfo: virtual TBase
00075   {
00077     TModeSwitchInfo():
00078       myModeSwitch(eFULL_INTERLACE)
00079     {}
00080 
00082     TModeSwitchInfo(EModeSwitch theModeSwitch):
00083       myModeSwitch(theModeSwitch)
00084     {}
00085 
00086     EModeSwitch myModeSwitch; 
00087     EModeSwitch GetModeSwitch() const { return myModeSwitch;}
00088   };
00089 
00090 
00091   //---------------------------------------------------------------
00093   struct TMeshInfo: virtual TNameInfo
00094   {
00095     TInt myDim; 
00096     TInt GetDim() const { return myDim;} 
00097 
00098     EMaillage myType; 
00099     EMaillage GetType() const { return myType;} 
00100 
00101     TString myDesc; 
00102     virtual std::string GetDesc() const = 0; 
00103     virtual void SetDesc(const std::string& theValue) = 0; 
00104   };
00105   
00106 
00107   //---------------------------------------------------------------
00108   typedef TVector<TInt> TIntVector;
00109   typedef TSlice<TIntVector> TIntVecSlice;
00110   typedef TCSlice<TIntVector> TCIntVecSlice;
00111 
00112   typedef TIntVector TFamAttr;
00113 
00115   struct TFamilyInfo: virtual TNameInfo
00116   {
00117     PMeshInfo myMeshInfo; 
00118 
00119     const PMeshInfo& GetMeshInfo() const { return myMeshInfo;} 
00120 
00121     TInt myId; 
00122     TInt GetId() const { return myId;} 
00123     void SetId(TInt theId) { myId = theId;} 
00124 
00125     TInt myNbGroup; 
00126 
00127     TInt GetNbGroup() const { return myNbGroup;} 
00128 
00130     TString myGroupNames; 
00132     virtual std::string GetGroupName(TInt theId) const = 0;
00134     virtual void SetGroupName(TInt theId, const std::string& theValue) = 0;
00135 
00136     TInt myNbAttr; 
00137 
00138     TInt GetNbAttr() const { return myNbAttr;} 
00139 
00141     TFamAttr myAttrId; 
00143     TInt GetAttrId(TInt theId) const;
00145     void SetAttrId(TInt theId, TInt theVal);
00146 
00148     TFamAttr myAttrVal;
00150     TInt GetAttrVal(TInt theId) const;
00152     void SetAttrVal(TInt theId, TInt theVal);
00153 
00155     TString myAttrDesc;
00157     virtual std::string GetAttrDesc(TInt theId) const = 0;
00159     virtual void SetAttrDesc(TInt theId, const std::string& theValue) = 0;
00160   };
00161 
00162 
00163   //---------------------------------------------------------------
00164   typedef TIntVector TElemNum;
00165   
00167   struct TElemInfo: virtual TBase
00168   {
00169     PMeshInfo myMeshInfo; 
00170 
00171     const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
00172 
00173     TInt myNbElem; //<! Number of corresponding mesh entities
00174     TInt GetNbElem() const { return myNbElem;} 
00175     
00177     TElemNum myFamNum; 
00179     TInt GetFamNum(TInt theId) const;
00181     void SetFamNum(TInt theId, TInt theVal);
00182 
00184     EBooleen myIsElemNum;
00186     EBooleen IsElemNum() const { return myIsElemNum;}
00187 
00189     TElemNum myElemNum;
00191     TInt GetElemNum(TInt theId) const;
00193     void SetElemNum(TInt theId, TInt theVal);
00194 
00196     EBooleen myIsElemNames;
00198     EBooleen IsElemNames() const { return myIsElemNames;}
00199 
00201     TString myElemNames;
00203     virtual std::string GetElemName(TInt theId) const = 0;
00205     virtual void SetElemName(TInt theId, const std::string& theValue) = 0;
00206   };
00207 
00208 
00209   //---------------------------------------------------------------
00210   typedef TVector<TFloat> TFloatVector;
00211   typedef TSlice<TFloatVector> TFloatVecSlice;
00212   typedef TCSlice<TFloatVector> TCFloatVecSlice;
00213 
00214   typedef TFloatVector TNodeCoord;
00215   typedef TFloatVecSlice TCoordSlice;
00216   typedef TCFloatVecSlice TCCoordSlice;
00217 
00219   struct TNodeInfo: 
00220     virtual TElemInfo,
00221     virtual TModeSwitchInfo 
00222   {
00223     TNodeCoord myCoord; 
00224 
00226     TCCoordSlice GetCoordSlice(TInt theId) const;
00228     TCoordSlice GetCoordSlice(TInt theId);
00229 
00230     ERepere mySystem; 
00231 
00232     ERepere GetSystem() const { return mySystem;}
00234     void SetSystem(ERepere theSystem) { mySystem = theSystem;}
00235 
00236     TString myCoordNames; 
00237 
00238     virtual std::string GetCoordName(TInt theId) const = 0;
00240     virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
00241 
00242     TString myCoordUnits; 
00243 
00244     virtual std::string GetCoordUnit(TInt theId) const = 0;
00246     virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
00247   };
00248 
00249 
00250   //---------------------------------------------------------------
00251   typedef TIntVecSlice TConnSlice;
00252   typedef TCIntVecSlice TCConnSlice;
00253 
00255   struct TCellInfo: 
00256     virtual TElemInfo,
00257     virtual TModeSwitchInfo 
00258   {
00259     EEntiteMaillage myEntity; 
00260 
00261     EEntiteMaillage GetEntity() const { return myEntity;}
00262 
00263     EGeometrieElement myGeom; 
00264 
00265     EGeometrieElement GetGeom() const { return myGeom;}
00266 
00267     EConnectivite myConnMode; 
00268 
00269     EConnectivite GetConnMode() const { return myConnMode;}
00270 
00271     virtual TInt GetConnDim() const = 0; 
00272 
00273     TElemNum myConn; 
00274 
00276     TCConnSlice GetConnSlice(TInt theElemId) const;
00278     TConnSlice GetConnSlice(TInt theElemId);
00279   };
00280 
00281   //---------------------------------------------------------------
00283   struct TPolygoneInfo: 
00284     virtual TElemInfo
00285   {
00287     EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
00289     EEntiteMaillage GetEntity() const { return myEntity;}
00290 
00292     EGeometrieElement myGeom; // ePOLYGONE
00294     EGeometrieElement GetGeom() const { return ePOLYGONE;}
00295 
00297     EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
00299     EConnectivite GetConnMode() const { return myConnMode;}
00300 
00301     TElemNum myConn; 
00302     TElemNum myIndex; 
00303 
00305     TInt GetNbConn(TInt theElemId) const;
00306 
00308     TCConnSlice GetConnSlice(TInt theElemId) const;
00310     TConnSlice GetConnSlice(TInt theElemId);
00311   };
00312 
00313   //---------------------------------------------------------------
00314   typedef TVector<TCConnSlice> TCConnSliceArr;
00315   typedef TVector<TConnSlice> TConnSliceArr;
00316 
00318   struct TPolyedreInfo: 
00319     virtual TElemInfo
00320   {
00322     EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
00324     EEntiteMaillage GetEntity() const { return myEntity;}
00325 
00327     EGeometrieElement myGeom; // ePOLYEDRE
00329     EGeometrieElement GetGeom() const { return ePOLYEDRE;}
00330 
00332     EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
00334     EConnectivite GetConnMode() const { return myConnMode;}
00335 
00336     TElemNum myConn; 
00337     TElemNum myFaces; 
00338     TElemNum myIndex; 
00339 
00341     TInt GetNbFaces(TInt theElemId) const;
00343     TInt GetNbNodes(TInt theElemId) const;
00344 
00346     TCConnSliceArr GetConnSliceArr(TInt theElemId) const;
00348     TConnSliceArr GetConnSliceArr(TInt theElemId);
00349   };
00350 
00351   //---------------------------------------------------------------
00353   struct TFieldInfo: 
00354     virtual TNameInfo
00355   {
00356     PMeshInfo myMeshInfo; 
00357 
00358     const PMeshInfo& GetMeshInfo() const { return myMeshInfo;}
00359 
00360     ETypeChamp myType; 
00361 
00362     ETypeChamp GetType() const { return myType;}
00363 
00364     TInt myNbComp; 
00365 
00366     TInt GetNbComp() const { return myNbComp;}
00367 
00368     EBooleen myIsLocal; 
00369 
00370     EBooleen GetIsLocal() const { return myIsLocal;}
00371 
00372     TInt myNbRef; 
00373 
00374     TInt GetNbRef() const { return myNbRef;}
00375 
00376     TString myCompNames; 
00377 
00378     virtual std::string GetCompName(TInt theId) const = 0;
00380     virtual void SetCompName(TInt theId, const std::string& theValue) = 0;
00381 
00382     TString myUnitNames; 
00383 
00384     virtual std::string GetUnitName(TInt theId) const = 0;
00386     virtual void SetUnitName(TInt theId, const std::string& theValue) = 0;
00387   };
00388 
00389 
00390   //---------------------------------------------------------------
00392   TInt
00393   GetDimGaussCoord(EGeometrieElement theGeom);
00394 
00396   TInt
00397   GetNbRefCoord(EGeometrieElement theGeom);
00398 
00399   typedef TFloatVector TWeight;
00400 
00402   struct TGaussInfo: 
00403     virtual TNameInfo,
00404     virtual TModeSwitchInfo 
00405   {
00406     typedef boost::tuple<EGeometrieElement,std::string> TKey;
00407     typedef boost::tuple<TKey,TInt> TInfo;
00408     struct TLess
00409     {
00410       bool
00411       operator()(const TKey& theLeft, const TKey& theRight) const;
00412 
00413       bool
00414       operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const;
00415     };
00416 
00418     EGeometrieElement myGeom; 
00420     EGeometrieElement GetGeom() const { return myGeom;}
00421 
00423     TNodeCoord myRefCoord; 
00424 
00426     TCCoordSlice GetRefCoordSlice(TInt theId) const;
00428     TCoordSlice GetRefCoordSlice(TInt theId);
00429 
00431     TNodeCoord myGaussCoord;
00432 
00434     TCCoordSlice GetGaussCoordSlice(TInt theId) const;
00436     TCoordSlice GetGaussCoordSlice(TInt theId);
00437 
00439     TWeight myWeight;
00440 
00442     TInt GetNbRef() const { return GetNbRefCoord(GetGeom());}
00443 
00445     TInt GetDim() const { return GetDimGaussCoord(GetGeom());}
00446 
00448     TInt GetNbGauss() const { return myGaussCoord.size()/GetDim();}
00449   };
00450 
00451 
00452   //---------------------------------------------------------------
00453   typedef std::map<EGeometrieElement,PGaussInfo> TGeom2Gauss;
00454   typedef std::map<EGeometrieElement,TInt> TGeom2NbGauss;
00455 
00457   struct TTimeStampInfo: 
00458     virtual TBase
00459   {
00460     PFieldInfo myFieldInfo; 
00461 
00462     const PFieldInfo& GetFieldInfo() const { return myFieldInfo;}
00463 
00465     EEntiteMaillage myEntity;
00467     EEntiteMaillage GetEntity() const { return myEntity;}
00468 
00470     TGeom2Size myGeom2Size;
00472     const TGeom2Size& GetGeom2Size() const { return myGeom2Size;}
00473 
00474     TGeom2NbGauss myGeom2NbGauss; 
00475     TInt GetNbGauss(EGeometrieElement theGeom) const; 
00476 
00477     TInt myNumDt; 
00478     TInt GetNumDt() const { return myNumDt;} 
00479 
00480     TInt myNumOrd; 
00481     TInt GetNumOrd() const { return myNumOrd;} 
00482 
00483     TFloat myDt; 
00484     TFloat GetDt() const { return myDt;} 
00485 
00487     TGeom2Gauss myGeom2Gauss;
00489     const TGeom2Gauss& GetGeom2Gauss() const { return myGeom2Gauss;}
00490 
00491     TString myUnitDt; 
00492 
00493     virtual std::string GetUnitDt() const = 0;
00495     virtual void SetUnitDt(const std::string& theValue) = 0;
00496   };
00497   
00498 
00499   //---------------------------------------------------------------
00501   struct TProfileInfo: 
00502     virtual TNameInfo
00503   {
00504     typedef std::string TKey;
00505     typedef boost::tuple<TKey,TInt> TInfo;
00506 
00507     EModeProfil myMode; 
00508 
00509     EModeProfil GetMode() const { return myMode;}
00511     void SetMode(EModeProfil theMode) { myMode = theMode;}
00512 
00513     TElemNum myElemNum; 
00514 
00515     TInt GetElemNum(TInt theId) const;
00517     void SetElemNum(TInt theId, TInt theVal);
00518 
00520     bool IsPresent() const { return GetName() != "";}
00521 
00523     TInt GetSize() const { return myElemNum.size();}
00524   };
00525 
00526 
00527   //---------------------------------------------------------------
00528   typedef TFloatVector TValue;
00529   typedef TSlice<TValue> TValueSlice;
00530   typedef TCSlice<TValue> TCValueSlice;
00531 
00532   typedef TVector<TCValueSlice> TCValueSliceArr;
00533   typedef TVector<TValueSlice> TValueSliceArr;
00534 
00536   struct TMeshValue:
00537     virtual TModeSwitchInfo 
00538   {
00539     TValue myValue;
00540 
00541     TInt myNbElem;
00542     TInt myNbComp;
00543     TInt myNbGauss;
00544     TInt myStep;
00545 
00547     void
00548     Init(TInt theNbElem,
00549       TInt theNbGauss,
00550       TInt theNbComp,
00551       EModeSwitch theMode = eFULL_INTERLACE);
00552 
00554     TCValueSliceArr
00555     GetGaussValueSliceArr(TInt theElemId) const;
00556 
00558     TValueSliceArr 
00559     GetGaussValueSliceArr(TInt theElemId);
00560 
00562     TCValueSliceArr
00563     GetCompValueSliceArr(TInt theElemId) const;
00564 
00566     TValueSliceArr 
00567     GetCompValueSliceArr(TInt theElemId);
00568   };
00569 
00570 
00571   //---------------------------------------------------------------
00572   typedef std::map<EGeometrieElement,TMeshValue> TGeom2Value;
00573   typedef std::map<EGeometrieElement,PProfileInfo> TGeom2Profile;
00574 
00576   struct TTimeStampVal: 
00577     virtual TModeSwitchInfo 
00578   {
00579     PTimeStampInfo myTimeStampInfo; 
00580 
00581     const PTimeStampInfo& GetTimeStampInfo() const { return myTimeStampInfo;}
00582 
00584     TGeom2Profile myGeom2Profile;
00586     const TGeom2Profile& GetGeom2Profile() const { return myGeom2Profile;}
00587 
00588     TGeom2Value myGeom2Value;
00589 
00591     const TMeshValue& GetMeshValue(EGeometrieElement theGeom) const;
00592 
00594     TMeshValue& GetMeshValue(EGeometrieElement theGeom);
00595   };
00596 
00597 
00598   typedef std::map<TInt,TFloatVector> TIndexes;
00599   typedef std::map<TInt,TString> TNames;
00600   
00602   struct TGrilleInfo:
00603     virtual TModeSwitchInfo
00604   {
00605 
00606     PMeshInfo myMeshInfo;
00607     const PMeshInfo& GetMeshInfo() const { return myMeshInfo;} 
00608 
00609     TNodeCoord myCoord; 
00610 
00611     const TNodeCoord& GetNodeCoord() const;
00612     TNodeCoord GetNodeCoord();
00614     TNodeCoord GetCoord(TInt theId);
00616     TIntVector GetConn(TInt theId);
00617 
00618     EGrilleType myGrilleType; 
00619 
00620     const EGrilleType& GetGrilleType() const;
00622     EGrilleType GetGrilleType();
00624     void SetGrilleType(EGrilleType theGrilleType);
00625 
00626 
00627     
00628     TString myCoordNames; 
00629 
00630     virtual std::string GetCoordName(TInt theId) const = 0 ;
00632     virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
00633 
00634     TString myCoordUnits; 
00635 
00636     virtual std::string GetCoordUnit(TInt theId) const = 0;
00638     virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
00639 
00640 
00642     TIndexes myIndixes;
00644     const TIndexes& GetMapOfIndexes() const ;
00646     TIndexes GetMapOfIndexes();
00648     const TFloatVector& GetIndexes(TInt theAxisNumber) const;
00650     TFloatVector GetIndexes(TInt theAxisNumber);
00652     TInt GetNbIndexes(TInt theAxisNumber);
00653     
00654     TInt GetNbNodes();
00655     TInt GetNbCells();
00656     EGeometrieElement GetGeom();
00657     EEntiteMaillage   GetEntity();
00658 
00663     TIntVector myGrilleStructure;
00665     const TIntVector& GetGrilleStructure() const;
00667     TIntVector GetGrilleStructure();
00669     void SetGrilleStructure(TInt theAxis,TInt theNb);
00670     
00674     TElemNum myFamNum; 
00676     TInt GetFamNum(TInt theId) const;
00678     void SetFamNum(TInt theId, TInt theVal);
00679     
00683     TElemNum myFamNumNode;
00685     TInt GetFamNumNode(TInt theId) const;
00687     void SetFamNumNode(TInt theId, TInt theVal);
00688 
00689   };
00690 
00691 
00692 }
00693 
00694 #endif