1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "MED_V2_2_Wrapper.hxx"
24 #include "MED_Algorithm.hxx"
25 #include "MED_Utilities.hxx"
34 static int MYDEBUG = 0;
36 // static int MYDEBUG = 0;
45 GetDESCLength<eV2_2>()
52 GetIDENTLength<eV2_2>()
66 GetLNOMLength<eV2_2>()
73 GetPNOMLength<eV2_2>()
80 GetVersionRelease<eV2_2>(TInt& majeur, TInt& mineur, TInt& release)
84 release=MED_RELEASE_NUM;
89 GetNbConn<eV2_2>(EGeometrieElement typmai,
90 EEntiteMaillage typent,
99 //---------------------------------------------------------------
105 TFile(const std::string& theFileName):
108 myFileName(theFileName)
117 Open(EModeAcces theMode, TErr* theErr = NULL)
120 const char* aFileName = myFileName.c_str();
121 myFid = MEDfileOpen(aFileName,med_access_mode(theMode));
124 *theErr = TErr(myFid);
126 EXCEPTION(std::runtime_error,"TFile - MEDfileOpen('"<<myFileName<<"',"<<theMode<<")");
129 const TIdt& Id() const
132 EXCEPTION(std::runtime_error,"TFile - GetFid() < 0");
145 std::string myFileName;
149 //---------------------------------------------------------------
155 TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL):
158 myFile->Open(theMode,theErr);
168 //---------------------------------------------------------------
169 TVWrapper::TVWrapper(const std::string& theFileName):
170 myFile(new TFile(theFileName))
174 //----------------------------------------------------------------------------
177 ::GetNbMeshes(TErr* theErr)
179 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
181 if(theErr && *theErr < 0)
184 return MEDnMesh(myFile->Id());
188 //----------------------------------------------------------------------------
191 ::GetMeshInfo(TInt theMeshId,
192 MED::TMeshInfo& theInfo,
195 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
197 if(theErr && *theErr < 0)
200 TValueHolder<TString, char> aMeshName(theInfo.myName);
201 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
202 TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
203 TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
204 char dtunit[MED_SNAME_SIZE+1];
205 med_sorting_type sorttype;
208 int naxis=MEDmeshnAxis(myFile->Id(),theMeshId);
209 char *axisname=new char[naxis*MED_SNAME_SIZE+1];
210 char *axisunit=new char[naxis*MED_SNAME_SIZE+1];
211 TErr aRet = MEDmeshInfo(myFile->Id(),
227 EXCEPTION(std::runtime_error,"GetMeshInfo - MEDmeshInfo(...)");
231 //----------------------------------------------------------------------------
234 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
238 TFileWrapper aFileWrapper(myFile,theMode,theErr);
240 if(theErr && *theErr < 0)
243 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
245 TValueHolder<TString, char> aMeshName(anInfo.myName);
246 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
247 TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
248 TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
249 TValueHolder<TString, char> aDesc(anInfo.myDesc);
251 char *nam=new char[aSpaceDim*MED_SNAME_SIZE+1];
252 std::fill(nam,nam+aSpaceDim*MED_SNAME_SIZE+1,'\0');
253 char *unit=new char[aSpaceDim*MED_SNAME_SIZE+1];
254 std::fill(unit,unit+aSpaceDim*MED_SNAME_SIZE+1,'\0');
255 TErr aRet = MEDmeshCr(myFile->Id(),
270 // aRet = MEDunvCr(myFile->Id(),&aMeshName);
272 INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
277 EXCEPTION(std::runtime_error,"SetMeshInfo - MEDmeshCr(...)");
281 //----------------------------------------------------------------------------
284 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
288 SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
291 SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
294 SetMeshInfo(theInfo,eCREATION,&aRet);
301 //----------------------------------------------------------------------------
304 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
307 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
309 if(theErr && *theErr < 0)
312 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
313 TValueHolder<TString, char> aName(anInfo.myName);
314 return MEDnFamily(myFile->Id(),&aName);
318 //----------------------------------------------------------------------------
321 ::GetNbFamAttr(TInt theFamId,
322 const MED::TMeshInfo& theInfo,
325 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
327 if(theErr && *theErr < 0)
330 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
332 TValueHolder<TString, char> aName(anInfo.myName);
334 return MEDnFamily23Attribute(myFile->Id(),&aName,theFamId);
338 //----------------------------------------------------------------------------
341 ::GetNbFamGroup(TInt theFamId,
342 const MED::TMeshInfo& theInfo,
345 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
347 if(theErr && *theErr < 0)
350 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
352 TValueHolder<TString, char> aName(anInfo.myName);
354 return MEDnFamilyGroup(myFile->Id(),&aName,theFamId);
358 //----------------------------------------------------------------------------
361 ::GetFamilyInfo(TInt theFamId,
362 MED::TFamilyInfo& theInfo,
365 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
367 if(theErr && *theErr < 0)
370 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
372 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
373 TValueHolder<TString, char> aFamilyName(theInfo.myName);
374 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
375 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
376 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
377 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
378 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
380 TErr aRet = MEDfamily23Info(myFile->Id(),
393 EXCEPTION(std::runtime_error,"GetFamilyInfo - MEDfamily23Info(...) - "<<
394 " aMeshInfo.myName = '"<<&aMeshName<<
395 "'; theFamId = "<<theFamId<<
396 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
397 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
401 //----------------------------------------------------------------------------
404 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
408 TFileWrapper aFileWrapper(myFile,theMode,theErr);
410 if(theErr && *theErr < 0)
413 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
414 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
416 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
417 TValueHolder<TString, char> aFamilyName(anInfo.myName);
418 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
419 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
420 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
421 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
422 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
423 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
424 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
426 TErr aRet = MEDfamilyCr(myFile->Id(),
433 INITMSG(MYDEBUG,"TVWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
438 EXCEPTION(std::runtime_error,"SetFamilyInfo - MEDfamilyCr(...)");
442 //----------------------------------------------------------------------------
445 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
449 SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
452 SetFamilyInfo(theInfo,eLECTURE_AJOUT,&aRet);
458 //----------------------------------------------------------------------------
461 ::GetNames(TElemInfo& theInfo,
463 EEntiteMaillage theEntity,
464 EGeometrieElement theGeom,
467 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
469 if(theErr && *theErr < 0)
472 if ( theGeom == eBALL )
473 theGeom = GetBallGeom( theInfo.myMeshInfo );
475 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
477 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
478 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
479 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
480 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
482 TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
490 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
496 //----------------------------------------------------------------------------
499 ::GetNumeration(TElemInfo& theInfo,
501 EEntiteMaillage theEntity,
502 EGeometrieElement theGeom,
505 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
507 if(theErr && *theErr < 0)
510 if ( theGeom == eBALL )
511 theGeom = GetBallGeom( theInfo.myMeshInfo );
513 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
515 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
516 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
517 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
518 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
520 TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
528 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
534 //----------------------------------------------------------------------------
537 ::GetFamilies(TElemInfo& theInfo,
539 EEntiteMaillage theEntity,
540 EGeometrieElement theGeom,
543 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
545 if(theErr && *theErr < 0)
548 if ( theGeom == eBALL )
549 theGeom = GetBallGeom( theInfo.myMeshInfo );
551 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
553 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
554 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
555 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
556 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
558 TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
568 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
570 int aSize = (int)theInfo.myFamNum->size();
571 theInfo.myFamNum->clear();
572 theInfo.myFamNum->resize(aSize,0);
576 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
583 //----------------------------------------------------------------------------
586 ::SetNames(const TElemInfo& theInfo,
587 EEntiteMaillage theEntity,
588 EGeometrieElement theGeom,
591 SetNames(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
595 //----------------------------------------------------------------------------
598 ::SetNames(const TElemInfo& theInfo,
600 EEntiteMaillage theEntity,
601 EGeometrieElement theGeom,
604 TFileWrapper aFileWrapper(myFile,theMode,theErr);
606 if(theErr && *theErr < 0)
609 if ( theGeom == eBALL )
610 theGeom = GetBallGeom( theInfo.myMeshInfo );
612 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
613 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
616 if(theInfo.myIsElemNames)
618 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
619 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
620 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
621 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
623 aRet = MEDmeshEntityNameWr(myFile->Id(),
629 (TInt)anInfo.myElemNames->size(),
634 EXCEPTION(std::runtime_error,"SetNames - MEDmeshEntityNameWr(...)");
639 //----------------------------------------------------------------------------
642 ::SetNumeration(const TElemInfo& theInfo,
643 EEntiteMaillage theEntity,
644 EGeometrieElement theGeom,
647 SetNumeration(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
651 //----------------------------------------------------------------------------
654 ::SetNumeration(const TElemInfo& theInfo,
656 EEntiteMaillage theEntity,
657 EGeometrieElement theGeom,
660 TFileWrapper aFileWrapper(myFile,theMode,theErr);
662 if(theErr && *theErr < 0)
665 if ( theGeom == eBALL )
666 theGeom = GetBallGeom( theInfo.myMeshInfo );
668 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
669 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
672 if(theInfo.myIsElemNum)
674 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
675 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
676 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
677 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
679 aRet = MEDmeshEntityNumberWr(myFile->Id(),
685 (TInt)anInfo.myElemNum->size(),
690 EXCEPTION(std::runtime_error,"SetNumeration - MEDmeshEntityNumberWr(...)");
694 //----------------------------------------------------------------------------
697 ::SetFamilies(const TElemInfo& theInfo,
698 EEntiteMaillage theEntity,
699 EGeometrieElement theGeom,
702 SetFamilies(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
705 //----------------------------------------------------------------------------
708 ::SetFamilies(const TElemInfo& theInfo,
710 EEntiteMaillage theEntity,
711 EGeometrieElement theGeom,
714 TFileWrapper aFileWrapper(myFile,theMode,theErr);
716 if(theErr && *theErr < 0)
719 if ( theGeom == eBALL )
720 theGeom = GetBallGeom( theInfo.myMeshInfo );
722 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
723 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
725 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
726 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
727 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
728 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
730 TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
736 (TInt)anInfo.myFamNum->size(),
742 EXCEPTION(std::runtime_error,"SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
745 //----------------------------------------------------------------------------
748 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
752 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
754 if(theErr && *theErr < 0)
757 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
759 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
760 TValueHolder<ETable, med_data_type > aTable(theTable);
762 return MEDmeshnEntity(myFile->Id(),
775 //----------------------------------------------------------------------------
778 ::GetNodeInfo(MED::TNodeInfo& theInfo,
781 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
783 if(theErr && *theErr < 0)
786 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
788 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
789 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
790 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
791 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
792 TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
793 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
794 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
795 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
796 //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
797 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
798 //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
799 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
800 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
802 TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
809 TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
818 // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
820 int mySize = (int)theInfo.myFamNum->size();
821 theInfo.myFamNum->clear();
822 theInfo.myFamNum->resize(mySize,0);
825 // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
828 if ( MEDmeshEntityNameRd(myFile->Id(),
834 &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
836 if ( MEDmeshEntityNumberRd(myFile->Id(),
842 &anElemNum) < 0 ) theInfo.myIsElemNum=eFAUX;
847 EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
851 //----------------------------------------------------------------------------
854 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
858 TFileWrapper aFileWrapper(myFile,theMode,theErr);
860 if(theErr && *theErr < 0)
863 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
864 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
866 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
867 TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
868 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
869 TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
870 TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
871 TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
872 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
873 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
874 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
875 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
876 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
877 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
879 TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
888 MEDmeshEntityFamilyNumberWr(myFile->Id(),
897 MEDmeshEntityNameWr(myFile->Id(),
906 MEDmeshEntityNumberWr(myFile->Id(),
917 EXCEPTION(std::runtime_error,"SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
921 //----------------------------------------------------------------------------
924 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
928 SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
931 SetNodeInfo(theInfo,eLECTURE_AJOUT,&aRet);
938 //-----------------------------------------------------------------
941 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
944 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
946 if(theErr && *theErr < 0)
949 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
951 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
952 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
953 TInt aNbElem = (TInt)theInfo.myElemNum->size();
954 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
955 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
956 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
959 aRet = MEDmeshPolygonRd(myFile->Id(),
971 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolygonRd(...)");
973 if(theInfo.myIsElemNames){
974 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
979 if(theInfo.myIsElemNum){
980 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
985 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
990 //----------------------------------------------------------------------------
993 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
996 SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
999 //----------------------------------------------------------------------------
1002 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1006 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1008 if(theErr && *theErr < 0)
1011 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
1012 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1014 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1015 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1016 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1017 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1018 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1020 TErr aRet = MEDmeshPolygonWr(myFile->Id(),
1027 anInfo.myNbElem + 1,
1034 EXCEPTION(std::runtime_error,"SetPolygoneInfo - MEDmeshPolygonWr(...)");
1036 SetNames(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
1040 SetNumeration(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
1044 SetFamilies(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
1049 //----------------------------------------------------------------------------
1052 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1053 EEntiteMaillage theEntity,
1054 EGeometrieElement theGeom,
1055 EConnectivite theConnMode,
1058 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1061 //----------------------------------------------------------------------------
1064 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1065 EEntiteMaillage theEntity,
1066 EGeometrieElement theGeom,
1067 EConnectivite theConnMode,
1070 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1072 if(theErr && *theErr < 0)
1075 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1077 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1078 med_int aTaille = 0;
1080 aTaille=MEDmeshnEntity(myFile->Id(),
1084 med_entity_type(theEntity),
1087 med_connectivity_mode(theConnMode),
1093 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
1095 return TInt(aTaille);
1098 //-----------------------------------------------------------------
1101 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1104 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1106 if(theErr && *theErr < 0)
1109 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1111 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1112 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1113 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1114 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1115 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1116 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1119 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1132 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1134 if(theInfo.myIsElemNames){
1135 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1140 if(theInfo.myIsElemNum){
1141 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1146 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1151 //----------------------------------------------------------------------------
1154 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1157 SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
1160 //----------------------------------------------------------------------------
1163 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1167 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1169 if(theErr && *theErr < 0)
1172 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1173 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1175 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1176 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1177 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1178 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1179 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1182 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1191 (TInt)anInfo.myFaces->size(),
1198 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1200 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1202 if(theInfo.myIsElemNames){
1203 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1204 aRet = MEDmeshEntityNameWr(myFile->Id(),
1210 (TInt)anInfo.myElemNames->size(),
1215 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1218 if(theInfo.myIsElemNum){
1219 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1220 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1226 (TInt)anInfo.myElemNum->size(),
1231 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1235 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1236 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1242 (TInt)anInfo.myFamNum->size(),
1248 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1251 //----------------------------------------------------------------------------
1254 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1255 EEntiteMaillage theEntity,
1256 EGeometrieElement theGeom,
1257 EConnectivite theConnMode,
1260 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1263 //----------------------------------------------------------------------------
1265 TVWrapper ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1268 EConnectivite theConnMode,
1271 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1273 if(theErr && *theErr < 0)
1274 EXCEPTION(std::runtime_error,"GetPolyedreConnSize - (...)");
1276 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1278 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1279 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1280 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1281 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1284 theNbFaces = MEDmeshnEntity(myFile->Id(),
1295 theConnSize = MEDmeshnEntity(myFile->Id(),
1306 if(theNbFaces < 0 || theConnSize<0)
1307 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
1311 //-----------------------------------------------------------------
1314 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1315 EConnectivite theConnMode,
1320 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1322 if(theErr && *theErr < 0)
1325 if(theMeshInfo.GetType() == eNON_STRUCTURE) {
1326 TInt aNbElem = GetNbNodes(theMeshInfo);
1328 anInfo[eNOEUD][ePOINT1] = aNbElem;
1329 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1330 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1331 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1332 for(; anIter != anIterEnd; anIter++){
1333 const EEntiteMaillage& anEntity = anIter->first;
1334 const TGeomSet& aGeomSet = anIter->second;
1335 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1336 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1337 for(; anIter2 != anIterEnd2; anIter2++){
1338 const EGeometrieElement& aGeom = *anIter2;
1339 aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
1341 if ( anEntity == eSTRUCT_ELEMENT ) {
1342 const TInt nbStructTypes = aNbElem;
1343 for ( TInt structType = 0; structType < nbStructTypes; ++structType ) {
1344 // check type name to keep only "MED_BALL" structured element
1345 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName );
1346 char geotypename[ MED_NAME_SIZE + 1] = "";
1347 med_geometry_type geotype;
1348 MEDmeshEntityInfo( myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1349 med_entity_type(anEntity), structType+1,
1350 geotypename, &geotype);
1351 if ( strcmp( geotypename, MED_BALL_NAME ) == 0 ) {
1352 aNbElem = GetNbCells( theMeshInfo, anEntity, EGeometrieElement(geotype),
1353 theConnMode, theErr);
1355 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1360 anInfo[anEntity][aGeom] = aNbElem;
1366 } else { // eSTRUCTURE
1367 EGrilleType aGrilleType;
1371 TInt aDim = theMeshInfo.GetDim();
1372 EGeometrieElement aGeom, aSubGeom;
1373 EEntiteMaillage aSubEntity = eMAILLE;
1375 GetGrilleType(theMeshInfo, aGrilleType);
1377 TIntVector aStruct(aDim);
1378 if(aGrilleType == eGRILLE_STANDARD)
1380 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1383 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1384 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1385 for(med_int anAxis = 0; anAxis < aDim; anAxis++)
1386 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1388 for(med_int i = 0; i < aDim; i++){
1389 aNbNodes = aNbNodes * aStruct[i];
1390 aNbElem = aNbElem * (aStruct[i] - 1);
1399 aSubEntity = eARETE;
1401 (aStruct[0] ) * (aStruct[1]-1) +
1402 (aStruct[0]-1) * (aStruct[1] );
1409 (aStruct[0] ) * (aStruct[1]-1) * (aStruct[2]-1) +
1410 (aStruct[0]-1) * (aStruct[1] ) * (aStruct[2]-1) +
1411 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2] );
1414 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1415 anInfo[eMAILLE][aGeom] = aNbElem;
1417 anInfo[aSubEntity][aSubGeom] = aNbSub;
1423 //-----------------------------------------------------------------
1426 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1427 EEntiteMaillage theEntity,
1428 EGeometrieElement theGeom,
1429 EConnectivite theConnMode,
1432 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1434 if(theErr && *theErr < 0)
1437 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1438 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1440 if(theGeom!=MED::ePOLYGONE && theGeom!=MED::ePOLYEDRE && theGeom != MED::eBALL)
1442 return MEDmeshnEntity(myFile->Id(),
1446 med_entity_type(theEntity),
1447 med_geometry_type(theGeom),
1449 med_connectivity_mode(theConnMode),
1453 else if(theGeom==MED::ePOLYGONE)
1455 return MEDmeshnEntity(myFile->Id(),&aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(theEntity),
1456 MED_POLYGON,MED_INDEX_NODE,med_connectivity_mode(theConnMode),&chgt,&trsf)-1;
1458 else if ( theGeom==MED::ePOLYEDRE )
1460 return MEDmeshnEntity(myFile->Id(),&aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(theEntity),
1461 MED_POLYHEDRON,MED_INDEX_FACE,med_connectivity_mode(theConnMode),&chgt,&trsf)-1;
1463 else if ( theGeom==MED::eBALL )
1465 return GetNbBalls( theMeshInfo );
1471 //----------------------------------------------------------------------------
1474 ::GetCellInfo(MED::TCellInfo& theInfo,
1477 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1479 if(theErr && *theErr < 0)
1482 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1484 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1485 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
1486 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
1487 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
1488 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
1489 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
1490 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
1491 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
1492 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
1493 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
1494 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1495 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
1498 aRet = MEDmeshElementRd(myFile->Id(),
1517 EXCEPTION(std::runtime_error,"GetCellInfo - MEDmeshElementRd(...)");
1519 if (anIsFamNum == MED_FALSE)
1521 int mySize = (int) theInfo.myFamNum->size();
1522 theInfo.myFamNum->clear();
1523 theInfo.myFamNum->resize(mySize, 0);
1529 //----------------------------------------------------------------------------
1532 ::SetCellInfo(const MED::TCellInfo& theInfo,
1536 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1538 if(theErr && *theErr < 0)
1541 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
1542 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1544 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1545 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
1546 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1547 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1548 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1549 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1550 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1551 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1552 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
1553 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
1554 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1555 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
1556 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1559 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
1571 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1580 MEDmeshEntityNameWr(myFile->Id(),
1589 MEDmeshEntityNumberWr(myFile->Id(),
1600 EXCEPTION(std::runtime_error,"SetCellInfo - MEDmeshElementWr(...)");
1604 //----------------------------------------------------------------------------
1607 ::SetCellInfo(const MED::TCellInfo& theInfo,
1610 SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
1613 //----------------------------------------------------------------------------
1614 //! Read geom type of MED_BALL structural element
1615 EGeometrieElement TVWrapper::GetBallGeom(const TMeshInfo& theMeshInfo)
1617 TFileWrapper aFileWrapper(myFile,eLECTURE);
1619 // read med_geometry_type of "MED_BALL" element
1620 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
1621 return EGeometrieElement( MEDstructElementGeotype( myFile->Id(), geotypename ) );
1624 //----------------------------------------------------------------------------
1625 //! Read number of balls in the Mesh
1626 TInt TVWrapper::GetNbBalls(const TMeshInfo& theMeshInfo)
1628 TFileWrapper aFileWrapper(myFile,eLECTURE);
1630 EGeometrieElement ballType = GetBallGeom( theMeshInfo );
1634 return GetNbCells( theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD );
1637 //----------------------------------------------------------------------------
1638 //! Read a MEDWrapped representation of MED_BALL from the MED file
1639 void TVWrapper::GetBallInfo(TBallInfo& theInfo, TErr* theErr)
1641 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1643 // check geometry of MED_BALL
1644 if ( theInfo.myGeom == eBALL )
1646 theInfo.myGeom = GetBallGeom( *theInfo.myMeshInfo );
1647 if ( theInfo.myGeom < 0 ) {
1649 EXCEPTION(std::runtime_error,"GetBallInfo - no balls in the mesh");
1650 *theErr = theInfo.myGeom;
1656 GetCellInfo( theInfo );
1659 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
1660 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1661 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
1662 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
1664 TErr aRet = MEDmeshStructElementVarAttRd( myFile->Id(), &aMeshName,
1665 MED_NO_DT, MED_NO_IT,
1671 else if ( aRet < 0 )
1672 EXCEPTION(std::runtime_error,"GetBallInfo - pb at reading diameters");
1676 //----------------------------------------------------------------------------
1677 //! Write a MEDWrapped representation of MED_BALL to the MED file
1678 void TVWrapper::SetBallInfo(const TBallInfo& theInfo, EModeAcces theMode, TErr* theErr)
1680 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1683 char ballsupportname[MED_NAME_SIZE+1]="BALL_SUPPORT_MESH";
1684 EGeometrieElement ballGeom = GetBallGeom( *theInfo.myMeshInfo );
1687 // no ball model in the file, create support mesh for it
1688 char dummyname [MED_NAME_SIZE*3+1]="";
1689 if (( ret = MEDsupportMeshCr( myFile->Id(),
1691 theInfo.myMeshInfo->GetSpaceDim(),
1692 theInfo.myMeshInfo->GetDim(),
1693 "Support mesh for a ball model",
1695 /*axisname=*/dummyname, /*unitname=*/dummyname)) < 0) {
1697 EXCEPTION(std::runtime_error,"SetBallInfo - MEDsupportMeshCr");
1701 // write coordinates of 1 node
1702 med_float coord[3] = {0,0,0};
1703 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
1704 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
1705 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
1707 EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshNodeCoordinateWr");
1711 // ball model creation
1712 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
1713 if (( ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
1715 theInfo.myMeshInfo->GetSpaceDim(),
1717 MED_NODE,MED_NONE)) < 0 ) {
1719 EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementCr");
1723 // create diameter attribute
1724 if (( ret = MEDstructElementVarAttCr(myFile->Id(),
1725 geotypename, MED_BALL_DIAMETER,
1726 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
1728 EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementVarAttCr");
1734 TBallInfo& aBallInfo = ((TBallInfo&) theInfo );
1735 aBallInfo.myGeom = ballGeom;
1738 SetCellInfo(theInfo,theMode,theErr);
1739 if ( theErr && theErr < 0 )
1743 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
1744 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
1745 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
1746 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
1747 MED_NO_DT, MED_NO_IT,
1748 aGeom, MED_BALL_DIAMETER,
1749 theInfo.myNbElem, &aDiam);
1753 EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshStructElementVarAttWr");
1756 //----------------------------------------------------------------------------
1757 //! Write a MEDWrapped representation of MED_BALL to the MED file
1758 void TVWrapper::SetBallInfo(const TBallInfo& theInfo, TErr* theErr)
1760 SetBallInfo( theInfo, eLECTURE_ECRITURE, theErr );
1763 //-----------------------------------------------------------------
1766 ::GetNbFields(TErr* theErr)
1768 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1770 if(theErr && *theErr < 0)
1773 return MEDnField(myFile->Id());
1777 //----------------------------------------------------------------------------
1780 ::GetNbComp(TInt theFieldId,
1783 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1785 if(theErr && *theErr < 0)
1788 return MEDfieldnComponent(myFile->Id(),theFieldId);
1792 //----------------------------------------------------------------------------
1795 ::GetFieldInfo(TInt theFieldId,
1796 MED::TFieldInfo& theInfo,
1799 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1801 if(theErr && *theErr < 0)
1804 TString aFieldName(256); // Protect from memory problems with too long names
1805 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
1806 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
1807 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
1808 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
1812 char dtunit[MED_SNAME_SIZE+1];
1813 char local_mesh_name[MED_NAME_SIZE+1]="";
1815 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(),theFieldId);
1816 aRet = MEDfieldInfo(myFile->Id(),
1827 if(strcmp(&aMeshInfo.myName[0],local_mesh_name) != 0 ) {
1833 theInfo.SetName(aFieldName);
1838 EXCEPTION(std::runtime_error,"GetFieldInfo - MEDfieldInfo(...)");
1842 //----------------------------------------------------------------------------
1845 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1849 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1851 if(theErr && *theErr < 0)
1854 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1856 TValueHolder<TString, char> aFieldName(anInfo.myName);
1857 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
1858 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
1859 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
1860 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
1862 char dtunit[MED_SNAME_SIZE+1];
1863 std::fill(dtunit,dtunit+MED_SNAME_SIZE+1,'\0');
1864 aRet = MEDfieldCr(myFile->Id(),
1871 &aMeshInfo.myName[0]);
1875 EXCEPTION(std::runtime_error,"SetFieldInfo - MEDfieldCr(...)");
1879 //----------------------------------------------------------------------------
1882 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1886 SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1889 SetFieldInfo(theInfo,eLECTURE_AJOUT,&aRet);
1896 //----------------------------------------------------------------------------
1899 ::GetNbGauss(TErr* theErr)
1901 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1903 if(theErr && *theErr < 0)
1906 return MEDnLocalization(myFile->Id());
1910 //----------------------------------------------------------------------------
1913 ::GetGaussPreInfo(TInt theId,
1916 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1918 if(theErr && *theErr < 0)
1919 return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 );
1921 med_int aNbGaussPoints = med_int();
1922 TVector<char> aName(GetNOMLength<eV2_2>()+1);
1923 med_geometry_type aGeom = MED_NONE;
1927 char geointerpname[MED_NAME_SIZE+1]="";
1928 char ipointstructmeshname[MED_NAME_SIZE+1]="";
1929 med_int nsectionmeshcell;
1930 med_geometry_type sectiongeotype;
1931 aRet = MEDlocalizationInfo (myFile->Id(),
1938 ipointstructmeshname,
1944 EXCEPTION(std::runtime_error,"GetGaussPreInfo - MEDlocalizationInfo(...)");
1945 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]),
1946 TInt(aNbGaussPoints));
1950 //----------------------------------------------------------------------------
1953 ::GetGaussInfo(TInt theId,
1954 TGaussInfo& theInfo,
1957 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1959 if(theErr && *theErr < 0)
1962 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
1963 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
1964 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
1965 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
1966 TValueHolder<TString, char> aGaussName(theInfo.myName);
1969 aRet = MEDlocalizationRd(myFile->Id(),
1979 EXCEPTION(std::runtime_error,"GetGaussInfo - MEDlocalizationRd(...)");
1983 //----------------------------------------------------------------------------
1986 ::GetNbProfiles(TErr* theErr)
1988 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1990 if(theErr && *theErr < 0)
1993 return MEDnProfile(myFile->Id());
1998 ::GetProfilePreInfo(TInt theId,
2001 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2003 if(theErr && *theErr < 0)
2004 return TProfileInfo::TInfo();
2007 TVector<char> aName(GetNOMLength<eV2_2>()+1);
2010 aRet = MEDprofileInfo(myFile->Id(),
2017 EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofileInfo(...)");
2019 return TProfileInfo::TInfo(&aName[0],aSize);
2024 ::GetProfileInfo(TInt theId,
2025 TProfileInfo& theInfo,
2028 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2030 if(theErr && *theErr < 0)
2033 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
2034 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
2035 TValueHolder<TString, char> aProfileName(anInfo.myName);
2038 aRet = MEDprofileRd(myFile->Id(),
2044 EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofileRd(...)");
2049 ::SetProfileInfo(const TProfileInfo& theInfo,
2053 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2055 if(theErr && *theErr < 0)
2058 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
2059 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
2060 TValueHolder<TString, char> aProfileName(anInfo.myName);
2063 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
2064 &aProfileName, // tableau de valeurs du profil.
2065 theInfo.GetSize(), // taille du profil.
2066 &anElemNum); // nom profil.
2070 EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofileWr(...)");
2075 ::SetProfileInfo(const TProfileInfo& theInfo,
2079 SetProfileInfo(theInfo,eLECTURE_ECRITURE,&aRet);
2082 SetProfileInfo(theInfo,eLECTURE_AJOUT,&aRet);
2085 SetProfileInfo(theInfo,eCREATION,&aRet);
2091 //-----------------------------------------------------------------
2094 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2095 const MED::TEntityInfo& theEntityInfo,
2096 EEntiteMaillage& theEntity,
2097 TGeom2Size& theGeom2Size,
2100 theEntity = EEntiteMaillage(-1);
2101 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2104 if(theEntityInfo.empty())
2108 }else if(theEntityInfo.empty())
2109 EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
2111 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2113 theGeom2Size.clear();
2114 TInt aNbTimeStamps = 0;
2115 TIdt anId = myFile->Id();
2117 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2118 TValueHolder<TString, char> aFieldName(anInfo.myName);
2119 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2121 // workaround for IPAL13676
2122 MED::TEntityInfo localEntityInfo = theEntityInfo;
2123 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2124 if(anLocalIter != localEntityInfo.end()){
2125 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2128 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2129 for(; anIter != localEntityInfo.end(); anIter++){
2130 med_entity_type anEntity = med_entity_type(anIter->first);
2131 const TGeom2Size& aGeom2Size = anIter->second;
2132 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2133 for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
2134 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2135 char aMeshName[MED_NAME_SIZE+1];
2138 char dtunit[MED_SNAME_SIZE+1];
2139 med_int myNbComp = MEDfieldnComponentByName(anId,&aFieldName);
2140 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2141 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2143 MEDfieldInfoByName(anId,
2160 MEDfieldComputingStepInfo(anId,
2166 char profilename[MED_NAME_SIZE+1];
2167 char locname[MED_NAME_SIZE+1];
2171 // protection from crash (division by zero)
2172 // inside MEDfieldnValueWithProfile function
2173 // caused by the workaround for IPAL13676 (see above)
2174 if( anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0 )
2177 nval = MEDfieldnValueWithProfile(anId,
2182 med_geometry_type(aGeom),
2190 bool anIsSatisfied =(nval > 0);
2193 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2194 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2195 if(anIsPerformAdditionalCheck){
2196 anIsSatisfied = !strcmp(&aMeshName[0],&aMeshInfo.myName[0]);
2199 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2200 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2205 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2206 theEntity = EEntiteMaillage(anEntity);
2207 aNbTimeStamps = aNbStamps;
2210 if(!theGeom2Size.empty())
2213 return aNbTimeStamps;
2217 //----------------------------------------------------------------------------
2220 ::GetTimeStampInfo(TInt theTimeStampId,
2221 MED::TTimeStampInfo& theInfo,
2224 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2226 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2229 if(aGeom2Size.empty())
2233 }else if(aGeom2Size.empty())
2234 EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell");
2236 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2237 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2239 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2240 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2241 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2242 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2243 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2244 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2245 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2246 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2247 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2249 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2251 // just to get a time stamp unit (anUnitDt)
2252 med_field_type aFieldType;
2253 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2254 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2255 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2257 MEDfieldInfoByName(myFile->Id(),
2266 delete [] aCompName;
2267 delete [] aCompUnit;
2269 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2270 for(; anIter != aGeom2Size.end(); anIter++){
2271 const EGeometrieElement& aGeom = anIter->first;
2272 med_int aNbGauss = -1;
2275 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2281 char profilename[MED_NAME_SIZE+1];
2283 char locname[MED_NAME_SIZE+1];
2284 MEDfieldnValueWithProfile(myFile->Id(),
2289 med_geometry_type(aGeom),
2297 static TInt MAX_NB_GAUSS_POINTS = 32;
2298 if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
2301 aGeom2NbGauss[aGeom] = aNbGauss;
2306 EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
2311 //----------------------------------------------------------------------------
2314 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2315 const TMKey2Profile& theMKey2Profile,
2316 const TKey2Gauss& theKey2Gauss,
2319 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2321 if(theErr && *theErr < 0)
2324 TIdt anId = myFile->Id();
2326 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
2327 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2329 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2330 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
2331 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2332 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2334 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2335 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2336 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
2338 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2339 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2341 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2342 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
2344 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
2345 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
2346 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
2348 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
2349 TGeom2Size::iterator anIter = aGeom2Size.begin();
2350 for(; anIter != aGeom2Size.end(); anIter++){
2351 EGeometrieElement aGeom = anIter->first;
2352 TInt aNbElem = anIter->second;
2353 med_int profilesize,aNbGauss;
2355 TInt aNbVal = MEDfieldnValueWithProfile(anId,
2360 med_geometry_type(aGeom),
2373 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
2376 TInt aNbComp = aFieldInfo->myNbComp;
2377 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
2378 theTimeStampValue->AllocateValue(aGeom,
2382 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
2385 "TVWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
2386 "; aNbVal = "<<aNbVal<<
2387 "; aNbValue = "<<aNbValue<<
2388 "; aNbGauss = "<<aNbGauss<<
2389 "; aNbComp = "<<aNbComp<<
2392 TErr aRet = MEDfieldValueWithProfileRd(anId,
2397 med_geometry_type(aGeom),
2401 MED_ALL_CONSTITUENT,
2402 theTimeStampValue->GetValuePtr(aGeom));
2405 *theErr = MED_FALSE;
2408 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
2411 MED::PGaussInfo aGaussInfo;
2412 TGaussInfo::TKey aKey(aGeom,&aGaussName[0]);
2413 if(strcmp(&aGaussName[0],"") != 0){
2414 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
2415 if(anIter != theKey2Gauss.end()){
2416 aGaussInfo = anIter->second;
2417 aGeom2Gauss[aGeom] = aGaussInfo;
2421 MED::PProfileInfo aProfileInfo;
2422 if(strcmp(&aProfileName[0],MED_NO_PROFILE) != 0){
2423 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
2424 if(anIter != aKey2Profile.end()){
2425 aProfileInfo = anIter->second;
2426 aGeom2Profile[aGeom] = aProfileInfo;
2430 if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){
2432 *theErr = MED_FALSE;
2435 EXCEPTION(std::runtime_error,"GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
2438 if(aProfileInfo && aProfileInfo->IsPresent()){
2439 TInt aNbSubElem = aProfileInfo->GetSize();
2440 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
2441 if(aProfileSize != aValueSize){
2446 EXCEPTION(std::runtime_error,
2447 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
2448 ") != aValueSize("<<aValueSize<<
2449 "); aNbVal = "<<aNbVal<<
2450 "; anEntity = "<<anEntity<<
2451 "; aGeom = "<<aGeom<<
2452 "; aNbElem = "<<aNbElem<<
2453 "; aNbSubElem = "<<aNbSubElem<<
2454 "; aNbComp = "<<aNbComp<<
2455 "; aNbGauss = "<<aNbGauss<<
2459 if((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)){
2464 EXCEPTION(std::runtime_error,
2465 "GetTimeStampValue - aNbElem("<<aNbElem<<
2466 ") != aNbValue("<<aNbValue<<
2467 "); aNbVal = "<<aNbVal<<
2468 "; anEntity = "<<anEntity<<
2469 "; aGeom = "<<aGeom<<
2470 "; aNbElem = "<<aNbElem<<
2471 "; aNbComp = "<<aNbComp<<
2472 "; aNbGauss = "<<aNbGauss<<
2480 //----------------------------------------------------------------------------
2483 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
2487 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2489 if(theErr && *theErr < 0)
2493 TIdt anId = myFile->Id();
2495 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
2496 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2498 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2499 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
2500 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2501 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2502 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
2503 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
2504 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2506 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2507 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2509 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2510 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2512 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
2513 TGeomSet::const_iterator anIter = aGeomSet.begin();
2514 for(; anIter != aGeomSet.end(); anIter++){
2515 EGeometrieElement aGeom = *anIter;
2517 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
2518 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
2519 if(aGaussIter != aGeom2Gauss.end()){
2520 MED::PGaussInfo aGaussInfo = aGaussIter->second;
2521 strcpy(&aGaussName[0],&aGaussInfo->myName[0]);
2524 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
2525 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
2526 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
2527 if(aProfileIter != aGeom2Profile.end()){
2528 MED::PProfileInfo aProfileInfo = aProfileIter->second;
2529 aProfileMode = med_storage_mode(aProfileInfo->myMode);
2530 strcpy(&aProfileName[0],&aProfileInfo->myName[0]);
2533 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
2535 aRet = MEDfieldValueWithProfileWr(anId,
2541 med_geometry_type(aGeom),
2546 MED_ALL_CONSTITUENT,
2548 theTimeStampValue->GetValuePtr(aGeom));
2551 *theErr = MED_FALSE;
2554 EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
2559 INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
2563 //----------------------------------------------------------------------------
2566 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2570 SetTimeStampValue(theTimeStampValue,eLECTURE_ECRITURE,&aRet);
2573 SetTimeStampValue(theTimeStampValue,eLECTURE_AJOUT,&aRet);
2579 //----------------------------------------------------------------------------
2582 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2585 SetGrilleInfo(theInfo,eLECTURE_ECRITURE,theErr);
2588 //----------------------------------------------------------------------------
2591 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2595 if(theInfo.myMeshInfo->myType != eSTRUCTURE)
2597 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2599 if(theErr && *theErr < 0)
2602 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
2604 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2605 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2607 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
2610 aRet = MEDmeshGridTypeRd(myFile->Id(),
2616 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridTypeRd(...)");
2618 if(anInfo.myGrilleType == eGRILLE_STANDARD){
2619 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
2620 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
2621 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
2622 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
2623 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
2624 //med_axis_type aRepere = MED_CARTESIAN;
2626 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
2636 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
2638 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
2639 aRet = MEDmeshGridStructWr(myFile->Id(),
2646 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridStructWr(...)");
2649 for(med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++){
2650 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
2656 anInfo.GetIndexes(aAxis).size(),
2657 &anInfo.GetIndexes(aAxis)[0]);
2660 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
2668 //----------------------------------------------------------------------------
2671 ::GetGrilleInfo(TGrilleInfo& theInfo,
2674 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2676 if(theErr && *theErr < 0)
2679 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2680 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2681 EMaillage aMaillageType = aMeshInfo.myType;
2683 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
2684 EGrilleType aGrilleType = theInfo.myGrilleType;
2687 if(aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
2688 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
2690 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
2691 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2692 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
2693 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
2694 //med_axis_type aRepere;
2696 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
2706 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
2708 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
2709 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
2711 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2721 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
2723 int mySize = (int)theInfo.myFamNumNode.size();
2724 theInfo.myFamNumNode.clear();
2725 theInfo.myFamNumNode.resize(mySize,0);
2729 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
2734 //============================
2737 if(aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD){
2739 for(med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++){
2742 aTable = eCOOR_IND1;
2745 aTable = eCOOR_IND2;
2748 aTable = eCOOR_IND3;
2757 EXCEPTION(std::runtime_error,"GetGrilleInfo - anAxis number out of range(...)");
2759 TInt aNbIndexes = GetNbNodes(aMeshInfo,aTable);
2761 EXCEPTION(std::runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
2763 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
2764 //TValueHolder<ETable, med_data_type > table(aTable);
2765 //char aCompNames[MED_SNAME_SIZE+1];
2766 //char anUnitNames[MED_SNAME_SIZE+1];
2767 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),&aMeshName,
2768 MED_NO_DT,MED_NO_IT,
2772 //theInfo.SetCoordName(anAxis-1, aCompNames);
2773 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
2774 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
2779 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)");
2783 EGeometrieElement aGeom = theInfo.GetGeom();
2784 EEntiteMaillage aEntity = theInfo.GetEntity();
2785 TInt aNbCells = theInfo.GetNbCells();
2787 theInfo.myFamNum.resize(aNbCells);
2788 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
2790 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2791 &aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(aEntity),
2792 med_geometry_type(aGeom),&aFamNum);
2794 if ( aMeshInfo.myDim == 3 )
2796 aGeom = theInfo.GetSubGeom();
2797 aEntity = theInfo.GetSubEntity();
2798 aNbCells = theInfo.GetNbSubCells();
2800 theInfo.myFamSubNum.resize(aNbCells,0);
2801 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
2803 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2804 &aMeshName,MED_NO_DT,MED_NO_IT,
2805 med_entity_type(aEntity),
2806 med_geometry_type(aGeom),&aFamNum);
2810 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
2812 int mySize = (int)theInfo.myFamNumNode.size();
2813 theInfo.myFamNumNode.clear();
2814 theInfo.myFamNumNode.resize(mySize,0);
2818 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
2826 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
2827 EGrilleType& theGridType,
2830 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2832 if(theErr && *theErr < 0)
2833 EXCEPTION(std::runtime_error," GetGrilleType - aFileWrapper (...)");
2835 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2837 if(aMeshInfo.myType == eSTRUCTURE){
2838 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2839 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
2840 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
2845 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridTypeRd(...)");
2851 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
2852 TIntVector& theStruct,
2855 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2857 if(theErr && *theErr < 0)
2861 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2863 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2864 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
2866 aRet = MEDmeshGridStructRd(myFile->Id(),
2874 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridStructRd(...)");