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 #include "MED_V2_2_Wrapper.hxx"
30 #include "MED_Utilities.hxx"
37 static int MYDEBUG = 0;
39 static int MYDEBUG = 0;
47 //---------------------------------------------------------------
53 TFile(const std::string& theFileName):
56 myFileName(theFileName)
63 void Open(EModeAcces theMode, TErr* theErr = NULL){
65 char* aFileName = const_cast<char*>(myFileName.c_str());
66 myFid = MEDouvrir(aFileName,med_mode_acces(theMode));
69 *theErr = TErr(myFid > 0);
71 EXCEPTION(runtime_error,"TFile - MEDouvrir('"<<myFileName<<"',"<<theMode<<")");
74 const TIdt& Id() const {
76 EXCEPTION(runtime_error,"TFile - GetFid() < 0");
86 std::string myFileName;
92 //---------------------------------------------------------------
97 TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL):
100 myFile->Open(theMode,theErr);
109 //---------------------------------------------------------------
110 TVWrapper::TVWrapper(const std::string& theFileName):
111 myFile(new TFile(theFileName))
116 TInt TVWrapper::GetNbMeshes(TErr* theErr)
118 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
120 if(theErr && !*theErr)
123 return MEDnMaa(myFile->Id());
127 void TVWrapper::GetMeshInfo(TInt theMeshId,
128 MED::TMeshInfo& theInfo,
131 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
133 if(theErr && !*theErr)
136 med_maillage& aType = static_cast<med_maillage>(theInfo.myType);
138 TErr aRet = MEDmaaInfo(myFile->Id(),
147 EXCEPTION(runtime_error,"GetMeshInfo - MEDmaaInfo(...)");
151 void TVWrapper::SetMeshInfo(const MED::TMeshInfo& theInfo,
155 TFileWrapper aFileWrapper(myFile,theMode,theErr);
157 if(theErr && !*theErr)
160 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
162 med_maillage& aType = static_cast<med_maillage>(theInfo.myType);
164 TErr aRet = MEDmaaCr(myFile->Id(),
170 aRet = MEDunvCr(myFile->Id(),
174 INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
179 EXCEPTION(runtime_error,"SetMeshInfo - MEDmaaCr(...)");
183 void TVWrapper::SetMeshInfo(const MED::TMeshInfo& theInfo,
187 SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
190 SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
193 SetMeshInfo(theInfo,eCREATION,theErr);
197 TInt TVWrapper::GetNbFamilies(const MED::TMeshInfo& theInfo,
200 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
202 if(theErr && !*theErr)
205 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
206 return MEDnFam(myFile->Id(),
211 TInt TVWrapper::GetNbFamAttr(TInt theFamId,
212 const MED::TMeshInfo& theInfo,
215 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
217 if(theErr && !*theErr)
220 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
221 return MEDnAttribut(myFile->Id(),
227 TInt TVWrapper::GetNbFamGroup(TInt theFamId,
228 const MED::TMeshInfo& theInfo,
231 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
233 if(theErr && !*theErr)
236 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
237 return MEDnGroupe(myFile->Id(),
243 void TVWrapper::GetFamilyInfo(TInt theFamId,
244 MED::TFamilyInfo& theInfo,
247 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
249 if(theErr && !*theErr)
252 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
254 TErr aRet = MEDfamInfo(myFile->Id(),
255 &aMeshInfo.myName[0],
259 &theInfo.myAttrId[0],
260 &theInfo.myAttrVal[0],
261 &theInfo.myAttrDesc[0],
263 &theInfo.myGroupNames[0],
269 EXCEPTION(runtime_error,"GetFamilyInfo - MEDfamInfo(...) - "<<
270 " aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<
271 "'; theFamId = "<<theFamId<<
272 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
273 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
275 INITMSG(MYDEBUG,"GetFamilyInfo - MEDfamInfo(...) - "<<
276 " aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<
277 "'; theFamId = "<<theFamId<<
278 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
279 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
283 void TVWrapper::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
287 TFileWrapper aFileWrapper(myFile,theMode,theErr);
289 if(theErr && !*theErr)
292 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
293 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
295 TErr aRet = MEDfamCr(myFile->Id(),
296 &aMeshInfo.myName[0],
300 &anInfo.myAttrVal[0],
301 &anInfo.myAttrDesc[0],
303 &anInfo.myGroupNames[0],
306 INITMSG(MYDEBUG,"TVWrapper::GetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
311 EXCEPTION(runtime_error,"SetFamilyInfo - MEDfamCr(...)");
315 void TVWrapper::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
319 SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
322 SetFamilyInfo(theInfo,eLECTURE_AJOUT,theErr);
325 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
326 void TVWrapper::GetNames(TElemInfo& theInfo,
328 EEntiteMaillage theTEntity,
329 EGeometrieElement theTGeom,
332 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
334 if(theErr && !*theErr)
337 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
339 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
340 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
342 TErr aRet = MEDnomLire(myFile->Id(),
343 &aMeshInfo.myName[0],
344 &theInfo.myElemNames[0],
349 theInfo.myIsElemNames = (theInfo.myElemNames).empty()? EBooleen(0) : EBooleen(1) ;
354 EXCEPTION(runtime_error,"GetNames - MEDnomLire(...)");
357 void TVWrapper::GetNumeration(TElemInfo& theInfo,
359 EEntiteMaillage theTEntity,
360 EGeometrieElement theTGeom,
363 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
365 if(theErr && !*theErr)
368 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
370 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
371 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
373 TErr aRet = MEDnumLire(myFile->Id(),
374 &aMeshInfo.myName[0],
375 &theInfo.myElemNum[0],
380 theInfo.myIsElemNum = (theInfo.myElemNum).empty()? EBooleen(0) : EBooleen(1) ;
385 EXCEPTION(runtime_error,"GetNumeration - MEDnumLire(...)");
388 void TVWrapper::GetFamilies(TElemInfo& theInfo,
390 EEntiteMaillage theTEntity,
391 EGeometrieElement theTGeom,
394 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
396 if(theErr && !*theErr)
399 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
401 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
402 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
404 TErr aRet = MEDfamLire(myFile->Id(),
405 &aMeshInfo.myName[0],
406 &theInfo.myFamNum[0],
414 EXCEPTION(runtime_error,"GetFamilies - MEDfamLire(...)");
417 void TVWrapper::SetNames(const TElemInfo& theInfo,
418 EEntiteMaillage theTEntity,
419 EGeometrieElement theTGeom,
422 SetNames(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr);
425 void TVWrapper::SetNames(const TElemInfo& theInfo,
427 EEntiteMaillage theTEntity,
428 EGeometrieElement theTGeom,
431 TFileWrapper aFileWrapper(myFile,theMode,theErr);
433 if(theErr && !*theErr)
436 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
437 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
439 med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
440 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
441 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
445 aRet = MEDnomEcr(myFile->Id(),
446 &aMeshInfo.myName[0],
447 &anInfo.myElemNames[0],
448 anInfo.myElemNames.size(),
454 EXCEPTION(runtime_error,"SetNames - MEDnomEcr(...)");
458 void TVWrapper::SetNumeration(const TElemInfo& theInfo,
459 EEntiteMaillage theTEntity,
460 EGeometrieElement theTGeom,
463 SetNumeration(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr);
466 void TVWrapper::SetNumeration(const TElemInfo& theInfo,
468 EEntiteMaillage theTEntity,
469 EGeometrieElement theTGeom,
472 TFileWrapper aFileWrapper(myFile,theMode,theErr);
474 if(theErr && !*theErr)
477 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
478 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
480 med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
481 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
482 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
486 aRet = MEDnumEcr(myFile->Id(),
487 &aMeshInfo.myName[0],
488 &anInfo.myElemNum[0],
489 anInfo.myElemNum.size(),
495 EXCEPTION(runtime_error,"SetNumeration - MEDnumEcr(...)");
499 void TVWrapper::SetFamilies(const TElemInfo& theInfo,
500 EEntiteMaillage theTEntity,
501 EGeometrieElement theTGeom,
504 SetFamilies(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr);
507 void TVWrapper::SetFamilies(const TElemInfo& theInfo,
509 EEntiteMaillage theTEntity,
510 EGeometrieElement theTGeom,
513 TFileWrapper aFileWrapper(myFile,theMode,theErr);
515 if(theErr && !*theErr)
518 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
519 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
521 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
522 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
524 TErr aRet = MEDfamEcr(myFile->Id(),
525 &aMeshInfo.myName[0],
527 anInfo.myFamNum.size(),
534 EXCEPTION(runtime_error,"SetFamilies - MEDfamEcr(...)");
537 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
538 TInt TVWrapper::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
541 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
543 if(theErr && !*theErr)
546 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
548 return MEDnEntMaa(myFile->Id(),
549 &aMeshInfo.myName[0],
552 med_geometrie_element(0),
553 med_connectivite(0));
557 void TVWrapper::GetNodeInfo(MED::TNodeInfo& theInfo,
560 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
562 if(theErr && !*theErr)
565 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
567 med_repere& aRepere = static_cast<med_repere>(theInfo.mySystem);
568 med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
569 med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
571 TErr aRet = MEDnoeudsLire(myFile->Id(),
572 &aMeshInfo.myName[0],
577 &theInfo.myCoordNames[0],
578 &theInfo.myCoordUnits[0],
579 &theInfo.myElemNames[0],
581 &theInfo.myElemNum[0],
583 &theInfo.myFamNum[0],
588 EXCEPTION(runtime_error,"GetNodeInfo - MEDnoeudsLire(...)");
592 void TVWrapper::SetNodeInfo(const MED::TNodeInfo& theInfo,
596 TFileWrapper aFileWrapper(myFile,theMode,theErr);
598 if(theErr && !*theErr)
601 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
602 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
604 med_repere& aRepere = static_cast<med_repere>(theInfo.mySystem);
605 med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
606 med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
608 TErr aRet = MEDnoeudsEcr(myFile->Id(),
609 &aMeshInfo.myName[0],
614 &anInfo.myCoordNames[0],
615 &anInfo.myCoordUnits[0],
616 &anInfo.myElemNames[0],
618 &anInfo.myElemNum[0],
625 EXCEPTION(runtime_error,"SetNodeInfo - MEDnoeudsEcr(...)");
629 void TVWrapper::SetNodeInfo(const MED::TNodeInfo& theInfo,
633 SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
636 SetNodeInfo(theInfo,eLECTURE_AJOUT,theErr);
639 void TVWrapper::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
642 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
644 if(theErr && !*theErr)
647 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
648 TInt aNbElem = theInfo.myElemNum.size();
650 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
651 med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
655 aRet = MEDpolygoneConnLire(myFile->Id(),
656 &aMeshInfo.myName[0],
666 EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)");
669 GetNames(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet);
673 GetNumeration(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet);
677 GetFamilies(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet);
682 void TVWrapper::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
685 SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
688 void TVWrapper::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
692 TFileWrapper aFileWrapper(myFile,theMode,theErr);
694 if(theErr && !*theErr)
697 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
698 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
700 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
701 med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
703 TErr aRet = MEDpolygoneConnEcr(myFile->Id(),
704 &aMeshInfo.myName[0],
714 EXCEPTION(runtime_error,"SetPolygoneInfo - MEDpolygoneConnEcr(...)");
716 SetNames(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet);
720 SetNumeration(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet);
724 SetFamilies(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet);
729 TInt TVWrapper::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
730 EEntiteMaillage theTEntity,
731 EGeometrieElement theTGeom,
732 EConnectivite theTConn,
735 return GetNbCells(theMeshInfo,theTEntity,theTGeom,theTConn,theErr);
738 TInt TVWrapper::GetNbPolygoneConn(const MED::TMeshInfo& theMeshInfo,
739 EEntiteMaillage theTEntity,
740 EGeometrieElement theTGeom,
741 EConnectivite theTConn,
744 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
746 if(theErr && !*theErr)
749 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
751 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
752 med_connectivite& aConn = static_cast<med_connectivite>(theTConn);
756 TErr aRet = MEDpolygoneInfo(myFile->Id(),
757 &aMeshInfo.myName[0],
765 EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)");
770 void TVWrapper::GetPolyedreInfo(TPolyedreInfo& theInfo,
773 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
775 if(theErr && !*theErr)
778 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
779 TInt aNbElem = theInfo.myElemNum.size();
781 med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
785 aRet = MEDpolyedreConnLire(myFile->Id(),
786 &aMeshInfo.myName[0],
789 &theInfo.myFacesIndex[0],
790 theInfo.myNbFacesIndex,
797 EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreConnLire(...)");
799 GetNames(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet);
803 GetNumeration(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet);
807 GetFamilies(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet);
812 void TVWrapper::SetPolyedreInfo(const TPolyedreInfo& theInfo,
815 SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
818 void TVWrapper::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
822 TFileWrapper aFileWrapper(myFile,theMode,theErr);
824 if(theErr && !*theErr)
827 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
828 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
830 med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
831 med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
832 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
833 med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
835 TErr aRet = MEDpolyedreConnEcr(myFile->Id(),
836 &aMeshInfo.myName[0],
839 &anInfo.myFacesIndex[0],
840 anInfo.myNbFacesIndex,
847 EXCEPTION(runtime_error,"SetPolyedreInfo - MEDpolyedreConnEcr(...)");
850 aRet = MEDnomEcr(myFile->Id(),
851 &aMeshInfo.myName[0],
852 &anInfo.myElemNames[0],
853 anInfo.myElemNames.size(),
859 EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnomEcr(...)");
863 aRet = MEDnumEcr(myFile->Id(),
864 &aMeshInfo.myName[0],
865 &anInfo.myElemNum[0],
866 anInfo.myElemNum.size(),
872 EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnumEcr(...)");
876 aRet = MEDfamEcr(myFile->Id(),
877 &aMeshInfo.myName[0],
879 anInfo.myFamNum.size(),
886 EXCEPTION(runtime_error,"SetPolyedreInfo - MEDfamEcr(...)");
889 TInt TVWrapper::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
890 EEntiteMaillage theTEntity,
891 EGeometrieElement theTGeom,
892 EConnectivite theTConn,
895 return GetNbCells(theMeshInfo,theTEntity,theTGeom,theTConn,theErr);
898 void TVWrapper::GetNbPolyedreConnF(const MED::TMeshInfo& theMeshInfo,
899 EConnectivite theTConn,
904 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
906 if(theErr && !*theErr) EXCEPTION(runtime_error,"GetPolyedreInfo - (...)");
908 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
909 med_connectivite& aConn = static_cast<med_connectivite>(theTConn);
911 TErr aRet = MEDpolyedreInfo(myFile->Id(),
912 &aMeshInfo.myName[0],
920 EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreInfo(...)");
924 TEntityInfo TVWrapper::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
925 EConnectivite theTConn,
930 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
932 if(theErr && *theErr < 0)
935 TInt aNbElem = GetNbNodes(theMeshInfo);
937 anInfo[eNOEUD][ePOINT1] = aNbElem;
938 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
939 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
940 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
941 for(; anIter != anIterEnd; anIter++){
942 const EEntiteMaillage& anEntity = anIter->first;
943 const TGeomSet& aGeomSet = anIter->second;
944 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
945 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
946 for(; anIter2 != anIterEnd2; anIter2++){
947 const EGeometrieElement& aGeom = *anIter2;
948 aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theTConn,theErr);
950 anInfo[anEntity][aGeom] = aNbElem;
958 TInt TVWrapper::GetNbCells(const MED::TMeshInfo& theMeshInfo,
959 EEntiteMaillage theTEntity,
960 EGeometrieElement theTGeom,
961 EConnectivite theTConn,
964 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
966 if(theErr && !*theErr)
969 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
971 med_entite_maillage anEntity = med_entite_maillage(theTEntity);
972 med_geometrie_element aGeom = med_geometrie_element(theTGeom);
973 med_connectivite aConn = med_connectivite(theTConn);
975 return MEDnEntMaa(myFile->Id(),
976 &aMeshInfo.myName[0],
984 void TVWrapper::GetCellInfo(MED::TCellInfo& theInfo,
987 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
989 if(theErr && !*theErr)
992 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
993 TInt aNbElem = theInfo.myElemNum.size();
995 med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
996 med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
997 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
998 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theInfo.myTGeom);
999 med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
1001 TErr aRet = MEDelementsLire(myFile->Id(),
1002 &aMeshInfo.myName[0],
1006 &theInfo.myElemNames[0],
1008 &theInfo.myElemNum[0],
1010 &theInfo.myFamNum[0],
1018 EXCEPTION(runtime_error,"GetCellInfo - MEDelementsLire(...)");
1022 void TVWrapper::SetCellInfo(const MED::TCellInfo& theInfo,
1026 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1028 if(theErr && !*theErr)
1031 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
1032 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1034 med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
1035 med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
1036 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
1037 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theInfo.myTGeom);
1038 med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
1040 TErr aRet = MEDelementsEcr(myFile->Id(),
1041 &aMeshInfo.myName[0],
1045 &anInfo.myElemNames[0],
1047 &anInfo.myElemNum[0],
1049 &anInfo.myFamNum[0],
1058 EXCEPTION(runtime_error,"SetCellInfo - MEDelementsLire(...)");
1062 void TVWrapper::SetCellInfo(const MED::TCellInfo& theInfo,
1065 SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
1069 TInt TVWrapper::GetNbFields(TErr* theErr)
1071 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1073 if(theErr && !*theErr)
1076 return MEDnChamp(myFile->Id(),0);
1080 TInt TVWrapper::GetNbComp(TInt theFieldId,
1083 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1085 if(theErr && !*theErr)
1088 return MEDnChamp(myFile->Id(),theFieldId);
1092 void TVWrapper::GetFieldInfo(TInt theFieldId,
1093 MED::TFieldInfo& theInfo,
1096 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1098 if(theErr && !*theErr)
1101 med_type_champ& aType = static_cast<med_type_champ>(theInfo.myType);
1103 TErr aRet = MEDchampInfo(myFile->Id(),
1107 &theInfo.myCompNames[0],
1108 &theInfo.myUnitNames[0],
1113 EXCEPTION(runtime_error,"GetFieldInfo - MEDchampInfo(...)");
1117 void TVWrapper::SetFieldInfo(const MED::TFieldInfo& theInfo,
1121 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1123 if(theErr && !*theErr)
1126 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1128 med_type_champ& aType = static_cast<med_type_champ>(theInfo.myType);
1130 TErr aRet = MEDchampCr(myFile->Id(),
1133 &anInfo.myCompNames[0],
1134 &anInfo.myUnitNames[0],
1139 EXCEPTION(runtime_error,"SetFieldInfo - MEDchampEcr(...)");
1143 void TVWrapper::SetFieldInfo(const MED::TFieldInfo& theInfo,
1147 SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1150 SetFieldInfo(theInfo,eLECTURE_AJOUT,theErr);
1154 TInt TVWrapper::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
1155 const MED::TEntityInfo& theEntityInfo,
1156 EEntiteMaillage& theEntity,
1160 theEntity = EEntiteMaillage(-1);
1161 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1164 if(theEntityInfo.empty())
1168 }else if(theEntityInfo.empty())
1169 EXCEPTION(runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
1172 TInt aNbTimeStamps = 0;
1173 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1174 TEntityInfo::const_iterator anIter = theEntityInfo.begin();
1175 for(; anIter != theEntityInfo.end(); anIter++){
1176 const med_entite_maillage& anEntity = static_cast<const med_entite_maillage>(anIter->first);
1177 const TGeom& aTGeom = anIter->second;
1178 TGeom::const_iterator anGeomIter = aTGeom.begin();
1179 for(; anGeomIter != aTGeom.end(); anGeomIter++){
1180 const med_geometrie_element& aGeom = static_cast<const med_geometrie_element>(anGeomIter->first);
1181 TInt aTmp = MEDnPasdetemps(myFile->Id(),&anInfo.myName[0],anEntity,aGeom);
1182 aNbTimeStamps = max(aTmp,aNbTimeStamps);
1183 if (aNbTimeStamps<1)
1185 BEGMSG(MYDEBUG,"GetNbTimeStamps aNbTimeStamps="<<aTmp<<"; aGeom="<<aGeom<<"; anEntity="<<anEntity<<"\n");
1187 theEntity = EEntiteMaillage(anEntity);
1188 ADDMSG(MYDEBUG,"theEntity="<<theEntity<<"\n");
1189 theGeom[EGeometrieElement(aGeom)] = anGeomIter->second;
1192 if(!theGeom.empty())
1195 return aNbTimeStamps;
1199 void TVWrapper::GetTimeStampInfo(TInt theTimeStampId,
1200 MED::TTimeStampInfo& theInfo,
1203 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1205 TGeom& aTGeom = theInfo.myGeom;
1212 }else if(aTGeom.empty())
1213 EXCEPTION(runtime_error,"GetTimeStampInfo - There is no any cell");
1215 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
1216 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1218 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myEntity);
1220 TGeom::iterator anIter = aTGeom.begin();
1221 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(anIter->first);
1223 med_booleen& anIsLocal = static_cast<med_booleen>(aFieldInfo.myIsLocal);
1225 TErr aRet = MEDpasdetempsInfo(myFile->Id(),
1226 &aFieldInfo.myName[0],
1233 &theInfo.myUnitDt[0],
1235 &aMeshInfo.myName[0],
1237 &aFieldInfo.myNbRef);
1241 EXCEPTION(runtime_error,"GetTimeStampInfo - MEDpasdetempsInfo(...)");
1243 static TInt MAX_NB_GAUSS_POINTS = 32;
1244 if(theInfo.myNbGauss <= 0 || theInfo.myNbGauss > MAX_NB_GAUSS_POINTS)
1245 theInfo.myNbGauss = 1;
1249 void TVWrapper::GetTimeStampVal(MED::TTimeStampVal& theVal,
1252 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1254 if(theErr && !*theErr)
1257 TIdt anId = myFile->Id();
1259 MED::TTimeStampInfo& aTimeStampInfo = *theVal.myTimeStampInfo;
1260 MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo;
1261 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1263 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(aTimeStampInfo.myEntity);
1264 med_mode_profil& aPflMode = static_cast<med_mode_profil>(theVal.myPflMode);
1265 TGeom& aTGeom = aTimeStampInfo.myGeom;
1266 TGeom::iterator anIter = aTGeom.begin();
1267 for(; anIter != aTGeom.end(); anIter++){
1268 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(anIter->first);
1269 TInt aNbVal = MEDnVal(anId,
1270 &aFieldInfo.myName[0],
1273 aTimeStampInfo.myNumDt,
1274 aTimeStampInfo.myNumOrd,
1275 &aMeshInfo.myName[0],
1282 EXCEPTION(runtime_error,"GetTimeStampInfo - MEDnVal(...) - aNbVal == "<<aNbVal<<" <= 0");
1285 TValue& aValue = theVal.myMeshValue[EGeometrieElement(aGeom)];
1286 TInt iEnd = aNbVal*aFieldInfo.myNbComp;
1288 if(iEnd != aValue.size()){
1293 EXCEPTION(runtime_error,
1294 "GetTimeStampInfo - iEnd("<<iEnd<<
1295 ") != aValue.size()("<<aValue.size()<<
1296 "); aNbVal = "<<aNbVal<<
1297 "; anEntity = "<<anEntity<<
1298 "; aGeom = "<<aGeom);
1302 switch(aFieldInfo.myType){
1304 std::vector<TFloat> anArray(iEnd);
1305 aRet = MEDchampLire(anId,
1306 &aMeshInfo.myName[0],
1307 &aFieldInfo.myName[0],
1308 (unsigned char*)&anArray[0],
1311 &aTimeStampInfo.myGaussName[0],
1312 &theVal.myPflName[0],
1316 aTimeStampInfo.myNumDt,
1317 aTimeStampInfo.myNumOrd);
1319 for(TInt i = 0; i < iEnd; i++)
1320 aValue[i] = anArray[i];
1324 std::vector<TInt> anArray(iEnd);
1325 aRet = MEDchampLire(anId,
1326 &aMeshInfo.myName[0],
1327 &aFieldInfo.myName[0],
1328 (unsigned char*)&anArray[0],
1331 &aTimeStampInfo.myGaussName[0],
1332 &theVal.myPflName[0],
1336 aTimeStampInfo.myNumDt,
1337 aTimeStampInfo.myNumOrd);
1339 for(med_int i = 0; i < iEnd; i++)
1340 aValue[i] = anArray[i];
1348 EXCEPTION(runtime_error,"GetValTimeStamp - MEDchampLire(...)");
1354 void TVWrapper::SetTimeStamp(const MED::TTimeStampVal& theVal,
1358 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1360 if(theErr && !*theErr)
1364 TIdt anId = myFile->Id();
1366 MED::TTimeStampVal& aVal = const_cast<MED::TTimeStampVal&>(theVal);
1367 MED::TTimeStampInfo& aTimeStampInfo = *aVal.myTimeStampInfo;
1368 MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo;
1369 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1370 MED::TMeshValue& aMeshValue = aVal.myMeshValue;
1372 med_entite_maillage& anEntity = static_cast<med_entite_maillage>(aTimeStampInfo.myEntity);
1373 med_mode_profil& aPflMode = static_cast<med_mode_profil>(theVal.myPflMode);
1374 TMeshValue::iterator anIter = aMeshValue.begin();
1375 for(; anIter != aMeshValue.end(); anIter++){
1376 med_geometrie_element& aGeom = static_cast<med_geometrie_element>(anIter->first);
1377 TValue& aValue = aVal.myMeshValue[EGeometrieElement(aGeom)];
1378 med_int iEnd = aValue.size();
1379 med_int aNbVal = iEnd / aFieldInfo.myNbComp;
1381 switch(aFieldInfo.myType){
1383 std::vector<TFloat>& anArray = aValue;
1385 aRet = MEDchampEcr(anId,
1386 &aMeshInfo.myName[0],
1387 &aFieldInfo.myName[0],
1388 (unsigned char*)&anArray[0],
1391 &aTimeStampInfo.myGaussName[0],
1397 aTimeStampInfo.myNumDt,
1398 &aTimeStampInfo.myUnitDt[0],
1399 aTimeStampInfo.myDt,
1400 aTimeStampInfo.myNumOrd);
1404 vector<TInt> anArray(iEnd);
1405 for(TInt i = 0; i< iEnd; i++) anArray[i] = TInt(aValue[i]);
1407 aRet = MEDchampEcr(anId,
1408 &aMeshInfo.myName[0],
1409 &aFieldInfo.myName[0],
1410 (unsigned char*)&anArray[0],
1413 &aTimeStampInfo.myGaussName[0],
1419 aTimeStampInfo.myNumDt,
1420 &aTimeStampInfo.myUnitDt[0],
1421 aTimeStampInfo.myDt,
1422 aTimeStampInfo.myNumOrd);
1431 EXCEPTION(runtime_error,"SetTimeStamp - MEDchampEcr(...)");
1436 INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
1440 void TVWrapper::SetTimeStamp(const MED::TTimeStampVal& theVal,
1444 SetTimeStamp(theVal,eLECTURE_ECRITURE,&aRet);
1447 SetTimeStamp(theVal,eLECTURE_AJOUT,theErr);