1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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"
31 static int MYDEBUG = 0;
33 // static int MYDEBUG = 0;
42 GetDESCLength<eV2_2>()
49 GetIDENTLength<eV2_2>()
63 GetLNOMLength<eV2_2>()
70 GetPNOMLength<eV2_2>()
77 GetVersionRelease<eV2_2>(TInt& majeur, TInt& mineur, TInt& release)
81 release=MED_RELEASE_NUM;
86 GetNbConn<eV2_2>(EGeometrieElement typmai,
87 EEntiteMaillage typent,
96 //---------------------------------------------------------------
102 TFile(const std::string& theFileName):
105 myFileName(theFileName)
114 Open(EModeAcces theMode, TErr* theErr = NULL)
117 const char* aFileName = myFileName.c_str();
118 myFid = MEDfileOpen(aFileName,med_access_mode(theMode));
121 *theErr = TErr(myFid);
123 EXCEPTION(std::runtime_error,"TFile - MEDfileOpen('"<<myFileName<<"',"<<theMode<<")");
126 const TIdt& Id() const
129 EXCEPTION(std::runtime_error,"TFile - GetFid() < 0");
142 std::string myFileName;
146 //---------------------------------------------------------------
152 TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL):
155 myFile->Open(theMode,theErr);
165 //---------------------------------------------------------------
166 TVWrapper::TVWrapper(const std::string& theFileName):
167 myFile(new TFile(theFileName))
171 //----------------------------------------------------------------------------
174 ::GetNbMeshes(TErr* theErr)
176 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
178 if(theErr && *theErr < 0)
181 return MEDnMesh(myFile->Id());
185 //----------------------------------------------------------------------------
188 ::GetMeshInfo(TInt theMeshId,
189 MED::TMeshInfo& theInfo,
192 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
194 if(theErr && *theErr < 0)
197 TValueHolder<TString, char> aMeshName(theInfo.myName);
198 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
199 TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
200 TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
201 char dtunit[MED_SNAME_SIZE+1];
202 med_sorting_type sorttype;
205 int naxis=MEDmeshnAxis(myFile->Id(),theMeshId);
206 char *axisname=new char[naxis*MED_SNAME_SIZE+1];
207 char *axisunit=new char[naxis*MED_SNAME_SIZE+1];
208 TErr aRet = MEDmeshInfo(myFile->Id(),
224 EXCEPTION(std::runtime_error,"GetMeshInfo - MEDmeshInfo(...)");
228 //----------------------------------------------------------------------------
231 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
235 TFileWrapper aFileWrapper(myFile,theMode,theErr);
237 if(theErr && *theErr < 0)
240 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
242 TValueHolder<TString, char> aMeshName(anInfo.myName);
243 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
244 TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
245 TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
246 TValueHolder<TString, char> aDesc(anInfo.myDesc);
248 char *nam=new char[aSpaceDim*MED_SNAME_SIZE+1];
249 std::fill(nam,nam+aSpaceDim*MED_SNAME_SIZE+1,'\0');
250 char *unit=new char[aSpaceDim*MED_SNAME_SIZE+1];
251 std::fill(unit,unit+aSpaceDim*MED_SNAME_SIZE+1,'\0');
252 TErr aRet = MEDmeshCr(myFile->Id(),
267 // aRet = MEDunvCr(myFile->Id(),&aMeshName);
269 INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
274 EXCEPTION(std::runtime_error,"SetMeshInfo - MEDmeshCr(...)");
278 //----------------------------------------------------------------------------
281 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
285 SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
288 SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
291 SetMeshInfo(theInfo,eCREATION,&aRet);
298 //----------------------------------------------------------------------------
301 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
304 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
306 if(theErr && *theErr < 0)
309 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
310 TValueHolder<TString, char> aName(anInfo.myName);
311 return MEDnFamily(myFile->Id(),&aName);
315 //----------------------------------------------------------------------------
318 ::GetNbFamAttr(TInt theFamId,
319 const MED::TMeshInfo& theInfo,
322 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
324 if(theErr && *theErr < 0)
327 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
329 TValueHolder<TString, char> aName(anInfo.myName);
331 return MEDnFamily23Attribute(myFile->Id(),&aName,theFamId);
335 //----------------------------------------------------------------------------
338 ::GetNbFamGroup(TInt theFamId,
339 const MED::TMeshInfo& theInfo,
342 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
344 if(theErr && *theErr < 0)
347 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
349 TValueHolder<TString, char> aName(anInfo.myName);
351 return MEDnFamilyGroup(myFile->Id(),&aName,theFamId);
355 //----------------------------------------------------------------------------
358 ::GetFamilyInfo(TInt theFamId,
359 MED::TFamilyInfo& theInfo,
362 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
364 if(theErr && *theErr < 0)
367 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
369 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
370 TValueHolder<TString, char> aFamilyName(theInfo.myName);
371 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
372 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
373 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
374 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
375 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
377 TErr aRet = MEDfamily23Info(myFile->Id(),
390 EXCEPTION(std::runtime_error,"GetFamilyInfo - MEDfamily23Info(...) - "<<
391 " aMeshInfo.myName = '"<<&aMeshName<<
392 "'; theFamId = "<<theFamId<<
393 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
394 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
398 //----------------------------------------------------------------------------
401 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
405 TFileWrapper aFileWrapper(myFile,theMode,theErr);
407 if(theErr && *theErr < 0)
410 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
411 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
413 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
414 TValueHolder<TString, char> aFamilyName(anInfo.myName);
415 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
416 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
417 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
418 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
419 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
420 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
421 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
423 TErr aRet = MEDfamilyCr(myFile->Id(),
430 INITMSG(MYDEBUG,"TVWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
435 EXCEPTION(std::runtime_error,"SetFamilyInfo - MEDfamilyCr(...)");
439 //----------------------------------------------------------------------------
442 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
446 SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
449 SetFamilyInfo(theInfo,eLECTURE_AJOUT,&aRet);
455 //----------------------------------------------------------------------------
458 ::GetNames(TElemInfo& theInfo,
460 EEntiteMaillage theEntity,
461 EGeometrieElement theGeom,
464 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
466 if(theErr && *theErr < 0)
469 if ( theGeom == eBALL )
470 theGeom = GetBallGeom( theInfo.myMeshInfo );
472 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
474 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
475 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
476 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
477 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
479 TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
487 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
493 //----------------------------------------------------------------------------
496 ::GetNumeration(TElemInfo& theInfo,
498 EEntiteMaillage theEntity,
499 EGeometrieElement theGeom,
502 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
504 if(theErr && *theErr < 0)
507 if ( theGeom == eBALL )
508 theGeom = GetBallGeom( theInfo.myMeshInfo );
510 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
512 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
513 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
514 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
515 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
517 TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
525 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
531 //----------------------------------------------------------------------------
534 ::GetFamilies(TElemInfo& theInfo,
536 EEntiteMaillage theEntity,
537 EGeometrieElement theGeom,
540 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
542 if(theErr && *theErr < 0)
545 if ( theGeom == eBALL )
546 theGeom = GetBallGeom( theInfo.myMeshInfo );
548 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
550 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
551 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
552 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
553 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
555 TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
565 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
567 int aSize = (int)theInfo.myFamNum->size();
568 theInfo.myFamNum->clear();
569 theInfo.myFamNum->resize(aSize,0);
573 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
580 //----------------------------------------------------------------------------
583 ::SetNames(const TElemInfo& theInfo,
584 EEntiteMaillage theEntity,
585 EGeometrieElement theGeom,
588 SetNames(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
592 //----------------------------------------------------------------------------
595 ::SetNames(const TElemInfo& theInfo,
597 EEntiteMaillage theEntity,
598 EGeometrieElement theGeom,
601 TFileWrapper aFileWrapper(myFile,theMode,theErr);
603 if(theErr && *theErr < 0)
606 if ( theGeom == eBALL )
607 theGeom = GetBallGeom( theInfo.myMeshInfo );
609 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
610 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
613 if(theInfo.myIsElemNames)
615 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
616 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
617 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
618 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
620 aRet = MEDmeshEntityNameWr(myFile->Id(),
626 (TInt)anInfo.myElemNames->size(),
631 EXCEPTION(std::runtime_error,"SetNames - MEDmeshEntityNameWr(...)");
636 //----------------------------------------------------------------------------
639 ::SetNumeration(const TElemInfo& theInfo,
640 EEntiteMaillage theEntity,
641 EGeometrieElement theGeom,
644 SetNumeration(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
648 //----------------------------------------------------------------------------
651 ::SetNumeration(const TElemInfo& theInfo,
653 EEntiteMaillage theEntity,
654 EGeometrieElement theGeom,
657 TFileWrapper aFileWrapper(myFile,theMode,theErr);
659 if(theErr && *theErr < 0)
662 if ( theGeom == eBALL )
663 theGeom = GetBallGeom( theInfo.myMeshInfo );
665 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
666 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
669 if(theInfo.myIsElemNum)
671 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
672 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
673 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
674 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
676 aRet = MEDmeshEntityNumberWr(myFile->Id(),
682 (TInt)anInfo.myElemNum->size(),
687 EXCEPTION(std::runtime_error,"SetNumeration - MEDmeshEntityNumberWr(...)");
691 //----------------------------------------------------------------------------
694 ::SetFamilies(const TElemInfo& theInfo,
695 EEntiteMaillage theEntity,
696 EGeometrieElement theGeom,
699 SetFamilies(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
702 //----------------------------------------------------------------------------
705 ::SetFamilies(const TElemInfo& theInfo,
707 EEntiteMaillage theEntity,
708 EGeometrieElement theGeom,
711 TFileWrapper aFileWrapper(myFile,theMode,theErr);
713 if(theErr && *theErr < 0)
716 if ( theGeom == eBALL )
717 theGeom = GetBallGeom( theInfo.myMeshInfo );
719 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
720 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
722 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
723 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
724 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
725 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
727 TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
733 (TInt)anInfo.myFamNum->size(),
739 EXCEPTION(std::runtime_error,"SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
742 //----------------------------------------------------------------------------
745 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
749 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
751 if(theErr && *theErr < 0)
754 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
756 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
757 TValueHolder<ETable, med_data_type > aTable(theTable);
759 return MEDmeshnEntity(myFile->Id(),
772 //----------------------------------------------------------------------------
775 ::GetNodeInfo(MED::TNodeInfo& theInfo,
778 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
780 if(theErr && *theErr < 0)
783 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
785 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
786 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
787 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
788 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
789 TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
790 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
791 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
792 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
793 //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
794 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
795 //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
796 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
797 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
799 TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
806 TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
815 // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
817 int mySize = (int)theInfo.myFamNum->size();
818 theInfo.myFamNum->clear();
819 theInfo.myFamNum->resize(mySize,0);
822 // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
825 if ( MEDmeshEntityNameRd(myFile->Id(),
831 &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
833 if ( MEDmeshEntityNumberRd(myFile->Id(),
839 &anElemNum) < 0 ) theInfo.myIsElemNum=eFAUX;
844 EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
848 //----------------------------------------------------------------------------
851 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
855 TFileWrapper aFileWrapper(myFile,theMode,theErr);
857 if(theErr && *theErr < 0)
860 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
861 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
863 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
864 TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
865 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
866 TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
867 TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
868 TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
869 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
870 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
871 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
872 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
873 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
874 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
876 TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
885 MEDmeshEntityFamilyNumberWr(myFile->Id(),
894 MEDmeshEntityNameWr(myFile->Id(),
903 MEDmeshEntityNumberWr(myFile->Id(),
914 EXCEPTION(std::runtime_error,"SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
918 //----------------------------------------------------------------------------
921 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
925 SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
928 SetNodeInfo(theInfo,eLECTURE_AJOUT,&aRet);
935 //-----------------------------------------------------------------
938 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
941 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
943 if(theErr && *theErr < 0)
946 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
948 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
949 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
950 TInt aNbElem = (TInt)theInfo.myElemNum->size();
951 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
952 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
953 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
956 aRet = MEDmeshPolygonRd(myFile->Id(),
968 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolygonRd(...)");
970 if(theInfo.myIsElemNames){
971 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
976 if(theInfo.myIsElemNum){
977 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
982 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
987 //----------------------------------------------------------------------------
990 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
993 SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
996 //----------------------------------------------------------------------------
999 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1003 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1005 if(theErr && *theErr < 0)
1008 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
1009 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1011 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1012 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1013 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1014 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1015 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1017 TErr aRet = MEDmeshPolygonWr(myFile->Id(),
1024 anInfo.myNbElem + 1,
1031 EXCEPTION(std::runtime_error,"SetPolygoneInfo - MEDmeshPolygonWr(...)");
1033 SetNames(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
1037 SetNumeration(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
1041 SetFamilies(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
1046 //----------------------------------------------------------------------------
1049 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1050 EEntiteMaillage theEntity,
1051 EGeometrieElement theGeom,
1052 EConnectivite theConnMode,
1055 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1058 //----------------------------------------------------------------------------
1061 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1062 EEntiteMaillage theEntity,
1063 EGeometrieElement theGeom,
1064 EConnectivite theConnMode,
1067 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1069 if(theErr && *theErr < 0)
1072 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1074 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1075 med_int aTaille = 0;
1077 aTaille=MEDmeshnEntity(myFile->Id(),
1081 med_entity_type(theEntity),
1084 med_connectivity_mode(theConnMode),
1090 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
1092 return TInt(aTaille);
1095 //-----------------------------------------------------------------
1098 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1101 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1103 if(theErr && *theErr < 0)
1106 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1108 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1109 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1110 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1111 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1112 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1113 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1116 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1129 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1131 if(theInfo.myIsElemNames){
1132 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1137 if(theInfo.myIsElemNum){
1138 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1143 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1148 //----------------------------------------------------------------------------
1151 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1154 SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
1157 //----------------------------------------------------------------------------
1160 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1164 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1166 if(theErr && *theErr < 0)
1169 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1170 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1172 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1173 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1174 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1175 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1176 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1179 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1188 (TInt)anInfo.myFaces->size(),
1195 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1197 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1199 if(theInfo.myIsElemNames){
1200 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1201 aRet = MEDmeshEntityNameWr(myFile->Id(),
1207 (TInt)anInfo.myElemNames->size(),
1212 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1215 if(theInfo.myIsElemNum){
1216 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1217 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1223 (TInt)anInfo.myElemNum->size(),
1228 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1232 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1233 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1239 (TInt)anInfo.myFamNum->size(),
1245 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1248 //----------------------------------------------------------------------------
1251 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1252 EEntiteMaillage theEntity,
1253 EGeometrieElement theGeom,
1254 EConnectivite theConnMode,
1257 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1260 //----------------------------------------------------------------------------
1262 TVWrapper ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1265 EConnectivite theConnMode,
1268 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1270 if(theErr && *theErr < 0)
1271 EXCEPTION(std::runtime_error,"GetPolyedreConnSize - (...)");
1273 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1275 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1276 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1277 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1278 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1281 theNbFaces = MEDmeshnEntity(myFile->Id(),
1292 theConnSize = MEDmeshnEntity(myFile->Id(),
1303 if(theNbFaces < 0 || theConnSize<0)
1304 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
1308 //-----------------------------------------------------------------
1311 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1312 EConnectivite theConnMode,
1317 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1319 if(theErr && *theErr < 0)
1322 if(theMeshInfo.GetType() == eNON_STRUCTURE) {
1323 TInt aNbElem = GetNbNodes(theMeshInfo);
1325 anInfo[eNOEUD][ePOINT1] = aNbElem;
1326 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1327 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1328 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1329 for(; anIter != anIterEnd; anIter++){
1330 const EEntiteMaillage& anEntity = anIter->first;
1331 const TGeomSet& aGeomSet = anIter->second;
1332 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1333 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1334 for(; anIter2 != anIterEnd2; anIter2++){
1335 const EGeometrieElement& aGeom = *anIter2;
1336 aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
1338 if ( anEntity == eSTRUCT_ELEMENT ) {
1339 const TInt nbStructTypes = aNbElem;
1340 for ( TInt structType = 0; structType < nbStructTypes; ++structType ) {
1341 // check type name to keep only "MED_BALL" structured element
1342 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName );
1343 char geotypename[ MED_NAME_SIZE + 1] = "";
1344 med_geometry_type geotype;
1345 MEDmeshEntityInfo( myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1346 med_entity_type(anEntity), structType+1,
1347 geotypename, &geotype);
1348 if ( strcmp( geotypename, MED_BALL_NAME ) == 0 ) {
1349 aNbElem = GetNbCells( theMeshInfo, anEntity, EGeometrieElement(geotype),
1350 theConnMode, theErr);
1352 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1357 anInfo[anEntity][aGeom] = aNbElem;
1363 } else { // eSTRUCTURE
1364 EGrilleType aGrilleType;
1368 TInt aDim = theMeshInfo.GetDim();
1369 EGeometrieElement aGeom, aSubGeom;
1370 EEntiteMaillage aSubEntity = eMAILLE;
1372 GetGrilleType(theMeshInfo, aGrilleType);
1374 TIntVector aStruct(aDim);
1375 if(aGrilleType == eGRILLE_STANDARD)
1377 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1380 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1381 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1382 for(med_int anAxis = 0; anAxis < aDim; anAxis++)
1383 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1385 for(med_int i = 0; i < aDim; i++){
1386 aNbNodes = aNbNodes * aStruct[i];
1387 aNbElem = aNbElem * (aStruct[i] - 1);
1396 aSubEntity = eARETE;
1398 (aStruct[0] ) * (aStruct[1]-1) +
1399 (aStruct[0]-1) * (aStruct[1] );
1406 (aStruct[0] ) * (aStruct[1]-1) * (aStruct[2]-1) +
1407 (aStruct[0]-1) * (aStruct[1] ) * (aStruct[2]-1) +
1408 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2] );
1411 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1412 anInfo[eMAILLE][aGeom] = aNbElem;
1414 anInfo[aSubEntity][aSubGeom] = aNbSub;
1420 //-----------------------------------------------------------------
1423 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1424 EEntiteMaillage theEntity,
1425 EGeometrieElement theGeom,
1426 EConnectivite theConnMode,
1429 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1431 if(theErr && *theErr < 0)
1434 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1435 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1437 if(theGeom!=MED::ePOLYGONE && theGeom!=MED::ePOLYEDRE && theGeom != MED::eBALL)
1439 return MEDmeshnEntity(myFile->Id(),
1443 med_entity_type(theEntity),
1444 med_geometry_type(theGeom),
1446 med_connectivity_mode(theConnMode),
1450 else if(theGeom==MED::ePOLYGONE)
1452 return MEDmeshnEntity(myFile->Id(),&aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(theEntity),
1453 MED_POLYGON,MED_INDEX_NODE,med_connectivity_mode(theConnMode),&chgt,&trsf)-1;
1455 else if ( theGeom==MED::ePOLYEDRE )
1457 return MEDmeshnEntity(myFile->Id(),&aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(theEntity),
1458 MED_POLYHEDRON,MED_INDEX_FACE,med_connectivity_mode(theConnMode),&chgt,&trsf)-1;
1460 else if ( theGeom==MED::eBALL )
1462 return GetNbBalls( theMeshInfo );
1468 //----------------------------------------------------------------------------
1471 ::GetCellInfo(MED::TCellInfo& theInfo,
1474 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1476 if(theErr && *theErr < 0)
1479 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1481 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1482 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
1483 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
1484 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
1485 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
1486 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
1487 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
1488 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
1489 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
1490 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
1491 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1492 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
1495 aRet = MEDmeshElementRd(myFile->Id(),
1514 EXCEPTION(std::runtime_error,"GetCellInfo - MEDmeshElementRd(...)");
1516 if (anIsFamNum == MED_FALSE)
1518 int mySize = (int) theInfo.myFamNum->size();
1519 theInfo.myFamNum->clear();
1520 theInfo.myFamNum->resize(mySize, 0);
1526 //----------------------------------------------------------------------------
1529 ::SetCellInfo(const MED::TCellInfo& theInfo,
1533 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1535 if(theErr && *theErr < 0)
1538 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
1539 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1541 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1542 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
1543 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1544 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1545 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1546 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1547 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1548 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1549 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
1550 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
1551 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1552 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
1553 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1556 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
1568 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1577 MEDmeshEntityNameWr(myFile->Id(),
1586 MEDmeshEntityNumberWr(myFile->Id(),
1597 EXCEPTION(std::runtime_error,"SetCellInfo - MEDmeshElementWr(...)");
1601 //----------------------------------------------------------------------------
1604 ::SetCellInfo(const MED::TCellInfo& theInfo,
1607 SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
1610 //----------------------------------------------------------------------------
1611 //! Read geom type of MED_BALL structural element
1612 EGeometrieElement TVWrapper::GetBallGeom(const TMeshInfo& theMeshInfo)
1614 TFileWrapper aFileWrapper(myFile,eLECTURE);
1616 // read med_geometry_type of "MED_BALL" element
1617 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
1618 return EGeometrieElement( MEDstructElementGeotype( myFile->Id(), geotypename ) );
1621 //----------------------------------------------------------------------------
1622 //! Read number of balls in the Mesh
1623 TInt TVWrapper::GetNbBalls(const TMeshInfo& theMeshInfo)
1625 TFileWrapper aFileWrapper(myFile,eLECTURE);
1627 EGeometrieElement ballType = GetBallGeom( theMeshInfo );
1631 return GetNbCells( theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD );
1634 //----------------------------------------------------------------------------
1635 //! Read a MEDWrapped representation of MED_BALL from the MED file
1636 void TVWrapper::GetBallInfo(TBallInfo& theInfo, TErr* theErr)
1638 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1640 // check geometry of MED_BALL
1641 if ( theInfo.myGeom == eBALL )
1643 theInfo.myGeom = GetBallGeom( *theInfo.myMeshInfo );
1644 if ( theInfo.myGeom < 0 ) {
1646 EXCEPTION(std::runtime_error,"GetBallInfo - no balls in the mesh");
1647 *theErr = theInfo.myGeom;
1653 GetCellInfo( theInfo );
1656 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
1657 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1658 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
1659 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
1661 TErr aRet = MEDmeshStructElementVarAttRd( myFile->Id(), &aMeshName,
1662 MED_NO_DT, MED_NO_IT,
1668 else if ( aRet < 0 )
1669 EXCEPTION(std::runtime_error,"GetBallInfo - pb at reading diameters");
1673 //----------------------------------------------------------------------------
1674 //! Write a MEDWrapped representation of MED_BALL to the MED file
1675 void TVWrapper::SetBallInfo(const TBallInfo& theInfo, EModeAcces theMode, TErr* theErr)
1677 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1680 char ballsupportname[MED_NAME_SIZE+1]="BALL_SUPPORT_MESH";
1681 EGeometrieElement ballGeom = GetBallGeom( *theInfo.myMeshInfo );
1684 // no ball model in the file, create support mesh for it
1685 char dummyname [MED_NAME_SIZE*3+1]="";
1686 if (( ret = MEDsupportMeshCr( myFile->Id(),
1688 theInfo.myMeshInfo->GetSpaceDim(),
1689 theInfo.myMeshInfo->GetDim(),
1690 "Support mesh for a ball model",
1692 /*axisname=*/dummyname, /*unitname=*/dummyname)) < 0) {
1694 EXCEPTION(std::runtime_error,"SetBallInfo - MEDsupportMeshCr");
1698 // write coordinates of 1 node
1699 med_float coord[3] = {0,0,0};
1700 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
1701 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
1702 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
1704 EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshNodeCoordinateWr");
1708 // ball model creation
1709 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
1710 if (( ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
1712 theInfo.myMeshInfo->GetSpaceDim(),
1714 MED_NODE,MED_NONE)) < 0 ) {
1716 EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementCr");
1720 // create diameter attribute
1721 if (( ret = MEDstructElementVarAttCr(myFile->Id(),
1722 geotypename, MED_BALL_DIAMETER,
1723 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
1725 EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementVarAttCr");
1731 TBallInfo& aBallInfo = ((TBallInfo&) theInfo );
1732 aBallInfo.myGeom = ballGeom;
1735 SetCellInfo(theInfo,theMode,theErr);
1736 if ( theErr && theErr < 0 )
1740 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
1741 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
1742 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
1743 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
1744 MED_NO_DT, MED_NO_IT,
1745 aGeom, MED_BALL_DIAMETER,
1746 theInfo.myNbElem, &aDiam);
1750 EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshStructElementVarAttWr");
1753 //----------------------------------------------------------------------------
1754 //! Write a MEDWrapped representation of MED_BALL to the MED file
1755 void TVWrapper::SetBallInfo(const TBallInfo& theInfo, TErr* theErr)
1757 SetBallInfo( theInfo, eLECTURE_ECRITURE, theErr );
1760 //-----------------------------------------------------------------
1763 ::GetNbFields(TErr* theErr)
1765 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1767 if(theErr && *theErr < 0)
1770 return MEDnField(myFile->Id());
1774 //----------------------------------------------------------------------------
1777 ::GetNbComp(TInt theFieldId,
1780 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1782 if(theErr && *theErr < 0)
1785 return MEDfieldnComponent(myFile->Id(),theFieldId);
1789 //----------------------------------------------------------------------------
1792 ::GetFieldInfo(TInt theFieldId,
1793 MED::TFieldInfo& theInfo,
1796 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1798 if(theErr && *theErr < 0)
1801 TString aFieldName(256); // Protect from memory problems with too long names
1802 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
1803 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
1804 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
1805 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
1809 char dtunit[MED_SNAME_SIZE+1];
1810 char local_mesh_name[MED_NAME_SIZE+1]="";
1812 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(),theFieldId);
1813 aRet = MEDfieldInfo(myFile->Id(),
1824 if(strcmp(&aMeshInfo.myName[0],local_mesh_name) != 0 ) {
1830 theInfo.SetName(aFieldName);
1835 EXCEPTION(std::runtime_error,"GetFieldInfo - MEDfieldInfo(...)");
1839 //----------------------------------------------------------------------------
1842 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1846 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1848 if(theErr && *theErr < 0)
1851 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1853 TValueHolder<TString, char> aFieldName(anInfo.myName);
1854 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
1855 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
1856 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
1857 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
1859 char dtunit[MED_SNAME_SIZE+1];
1860 std::fill(dtunit,dtunit+MED_SNAME_SIZE+1,'\0');
1861 aRet = MEDfieldCr(myFile->Id(),
1868 &aMeshInfo.myName[0]);
1872 EXCEPTION(std::runtime_error,"SetFieldInfo - MEDfieldCr(...)");
1876 //----------------------------------------------------------------------------
1879 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1883 SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1886 SetFieldInfo(theInfo,eLECTURE_AJOUT,&aRet);
1893 //----------------------------------------------------------------------------
1896 ::GetNbGauss(TErr* theErr)
1898 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1900 if(theErr && *theErr < 0)
1903 return MEDnLocalization(myFile->Id());
1907 //----------------------------------------------------------------------------
1910 ::GetGaussPreInfo(TInt theId,
1913 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1915 if(theErr && *theErr < 0)
1916 return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 );
1918 med_int aNbGaussPoints = med_int();
1919 TVector<char> aName(GetNOMLength<eV2_2>()+1);
1920 med_geometry_type aGeom = MED_NONE;
1924 char geointerpname[MED_NAME_SIZE+1]="";
1925 char ipointstructmeshname[MED_NAME_SIZE+1]="";
1926 med_int nsectionmeshcell;
1927 med_geometry_type sectiongeotype;
1928 aRet = MEDlocalizationInfo (myFile->Id(),
1935 ipointstructmeshname,
1941 EXCEPTION(std::runtime_error,"GetGaussPreInfo - MEDlocalizationInfo(...)");
1942 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]),
1943 TInt(aNbGaussPoints));
1947 //----------------------------------------------------------------------------
1950 ::GetGaussInfo(TInt theId,
1951 TGaussInfo& theInfo,
1954 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1956 if(theErr && *theErr < 0)
1959 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
1960 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
1961 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
1962 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
1963 TValueHolder<TString, char> aGaussName(theInfo.myName);
1966 aRet = MEDlocalizationRd(myFile->Id(),
1976 EXCEPTION(std::runtime_error,"GetGaussInfo - MEDlocalizationRd(...)");
1980 //----------------------------------------------------------------------------
1983 ::GetNbProfiles(TErr* theErr)
1985 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1987 if(theErr && *theErr < 0)
1990 return MEDnProfile(myFile->Id());
1995 ::GetProfilePreInfo(TInt theId,
1998 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2000 if(theErr && *theErr < 0)
2001 return TProfileInfo::TInfo();
2004 TVector<char> aName(GetNOMLength<eV2_2>()+1);
2007 aRet = MEDprofileInfo(myFile->Id(),
2014 EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofileInfo(...)");
2016 return TProfileInfo::TInfo(&aName[0],aSize);
2021 ::GetProfileInfo(TInt theId,
2022 TProfileInfo& theInfo,
2025 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2027 if(theErr && *theErr < 0)
2030 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
2031 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
2032 TValueHolder<TString, char> aProfileName(anInfo.myName);
2035 aRet = MEDprofileRd(myFile->Id(),
2041 EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofileRd(...)");
2046 ::SetProfileInfo(const TProfileInfo& theInfo,
2050 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2052 if(theErr && *theErr < 0)
2055 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
2056 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
2057 TValueHolder<TString, char> aProfileName(anInfo.myName);
2060 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
2061 &aProfileName, // tableau de valeurs du profil.
2062 theInfo.GetSize(), // taille du profil.
2063 &anElemNum); // nom profil.
2067 EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofileWr(...)");
2072 ::SetProfileInfo(const TProfileInfo& theInfo,
2076 SetProfileInfo(theInfo,eLECTURE_ECRITURE,&aRet);
2079 SetProfileInfo(theInfo,eLECTURE_AJOUT,&aRet);
2082 SetProfileInfo(theInfo,eCREATION,&aRet);
2088 //-----------------------------------------------------------------
2091 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2092 const MED::TEntityInfo& theEntityInfo,
2093 EEntiteMaillage& theEntity,
2094 TGeom2Size& theGeom2Size,
2097 theEntity = EEntiteMaillage(-1);
2098 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2101 if(theEntityInfo.empty())
2105 }else if(theEntityInfo.empty())
2106 EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
2108 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2110 theGeom2Size.clear();
2111 TInt aNbTimeStamps = 0;
2112 TIdt anId = myFile->Id();
2114 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2115 TValueHolder<TString, char> aFieldName(anInfo.myName);
2116 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2118 // workaround for IPAL13676
2119 MED::TEntityInfo localEntityInfo = theEntityInfo;
2120 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2121 if(anLocalIter != localEntityInfo.end()){
2122 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2125 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2126 for(; anIter != localEntityInfo.end(); anIter++){
2127 med_entity_type anEntity = med_entity_type(anIter->first);
2128 const TGeom2Size& aGeom2Size = anIter->second;
2129 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2130 for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
2131 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2132 char aMeshName[MED_NAME_SIZE+1];
2135 char dtunit[MED_SNAME_SIZE+1];
2136 med_int myNbComp = MEDfieldnComponentByName(anId,&aFieldName);
2137 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2138 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2140 MEDfieldInfoByName(anId,
2157 MEDfieldComputingStepInfo(anId,
2163 char profilename[MED_NAME_SIZE+1];
2164 char locname[MED_NAME_SIZE+1];
2168 // protection from crash (division by zero)
2169 // inside MEDfieldnValueWithProfile function
2170 // caused by the workaround for IPAL13676 (see above)
2171 if( anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0 )
2174 nval = MEDfieldnValueWithProfile(anId,
2179 med_geometry_type(aGeom),
2187 bool anIsSatisfied =(nval > 0);
2190 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2191 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2192 if(anIsPerformAdditionalCheck){
2193 anIsSatisfied = !strcmp(&aMeshName[0],&aMeshInfo.myName[0]);
2196 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2197 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2202 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2203 theEntity = EEntiteMaillage(anEntity);
2204 aNbTimeStamps = aNbStamps;
2207 if(!theGeom2Size.empty())
2210 return aNbTimeStamps;
2214 //----------------------------------------------------------------------------
2217 ::GetTimeStampInfo(TInt theTimeStampId,
2218 MED::TTimeStampInfo& theInfo,
2221 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2223 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2226 if(aGeom2Size.empty())
2230 }else if(aGeom2Size.empty())
2231 EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell");
2233 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2234 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2236 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2237 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2238 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2239 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2240 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2241 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2242 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2243 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2244 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2246 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2248 // just to get a time stamp unit (anUnitDt)
2249 med_field_type aFieldType;
2250 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2251 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2252 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2254 MEDfieldInfoByName(myFile->Id(),
2263 delete [] aCompName;
2264 delete [] aCompUnit;
2266 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2267 for(; anIter != aGeom2Size.end(); anIter++){
2268 const EGeometrieElement& aGeom = anIter->first;
2269 med_int aNbGauss = -1;
2272 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2278 char profilename[MED_NAME_SIZE+1];
2280 char locname[MED_NAME_SIZE+1];
2281 MEDfieldnValueWithProfile(myFile->Id(),
2286 med_geometry_type(aGeom),
2294 static TInt MAX_NB_GAUSS_POINTS = 32;
2295 if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
2298 aGeom2NbGauss[aGeom] = aNbGauss;
2303 EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
2308 //----------------------------------------------------------------------------
2311 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2312 const TMKey2Profile& theMKey2Profile,
2313 const TKey2Gauss& theKey2Gauss,
2316 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2318 if(theErr && *theErr < 0)
2321 TIdt anId = myFile->Id();
2323 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
2324 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2326 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2327 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
2328 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2329 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2331 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2332 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2333 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
2335 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2336 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2338 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2339 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
2341 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
2342 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
2343 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
2345 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
2346 TGeom2Size::iterator anIter = aGeom2Size.begin();
2347 for(; anIter != aGeom2Size.end(); anIter++){
2348 EGeometrieElement aGeom = anIter->first;
2349 TInt aNbElem = anIter->second;
2350 med_int profilesize,aNbGauss;
2352 TInt aNbVal = MEDfieldnValueWithProfile(anId,
2357 med_geometry_type(aGeom),
2370 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
2373 TInt aNbComp = aFieldInfo->myNbComp;
2374 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
2375 theTimeStampValue->AllocateValue(aGeom,
2379 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
2382 "TVWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
2383 "; aNbVal = "<<aNbVal<<
2384 "; aNbValue = "<<aNbValue<<
2385 "; aNbGauss = "<<aNbGauss<<
2386 "; aNbComp = "<<aNbComp<<
2389 TErr aRet = MEDfieldValueWithProfileRd(anId,
2394 med_geometry_type(aGeom),
2398 MED_ALL_CONSTITUENT,
2399 theTimeStampValue->GetValuePtr(aGeom));
2402 *theErr = MED_FALSE;
2405 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
2408 MED::PGaussInfo aGaussInfo;
2409 TGaussInfo::TKey aKey(aGeom,&aGaussName[0]);
2410 if(strcmp(&aGaussName[0],"") != 0){
2411 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
2412 if(anIter != theKey2Gauss.end()){
2413 aGaussInfo = anIter->second;
2414 aGeom2Gauss[aGeom] = aGaussInfo;
2418 MED::PProfileInfo aProfileInfo;
2419 if(strcmp(&aProfileName[0],MED_NO_PROFILE) != 0){
2420 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
2421 if(anIter != aKey2Profile.end()){
2422 aProfileInfo = anIter->second;
2423 aGeom2Profile[aGeom] = aProfileInfo;
2427 if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){
2429 *theErr = MED_FALSE;
2432 EXCEPTION(std::runtime_error,"GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
2435 if(aProfileInfo && aProfileInfo->IsPresent()){
2436 TInt aNbSubElem = aProfileInfo->GetSize();
2437 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
2438 if(aProfileSize != aValueSize){
2443 EXCEPTION(std::runtime_error,
2444 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
2445 ") != aValueSize("<<aValueSize<<
2446 "); aNbVal = "<<aNbVal<<
2447 "; anEntity = "<<anEntity<<
2448 "; aGeom = "<<aGeom<<
2449 "; aNbElem = "<<aNbElem<<
2450 "; aNbSubElem = "<<aNbSubElem<<
2451 "; aNbComp = "<<aNbComp<<
2452 "; aNbGauss = "<<aNbGauss<<
2456 if((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)){
2461 EXCEPTION(std::runtime_error,
2462 "GetTimeStampValue - aNbElem("<<aNbElem<<
2463 ") != aNbValue("<<aNbValue<<
2464 "); aNbVal = "<<aNbVal<<
2465 "; anEntity = "<<anEntity<<
2466 "; aGeom = "<<aGeom<<
2467 "; aNbElem = "<<aNbElem<<
2468 "; aNbComp = "<<aNbComp<<
2469 "; aNbGauss = "<<aNbGauss<<
2477 //----------------------------------------------------------------------------
2480 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
2484 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2486 if(theErr && *theErr < 0)
2490 TIdt anId = myFile->Id();
2492 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
2493 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2495 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2496 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
2497 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2498 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2499 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
2500 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
2501 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2503 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2504 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2506 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2507 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2509 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
2510 TGeomSet::const_iterator anIter = aGeomSet.begin();
2511 for(; anIter != aGeomSet.end(); anIter++){
2512 EGeometrieElement aGeom = *anIter;
2514 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
2515 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
2516 if(aGaussIter != aGeom2Gauss.end()){
2517 MED::PGaussInfo aGaussInfo = aGaussIter->second;
2518 strcpy(&aGaussName[0],&aGaussInfo->myName[0]);
2521 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
2522 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
2523 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
2524 if(aProfileIter != aGeom2Profile.end()){
2525 MED::PProfileInfo aProfileInfo = aProfileIter->second;
2526 aProfileMode = med_storage_mode(aProfileInfo->myMode);
2527 strcpy(&aProfileName[0],&aProfileInfo->myName[0]);
2530 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
2532 aRet = MEDfieldValueWithProfileWr(anId,
2538 med_geometry_type(aGeom),
2543 MED_ALL_CONSTITUENT,
2545 theTimeStampValue->GetValuePtr(aGeom));
2548 *theErr = MED_FALSE;
2551 EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
2556 INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
2560 //----------------------------------------------------------------------------
2563 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2567 SetTimeStampValue(theTimeStampValue,eLECTURE_ECRITURE,&aRet);
2570 SetTimeStampValue(theTimeStampValue,eLECTURE_AJOUT,&aRet);
2576 //----------------------------------------------------------------------------
2579 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2582 SetGrilleInfo(theInfo,eLECTURE_ECRITURE,theErr);
2585 //----------------------------------------------------------------------------
2588 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2592 if(theInfo.myMeshInfo->myType != eSTRUCTURE)
2594 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2596 if(theErr && *theErr < 0)
2599 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
2601 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2602 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2604 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
2607 aRet = MEDmeshGridTypeRd(myFile->Id(),
2613 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridTypeRd(...)");
2615 if(anInfo.myGrilleType == eGRILLE_STANDARD){
2616 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
2617 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
2618 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
2619 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
2620 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
2621 //med_axis_type aRepere = MED_CARTESIAN;
2623 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
2633 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
2635 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
2636 aRet = MEDmeshGridStructWr(myFile->Id(),
2643 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridStructWr(...)");
2646 for(med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++){
2647 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
2653 anInfo.GetIndexes(aAxis).size(),
2654 &anInfo.GetIndexes(aAxis)[0]);
2657 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
2665 //----------------------------------------------------------------------------
2668 ::GetGrilleInfo(TGrilleInfo& theInfo,
2671 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2673 if(theErr && *theErr < 0)
2676 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2677 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2678 EMaillage aMaillageType = aMeshInfo.myType;
2680 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
2681 EGrilleType aGrilleType = theInfo.myGrilleType;
2684 if(aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
2685 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
2687 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
2688 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2689 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
2690 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
2691 //med_axis_type aRepere;
2693 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
2703 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
2705 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
2706 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
2708 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2718 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
2720 int mySize = (int)theInfo.myFamNumNode.size();
2721 theInfo.myFamNumNode.clear();
2722 theInfo.myFamNumNode.resize(mySize,0);
2726 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
2731 //============================
2734 if(aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD){
2736 for(med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++){
2739 aTable = eCOOR_IND1;
2742 aTable = eCOOR_IND2;
2745 aTable = eCOOR_IND3;
2754 EXCEPTION(std::runtime_error,"GetGrilleInfo - anAxis number out of range(...)");
2756 TInt aNbIndexes = GetNbNodes(aMeshInfo,aTable);
2758 EXCEPTION(std::runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
2760 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
2761 //TValueHolder<ETable, med_data_type > table(aTable);
2762 //char aCompNames[MED_SNAME_SIZE+1];
2763 //char anUnitNames[MED_SNAME_SIZE+1];
2764 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),&aMeshName,
2765 MED_NO_DT,MED_NO_IT,
2769 //theInfo.SetCoordName(anAxis-1, aCompNames);
2770 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
2771 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
2776 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)");
2780 EGeometrieElement aGeom = theInfo.GetGeom();
2781 EEntiteMaillage aEntity = theInfo.GetEntity();
2782 TInt aNbCells = theInfo.GetNbCells();
2784 theInfo.myFamNum.resize(aNbCells);
2785 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
2787 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2788 &aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(aEntity),
2789 med_geometry_type(aGeom),&aFamNum);
2791 if ( aMeshInfo.myDim == 3 )
2793 aGeom = theInfo.GetSubGeom();
2794 aEntity = theInfo.GetSubEntity();
2795 aNbCells = theInfo.GetNbSubCells();
2797 theInfo.myFamSubNum.resize(aNbCells,0);
2798 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
2800 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2801 &aMeshName,MED_NO_DT,MED_NO_IT,
2802 med_entity_type(aEntity),
2803 med_geometry_type(aGeom),&aFamNum);
2807 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
2809 int mySize = (int)theInfo.myFamNumNode.size();
2810 theInfo.myFamNumNode.clear();
2811 theInfo.myFamNumNode.resize(mySize,0);
2815 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
2823 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
2824 EGrilleType& theGridType,
2827 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2829 if(theErr && *theErr < 0)
2830 EXCEPTION(std::runtime_error," GetGrilleType - aFileWrapper (...)");
2832 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2834 if(aMeshInfo.myType == eSTRUCTURE){
2835 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2836 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
2837 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
2842 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridTypeRd(...)");
2848 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
2849 TIntVector& theStruct,
2852 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2854 if(theErr && *theErr < 0)
2858 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2860 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2861 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
2863 aRet = MEDmeshGridStructRd(myFile->Id(),
2871 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridStructRd(...)");