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_Algorithm.hxx"
31 #include "MED_Utilities.hxx"
38 MEDgaussInfo(med_idt fid, int indice, char * locname, med_geometrie_element * type_geo,
43 static int MYDEBUG = 0;
45 static int MYDEBUG = 0;
54 GetDESCLength<eV2_2>()
61 GetIDENTLength<eV2_2>()
75 GetLNOMLength<eV2_2>()
82 GetPNOMLength<eV2_2>()
89 GetNbConn<eV2_2>(EGeometrieElement typmai,
90 EEntiteMaillage typent,
99 //---------------------------------------------------------------
105 TFile(const std::string& theFileName):
108 myFileName(theFileName)
115 void Open(EModeAcces theMode, TErr* theErr = NULL){
117 char* aFileName = const_cast<char*>(myFileName.c_str());
118 myFid = MEDouvrir(aFileName,med_mode_acces(theMode));
121 *theErr = TErr(myFid > 0);
123 EXCEPTION(runtime_error,"TFile - MEDouvrir('"<<myFileName<<"',"<<theMode<<")");
126 const TIdt& Id() const {
128 EXCEPTION(runtime_error,"TFile - GetFid() < 0");
138 std::string myFileName;
144 //---------------------------------------------------------------
149 TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL):
152 myFile->Open(theMode,theErr);
161 //---------------------------------------------------------------
162 TVWrapper::TVWrapper(const std::string& theFileName):
163 myFile(new TFile(theFileName))
170 ::GetNbMeshes(TErr* theErr)
172 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
174 if(theErr && !*theErr)
177 return MEDnMaa(myFile->Id());
183 ::GetMeshInfo(TInt theMeshId,
184 MED::TMeshInfo& theInfo,
187 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
189 if(theErr && !*theErr)
192 TErr aRet = MEDmaaInfo(myFile->Id(),
195 (med_int*)&theInfo.myDim,
196 (med_maillage*)&theInfo.myType,
201 EXCEPTION(runtime_error,"GetMeshInfo - MEDmaaInfo(...)");
207 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
211 TFileWrapper aFileWrapper(myFile,theMode,theErr);
213 if(theErr && !*theErr)
216 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
218 TErr aRet = MEDmaaCr(myFile->Id(),
220 med_int(anInfo.myDim),
221 med_maillage(theInfo.myType),
224 aRet = MEDunvCr(myFile->Id(),
228 INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
233 EXCEPTION(runtime_error,"SetMeshInfo - MEDmaaCr(...)");
239 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
243 SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
246 SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
249 SetMeshInfo(theInfo,eCREATION,theErr);
255 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
258 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
260 if(theErr && !*theErr)
263 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
264 return MEDnFam(myFile->Id(),
271 ::GetNbFamAttr(TInt theFamId,
272 const MED::TMeshInfo& theInfo,
275 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
277 if(theErr && !*theErr)
280 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
281 return MEDnAttribut(myFile->Id(),
289 ::GetNbFamGroup(TInt theFamId,
290 const MED::TMeshInfo& theInfo,
293 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
295 if(theErr && !*theErr)
298 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
299 return MEDnGroupe(myFile->Id(),
307 ::GetFamilyInfo(TInt theFamId,
308 MED::TFamilyInfo& theInfo,
311 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
313 if(theErr && !*theErr)
316 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
318 med_int* anAttrId = theInfo.myNbAttr > 0? (med_int*)&theInfo.myAttrId[0]: NULL;
319 med_int* anAttrVal = theInfo.myNbAttr > 0? (med_int*)&theInfo.myAttrVal[0]: NULL;
320 char* anAttrDesc = theInfo.myNbAttr > 0? &theInfo.myAttrDesc[0]: NULL;
321 char* aGroupNames = theInfo.myNbGroup > 0? &theInfo.myGroupNames[0]: NULL;
323 TErr aRet = MEDfamInfo(myFile->Id(),
324 &aMeshInfo.myName[0],
327 (med_int*)&theInfo.myId,
331 (med_int*)&theInfo.myNbAttr,
333 (med_int*)&theInfo.myNbGroup);
338 EXCEPTION(runtime_error,"GetFamilyInfo - MEDfamInfo(...) - "<<
339 " aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<
340 "'; theFamId = "<<theFamId<<
341 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
342 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
348 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
352 TFileWrapper aFileWrapper(myFile,theMode,theErr);
354 if(theErr && !*theErr)
357 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
358 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
360 med_int* anAttrId = anInfo.myNbAttr > 0? (med_int*)&anInfo.myAttrId[0]: NULL;
361 med_int* anAttrVal = anInfo.myNbAttr > 0? (med_int*)&anInfo.myAttrVal[0]: NULL;
362 char* anAttrDesc = anInfo.myNbAttr > 0? &anInfo.myAttrDesc[0]: NULL;
363 char* aGroupNames = anInfo.myNbGroup > 0? &anInfo.myGroupNames[0]: NULL;
365 TErr aRet = MEDfamCr(myFile->Id(),
366 &aMeshInfo.myName[0],
376 INITMSG(MYDEBUG,"TVWrapper::GetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
381 EXCEPTION(runtime_error,"SetFamilyInfo - MEDfamCr(...)");
387 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
391 SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
394 SetFamilyInfo(theInfo,eLECTURE_AJOUT,theErr);
397 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
400 ::GetNames(TElemInfo& theInfo,
402 EEntiteMaillage theEntity,
403 EGeometrieElement theGeom,
406 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
408 if(theErr && !*theErr)
411 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
413 TErr aRet = MEDnomLire(myFile->Id(),
414 &aMeshInfo.myName[0],
415 &theInfo.myElemNames[0],
417 med_entite_maillage(theEntity),
418 med_geometrie_element(theGeom));
420 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
425 ::GetNumeration(TElemInfo& theInfo,
427 EEntiteMaillage theEntity,
428 EGeometrieElement theGeom,
431 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
433 if(theErr && !*theErr)
436 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
438 med_entite_maillage& anEntity = (med_entite_maillage&)(theEntity);
439 med_geometrie_element& aGeom = (med_geometrie_element&)(theGeom);
441 TErr aRet = MEDnumLire(myFile->Id(),
442 &aMeshInfo.myName[0],
443 (med_int*)&theInfo.myElemNum[0],
448 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
453 ::GetFamilies(TElemInfo& theInfo,
455 EEntiteMaillage theEntity,
456 EGeometrieElement theGeom,
459 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
461 if(theErr && !*theErr)
464 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
466 TErr aRet = MEDfamLire(myFile->Id(),
467 &aMeshInfo.myName[0],
468 (med_int*)&theInfo.myFamNum[0],
470 med_entite_maillage(theEntity),
471 med_geometrie_element(theGeom));
476 EXCEPTION(runtime_error,"GetFamilies - MEDfamLire(...)");
481 ::SetNames(const TElemInfo& theInfo,
482 EEntiteMaillage theEntity,
483 EGeometrieElement theGeom,
486 SetNames(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
491 ::SetNames(const TElemInfo& theInfo,
493 EEntiteMaillage theEntity,
494 EGeometrieElement theGeom,
497 TFileWrapper aFileWrapper(myFile,theMode,theErr);
499 if(theErr && !*theErr)
502 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
503 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
506 if(theInfo.myIsElemNames){
507 aRet = MEDnomEcr(myFile->Id(),
508 &aMeshInfo.myName[0],
509 &anInfo.myElemNames[0],
510 anInfo.myElemNames.size(),
511 med_entite_maillage(theEntity),
512 med_geometrie_element(theGeom));
516 EXCEPTION(runtime_error,"SetNames - MEDnomEcr(...)");
522 ::SetNumeration(const TElemInfo& theInfo,
523 EEntiteMaillage theEntity,
524 EGeometrieElement theGeom,
527 SetNumeration(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
532 ::SetNumeration(const TElemInfo& theInfo,
534 EEntiteMaillage theEntity,
535 EGeometrieElement theGeom,
538 TFileWrapper aFileWrapper(myFile,theMode,theErr);
540 if(theErr && !*theErr)
543 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
544 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
547 if(theInfo.myIsElemNum){
548 aRet = MEDnumEcr(myFile->Id(),
549 &aMeshInfo.myName[0],
550 (med_int*)&anInfo.myElemNum[0],
551 anInfo.myElemNum.size(),
552 med_entite_maillage(theEntity),
553 med_geometrie_element(theGeom));
557 EXCEPTION(runtime_error,"SetNumeration - MEDnumEcr(...)");
563 ::SetFamilies(const TElemInfo& theInfo,
564 EEntiteMaillage theEntity,
565 EGeometrieElement theGeom,
568 SetFamilies(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
573 ::SetFamilies(const TElemInfo& theInfo,
575 EEntiteMaillage theEntity,
576 EGeometrieElement theGeom,
579 TFileWrapper aFileWrapper(myFile,theMode,theErr);
581 if(theErr && !*theErr)
584 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
585 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
587 TErr aRet = MEDfamEcr(myFile->Id(),
588 &aMeshInfo.myName[0],
589 (med_int*)&anInfo.myFamNum[0],
590 anInfo.myFamNum.size(),
591 med_entite_maillage(theEntity),
592 med_geometrie_element(theGeom));
597 EXCEPTION(runtime_error,"SetFamilies - MEDfamEcr(...)");
600 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
603 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
607 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
609 if(theErr && !*theErr)
612 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
614 return MEDnEntMaa(myFile->Id(),
615 &aMeshInfo.myName[0],
618 med_geometrie_element(0),
619 med_connectivite(0));
625 ::GetNodeInfo(MED::TNodeInfo& theInfo,
628 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
630 if(theErr && !*theErr)
633 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
635 char* anElemNames = theInfo.myIsElemNames? &theInfo.myElemNames[0]: NULL;
636 med_int* anElemNum = theInfo.myIsElemNum? &theInfo.myElemNum[0]: NULL;
638 TErr aRet = MEDnoeudsLire(myFile->Id(),
639 &aMeshInfo.myName[0],
642 med_mode_switch(theInfo.myModeSwitch),
643 (med_repere*)&theInfo.mySystem,
644 &theInfo.myCoordNames[0],
645 &theInfo.myCoordUnits[0],
647 (med_booleen*)&theInfo.myIsElemNames,
649 (med_booleen*)&theInfo.myIsElemNum,
650 (med_int*)&theInfo.myFamNum[0],
655 EXCEPTION(runtime_error,"GetNodeInfo - MEDnoeudsLire(...)");
661 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
665 TFileWrapper aFileWrapper(myFile,theMode,theErr);
667 if(theErr && !*theErr)
670 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
671 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
673 char* anElemNames = theInfo.myIsElemNames? &anInfo.myElemNames[0]: NULL;
674 med_int* anElemNum = theInfo.myIsElemNum? &anInfo.myElemNum[0]: NULL;
676 TErr aRet = MEDnoeudsEcr(myFile->Id(),
677 &aMeshInfo.myName[0],
680 med_mode_switch(theInfo.myModeSwitch),
681 med_repere(theInfo.mySystem),
682 &anInfo.myCoordNames[0],
683 &anInfo.myCoordUnits[0],
685 med_booleen(theInfo.myIsElemNames),
687 med_booleen(theInfo.myIsElemNum),
688 (med_int*)&anInfo.myFamNum[0],
693 EXCEPTION(runtime_error,"SetNodeInfo - MEDnoeudsEcr(...)");
699 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
703 SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
706 SetNodeInfo(theInfo,eLECTURE_AJOUT,theErr);
710 //-----------------------------------------------------------------
713 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
716 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
718 if(theErr && !*theErr)
721 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
722 TInt aNbElem = theInfo.myElemNum.size();
725 aRet = MEDpolygoneConnLire(myFile->Id(),
726 &aMeshInfo.myName[0],
727 (med_int*)&theInfo.myIndex[0],
729 (med_int*)&theInfo.myConn[0],
730 med_entite_maillage(theInfo.myEntity),
731 med_connectivite(theInfo.myConnMode));
736 EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)");
738 if(theInfo.myIsElemNames){
739 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
744 if(theInfo.myIsElemNum){
745 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
750 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
757 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
760 SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
765 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
769 TFileWrapper aFileWrapper(myFile,theMode,theErr);
771 if(theErr && !*theErr)
774 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
775 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
777 TErr aRet = MEDpolygoneConnEcr(myFile->Id(),
778 &aMeshInfo.myName[0],
779 (med_int*)&anInfo.myIndex[0],
781 (med_int*)&anInfo.myConn[0],
782 med_entite_maillage(theInfo.myEntity),
783 med_connectivite(theInfo.myConnMode));
788 EXCEPTION(runtime_error,"SetPolygoneInfo - MEDpolygoneConnEcr(...)");
790 SetNames(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
794 SetNumeration(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
798 SetFamilies(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
805 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
806 EEntiteMaillage theEntity,
807 EGeometrieElement theGeom,
808 EConnectivite theConnMode,
811 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
816 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
817 EEntiteMaillage theEntity,
818 EGeometrieElement theGeom,
819 EConnectivite theConnMode,
822 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
824 if(theErr && !*theErr)
827 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
832 aRet = MEDpolygoneInfo(myFile->Id(),
833 &aMeshInfo.myName[0],
834 med_entite_maillage(theEntity),
835 med_connectivite(theConnMode),
841 EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)");
846 //-----------------------------------------------------------------
849 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
852 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
854 if(theErr && !*theErr)
857 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
858 TInt aNbElem = theInfo.myElemNum.size();
861 aRet = MEDpolyedreConnLire(myFile->Id(),
862 &aMeshInfo.myName[0],
863 (med_int*)&theInfo.myIndex[0],
865 (med_int*)&theInfo.myFaces[0],
866 theInfo.myFaces.size(),
867 (med_int*)&theInfo.myConn[0],
868 med_connectivite(theInfo.myConnMode));
873 EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreConnLire(...)");
875 if(theInfo.myIsElemNames){
876 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
881 if(theInfo.myIsElemNum){
882 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
887 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
894 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
897 SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
902 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
906 TFileWrapper aFileWrapper(myFile,theMode,theErr);
908 if(theErr && !*theErr)
911 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
912 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
915 aRet = MEDpolyedreConnEcr(myFile->Id(),
916 &aMeshInfo.myName[0],
917 (med_int*)&anInfo.myIndex[0],
919 (med_int*)&anInfo.myFaces[0],
920 anInfo.myFaces.size(),
921 (med_int*)&anInfo.myConn[0],
922 med_connectivite(theInfo.myConnMode));
927 EXCEPTION(runtime_error,"SetPolyedreInfo - MEDpolyedreConnEcr(...)");
929 if(theInfo.myIsElemNames){
930 aRet = MEDnomEcr(myFile->Id(),
931 &aMeshInfo.myName[0],
932 &anInfo.myElemNames[0],
933 anInfo.myElemNames.size(),
934 med_entite_maillage(theInfo.myEntity),
939 EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnomEcr(...)");
942 if(theInfo.myIsElemNum){
943 aRet = MEDnumEcr(myFile->Id(),
944 &aMeshInfo.myName[0],
945 (med_int*)&anInfo.myElemNum[0],
946 anInfo.myElemNum.size(),
947 med_entite_maillage(theInfo.myEntity),
952 EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnumEcr(...)");
956 aRet = MEDfamEcr(myFile->Id(),
957 &aMeshInfo.myName[0],
958 (med_int*)&anInfo.myFamNum[0],
959 anInfo.myFamNum.size(),
960 med_entite_maillage(theInfo.myEntity),
966 EXCEPTION(runtime_error,"SetPolyedreInfo - MEDfamEcr(...)");
971 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
972 EEntiteMaillage theEntity,
973 EGeometrieElement theGeom,
974 EConnectivite theConnMode,
977 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
982 ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
985 EConnectivite theConnMode,
988 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
990 if(theErr && !*theErr)
991 EXCEPTION(runtime_error,"GetPolyedreInfo - (...)");
993 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
995 TErr aRet = MEDpolyedreInfo(myFile->Id(),
996 &aMeshInfo.myName[0],
997 med_connectivite(theConnMode),
998 (med_int*)&theNbFaces,
999 (med_int*)&theConnSize);
1004 EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreInfo(...)");
1008 //-----------------------------------------------------------------
1011 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1012 EConnectivite theConnMode,
1017 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1019 if(theErr && *theErr < 0)
1022 if(theMeshInfo.GetType() == eNON_STRUCTURE) {
1024 TInt aNbElem = GetNbNodes(theMeshInfo);
1026 anInfo[eNOEUD][ePOINT1] = aNbElem;
1027 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1028 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1029 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1030 for(; anIter != anIterEnd; anIter++){
1031 const EEntiteMaillage& anEntity = anIter->first;
1032 const TGeomSet& aGeomSet = anIter->second;
1033 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1034 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1035 for(; anIter2 != anIterEnd2; anIter2++){
1036 const EGeometrieElement& aGeom = *anIter2;
1037 aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
1039 anInfo[anEntity][aGeom] = aNbElem;
1043 } else { // eSTRUCTURE
1044 EGrilleType aGrilleType;
1047 TInt aDim = theMeshInfo.GetDim();
1048 EGeometrieElement aGeom;
1049 EEntiteMaillage anEntity = eMAILLE;
1062 GetGrilleType(theMeshInfo,aGrilleType);
1064 if (aGrilleType == eGRILLE_STANDARD){
1065 TIntVector theStruct;
1066 theStruct.resize(aDim);
1067 GetGrilleStruct(theMeshInfo,theStruct,theErr);
1068 for(med_int i=0;i<aDim;i++){
1069 aNbNodes = aNbNodes * theStruct[i];
1070 aNbElem = aNbElem * (theStruct[i]-1);
1072 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1073 anInfo[anEntity][aGeom] = aNbElem;
1075 } else { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1077 for(int aAxe=1;aAxe<=aDim;aAxe++)
1081 quoi = MED_COOR_IND1;
1084 quoi = MED_COOR_IND2;
1087 quoi = MED_COOR_IND3;
1090 TInt nbn = GetNbNodes(theMeshInfo,(ETable)quoi);
1091 aNbNodes = aNbNodes * nbn;
1092 aNbElem = aNbElem * (nbn-1);
1094 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1095 anInfo[anEntity][aGeom] = aNbElem;
1102 //-----------------------------------------------------------------
1105 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1106 EEntiteMaillage theEntity,
1107 EGeometrieElement theGeom,
1108 EConnectivite theConnMode,
1111 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1113 if(theErr && !*theErr)
1116 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1118 return MEDnEntMaa(myFile->Id(),
1119 &aMeshInfo.myName[0],
1121 med_entite_maillage(theEntity),
1122 med_geometrie_element(theGeom),
1123 med_connectivite(theConnMode));
1129 ::GetCellInfo(MED::TCellInfo& theInfo,
1132 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1134 if(theErr && !*theErr)
1137 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1138 TInt aNbElem = theInfo.myElemNum.size();
1140 char* anElemNames = theInfo.myIsElemNames? &theInfo.myElemNames[0]: NULL;
1141 med_int* anElemNum = theInfo.myIsElemNum? &theInfo.myElemNum[0]: NULL;
1144 aRet = MEDelementsLire(myFile->Id(),
1145 &aMeshInfo.myName[0],
1147 (med_int*)&theInfo.myConn[0],
1148 med_mode_switch(theInfo.myModeSwitch),
1150 (med_booleen*)&theInfo.myIsElemNames,
1152 (med_booleen*)&theInfo.myIsElemNum,
1153 (med_int*)&theInfo.myFamNum[0],
1155 med_entite_maillage(theInfo.myEntity),
1156 med_geometrie_element(theInfo.myGeom),
1157 med_connectivite(theInfo.myConnMode));
1161 EXCEPTION(runtime_error,"GetCellInfo - MEDelementsLire(...)");
1167 ::SetCellInfo(const MED::TCellInfo& theInfo,
1171 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1173 if(theErr && !*theErr)
1176 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
1177 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1179 char* anElemNames = theInfo.myIsElemNames? &anInfo.myElemNames[0]: NULL;
1180 med_int* anElemNum = theInfo.myIsElemNum? &anInfo.myElemNum[0]: NULL;
1183 aRet = MEDelementsEcr(myFile->Id(),
1184 &aMeshInfo.myName[0],
1186 (med_int*)&anInfo.myConn[0],
1187 med_mode_switch(theInfo.myModeSwitch),
1189 med_booleen(theInfo.myIsElemNames),
1191 med_booleen(theInfo.myIsElemNum),
1192 (med_int*)&anInfo.myFamNum[0],
1194 med_entite_maillage(theInfo.myEntity),
1195 med_geometrie_element(theInfo.myGeom),
1196 med_connectivite(theInfo.myConnMode));
1201 EXCEPTION(runtime_error,"SetCellInfo - MEDelementsLire(...)");
1207 ::SetCellInfo(const MED::TCellInfo& theInfo,
1210 SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
1214 //-----------------------------------------------------------------
1217 ::GetNbFields(TErr* theErr)
1219 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1221 if(theErr && !*theErr)
1224 return MEDnChamp(myFile->Id(),0);
1230 ::GetNbComp(TInt theFieldId,
1233 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1235 if(theErr && !*theErr)
1238 return MEDnChamp(myFile->Id(),theFieldId);
1244 ::GetFieldInfo(TInt theFieldId,
1245 MED::TFieldInfo& theInfo,
1248 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1250 if(theErr && !*theErr)
1254 aRet = MEDchampInfo(myFile->Id(),
1257 (med_type_champ*)&theInfo.myType,
1258 &theInfo.myCompNames[0],
1259 &theInfo.myUnitNames[0],
1264 EXCEPTION(runtime_error,"GetFieldInfo - MEDchampInfo(...)");
1270 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1274 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1276 if(theErr && !*theErr)
1279 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1282 aRet = MEDchampCr(myFile->Id(),
1284 med_type_champ(theInfo.myType),
1285 &anInfo.myCompNames[0],
1286 &anInfo.myUnitNames[0],
1291 EXCEPTION(runtime_error,"SetFieldInfo - MEDchampEcr(...)");
1297 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1301 SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1304 SetFieldInfo(theInfo,eLECTURE_AJOUT,theErr);
1308 //-----------------------------------------------------------------
1311 ::GetNbGauss(TErr* theErr)
1313 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1315 if(theErr && *theErr < 0)
1318 return MEDnGauss(myFile->Id());
1324 ::GetGaussPreInfo(TInt theId,
1327 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1329 if(theErr && *theErr < 0)
1330 return TGaussInfo::TInfo();
1332 med_int aNbGaussPoints = med_int();
1333 TVector<char> aName(GetNOMLength<eV2_2>()+1);
1334 med_geometrie_element aGeom = MED_NONE;
1337 aRet = MEDgaussInfo(myFile->Id(),
1345 EXCEPTION(runtime_error,"GetGaussPreInfo - MEDgaussInfo(...)");
1347 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]),
1348 TInt(aNbGaussPoints));
1354 ::GetGaussInfo(TInt theId,
1355 TGaussInfo& theInfo,
1358 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1360 if(theErr && *theErr < 0)
1364 aRet = MEDgaussLire(myFile->Id(),
1365 &theInfo.myRefCoord[0],
1366 &theInfo.myGaussCoord[0],
1367 &theInfo.myWeight[0],
1368 med_mode_switch(theInfo.myModeSwitch),
1369 &theInfo.myName[0]);
1374 EXCEPTION(runtime_error,"GetGaussInfo - MEDgaussLire(...)");
1378 //-----------------------------------------------------------------
1381 ::GetNbProfiles(TErr* theErr)
1383 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1385 if(theErr && *theErr < 0)
1388 return MEDnProfil(myFile->Id());
1394 ::GetProfilePreInfo(TInt theId,
1397 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1399 if(theErr && *theErr < 0)
1400 return TProfileInfo::TInfo();
1403 TVector<char> aName(GetNOMLength<eV2_2>()+1);
1406 aRet = MEDprofilInfo(myFile->Id(),
1413 EXCEPTION(runtime_error,"GetProfilePreInfo - MEDprofilInfo(...)");
1415 return TProfileInfo::TInfo(&aName[0],aSize);
1421 ::GetProfileInfo(TInt theId,
1422 TProfileInfo& theInfo,
1425 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1427 if(theErr && *theErr < 0)
1431 aRet = MEDprofilLire(myFile->Id(),
1432 &theInfo.myElemNum[0],
1433 &theInfo.myName[0]);
1437 EXCEPTION(runtime_error,"GetProfileInfo - MEDprofilLire(...)");
1441 //-----------------------------------------------------------------
1444 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
1445 const MED::TEntityInfo& theEntityInfo,
1446 EEntiteMaillage& theEntity,
1447 TGeom2Size& theGeom2Size,
1450 theEntity = EEntiteMaillage(-1);
1451 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1454 if(theEntityInfo.empty())
1458 }else if(theEntityInfo.empty())
1459 EXCEPTION(runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
1461 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
1463 static bool anIsCheckOnlyFirstTimeStamp = false;
1465 static bool anIsCheckOnlyFirstTimeStamp = true;
1468 theGeom2Size.clear();
1469 TInt aNbTimeStamps = 0;
1470 TIdt anId = myFile->Id();
1472 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1473 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
1475 TEntityInfo::const_iterator anIter = theEntityInfo.begin();
1476 for(; anIter != theEntityInfo.end(); anIter++){
1477 med_entite_maillage anEntity = med_entite_maillage(anIter->first);
1478 const TGeom2Size& aGeom2Size = anIter->second;
1479 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
1480 for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
1481 med_geometrie_element aGeom = med_geometrie_element(anGeomIter->first);
1482 TInt aNbStamps = MEDnPasdetemps(anId,
1486 bool anIsSatisfied = aNbStamps > 0;
1489 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
1490 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
1491 if(anIsPerformAdditionalCheck){
1492 TInt iTimeStampEnd = anIsCheckOnlyFirstTimeStamp? 1: aNbStamps;
1493 for(TInt iTimeStamp = 1; iTimeStamp <= iTimeStampEnd; iTimeStamp++){
1494 TVector<char> aMeshName(GetNOMLength<eV2_2>()+1);
1495 TVector<char> aDtUnit(GetPNOMLength<eV2_2>()+1);
1500 med_booleen anIsLocal;
1502 TErr aRet = MEDpasdetempsInfo(anId,
1516 anIsSatisfied = (aRet == 0 && (!strcmp(&aMeshName[0],&aMeshInfo.myName[0])));
1519 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
1520 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
1527 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
1528 theEntity = EEntiteMaillage(anEntity);
1529 aNbTimeStamps = aNbStamps;
1532 if(!theGeom2Size.empty())
1535 return aNbTimeStamps;
1541 ::GetTimeStampInfo(TInt theTimeStampId,
1542 MED::TTimeStampInfo& theInfo,
1545 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1547 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
1550 if(aGeom2Size.empty())
1554 }else if(aGeom2Size.empty())
1555 EXCEPTION(runtime_error,"GetTimeStampInfo - There is no any cell");
1557 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
1558 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1560 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
1562 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
1563 for(; anIter != aGeom2Size.end(); anIter++){
1564 const EGeometrieElement& aGeom = anIter->first;
1565 med_int aNbGauss = -1;
1568 aRet = MEDpasdetempsInfo(myFile->Id(),
1569 &aFieldInfo.myName[0],
1570 med_entite_maillage(theInfo.myEntity),
1571 med_geometrie_element(aGeom),
1574 (med_int*)&theInfo.myNumDt,
1575 (med_int*)&theInfo.myNumOrd,
1576 &theInfo.myUnitDt[0],
1578 &aMeshInfo.myName[0],
1579 (med_booleen*)&aFieldInfo.myIsLocal,
1580 (med_int*)&aFieldInfo.myNbRef);
1582 static TInt MAX_NB_GAUSS_POINTS = 32;
1583 if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
1586 aGeom2NbGauss[aGeom] = aNbGauss;
1591 EXCEPTION(runtime_error,"GetTimeStampInfo - MEDpasdetempsInfo(...)");
1598 ::GetTimeStampVal(TTimeStampVal& theVal,
1599 const TMKey2Profile& theMKey2Profile,
1600 const TKey2Gauss& theKey2Gauss,
1603 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1605 if(theErr && !*theErr)
1608 TIdt anId = myFile->Id();
1610 MED::TTimeStampInfo& aTimeStampInfo = *theVal.myTimeStampInfo;
1611 MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo;
1612 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1614 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.myGeom2Gauss;
1615 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
1617 med_mode_profil aProfileMode = med_mode_profil(boost::get<0>(theMKey2Profile));
1618 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
1619 MED::TGeom2Profile& aGeom2Profile = theVal.myGeom2Profile;
1620 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
1622 TGeom2Size& aGeom2Size = aTimeStampInfo.myGeom2Size;
1623 TGeom2Size::iterator anIter = aGeom2Size.begin();
1624 for(; anIter != aGeom2Size.end(); anIter++){
1625 EGeometrieElement aGeom = anIter->first;
1626 TInt aNbCells = anIter->second;
1628 TInt aNbMeshRef = MEDnChampRef(anId,
1629 &aFieldInfo.myName[0],
1630 med_entite_maillage(aTimeStampInfo.myEntity),
1631 med_geometrie_element(aGeom),
1632 aTimeStampInfo.myNumDt,
1633 aTimeStampInfo.myNumOrd);
1639 EXCEPTION(runtime_error,"GetTimeStampVal - MEDnChampRef(...) < 1");
1643 med_int aNbGauss = -1;
1644 aRet = MEDchampRefInfo(anId,
1645 &aFieldInfo.myName[0],
1646 med_entite_maillage(aTimeStampInfo.myEntity),
1647 med_geometrie_element(aGeom),
1649 aTimeStampInfo.myNumDt,
1650 aTimeStampInfo.myNumOrd,
1651 &aMeshInfo.myName[0],
1652 (med_booleen*)&aFieldInfo.myIsLocal,
1660 EXCEPTION(runtime_error,"GetTimeStampVal - MEDchampRefInfo(...)");
1663 TInt aNbVal = MEDnVal(anId,
1664 &aFieldInfo.myName[0],
1665 med_entite_maillage(aTimeStampInfo.myEntity),
1666 med_geometrie_element(aGeom),
1667 aTimeStampInfo.myNumDt,
1668 aTimeStampInfo.myNumOrd,
1669 &aMeshInfo.myName[0],
1676 EXCEPTION(runtime_error,"GetTimeStampInfo - MEDnVal(...) - aNbVal == "<<aNbVal<<" <= 0");
1679 TMeshValue& aMeshValue = theVal.GetMeshValue(aGeom);
1680 TInt aNbElem = aNbVal / aNbGauss;
1681 aMeshValue.Init(aNbElem,
1683 aFieldInfo.myNbComp);
1684 TValue& aValue = aMeshValue.myValue;
1685 TInt anEnd = aValue.size();
1687 switch(aFieldInfo.myType){
1689 TVector<TFloat> anArray(anEnd);
1690 aRet = MEDchampLire(anId,
1691 &aMeshInfo.myName[0],
1692 &aFieldInfo.myName[0],
1693 (unsigned char*)&anArray[0],
1694 med_mode_switch(theVal.myModeSwitch),
1699 med_entite_maillage(aTimeStampInfo.myEntity),
1700 med_geometrie_element(aGeom),
1701 aTimeStampInfo.myNumDt,
1702 aTimeStampInfo.myNumOrd);
1704 for(TInt anId = 0; anId < anEnd; anId++)
1705 aValue[anId] = anArray[anId];
1709 TVector<TInt> anArray(anEnd);
1710 aRet = MEDchampLire(anId,
1711 &aMeshInfo.myName[0],
1712 &aFieldInfo.myName[0],
1713 (unsigned char*)&anArray[0],
1714 med_mode_switch(theVal.myModeSwitch),
1719 med_entite_maillage(aTimeStampInfo.myEntity),
1720 med_geometrie_element(aGeom),
1721 aTimeStampInfo.myNumDt,
1722 aTimeStampInfo.myNumOrd);
1724 for(TInt anId = 0; anId < anEnd; anId++)
1725 aValue[anId] = anArray[anId];
1734 EXCEPTION(runtime_error,"GetValTimeStamp - MEDchampLire(...)");
1737 MED::PGaussInfo aGaussInfo;
1738 TGaussInfo::TKey aKey(aGeom,&aGaussName[0]);
1739 if(strcmp(&aGaussName[0],"") != 0){
1740 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
1741 if(anIter != theKey2Gauss.end()){
1742 aGaussInfo = anIter->second;
1743 aGeom2Gauss[aGeom] = aGaussInfo;
1747 MED::PProfileInfo aProfileInfo;
1748 if(strcmp(&aProfileName[0],"") != 0){
1749 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
1750 if(anIter != aKey2Profile.end()){
1751 aProfileInfo = anIter->second;
1752 aGeom2Profile[aGeom] = aProfileInfo;
1756 if(aNbGauss > 1 && !aGaussInfo){
1761 EXCEPTION(runtime_error,"GetValTimeStamp "<<
1762 "- aNbGauss("<<aNbGauss<<") > 1 && !aGaussInfo"<<
1763 "; aGaussName = '"<<&aGaussName[0]<<"'"<<
1764 "; aGeom = "<<aGeom<<
1768 if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){
1773 EXCEPTION(runtime_error,"GetValTimeStamp - aNbGauss != aGaussInfo->GetNbGauss()");
1776 if(aProfileInfo && aProfileInfo->IsPresent()){
1777 TInt aNbSubCells = aProfileInfo->GetSize();
1779 TInt aSize = aNbSubCells*aFieldInfo.myNbComp*aNbGauss;
1780 if(aSize != aValue.size()){
1785 EXCEPTION(runtime_error,
1786 "GetTimeStampInfo - aSize("<<aSize<<
1787 ") != aValue.size()("<<aValue.size()<<
1788 "); aNbVal = "<<aNbVal<<
1789 "; anEntity = "<<aTimeStampInfo.myEntity<<
1790 "; aGeom = "<<aGeom<<
1791 "; aNbCells = "<<aNbCells<<
1792 "; aNbSubCells = "<<aNbSubCells<<
1793 "; aNbComp = "<<aFieldInfo.myNbComp<<
1794 "; aNbGauss = "<<aNbGauss<<
1798 if(anEnd != aValue.size()){
1803 EXCEPTION(runtime_error,
1804 "GetTimeStampInfo - anEnd("<<anEnd<<
1805 ") != aValue.size()("<<aValue.size()<<
1806 "); aNbVal = "<<aNbVal<<
1807 "; anEntity = "<<aTimeStampInfo.myEntity<<
1808 "; aGeom = "<<aGeom<<
1809 "; aNbCells = "<<aNbCells<<
1810 "; aNbComp = "<<aFieldInfo.myNbComp<<
1811 "; aNbGauss = "<<aNbGauss<<
1821 ::SetTimeStamp(const MED::TTimeStampVal& theVal,
1825 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1827 if(theErr && !*theErr)
1831 TIdt anId = myFile->Id();
1833 MED::TTimeStampVal& aVal = const_cast<MED::TTimeStampVal&>(theVal);
1835 MED::TTimeStampInfo& aTimeStampInfo = *aVal.myTimeStampInfo;
1836 MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo;
1837 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1838 MED::TGeom2Value& aGeom2Value = aVal.myGeom2Value;
1840 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.myGeom2Gauss;
1841 MED::TGeom2Profile& aGeom2Profile = aVal.myGeom2Profile;
1843 TGeom2Value::iterator anIter = aGeom2Value.begin();
1844 for(; anIter != aGeom2Value.end(); anIter++){
1845 EGeometrieElement aGeom = anIter->first;
1846 TMeshValue& aMeshValue = anIter->second;
1848 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
1849 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
1850 if(aGaussIter != aGeom2Gauss.end()){
1851 MED::PGaussInfo aGaussInfo = aGaussIter->second;
1852 strcpy(&aGaussName[0],&aGaussInfo->myName[0]);
1855 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
1856 med_mode_profil aProfileMode = med_mode_profil(eNO_PFLMOD);
1857 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
1858 if(aProfileIter != aGeom2Profile.end()){
1859 MED::PProfileInfo aProfileInfo = aProfileIter->second;
1860 aProfileMode = med_mode_profil(aProfileInfo->myMode);
1861 strcpy(&aProfileName[0],&aProfileInfo->myName[0]);
1864 med_int aNbVal = aMeshValue.myNbElem / aFieldInfo.myNbComp;
1865 TValue& aValue = aMeshValue.myValue;
1866 TInt anEnd = aValue.size();
1868 switch(aFieldInfo.myType){
1870 TVector<TFloat>& anArray = aValue;
1872 aRet = MEDchampEcr(anId,
1873 &aMeshInfo.myName[0],
1874 &aFieldInfo.myName[0],
1875 (unsigned char*)&anArray[0],
1876 med_mode_switch(theVal.myModeSwitch),
1882 med_entite_maillage(aTimeStampInfo.myEntity),
1883 med_geometrie_element(aGeom),
1884 aTimeStampInfo.myNumDt,
1885 &aTimeStampInfo.myUnitDt[0],
1886 aTimeStampInfo.myDt,
1887 aTimeStampInfo.myNumOrd);
1891 vector<TInt> anArray(anEnd);
1892 for(TInt anID = 0; anID < anEnd; anID++)
1893 anArray[anID] = TInt(aValue[anID]);
1895 aRet = MEDchampEcr(anId,
1896 &aMeshInfo.myName[0],
1897 &aFieldInfo.myName[0],
1898 (unsigned char*)&anArray[0],
1899 med_mode_switch(theVal.myModeSwitch),
1905 med_entite_maillage(aTimeStampInfo.myEntity),
1906 med_geometrie_element(aGeom),
1907 aTimeStampInfo.myNumDt,
1908 &aTimeStampInfo.myUnitDt[0],
1909 aTimeStampInfo.myDt,
1910 aTimeStampInfo.myNumOrd);
1919 EXCEPTION(runtime_error,"SetTimeStamp - MEDchampEcr(...)");
1924 INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
1930 ::SetTimeStamp(const MED::TTimeStampVal& theVal,
1934 SetTimeStamp(theVal,eLECTURE_ECRITURE,&aRet);
1937 SetTimeStamp(theVal,eLECTURE_AJOUT,theErr);
1942 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
1945 SetGrilleInfo(theInfo,eLECTURE_ECRITURE,theErr);
1950 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
1954 if(theInfo.myMeshInfo->myType != eSTRUCTURE)
1956 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1962 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
1963 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1966 aRet = MEDnatureGrilleEcr(myFile->Id(),
1967 &aMeshInfo.myName[0],
1968 (med_type_grille)anInfo.myGrilleType);
1972 EXCEPTION(runtime_error,"SetGrilleInfo - MEDnatureGrilleEcr(...)");
1974 if(anInfo.myGrilleType == eGRILLE_STANDARD){
1975 med_int nnoeuds = (med_int)(anInfo.myCoord.size()/aMeshInfo.myDim);
1976 aRet = MEDcoordEcr(myFile->Id(),
1977 &aMeshInfo.myName[0],
1980 med_mode_switch(anInfo.myModeSwitch),
1982 (med_repere)theInfo.myGrilleType,
1983 &anInfo.myCoordNames[0],
1984 &anInfo.myCoordUnits[0]);
1987 EXCEPTION(runtime_error,"SetGrilleInfo - MEDcoordEcr(...)");
1989 aRet = MEDstructureCoordEcr(myFile->Id(),
1990 &aMeshInfo.myName[0],
1992 &anInfo.myGrilleStructure[0]);
1994 EXCEPTION(runtime_error,"SetGrilleInfo - MEDstructureCoordEcr(...)");
1997 for(int aAxe=0;aAxe<aMeshInfo.myDim;aAxe++){
1998 aRet = MEDindicesCoordEcr(myFile->Id(),
1999 &aMeshInfo.myName[0],
2001 &anInfo.GetIndexes(aAxe)[0],
2002 anInfo.GetIndexes(aAxe).size(),
2004 &anInfo.GetCoordName(aAxe)[0],
2005 &anInfo.GetCoordUnit(aAxe)[0]);
2007 EXCEPTION(runtime_error,"SetGrilleInfo - MEDindicesCoordEcr(...)");
2017 ::GetGrilleInfo(TGrilleInfo& theInfo,
2020 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2026 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2028 EMaillage type_maillage = aMeshInfo.myType;
2030 GetGrilleType(aMeshInfo,theInfo.myGrilleType,theErr);
2031 EGrilleType type = theInfo.myGrilleType;
2034 if(type_maillage == eSTRUCTURE && type == eGRILLE_STANDARD){
2036 GetGrilleStruct(aMeshInfo,theInfo.myGrilleStructure,theErr);
2038 aRet = MEDcoordLire(myFile->Id(),
2039 &aMeshInfo.myName[0],
2041 &theInfo.myCoord[0],
2042 med_mode_switch(theInfo.myModeSwitch),
2043 MED_ALL, // all coordinates must be return
2046 (med_repere*)&theInfo.myGrilleType,
2047 &theInfo.myCoordNames[0],
2048 &theInfo.myCoordUnits[0]);
2053 EXCEPTION(runtime_error,"GetGrilleInfo - MEDcoordLire(...)");
2054 //============================
2057 if(type_maillage == eSTRUCTURE && type != eGRILLE_STANDARD){
2059 for(int aAxe=1;aAxe<=aMeshInfo.myDim;aAxe++)
2063 quoi = MED_COOR_IND1;
2066 quoi = MED_COOR_IND2;
2069 quoi = MED_COOR_IND3;
2079 EXCEPTION(runtime_error,"GetGrilleInfo - Axe number out of range(...)");
2081 TInt nind = GetNbNodes(aMeshInfo,(ETable)quoi);
2083 EXCEPTION(runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
2085 med_float* indices = (med_float*)&theInfo.myIndixes[aAxe-1][0];
2087 char comp[MED_TAILLE_PNOM+1];
2088 char unit[MED_TAILLE_PNOM+1];
2090 aRet = MEDindicesCoordLire(myFile->Id(),
2091 &aMeshInfo.myName[0],
2098 theInfo.SetCoordName(aAxe-1,comp);
2099 theInfo.SetCoordUnit(aAxe-1,unit);
2103 EXCEPTION(runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)");
2110 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
2114 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2118 EXCEPTION(runtime_error," GetGrilleType - aFileWrapper (...)");
2120 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2122 EMaillage type_maillage = aMeshInfo.myType;
2125 if(type_maillage == eSTRUCTURE){
2126 med_type_grille Mtype;
2127 aRet = MEDnatureGrilleLire(myFile->Id(),
2128 &aMeshInfo.myName[0],
2131 EXCEPTION(runtime_error,"GetGrilleInfo - MEDnatureGrilleLire(...)");
2133 type = (EGrilleType)Mtype;
2140 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
2141 TIntVector& theStruct,
2144 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2151 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2153 med_int* anGrilleStruct = aMeshInfo.myDim > 0? (med_int*)&theStruct[0]: NULL;
2155 aRet = MEDstructureCoordLire(myFile->Id(),
2156 &aMeshInfo.myName[0],
2162 EXCEPTION(runtime_error,"GetGrilleInfo - MEDstructureCoordLire(...)");