Back to index

salome-med  6.5.0
MED_TStructures.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  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 //  File   : 
00024 //  Author : 
00025 //  Module : 
00026 //
00027 #ifndef MED_TStructures_HeaderFile
00028 #define MED_TStructures_HeaderFile
00029 
00030 #include "MED_Structures.hxx"
00031 
00032 #ifdef WNT
00033 #pragma warning(disable:4250)
00034 #endif
00035 
00036 namespace MED
00037 {
00038   //---------------------------------------------------------------
00040   template<class TValue, class TRepresentation>
00041   struct TValueHolder
00042   {
00043     TValue& myValue;
00044     TRepresentation myRepresentation;
00045 
00046     TValueHolder(TValue& theValue):
00047       myValue(theValue),
00048       myRepresentation(TRepresentation(theValue))
00049     {}
00050 
00051     ~TValueHolder()
00052     {
00053       myValue = TValue(myRepresentation);
00054     }
00055 
00056     TRepresentation*
00057     operator& ()
00058     {
00059       return &myRepresentation;
00060     }
00061 
00062     operator TRepresentation () const
00063     {
00064       return myRepresentation;
00065     }  
00066 
00067     const TValue&
00068     operator() () const
00069     {
00070       return myValue;
00071     }  
00072   };
00073   
00075   template<class TVal, class TRepresentation>
00076   struct TValueHolder<TVector<TVal>, TRepresentation>
00077   {
00078     typedef TVector<TVal> TValue;
00079     TValue& myValue;
00080     TRepresentation* myRepresentation;
00081 
00082     TValueHolder(TValue& theValue):
00083       myValue(theValue)
00084     {
00085       if(theValue.empty())
00086         myRepresentation = (TRepresentation*)NULL;
00087       else
00088         myRepresentation = (TRepresentation*)&theValue[0];
00089     }
00090 
00091     TRepresentation*
00092     operator& ()
00093     {
00094       return myRepresentation;
00095     }
00096   };
00097   
00098   //---------------------------------------------------------------
00099   template<EVersion eVersion>
00100   struct TTNameInfo: virtual TNameInfo
00101   {
00102     TTNameInfo(const std::string& theValue)
00103     {
00104       myName.resize(GetNOMLength<eVersion>()+1);
00105       SetName(theValue);
00106     }
00107 
00108     virtual
00109     std::string
00110     GetName() const 
00111     { 
00112       return GetString(0, GetNOMLength<eVersion>(), myName);
00113     }
00114 
00115     virtual
00116     void
00117     SetName(const std::string& theValue)
00118     {
00119       SetString(0, GetNOMLength<eVersion>(), myName, theValue);
00120     }
00121 
00122     virtual
00123     void
00124     SetName(const TString& theValue)
00125     {
00126       SetString(0, GetNOMLength<eVersion>(), myName, theValue);
00127     }
00128   };
00129 
00130 
00131   //---------------------------------------------------------------
00132   template<EVersion eVersion>
00133   struct TTMeshInfo: 
00134     virtual TMeshInfo, 
00135     virtual TTNameInfo<eVersion>
00136   {
00137     typedef TTNameInfo<eVersion> TNameInfoBase;
00138 
00139     TTMeshInfo(const PMeshInfo& theInfo):
00140       TNameInfoBase(theInfo->GetName())
00141     {
00142       myDim = theInfo->GetDim();
00143       mySpaceDim = theInfo->GetSpaceDim();
00144       myType = theInfo->GetType();
00145       
00146       myDesc.resize(GetDESCLength<eVersion>()+1);
00147       SetDesc(theInfo->GetDesc());
00148     }
00149 
00150     TTMeshInfo(TInt theDim, TInt theSpaceDim,
00151                const std::string& theValue,
00152                EMaillage theType,
00153                const std::string& theDesc):
00154       TNameInfoBase(theValue)
00155     {
00156       myDim = theDim;
00157       mySpaceDim = theSpaceDim;
00158       myType = theType;
00159       
00160       myDesc.resize(GetDESCLength<eVersion>()+1);
00161       SetDesc(theDesc);
00162     }
00163 
00164     virtual 
00165     std::string
00166     GetDesc() const 
00167     { 
00168       return GetString(0, GetDESCLength<eVersion>(), myDesc);
00169     }
00170 
00171     virtual
00172     void
00173     SetDesc(const std::string& theValue)
00174     {
00175       SetString(0, GetDESCLength<eVersion>(), myDesc, theValue);
00176     }
00177   };
00178 
00179 
00180   //---------------------------------------------------------------
00181   template<EVersion eVersion>
00182   struct TTFamilyInfo: 
00183     virtual TFamilyInfo, 
00184     virtual TTNameInfo<eVersion>
00185   {
00186     typedef TTNameInfo<eVersion> TNameInfoBase;
00187 
00188     TTFamilyInfo(const PMeshInfo& theMeshInfo, const PFamilyInfo& theInfo):
00189       TNameInfoBase(theInfo->GetName())
00190     {
00191       myMeshInfo = theMeshInfo;
00192 
00193       myId = theInfo->GetId();
00194 
00195       myNbGroup = theInfo->GetNbGroup();
00196       myGroupNames.resize(myNbGroup*GetLNOMLength<eVersion>()+1);
00197       if(myNbGroup){
00198         for(TInt anId = 0; anId < myNbGroup; anId++){
00199           SetGroupName(anId,theInfo->GetGroupName(anId));
00200         }
00201       }
00202 
00203       myNbAttr = theInfo->GetNbAttr();
00204       myAttrId.resize(myNbAttr);
00205       myAttrVal.resize(myNbAttr);
00206       myAttrDesc.resize(myNbAttr*GetDESCLength<eVersion>()+1);
00207       if(myNbAttr){
00208         for(TInt anId = 0; anId < myNbAttr; anId++){
00209           SetAttrDesc(anId,theInfo->GetAttrDesc(anId));
00210           myAttrVal[anId] = theInfo->GetAttrVal(anId);
00211           myAttrId[anId] = theInfo->GetAttrId(anId);
00212         }
00213       }
00214     }
00215 
00216     TTFamilyInfo(const PMeshInfo& theMeshInfo,
00217                  TInt theNbGroup, 
00218                  TInt theNbAttr,
00219                  TInt theId,
00220                  const std::string& theValue):
00221       TNameInfoBase(theValue)
00222     {
00223       myMeshInfo = theMeshInfo;
00224 
00225       myId = theId;
00226 
00227       myNbGroup = theNbGroup;
00228       myGroupNames.resize(theNbGroup*GetLNOMLength<eVersion>()+1);
00229 
00230       myNbAttr = theNbAttr;
00231       myAttrId.resize(theNbAttr);
00232       myAttrVal.resize(theNbAttr);
00233       myAttrDesc.resize(theNbAttr*GetDESCLength<eVersion>()+1);
00234     }
00235 
00236     TTFamilyInfo(const PMeshInfo& theMeshInfo,
00237                  const std::string& theValue,
00238                  TInt theId,
00239                  const TStringSet& theGroupNames, 
00240                  const TStringVector& theAttrDescs, 
00241                  const TIntVector& theAttrIds, 
00242                  const TIntVector& theAttrVals):
00243       TNameInfoBase(theValue)
00244     {
00245       myMeshInfo = theMeshInfo;
00246 
00247       myId = theId;
00248 
00249       myNbGroup = (TInt)theGroupNames.size();
00250       myGroupNames.resize(myNbGroup*GetLNOMLength<eVersion>()+1);
00251       if(myNbGroup){
00252         TStringSet::const_iterator anIter = theGroupNames.begin();
00253         for(TInt anId = 0; anIter != theGroupNames.end(); anIter++, anId++){
00254           const std::string& aVal = *anIter;
00255           SetGroupName(anId,aVal);
00256         }
00257       }
00258 
00259       myNbAttr = (TInt)theAttrDescs.size();
00260       myAttrId.resize(myNbAttr);
00261       myAttrVal.resize(myNbAttr);
00262       myAttrDesc.resize(myNbAttr*GetDESCLength<eVersion>()+1);
00263       if(myNbAttr){
00264         for(TInt anId = 0, anEnd = (TInt)theAttrDescs.size(); anId < anEnd; anId++){
00265           SetAttrDesc(anId,theAttrDescs[anId]);
00266           myAttrVal[anId] = theAttrVals[anId];
00267           myAttrId[anId] = theAttrIds[anId];
00268         }
00269       }
00270     }
00271 
00272     virtual
00273     std::string
00274     GetGroupName(TInt theId) const 
00275     { 
00276       return GetString(theId, GetLNOMLength<eVersion>(), myGroupNames);
00277     }
00278 
00279     virtual
00280     void
00281     SetGroupName(TInt theId, const std::string& theValue)
00282     {
00283       SetString(theId, GetLNOMLength<eVersion>(), myGroupNames, theValue);
00284     }
00285 
00286     virtual
00287     std::string
00288     GetAttrDesc(TInt theId) const 
00289     { 
00290       return GetString(theId, GetDESCLength<eVersion>(), myAttrDesc);
00291     }
00292 
00293     virtual
00294     void
00295     SetAttrDesc(TInt theId, const std::string& theValue)
00296     {
00297       SetString(theId, GetDESCLength<eVersion>(), myAttrDesc, theValue);
00298     }
00299   };
00300 
00301 
00302   //---------------------------------------------------------------
00303   template<EVersion eVersion>
00304   struct TTElemInfo: virtual TElemInfo
00305   {
00306     TTElemInfo(const PMeshInfo& theMeshInfo, const PElemInfo& theInfo)
00307     {
00308       myMeshInfo = theMeshInfo;
00309       
00310       myNbElem = theInfo->GetNbElem();
00311       myFamNum.reset(new TElemNum(myNbElem));
00312       myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
00313 
00314       myIsElemNum = theInfo->IsElemNum();
00315       if(theInfo->IsElemNum())
00316         myElemNum.reset(new TElemNum(myNbElem));
00317       else
00318         myElemNum.reset(new TElemNum());
00319 
00320       myIsElemNames = theInfo->IsElemNames();
00321       if(theInfo->IsElemNames())
00322         myElemNames.reset(new TString(myNbElem*GetPNOMLength<eVersion>() + 1));
00323       else
00324         myElemNames.reset(new TString());
00325 
00326       if(theInfo->GetNbElem()){
00327         for(TInt anId = 0; anId < myNbElem; anId++){
00328           SetFamNum(anId, theInfo->GetFamNum(anId));
00329         }
00330         if(theInfo->IsElemNum() == eVRAI){
00331           for(TInt anId = 0; anId < myNbElem; anId++){
00332             SetElemNum(anId, theInfo->GetElemNum(anId));
00333           }
00334         }
00335         if(theInfo->IsElemNames() == eVRAI){
00336           for(TInt anId = 0; anId < myNbElem; anId++){
00337             SetElemName(anId,theInfo->GetElemName(anId));
00338           }
00339         }
00340       }
00341     }
00342 
00343     TTElemInfo(const PMeshInfo& theMeshInfo, 
00344                TInt theNbElem,
00345                EBooleen theIsElemNum,
00346                EBooleen theIsElemNames)
00347     {
00348       myMeshInfo = theMeshInfo;
00349 
00350       myNbElem = theNbElem;
00351       myFamNum.reset(new TElemNum(theNbElem));
00352       myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
00353 
00354       myIsElemNum = theIsElemNum;
00355       if(theIsElemNum)
00356         myElemNum.reset(new TElemNum(theNbElem));
00357       else
00358         myElemNum.reset(new TElemNum());
00359 
00360       myIsElemNames = theIsElemNames;
00361       if(theIsElemNames)
00362         myElemNames.reset(new TString(theNbElem*GetPNOMLength<eVersion>() + 1));
00363       else
00364         myElemNames.reset(new TString());
00365    }
00366     
00367     TTElemInfo(const PMeshInfo& theMeshInfo, 
00368                TInt theNbElem,
00369                const TIntVector& theFamilyNums,
00370                const TIntVector& theElemNums,
00371                const TStringVector& theElemNames)
00372     {
00373       myMeshInfo = theMeshInfo;
00374       
00375       myNbElem = theNbElem;
00376       myFamNum.reset(new TElemNum(theNbElem));
00377       myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
00378       
00379       myIsElemNum = theElemNums.size()? eVRAI: eFAUX;
00380       if(myIsElemNum)
00381         myElemNum.reset(new TElemNum(theNbElem));
00382       else
00383         myElemNum.reset(new TElemNum());
00384       
00385       myIsElemNames = theElemNames.size()? eVRAI: eFAUX;
00386       if(myIsElemNames)
00387         myElemNames.reset(new TString(theNbElem*GetPNOMLength<eVersion>() + 1));
00388       else
00389         myElemNames.reset(new TString());
00390      
00391       if(theNbElem){
00392 
00393         if(theFamilyNums.size())
00394           *myFamNum = theFamilyNums;
00395 
00396         if(myIsElemNum)
00397           *myElemNum = theElemNums;
00398 
00399         if(myIsElemNames){
00400           for(TInt anId = 0; anId < theNbElem; anId++){
00401             const std::string& aVal = theElemNames[anId];
00402             SetElemName(anId,aVal);
00403           }
00404         }
00405       }
00406     }
00407 
00408     virtual
00409     std::string
00410     GetElemName(TInt theId) const 
00411     { 
00412       return GetString(theId,GetPNOMLength<eVersion>(), *myElemNames);
00413     }
00414 
00415     virtual
00416     void
00417     SetElemName(TInt theId, const std::string& theValue)
00418     {
00419       SetString(theId,GetPNOMLength<eVersion>(), *myElemNames, theValue);
00420     }
00421   };
00422 
00423 
00424   //---------------------------------------------------------------
00425   template<EVersion eVersion>
00426   struct TTNodeInfo: 
00427     virtual TNodeInfo, 
00428     virtual TTElemInfo<eVersion>
00429   {
00430     typedef TTElemInfo<eVersion> TElemInfoBase;
00431 
00432     TTNodeInfo(const PMeshInfo& theMeshInfo, const PNodeInfo& theInfo):
00433       TNodeInfo(theInfo),
00434       TElemInfoBase(theMeshInfo, theInfo)
00435     {
00436       myModeSwitch = theInfo->GetModeSwitch();
00437       
00438       mySystem = theInfo->GetSystem();
00439       
00440       myCoord.reset(new TNodeCoord(*theInfo->myCoord));
00441       
00442       TInt aSpaceDim = theMeshInfo->GetSpaceDim();
00443 
00444       myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
00445       for(TInt anId = 0; anId < aSpaceDim; anId++)
00446         SetCoordName(anId,theInfo->GetCoordName(anId));
00447       
00448       myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
00449       for(TInt anId = 0; anId < aSpaceDim; anId++)
00450         SetCoordUnit(anId,theInfo->GetCoordUnit(anId));
00451     }
00452 
00453     TTNodeInfo(const PMeshInfo& theMeshInfo, 
00454                TInt theNbElem,
00455                EModeSwitch theMode,
00456                ERepere theSystem, 
00457                EBooleen theIsElemNum,
00458                EBooleen theIsElemNames):
00459       TModeSwitchInfo(theMode),
00460       TElemInfoBase(theMeshInfo,
00461                     theNbElem,
00462                     theIsElemNum,
00463                     theIsElemNames)
00464     {
00465       mySystem = theSystem;
00466 
00467       myCoord.reset(new TNodeCoord(theNbElem * theMeshInfo->mySpaceDim));
00468 
00469       myCoordUnits.resize(theMeshInfo->mySpaceDim*GetPNOMLength<eVersion>()+1);
00470 
00471       myCoordNames.resize(theMeshInfo->mySpaceDim*GetPNOMLength<eVersion>()+1);
00472     }
00473 
00474     
00475     TTNodeInfo(const PMeshInfo& theMeshInfo, 
00476                const TFloatVector& theNodeCoords,
00477                EModeSwitch theMode,
00478                ERepere theSystem, 
00479                const TStringVector& theCoordNames,
00480                const TStringVector& theCoordUnits,
00481                const TIntVector& theFamilyNums,
00482                const TIntVector& theElemNums,
00483                const TStringVector& theElemNames):
00484       TModeSwitchInfo(theMode),
00485       TElemInfoBase(theMeshInfo,
00486                     (TInt)theNodeCoords.size()/theMeshInfo->GetDim(),
00487                     theFamilyNums,
00488                     theElemNums,
00489                     theElemNames)
00490     {
00491       mySystem = theSystem;
00492 
00493       myCoord.reset(new TNodeCoord(theNodeCoords));
00494       
00495       TInt aSpaceDim = theMeshInfo->GetSpaceDim();
00496 
00497       myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
00498       if(!theCoordNames.empty())
00499         for(TInt anId = 0; anId < aSpaceDim; anId++)
00500           SetCoordName(anId,theCoordNames[anId]);
00501       
00502       myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>() + 1);
00503       if(!theCoordUnits.empty())
00504         for(TInt anId = 0; anId < aSpaceDim; anId++)
00505           SetCoordUnit(anId, theCoordUnits[anId]);
00506     }
00507 
00508     virtual
00509     std::string
00510     GetCoordName(TInt theId) const 
00511     { 
00512       return GetString(theId,GetPNOMLength<eVersion>(),myCoordNames);
00513     }
00514 
00515     virtual
00516     void
00517     SetCoordName(TInt theId, const std::string& theValue)
00518     {
00519       SetString(theId,GetPNOMLength<eVersion>(),myCoordNames,theValue);
00520     }
00521 
00522     virtual
00523     std::string 
00524     GetCoordUnit(TInt theId) const 
00525     { 
00526       return GetString(theId,GetPNOMLength<eVersion>(),myCoordUnits);
00527     }
00528 
00529     virtual
00530     void
00531     SetCoordUnit(TInt theId, const std::string& theValue)
00532     {
00533       SetString(theId,GetPNOMLength<eVersion>(),myCoordUnits,theValue);
00534     }
00535   };
00536 
00537   //---------------------------------------------------------------
00538   template<EVersion eVersion>
00539   struct TTPolygoneInfo: 
00540     virtual TPolygoneInfo, 
00541     virtual TTElemInfo<eVersion>
00542   {
00543     typedef TTElemInfo<eVersion> TElemInfoBase;
00544 
00545     TTPolygoneInfo(const PMeshInfo& theMeshInfo, const PPolygoneInfo& theInfo):
00546       TElemInfoBase(theMeshInfo,theInfo)
00547     {
00548       myEntity = theInfo->GetEntity();
00549       myGeom = theInfo->GetGeom();
00550 
00551       myIndex.reset(new TElemNum(*theInfo->myIndex));
00552       myConn.reset(new TElemNum(*theInfo->myConn));
00553 
00554       myConnMode = theInfo->GetConnMode();
00555     }
00556 
00557     TTPolygoneInfo(const PMeshInfo& theMeshInfo, 
00558                    EEntiteMaillage theEntity, 
00559                    EGeometrieElement theGeom,
00560                    TInt theNbElem,
00561                    TInt theConnSize,
00562                    EConnectivite theConnMode,
00563                    EBooleen theIsElemNum,
00564                    EBooleen theIsElemNames):
00565       TElemInfoBase(theMeshInfo,
00566                     theNbElem,
00567                     theIsElemNum,
00568                     theIsElemNames)
00569     {
00570       myEntity = theEntity;
00571       myGeom = theGeom;
00572 
00573       myIndex.reset(new TElemNum(theNbElem + 1));
00574       myConn.reset(new TElemNum(theConnSize));
00575 
00576       myConnMode = theConnMode;
00577     }
00578     
00579     TTPolygoneInfo(const PMeshInfo& theMeshInfo, 
00580                    EEntiteMaillage theEntity, 
00581                    EGeometrieElement theGeom,
00582                    const TIntVector& theIndexes,
00583                    const TIntVector& theConnectivities,
00584                    EConnectivite theConnMode,
00585                    const TIntVector& theFamilyNums,
00586                    const TIntVector& theElemNums,
00587                    const TStringVector& theElemNames):
00588       TElemInfoBase(theMeshInfo,
00589                     (TInt)theIndexes.size() - 1,
00590                     theFamilyNums,
00591                     theElemNums,
00592                     theElemNames)
00593     {
00594       myEntity = theEntity;
00595       myGeom = theGeom;
00596 
00597       myIndex.reset(new TElemNum(theIndexes));
00598       myConn.reset(new TElemNum(theConnectivities));
00599 
00600       myConnMode = theConnMode;
00601     }
00602   };
00603   
00604   //---------------------------------------------------------------
00605   template<EVersion eVersion>
00606   struct TTPolyedreInfo: 
00607     virtual TPolyedreInfo, 
00608     virtual TTElemInfo<eVersion>
00609   {
00610     typedef TTElemInfo<eVersion> TElemInfoBase;
00611 
00612     TTPolyedreInfo(const PMeshInfo& theMeshInfo, const PPolyedreInfo& theInfo):
00613       TElemInfoBase(theMeshInfo,theInfo)
00614     {
00615       myEntity = theInfo->GetEntity();
00616       myGeom = theInfo->GetGeom();
00617 
00618       myIndex.reset(new TElemNum(*theInfo->myIndex));
00619       myFaces.reset(new TElemNum(*theInfo->myFaces));
00620       myConn.reset(new TElemNum(*theInfo->myConn));
00621 
00622       myConnMode = theInfo->GetConnMode();
00623     }
00624 
00625     TTPolyedreInfo(const PMeshInfo& theMeshInfo, 
00626                    EEntiteMaillage theEntity, 
00627                    EGeometrieElement theGeom,
00628                    TInt theNbElem,
00629                    TInt theNbFaces,
00630                    TInt theConnSize,
00631                    EConnectivite theConnMode,
00632                    EBooleen theIsElemNum,
00633                    EBooleen theIsElemNames):
00634       TElemInfoBase(theMeshInfo,
00635                     theNbElem,
00636                     theIsElemNum,
00637                     theIsElemNames)
00638     {
00639       myEntity = theEntity;
00640       myGeom = theGeom;
00641 
00642       myIndex.reset(new TElemNum(theNbElem + 1));
00643       myFaces.reset(new TElemNum(theNbFaces));
00644       myConn.reset(new TElemNum(theConnSize));
00645 
00646       myConnMode = theConnMode;
00647     }
00648     
00649     TTPolyedreInfo(const PMeshInfo& theMeshInfo, 
00650                    EEntiteMaillage theEntity, 
00651                    EGeometrieElement theGeom,
00652                    const TIntVector& theIndexes,
00653                    const TIntVector& theFaces,
00654                    const TIntVector& theConnectivities,
00655                    EConnectivite theConnMode,
00656                    const TIntVector& theFamilyNums,
00657                    const TIntVector& theElemNums,
00658                    const TStringVector& theElemNames):
00659       TElemInfoBase(theMeshInfo,
00660                     (TInt)theIndexes.size()-1,
00661                     theFamilyNums,
00662                     theElemNums,
00663                     theElemNames)
00664     {
00665       myEntity = theEntity;
00666       myGeom = theGeom;
00667 
00668       myIndex.reset(new TElemNum(theIndexes));
00669       myFaces.reset(new TElemNum(theFaces));
00670       myConn.reset(new TElemNum(theConnectivities));
00671 
00672       myConnMode = theConnMode;
00673     }
00674   };
00675 
00676   //---------------------------------------------------------------
00677   template<EVersion eVersion>
00678   struct TTCellInfo: 
00679     virtual TCellInfo, 
00680     virtual TTElemInfo<eVersion>
00681   {
00682     typedef TTElemInfo<eVersion> TElemInfoBase;
00683 
00684     TTCellInfo(const PMeshInfo& theMeshInfo, const PCellInfo& theInfo):
00685       TElemInfoBase(theMeshInfo,theInfo)
00686     {
00687       myEntity = theInfo->GetEntity();
00688       myGeom = theInfo->GetGeom();
00689       myConnMode  = theInfo->GetConnMode();
00690       
00691       TInt aConnDim = GetNbNodes(myGeom);
00692       TInt aNbConn = GetNbConn<eVersion>(myGeom, myEntity, myMeshInfo->myDim);
00693       myConn.reset(new TElemNum(myNbElem * aNbConn));
00694       for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){
00695         TConnSlice aConnSlice = GetConnSlice(anElemId);
00696         TCConnSlice aConnSlice2 = theInfo->GetConnSlice(anElemId);
00697         for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){
00698           aConnSlice[anConnId] = aConnSlice2[anConnId];
00699         }
00700       }
00701     }
00702 
00703     TTCellInfo(const PMeshInfo& theMeshInfo, 
00704                EEntiteMaillage theEntity, 
00705                EGeometrieElement theGeom,
00706                TInt theNbElem,
00707                EConnectivite theConnMode,
00708                EBooleen theIsElemNum,
00709                EBooleen theIsElemNames,
00710                EModeSwitch theMode):
00711       TModeSwitchInfo(theMode),
00712       TElemInfoBase(theMeshInfo,
00713                     theNbElem,
00714                     theIsElemNum,
00715                     theIsElemNames)
00716     {
00717       myEntity = theEntity;
00718       myGeom = theGeom;
00719 
00720       myConnMode = theConnMode;
00721       TInt aNbConn = GetNbConn<eVersion>(theGeom, myEntity, theMeshInfo->myDim);
00722       myConn.reset(new TElemNum(theNbElem * aNbConn));
00723     }
00724     
00725     TTCellInfo(const PMeshInfo& theMeshInfo, 
00726                EEntiteMaillage theEntity, 
00727                EGeometrieElement theGeom,
00728                const TIntVector& theConnectivities,
00729                EConnectivite theConnMode,
00730                const TIntVector& theFamilyNums,
00731                const TIntVector& theElemNums,
00732                const TStringVector& theElemNames,
00733                EModeSwitch theMode):
00734       TModeSwitchInfo(theMode),
00735       TElemInfoBase(theMeshInfo,
00736                     (TInt)theConnectivities.size() / GetNbNodes(theGeom),
00737                     theFamilyNums,
00738                     theElemNums,
00739                     theElemNames)
00740     {
00741       myEntity = theEntity;
00742       myGeom = theGeom;
00743 
00744       myConnMode = theConnMode;
00745       TInt aConnDim = GetNbNodes(myGeom);
00746       TInt aNbConn = GetNbConn<eVersion>(myGeom, myEntity, myMeshInfo->myDim);
00747       myConn.reset(new TElemNum(myNbElem * aNbConn));
00748       for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){
00749         TConnSlice aConnSlice = GetConnSlice(anElemId);
00750         for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){
00751           aConnSlice[anConnId] = theConnectivities[anElemId*aConnDim + anConnId];
00752         }
00753       }
00754     }
00755 
00756     virtual 
00757     TInt
00758     GetConnDim() const 
00759     { 
00760       return GetNbConn<eVersion>(myGeom, myEntity, myMeshInfo->myDim);
00761     }
00762 
00763   };
00764 
00765 
00766   //---------------------------------------------------------------
00767   template<EVersion eVersion>
00768   struct TTFieldInfo: 
00769     virtual TFieldInfo, 
00770     virtual TTNameInfo<eVersion>
00771   {
00772     typedef TTNameInfo<eVersion> TNameInfoBase;
00773 
00774     TTFieldInfo(const PMeshInfo& theMeshInfo, const PFieldInfo& theInfo):
00775       TNameInfoBase(theInfo->GetName())
00776     {
00777       myMeshInfo = theMeshInfo;
00778 
00779       myNbComp = theInfo->GetNbComp();
00780       myCompNames.resize(myNbComp*GetPNOMLength<eVersion>()+1);
00781       for(TInt anId = 0; anId < myNbComp; anId++){
00782         SetCompName(anId,theInfo->GetCompName(anId));
00783       }
00784 
00785       myUnitNames.resize(myNbComp*GetPNOMLength<eVersion>()+1);
00786       for(TInt anId = 0; anId < myNbComp; anId++){
00787         SetUnitName(anId,theInfo->GetUnitName(anId));
00788       }
00789 
00790       myType = theInfo->GetType();
00791 
00792       myIsLocal = theInfo->GetIsLocal();
00793       myNbRef = theInfo->GetNbRef();
00794     }
00795 
00796     TTFieldInfo(const PMeshInfo& theMeshInfo, 
00797                 TInt theNbComp,
00798                 ETypeChamp theType,
00799                 const std::string& theValue,
00800                 EBooleen theIsLocal,
00801                 TInt theNbRef):
00802       TNameInfoBase(theValue)
00803     {
00804       myMeshInfo = theMeshInfo;
00805 
00806       myNbComp = theNbComp;
00807       myCompNames.resize(theNbComp*GetPNOMLength<eVersion>()+1);
00808       myUnitNames.resize(theNbComp*GetPNOMLength<eVersion>()+1);
00809 
00810       myType = theType;
00811 
00812       myIsLocal = theIsLocal;
00813       myNbRef = theNbRef;
00814     }
00815     
00816     virtual 
00817     std::string
00818     GetCompName(TInt theId) const 
00819     { 
00820       return GetString(theId,GetPNOMLength<eVersion>(),myCompNames);
00821     }
00822 
00823     virtual
00824     void
00825     SetCompName(TInt theId, const std::string& theValue)
00826     {
00827       SetString(theId,GetPNOMLength<eVersion>(),myCompNames,theValue);
00828     }
00829 
00830     virtual
00831     std::string 
00832     GetUnitName(TInt theId) const 
00833     { 
00834       return GetString(theId,GetPNOMLength<eVersion>(),myUnitNames);
00835     }
00836 
00837     virtual
00838     void
00839     SetUnitName(TInt theId, const std::string& theValue)
00840     {
00841       SetString(theId,GetPNOMLength<eVersion>(),myUnitNames,theValue);
00842     }
00843   };
00844 
00845 
00846   //---------------------------------------------------------------
00847   template<EVersion eVersion>
00848   struct TTGaussInfo: 
00849     virtual TGaussInfo,
00850     virtual TTNameInfo<eVersion>
00851   {
00852     typedef TTNameInfo<eVersion> TNameInfoBase;
00853 
00854     TTGaussInfo(const TGaussInfo::TInfo& theInfo,
00855                 EModeSwitch theMode):
00856       TModeSwitchInfo(theMode),
00857       TNameInfoBase(boost::get<1>(boost::get<0>(theInfo)))
00858     {
00859       const TGaussInfo::TKey& aKey = boost::get<0>(theInfo);
00860 
00861       myGeom = boost::get<0>(aKey);
00862       myRefCoord.resize(GetNbRef()*GetDim());
00863 
00864       TInt aNbGauss = boost::get<1>(theInfo);
00865       myGaussCoord.resize(aNbGauss*GetDim());
00866       myWeight.resize(aNbGauss);
00867     }
00868   };
00869 
00870 
00871   //---------------------------------------------------------------
00872   template<EVersion eVersion>
00873   struct TTTimeStampInfo: virtual TTimeStampInfo
00874   {
00875     TTTimeStampInfo(const PFieldInfo& theFieldInfo, const PTimeStampInfo& theInfo)
00876     {
00877       myFieldInfo = theFieldInfo;
00878 
00879       myEntity = theInfo->GetEntity();
00880       myGeom2Size = theInfo->GetGeom2Size();
00881 
00882       myNumDt = theInfo->GetNumDt();
00883       myNumOrd = theInfo->GetNumOrd();
00884       myDt = theInfo->GetDt();
00885 
00886       myUnitDt.resize(GetPNOMLength<eVersion>()+1);
00887       SetUnitDt(theInfo->GetUnitDt());
00888 
00889       myGeom2NbGauss = theInfo->myGeom2NbGauss;
00890       myGeom2Gauss = theInfo->GetGeom2Gauss();
00891     }
00892 
00893     TTTimeStampInfo(const PFieldInfo& theFieldInfo, 
00894                     EEntiteMaillage theEntity,
00895                     const TGeom2Size& theGeom2Size,
00896                     const TGeom2NbGauss& theGeom2NbGauss,
00897                     TInt theNumDt,
00898                     TInt theNumOrd,
00899                     TFloat theDt,
00900                     const std::string& theUnitDt,
00901                     const TGeom2Gauss& theGeom2Gauss)
00902     {
00903       myFieldInfo = theFieldInfo;
00904 
00905       myEntity = theEntity;
00906       myGeom2Size = theGeom2Size;
00907 
00908       myNumDt = theNumDt;
00909       myNumOrd = theNumDt;
00910       myDt = theDt;
00911 
00912       myUnitDt.resize(GetPNOMLength<eVersion>()+1);
00913       SetUnitDt(theUnitDt);
00914 
00915       myGeom2NbGauss = theGeom2NbGauss;
00916       myGeom2Gauss = theGeom2Gauss;
00917     }
00918 
00919     virtual 
00920     std::string
00921     GetUnitDt() const
00922     { 
00923       return GetString(0,GetPNOMLength<eVersion>(),myUnitDt);
00924     }
00925 
00926     virtual
00927     void
00928     SetUnitDt(const std::string& theValue)
00929     {
00930       SetString(0,GetPNOMLength<eVersion>(),myUnitDt,theValue);
00931     }
00932   };
00933 
00934 
00935   //---------------------------------------------------------------
00936   template<EVersion eVersion>
00937   struct TTProfileInfo: 
00938     virtual TProfileInfo,
00939     virtual TTNameInfo<eVersion>
00940   {
00941     typedef TTNameInfo<eVersion> TNameInfoBase;
00942 
00943     TTProfileInfo(const TProfileInfo::TInfo& theInfo,
00944                   EModeProfil theMode):
00945       TNameInfoBase(boost::get<0>(theInfo))
00946     {
00947       TInt aSize = boost::get<1>(theInfo);
00948       myElemNum.reset(new TElemNum(aSize));
00949       myMode = aSize > 0? theMode: eNO_PFLMOD;
00950     }
00951   };
00952 
00953 
00954   //---------------------------------------------------------------
00955   template<EVersion eVersion, class TMeshValueType>
00956   struct TTTimeStampValue: virtual TTimeStampValue<TMeshValueType>
00957   {
00958     TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
00959                      const PTimeStampValueBase& theInfo,
00960                      ETypeChamp theTypeChamp)
00961     {
00962       typedef TTimeStampValue<TMeshValueType> TCompatible;
00963       if(TCompatible* aCompatible = dynamic_cast<TCompatible*>(theInfo.get())){
00964         this->myTimeStampInfo = theTimeStampInfo;
00965         this->myTypeChamp = theTypeChamp;
00966         this->myGeom2Profile = aCompatible->GetGeom2Profile();
00967         this->myGeom2Value = aCompatible->myGeom2Value;
00968         this->myGeomSet = aCompatible->GetGeomSet();
00969       }else
00970         EXCEPTION(std::runtime_error,"TTTimeStampValue::TTTimeStampValue - use incompatible arguments!");
00971     }
00972 
00973     TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
00974                      ETypeChamp theTypeChamp,
00975                      const TGeom2Profile& theGeom2Profile,
00976                      EModeSwitch theMode):
00977       TModeSwitchInfo(theMode)
00978     {
00979       this->myTimeStampInfo = theTimeStampInfo;
00980 
00981       this->myTypeChamp = theTypeChamp;
00982 
00983       this->myGeom2Profile = theGeom2Profile;
00984 
00985       TInt aNbComp = theTimeStampInfo->myFieldInfo->myNbComp;
00986 
00987       const TGeom2Size& aGeom2Size = theTimeStampInfo->GetGeom2Size();
00988       TGeom2Size::const_iterator anIter = aGeom2Size.begin();
00989       for(; anIter != aGeom2Size.end(); anIter++){
00990         const EGeometrieElement& aGeom = anIter->first;
00991         TInt aNbElem = anIter->second;
00992 
00993         MED::PProfileInfo aProfileInfo;
00994         MED::TGeom2Profile::const_iterator anIter = theGeom2Profile.find(aGeom);
00995         if(anIter != theGeom2Profile.end())
00996           aProfileInfo = anIter->second;
00997 
00998         if(aProfileInfo && aProfileInfo->IsPresent())
00999           aNbElem = aProfileInfo->GetSize();
01000 
01001         TInt aNbGauss = theTimeStampInfo->GetNbGauss(aGeom);
01002         
01003         this->GetMeshValue(aGeom).Allocate(aNbElem,aNbGauss,aNbComp);
01004       }
01005     }
01006 
01007     virtual 
01008     size_t
01009     GetValueSize(EGeometrieElement theGeom) const
01010     {
01011       return this->GetMeshValue(theGeom).GetSize();
01012     }
01013 
01014     virtual 
01015     size_t
01016     GetNbVal(EGeometrieElement theGeom) const
01017     {
01018       return this->GetMeshValue(theGeom).GetNbVal();
01019     }
01020 
01021     virtual 
01022     size_t
01023     GetNbGauss(EGeometrieElement theGeom) const
01024     {
01025       return this->GetMeshValue(theGeom).GetNbGauss();
01026     }
01027 
01028     virtual 
01029     void
01030     AllocateValue(EGeometrieElement theGeom,
01031                   TInt theNbElem,
01032                   TInt theNbGauss,
01033                   TInt theNbComp,
01034                   EModeSwitch theMode = eFULL_INTERLACE)
01035     {
01036       this->GetMeshValue(theGeom).Allocate(theNbElem,theNbGauss,theNbComp,theMode);
01037     }
01038     
01039     virtual 
01040     unsigned char*
01041     GetValuePtr(EGeometrieElement theGeom)
01042     {
01043       return this->GetMeshValue(theGeom).GetValuePtr();
01044     }
01045   };
01046 
01047   //---------------------------------------------------------------
01048   template<EVersion eVersion>
01049   struct TTGrilleInfo:
01050     virtual TGrilleInfo
01051   {
01052     TTGrilleInfo(const PMeshInfo& theMeshInfo,
01053                  const PGrilleInfo& theInfo)
01054     {
01055       myMeshInfo        = theMeshInfo;
01056 
01057       myCoord           = theInfo->GetNodeCoord();
01058       
01059       myGrilleType      = theInfo->GetGrilleType();
01060 
01061       myCoordNames      = theInfo->myCoordNames;
01062 
01063       myCoordUnits      = theInfo->myCoordUnits;
01064 
01065       myIndixes         = theInfo->GetMapOfIndexes();
01066 
01067       myGrilleStructure = theInfo->GetGrilleStructure();
01068 
01069       myGrilleType      = theInfo->GetGrilleType();
01070 
01071       myFamNumNode.resize(theInfo->GetNbNodes());
01072       myFamNumNode      = theInfo->myFamNumNode;
01073 
01074       myFamNum      = theInfo->myFamNum;
01075     }
01076 
01077     TTGrilleInfo(const PMeshInfo& theMeshInfo,
01078                  const EGrilleType& type,
01079                  const TInt nnoeuds)
01080     {
01081       myMeshInfo        = theMeshInfo;
01082       TInt aSpaceDim = theMeshInfo->GetSpaceDim();
01083       if(type == eGRILLE_STANDARD){
01084         myCoord.resize(aSpaceDim*nnoeuds);
01085         myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
01086         myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
01087       } else { //if(type == eGRILLE_CARTESIENNE){
01088         myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
01089         myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
01090       }
01091       myGrilleStructure.resize(aSpaceDim);
01092       myFamNumNode.resize(nnoeuds);
01093     }
01094 
01095     TTGrilleInfo(const PMeshInfo& theMeshInfo,
01096                  const EGrilleType& type)
01097     {
01098       myMeshInfo        = theMeshInfo;
01099       TInt aSpaceDim = theMeshInfo->GetSpaceDim();
01100       if(type == eGRILLE_STANDARD){
01101         myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
01102         myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
01103       } else {// if(type == eGRILLE_CARTESIENNE){
01104         myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
01105         myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
01106       }
01107       myGrilleStructure.resize(aSpaceDim);
01108     }
01109 
01110     TTGrilleInfo(const PMeshInfo& theMeshInfo,
01111                  const EGrilleType& type,
01112                  const MED::TIntVector& nbNodeVec)
01113     {
01114       myMeshInfo        = theMeshInfo;
01115 
01116       TInt aSpaceDim = theMeshInfo->GetSpaceDim();
01117       if(type == eGRILLE_STANDARD){
01118         myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
01119         myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+1);
01120       } else {// if(type == eGRILLE_CARTESIENNE){
01121         myCoordNames.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
01122         myCoordUnits.resize(aSpaceDim*GetPNOMLength<eVersion>()+aSpaceDim);
01123       }
01124 
01125       if(type != eGRILLE_STANDARD)
01126         for(unsigned int aAxe=0;aAxe<nbNodeVec.size();aAxe++){
01127           myIndixes[aAxe].resize(nbNodeVec[aAxe]);
01128         }
01129       myGrilleStructure.resize(aSpaceDim);
01130     }
01131 
01132     virtual
01133     std::string
01134     GetCoordName(TInt theId) const 
01135     { 
01136       return GetString(theId,GetPNOMLength<eVersion>(),myCoordNames);
01137     }
01138 
01139     virtual
01140     void
01141     SetCoordName(TInt theId, const std::string& theValue)
01142     {
01143       SetString(theId,GetPNOMLength<eVersion>(),myCoordNames,theValue);
01144     }
01145 
01146     virtual
01147     std::string 
01148     GetCoordUnit(TInt theId) const 
01149     { 
01150       return GetString(theId,GetPNOMLength<eVersion>(),myCoordUnits);
01151     }
01152 
01153     virtual
01154     void
01155     SetCoordUnit(TInt theId, const std::string& theValue)
01156     {
01157       SetString(theId,GetPNOMLength<eVersion>(),myCoordUnits,theValue);
01158     }
01159 
01160   };
01161 }
01162 
01163 #endif