1 // Copyright (C) 2007-2016 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;
69 GetVersionRelease(TInt& majeur, TInt& mineur, TInt& release)
73 release=MED_RELEASE_NUM;
77 GetNbConn(EGeometrieElement typmai,
78 EEntiteMaillage typent,
86 //---------------------------------------------------------------
92 TFile(const std::string& theFileName):
95 myFileName(theFileName)
104 Open(EModeAcces theMode, TErr* theErr = NULL)
107 const char* aFileName = myFileName.c_str();
108 myFid = MEDfileOpen(aFileName,med_access_mode(theMode));
111 *theErr = TErr(myFid);
113 EXCEPTION(std::runtime_error,"TFile - MEDfileOpen('"<<myFileName<<"',"<<theMode<<")");
116 const TIdt& Id() const
119 EXCEPTION(std::runtime_error,"TFile - GetFid() < 0");
132 std::string myFileName;
135 //---------------------------------------------------------------
141 TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL):
144 myFile->Open(theMode,theErr);
153 //---------------------------------------------------------------
154 TVWrapper::TVWrapper(const std::string& theFileName):
155 myFile(new TFile(theFileName))
158 myFile->Open( eLECTURE_ECRITURE, &aRet );
161 // myFile->Open( eLECTURE_AJOUT, &aRet );
165 myFile->Open( eLECTURE, &aRet );
169 myFile->Open( eCREATION, &aRet );
173 //----------------------------------------------------------------------------
176 ::GetNbMeshes(TErr* theErr)
178 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
180 if(theErr && *theErr < 0)
183 return MEDnMesh(myFile->Id());
186 //----------------------------------------------------------------------------
189 ::GetMeshInfo(TInt theMeshId,
190 MED::TMeshInfo& theInfo,
193 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
195 if(theErr && *theErr < 0)
198 TValueHolder<TString, char> aMeshName(theInfo.myName);
199 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
200 TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
201 TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
202 char dtunit[MED_SNAME_SIZE+1];
203 med_sorting_type sorttype;
206 int naxis=MEDmeshnAxis(myFile->Id(),theMeshId);
207 char *axisname=new char[naxis*MED_SNAME_SIZE+1];
208 char *axisunit=new char[naxis*MED_SNAME_SIZE+1];
209 TErr aRet = MEDmeshInfo(myFile->Id(),
225 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(...)");
277 //----------------------------------------------------------------------------
280 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
284 SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
287 SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
290 SetMeshInfo(theInfo,eCREATION,&aRet);
296 //----------------------------------------------------------------------------
299 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
302 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
304 if(theErr && *theErr < 0)
307 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
308 TValueHolder<TString, char> aName(anInfo.myName);
309 return MEDnFamily(myFile->Id(),&aName);
312 //----------------------------------------------------------------------------
315 ::GetNbFamAttr(TInt theFamId,
316 const MED::TMeshInfo& theInfo,
319 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
321 if(theErr && *theErr < 0)
324 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
326 TValueHolder<TString, char> aName(anInfo.myName);
328 return MEDnFamily23Attribute(myFile->Id(),&aName,theFamId);
331 //----------------------------------------------------------------------------
334 ::GetNbFamGroup(TInt theFamId,
335 const MED::TMeshInfo& theInfo,
338 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
340 if(theErr && *theErr < 0)
343 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
345 TValueHolder<TString, char> aName(anInfo.myName);
347 return MEDnFamilyGroup(myFile->Id(),&aName,theFamId);
350 //----------------------------------------------------------------------------
353 ::GetFamilyInfo(TInt theFamId,
354 MED::TFamilyInfo& theInfo,
357 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
359 if(theErr && *theErr < 0)
362 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
364 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
365 TValueHolder<TString, char> aFamilyName(theInfo.myName);
366 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
367 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
368 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
369 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
370 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
372 TErr aRet = MEDfamily23Info(myFile->Id(),
385 EXCEPTION(std::runtime_error,"GetFamilyInfo - MEDfamily23Info(...) - "<<
386 " aMeshInfo.myName = '"<<&aMeshName<<
387 "'; theFamId = "<<theFamId<<
388 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
389 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
392 //----------------------------------------------------------------------------
395 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
399 TFileWrapper aFileWrapper(myFile,theMode,theErr);
401 if(theErr && *theErr < 0)
404 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
405 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
407 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
408 TValueHolder<TString, char> aFamilyName(anInfo.myName);
409 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
410 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
411 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
412 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
413 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
414 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
415 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
417 TErr aRet = MEDfamilyCr(myFile->Id(),
424 INITMSG(MYDEBUG,"TVWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
429 EXCEPTION(std::runtime_error,"SetFamilyInfo - MEDfamilyCr(...)");
432 //----------------------------------------------------------------------------
435 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
439 SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
442 SetFamilyInfo(theInfo,eLECTURE_AJOUT,&aRet);
448 //----------------------------------------------------------------------------
451 ::GetNames(TElemInfo& theInfo,
453 EEntiteMaillage theEntity,
454 EGeometrieElement theGeom,
457 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
459 if(theErr && *theErr < 0)
462 if ( theGeom == eBALL )
463 theGeom = GetBallGeom( theInfo.myMeshInfo );
465 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
467 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
468 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
469 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
470 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
472 TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
480 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
486 //----------------------------------------------------------------------------
489 ::GetNumeration(TElemInfo& theInfo,
491 EEntiteMaillage theEntity,
492 EGeometrieElement theGeom,
495 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
497 if(theErr && *theErr < 0)
500 if ( theGeom == eBALL )
501 theGeom = GetBallGeom( theInfo.myMeshInfo );
503 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
505 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
506 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
507 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
508 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
510 TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
518 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
524 //----------------------------------------------------------------------------
527 ::GetFamilies(TElemInfo& theInfo,
529 EEntiteMaillage theEntity,
530 EGeometrieElement theGeom,
533 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
535 if(theErr && *theErr < 0)
538 if ( theGeom == eBALL )
539 theGeom = GetBallGeom( theInfo.myMeshInfo );
541 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
543 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
544 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
545 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
546 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
548 TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
558 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
560 int aSize = (int)theInfo.myFamNum->size();
561 theInfo.myFamNum->clear();
562 theInfo.myFamNum->resize(aSize,0);
566 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
572 //----------------------------------------------------------------------------
575 ::SetNames(const TElemInfo& theInfo,
576 EEntiteMaillage theEntity,
577 EGeometrieElement theGeom,
580 SetNames(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
583 //----------------------------------------------------------------------------
586 ::SetNames(const TElemInfo& theInfo,
588 EEntiteMaillage theEntity,
589 EGeometrieElement theGeom,
592 TFileWrapper aFileWrapper(myFile,theMode,theErr);
594 if(theErr && *theErr < 0)
597 if ( theGeom == eBALL )
598 theGeom = GetBallGeom( theInfo.myMeshInfo );
600 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
601 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
604 if(theInfo.myIsElemNames)
606 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
607 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
608 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
609 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
611 aRet = MEDmeshEntityNameWr(myFile->Id(),
617 (TInt)anInfo.myElemNames->size(),
622 EXCEPTION(std::runtime_error,"SetNames - MEDmeshEntityNameWr(...)");
626 //----------------------------------------------------------------------------
629 ::SetNumeration(const TElemInfo& theInfo,
630 EEntiteMaillage theEntity,
631 EGeometrieElement theGeom,
634 SetNumeration(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
637 //----------------------------------------------------------------------------
640 ::SetNumeration(const TElemInfo& theInfo,
642 EEntiteMaillage theEntity,
643 EGeometrieElement theGeom,
646 TFileWrapper aFileWrapper(myFile,theMode,theErr);
648 if(theErr && *theErr < 0)
651 if ( theGeom == eBALL )
652 theGeom = GetBallGeom( theInfo.myMeshInfo );
654 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
655 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
658 if(theInfo.myIsElemNum)
660 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
661 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
662 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
663 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
665 aRet = MEDmeshEntityNumberWr(myFile->Id(),
671 (TInt)anInfo.myElemNum->size(),
676 EXCEPTION(std::runtime_error,"SetNumeration - MEDmeshEntityNumberWr(...)");
680 //----------------------------------------------------------------------------
683 ::SetFamilies(const TElemInfo& theInfo,
684 EEntiteMaillage theEntity,
685 EGeometrieElement theGeom,
688 SetFamilies(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
691 //----------------------------------------------------------------------------
694 ::SetFamilies(const TElemInfo& theInfo,
696 EEntiteMaillage theEntity,
697 EGeometrieElement theGeom,
700 TFileWrapper aFileWrapper(myFile,theMode,theErr);
702 if(theErr && *theErr < 0)
705 if ( theGeom == eBALL )
706 theGeom = GetBallGeom( theInfo.myMeshInfo );
708 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
709 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
711 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
712 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
713 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
714 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
716 TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
722 (TInt)anInfo.myFamNum->size(),
728 EXCEPTION(std::runtime_error,"SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
731 //----------------------------------------------------------------------------
734 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
738 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
740 if(theErr && *theErr < 0)
743 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
745 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
746 TValueHolder<ETable, med_data_type > aTable(theTable);
748 return MEDmeshnEntity(myFile->Id(),
760 //----------------------------------------------------------------------------
763 ::GetNodeInfo(MED::TNodeInfo& theInfo,
766 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
768 if(theErr && *theErr < 0)
771 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
773 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
774 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
775 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
776 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
777 TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
778 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
779 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
780 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
781 //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
782 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
783 //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
784 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
785 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
787 TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
794 TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
803 // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
805 int mySize = (int)theInfo.myFamNum->size();
806 theInfo.myFamNum->clear();
807 theInfo.myFamNum->resize(mySize,0);
810 // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
813 if ( MEDmeshEntityNameRd(myFile->Id(),
819 &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
821 if ( MEDmeshEntityNumberRd(myFile->Id(),
827 &anElemNum) < 0 ) theInfo.myIsElemNum=eFAUX;
832 EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
835 //----------------------------------------------------------------------------
838 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
842 TFileWrapper aFileWrapper(myFile,theMode,theErr);
844 if(theErr && *theErr < 0)
847 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
848 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
850 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
851 TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
852 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
853 TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
854 TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
855 TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
856 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
857 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
858 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
859 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
860 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
861 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
863 TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
872 MEDmeshEntityFamilyNumberWr(myFile->Id(),
881 MEDmeshEntityNameWr(myFile->Id(),
890 MEDmeshEntityNumberWr(myFile->Id(),
901 EXCEPTION(std::runtime_error,"SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
904 //----------------------------------------------------------------------------
907 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
911 SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
914 SetNodeInfo(theInfo,eLECTURE_AJOUT,&aRet);
920 //-----------------------------------------------------------------
923 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
926 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
928 if(theErr && *theErr < 0)
931 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
933 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
934 TValueHolder<TElemNum, med_int > anIndex (theInfo.myIndex);
935 TValueHolder<TElemNum, med_int > aConn (theInfo.myConn);
936 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (theInfo.myEntity);
937 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
938 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
939 TInt aNbElem = (TInt)theInfo.myElemNum->size();
942 aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName,
943 MED_NO_DT, MED_NO_IT,
945 aConnMode, &anIndex, &aConn);
950 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolygonRd(...)");
952 if(theInfo.myIsElemNames){
953 GetNames(theInfo,aNbElem,theInfo.myEntity,theInfo.myGeom,&aRet);
958 if(theInfo.myIsElemNum){
959 GetNumeration(theInfo,aNbElem,theInfo.myEntity,theInfo.myGeom,&aRet);
964 GetFamilies(theInfo,aNbElem,theInfo.myEntity,theInfo.myGeom,&aRet);
969 //----------------------------------------------------------------------------
972 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
975 SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
978 //----------------------------------------------------------------------------
981 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
985 TFileWrapper aFileWrapper(myFile,theMode,theErr);
987 if(theErr && *theErr < 0)
990 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
991 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
993 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
994 TValueHolder<TElemNum, med_int > anIndex (anInfo.myIndex);
995 TValueHolder<TElemNum, med_int > aConn (anInfo.myConn);
996 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (anInfo.myEntity);
997 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
998 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1000 TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName,
1001 MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
1003 aConnMode, anInfo.myNbElem + 1,
1008 EXCEPTION(std::runtime_error,"SetPolygoneInfo - MEDmeshPolygonWr(...)");
1010 SetNames(anInfo,theInfo.myEntity,anInfo.myGeom,&aRet);
1014 SetNumeration(anInfo,theInfo.myEntity,anInfo.myGeom,&aRet);
1018 SetFamilies(anInfo,theInfo.myEntity,anInfo.myGeom,&aRet);
1023 //----------------------------------------------------------------------------
1026 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1027 EEntiteMaillage theEntity,
1028 EGeometrieElement theGeom,
1029 EConnectivite theConnMode,
1032 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1035 //----------------------------------------------------------------------------
1038 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1039 EEntiteMaillage theEntity,
1040 EGeometrieElement theGeom,
1041 EConnectivite theConnMode,
1044 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1046 if(theErr && *theErr < 0)
1049 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1051 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1052 med_int aTaille = 0;
1054 aTaille=MEDmeshnEntity(myFile->Id(),
1058 med_entity_type(theEntity),
1059 med_geometry_type(theGeom),
1061 med_connectivity_mode(theConnMode),
1067 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
1069 return TInt(aTaille);
1072 //-----------------------------------------------------------------
1075 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1078 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1080 if(theErr && *theErr < 0)
1083 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1085 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1086 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1087 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1088 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1089 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1090 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1093 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1106 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1108 if(theInfo.myIsElemNames){
1109 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1114 if(theInfo.myIsElemNum){
1115 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1120 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1125 //----------------------------------------------------------------------------
1128 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1131 SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
1134 //----------------------------------------------------------------------------
1137 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1141 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1143 if(theErr && *theErr < 0)
1146 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1147 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1149 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1150 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1151 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1152 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1153 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1156 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1165 (TInt)anInfo.myFaces->size(),
1172 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1174 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1176 if(theInfo.myIsElemNames){
1177 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1178 aRet = MEDmeshEntityNameWr(myFile->Id(),
1184 (TInt)anInfo.myElemNames->size(),
1189 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1192 if(theInfo.myIsElemNum){
1193 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1194 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1200 (TInt)anInfo.myElemNum->size(),
1205 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1209 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1210 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1216 (TInt)anInfo.myFamNum->size(),
1222 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1225 //----------------------------------------------------------------------------
1228 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1229 EEntiteMaillage theEntity,
1230 EGeometrieElement theGeom,
1231 EConnectivite theConnMode,
1234 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1237 //----------------------------------------------------------------------------
1239 TVWrapper ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1242 EConnectivite theConnMode,
1245 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1247 if(theErr && *theErr < 0)
1248 EXCEPTION(std::runtime_error,"GetPolyedreConnSize - (...)");
1250 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1252 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1253 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1254 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1255 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1258 theNbFaces = MEDmeshnEntity(myFile->Id(),
1269 theConnSize = MEDmeshnEntity(myFile->Id(),
1280 if(theNbFaces < 0 || theConnSize<0)
1281 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
1285 //-----------------------------------------------------------------
1288 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1289 EConnectivite theConnMode,
1294 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1296 if(theErr && *theErr < 0)
1299 if(theMeshInfo.GetType() == eNON_STRUCTURE) {
1300 TInt aNbElem = GetNbNodes(theMeshInfo);
1302 anInfo[eNOEUD][ePOINT1] = aNbElem;
1303 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1304 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1305 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1306 for(; anIter != anIterEnd; anIter++){
1307 const EEntiteMaillage& anEntity = anIter->first;
1308 const TGeomSet& aGeomSet = anIter->second;
1309 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1310 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1311 for(; anIter2 != anIterEnd2; anIter2++){
1312 const EGeometrieElement& aGeom = *anIter2;
1313 aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
1315 if ( anEntity == eSTRUCT_ELEMENT ) {
1316 const TInt nbStructTypes = aNbElem;
1317 for ( TInt structType = 0; structType < nbStructTypes; ++structType ) {
1318 // check type name to keep only "MED_BALL" structured element
1319 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName );
1320 char geotypename[ MED_NAME_SIZE + 1] = "";
1321 med_geometry_type geotype;
1322 MEDmeshEntityInfo( myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1323 med_entity_type(anEntity), structType+1,
1324 geotypename, &geotype);
1325 if ( strcmp( geotypename, MED_BALL_NAME ) == 0 ) {
1326 aNbElem = GetNbCells( theMeshInfo, anEntity, EGeometrieElement(geotype),
1327 theConnMode, theErr);
1329 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1334 anInfo[anEntity][aGeom] = aNbElem;
1340 } else { // eSTRUCTURE
1341 EGrilleType aGrilleType;
1345 TInt aDim = theMeshInfo.GetDim();
1346 EGeometrieElement aGeom, aSubGeom;
1347 EEntiteMaillage aSubEntity = eMAILLE;
1349 GetGrilleType(theMeshInfo, aGrilleType);
1351 TIntVector aStruct(aDim);
1352 if(aGrilleType == eGRILLE_STANDARD)
1354 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1357 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1358 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1359 for(med_int anAxis = 0; anAxis < aDim; anAxis++)
1360 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1362 for(med_int i = 0; i < aDim; i++){
1363 aNbNodes = aNbNodes * aStruct[i];
1364 aNbElem = aNbElem * (aStruct[i] - 1);
1373 aSubEntity = eARETE;
1375 (aStruct[0] ) * (aStruct[1]-1) +
1376 (aStruct[0]-1) * (aStruct[1] );
1383 (aStruct[0] ) * (aStruct[1]-1) * (aStruct[2]-1) +
1384 (aStruct[0]-1) * (aStruct[1] ) * (aStruct[2]-1) +
1385 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2] );
1388 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1389 anInfo[eMAILLE][aGeom] = aNbElem;
1391 anInfo[aSubEntity][aSubGeom] = aNbSub;
1396 //-----------------------------------------------------------------
1397 TInt TVWrapper::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1398 EEntiteMaillage theEntity,
1399 EGeometrieElement theGeom,
1400 EConnectivite theConnMode,
1403 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1405 if(theErr && *theErr < 0)
1408 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1409 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1413 case MED::ePOLYGONE:
1414 case MED::ePOLYGON2:
1416 return MEDmeshnEntity(myFile->Id(),&aMeshName,
1417 MED_NO_DT,MED_NO_IT,
1418 med_entity_type(theEntity),med_geometry_type(theGeom),
1419 MED_INDEX_NODE,med_connectivity_mode(theConnMode),
1422 case MED::ePOLYEDRE:
1424 return MEDmeshnEntity(myFile->Id(),&aMeshName,
1425 MED_NO_DT,MED_NO_IT,
1426 med_entity_type(theEntity),MED_POLYHEDRON,
1427 MED_INDEX_FACE,med_connectivity_mode(theConnMode),
1432 return GetNbBalls( theMeshInfo );
1436 return MEDmeshnEntity(myFile->Id(),&aMeshName,
1437 MED_NO_DT,MED_NO_IT,
1438 med_entity_type(theEntity),med_geometry_type(theGeom),
1439 MED_CONNECTIVITY,med_connectivity_mode(theConnMode),
1446 //----------------------------------------------------------------------------
1447 void TVWrapper::GetCellInfo(MED::TCellInfo& theInfo, TErr* theErr)
1449 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1451 if(theErr && *theErr < 0)
1454 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1456 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1457 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
1458 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
1459 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
1460 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
1461 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
1462 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
1463 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
1464 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
1465 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
1466 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1467 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
1470 aRet = MEDmeshElementRd(myFile->Id(),
1489 EXCEPTION(std::runtime_error,"GetCellInfo - MEDmeshElementRd(...)");
1491 if (anIsFamNum == MED_FALSE)
1493 int mySize = (int) theInfo.myFamNum->size();
1494 theInfo.myFamNum->clear();
1495 theInfo.myFamNum->resize(mySize, 0);
1500 //----------------------------------------------------------------------------
1503 ::SetCellInfo(const MED::TCellInfo& theInfo,
1507 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1509 if(theErr && *theErr < 0)
1512 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
1513 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1515 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1516 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
1517 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1518 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1519 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1520 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1521 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1522 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1523 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
1524 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
1525 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1526 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
1527 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1530 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
1542 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1551 MEDmeshEntityNameWr(myFile->Id(),
1560 MEDmeshEntityNumberWr(myFile->Id(),
1571 EXCEPTION(std::runtime_error,"SetCellInfo - MEDmeshElementWr(...)");
1574 //----------------------------------------------------------------------------
1577 ::SetCellInfo(const MED::TCellInfo& theInfo,
1580 SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
1583 //----------------------------------------------------------------------------
1584 //! Read geom type of MED_BALL structural element
1585 EGeometrieElement TVWrapper::GetBallGeom(const TMeshInfo& theMeshInfo)
1587 TFileWrapper aFileWrapper(myFile,eLECTURE);
1589 // read med_geometry_type of "MED_BALL" element
1590 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
1591 return EGeometrieElement( MEDstructElementGeotype( myFile->Id(), geotypename ) );
1594 //----------------------------------------------------------------------------
1595 //! Read number of balls in the Mesh
1596 TInt TVWrapper::GetNbBalls(const TMeshInfo& theMeshInfo)
1598 TFileWrapper aFileWrapper(myFile,eLECTURE);
1600 EGeometrieElement ballType = GetBallGeom( theMeshInfo );
1604 return GetNbCells( theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD );
1607 //----------------------------------------------------------------------------
1608 //! Read a MEDWrapped representation of MED_BALL from the MED file
1609 void TVWrapper::GetBallInfo(TBallInfo& theInfo, TErr* theErr)
1611 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1613 // check geometry of MED_BALL
1614 if ( theInfo.myGeom == eBALL )
1616 theInfo.myGeom = GetBallGeom( *theInfo.myMeshInfo );
1617 if ( theInfo.myGeom < 0 ) {
1619 EXCEPTION(std::runtime_error,"GetBallInfo - no balls in the mesh");
1620 *theErr = theInfo.myGeom;
1626 GetCellInfo( theInfo );
1629 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
1630 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1631 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
1632 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
1634 TErr aRet = MEDmeshStructElementVarAttRd( myFile->Id(), &aMeshName,
1635 MED_NO_DT, MED_NO_IT,
1641 else if ( aRet < 0 )
1642 EXCEPTION(std::runtime_error,"GetBallInfo - pb at reading diameters");
1645 //----------------------------------------------------------------------------
1646 //! Write a MEDWrapped representation of MED_BALL to the MED file
1647 void TVWrapper::SetBallInfo(const TBallInfo& theInfo, EModeAcces theMode, TErr* theErr)
1649 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1652 char ballsupportname[MED_NAME_SIZE+1]="BALL_SUPPORT_MESH";
1653 EGeometrieElement ballGeom = GetBallGeom( *theInfo.myMeshInfo );
1656 // no ball model in the file, create support mesh for it
1657 char dummyname [MED_NAME_SIZE*3+1]="";
1658 if (( ret = MEDsupportMeshCr( myFile->Id(),
1660 theInfo.myMeshInfo->GetSpaceDim(),
1661 theInfo.myMeshInfo->GetDim(),
1662 "Support mesh for a ball model",
1664 /*axisname=*/dummyname, /*unitname=*/dummyname)) < 0) {
1666 EXCEPTION(std::runtime_error,"SetBallInfo - MEDsupportMeshCr");
1670 // write coordinates of 1 node
1671 med_float coord[3] = {0,0,0};
1672 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
1673 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
1674 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
1676 EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshNodeCoordinateWr");
1680 // ball model creation
1681 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
1682 if (( ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
1684 theInfo.myMeshInfo->GetSpaceDim(),
1686 MED_NODE,MED_NONE)) < 0 ) {
1688 EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementCr");
1692 // create diameter attribute
1693 if (( ret = MEDstructElementVarAttCr(myFile->Id(),
1694 geotypename, MED_BALL_DIAMETER,
1695 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
1697 EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementVarAttCr");
1703 TBallInfo& aBallInfo = ((TBallInfo&) theInfo );
1704 aBallInfo.myGeom = ballGeom;
1707 SetCellInfo(theInfo,theMode,theErr);
1708 if ( theErr && theErr < 0 )
1712 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
1713 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
1714 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
1715 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
1716 MED_NO_DT, MED_NO_IT,
1717 aGeom, MED_BALL_DIAMETER,
1718 theInfo.myNbElem, &aDiam);
1722 EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshStructElementVarAttWr");
1725 //----------------------------------------------------------------------------
1726 //! Write a MEDWrapped representation of MED_BALL to the MED file
1727 void TVWrapper::SetBallInfo(const TBallInfo& theInfo, TErr* theErr)
1729 SetBallInfo( theInfo, eLECTURE_ECRITURE, theErr );
1732 //-----------------------------------------------------------------
1735 ::GetNbFields(TErr* theErr)
1737 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1739 if(theErr && *theErr < 0)
1742 return MEDnField(myFile->Id());
1745 //----------------------------------------------------------------------------
1748 ::GetNbComp(TInt theFieldId,
1751 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1753 if(theErr && *theErr < 0)
1756 return MEDfieldnComponent(myFile->Id(),theFieldId);
1759 //----------------------------------------------------------------------------
1762 ::GetFieldInfo(TInt theFieldId,
1763 MED::TFieldInfo& theInfo,
1766 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1768 if(theErr && *theErr < 0)
1771 TString aFieldName(256); // Protect from memory problems with too long names
1772 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
1773 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
1774 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
1775 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
1779 char dtunit[MED_SNAME_SIZE+1];
1780 char local_mesh_name[MED_NAME_SIZE+1]="";
1782 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(),theFieldId);
1783 aRet = MEDfieldInfo(myFile->Id(),
1794 if(strcmp(&aMeshInfo.myName[0],local_mesh_name) != 0 ) {
1800 theInfo.SetName(aFieldName);
1805 EXCEPTION(std::runtime_error,"GetFieldInfo - MEDfieldInfo(...)");
1808 //----------------------------------------------------------------------------
1811 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1815 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1817 if(theErr && *theErr < 0)
1820 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1822 TValueHolder<TString, char> aFieldName(anInfo.myName);
1823 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
1824 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
1825 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
1826 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
1828 char dtunit[MED_SNAME_SIZE+1];
1829 std::fill(dtunit,dtunit+MED_SNAME_SIZE+1,'\0');
1830 aRet = MEDfieldCr(myFile->Id(),
1837 &aMeshInfo.myName[0]);
1841 EXCEPTION(std::runtime_error,"SetFieldInfo - MEDfieldCr(...)");
1844 //----------------------------------------------------------------------------
1847 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1851 SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1854 SetFieldInfo(theInfo,eLECTURE_AJOUT,&aRet);
1860 //----------------------------------------------------------------------------
1863 ::GetNbGauss(TErr* theErr)
1865 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1867 if(theErr && *theErr < 0)
1870 return MEDnLocalization(myFile->Id());
1873 //----------------------------------------------------------------------------
1876 ::GetGaussPreInfo(TInt theId,
1879 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1881 if(theErr && *theErr < 0)
1882 return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 );
1884 med_int aNbGaussPoints = med_int();
1885 TVector<char> aName(GetNOMLength()+1);
1886 med_geometry_type aGeom = MED_NONE;
1890 char geointerpname[MED_NAME_SIZE+1]="";
1891 char ipointstructmeshname[MED_NAME_SIZE+1]="";
1892 med_int nsectionmeshcell;
1893 med_geometry_type sectiongeotype;
1894 aRet = MEDlocalizationInfo (myFile->Id(),
1901 ipointstructmeshname,
1907 EXCEPTION(std::runtime_error,"GetGaussPreInfo - MEDlocalizationInfo(...)");
1908 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]),
1909 TInt(aNbGaussPoints));
1912 //----------------------------------------------------------------------------
1915 ::GetGaussInfo(TInt theId,
1916 TGaussInfo& theInfo,
1919 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1921 if(theErr && *theErr < 0)
1924 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
1925 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
1926 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
1927 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
1928 TValueHolder<TString, char> aGaussName(theInfo.myName);
1931 aRet = MEDlocalizationRd(myFile->Id(),
1941 EXCEPTION(std::runtime_error,"GetGaussInfo - MEDlocalizationRd(...)");
1944 //----------------------------------------------------------------------------
1947 ::GetNbProfiles(TErr* theErr)
1949 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1951 if(theErr && *theErr < 0)
1954 return MEDnProfile(myFile->Id());
1959 ::GetProfilePreInfo(TInt theId,
1962 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1964 if(theErr && *theErr < 0)
1965 return TProfileInfo::TInfo();
1968 TVector<char> aName(GetNOMLength()+1);
1971 aRet = MEDprofileInfo(myFile->Id(),
1978 EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofileInfo(...)");
1980 return TProfileInfo::TInfo(&aName[0],aSize);
1985 ::GetProfileInfo(TInt theId,
1986 TProfileInfo& theInfo,
1989 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1991 if(theErr && *theErr < 0)
1994 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
1995 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1996 TValueHolder<TString, char> aProfileName(anInfo.myName);
1999 aRet = MEDprofileRd(myFile->Id(),
2005 EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofileRd(...)");
2010 ::SetProfileInfo(const TProfileInfo& theInfo,
2014 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2016 if(theErr && *theErr < 0)
2019 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
2020 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
2021 TValueHolder<TString, char> aProfileName(anInfo.myName);
2024 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
2025 &aProfileName, // tableau de valeurs du profil.
2026 theInfo.GetSize(), // taille du profil.
2027 &anElemNum); // nom profil.
2031 EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofileWr(...)");
2036 ::SetProfileInfo(const TProfileInfo& theInfo,
2040 SetProfileInfo(theInfo,eLECTURE_ECRITURE,&aRet);
2043 SetProfileInfo(theInfo,eLECTURE_AJOUT,&aRet);
2046 SetProfileInfo(theInfo,eCREATION,&aRet);
2052 //-----------------------------------------------------------------
2055 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2056 const MED::TEntityInfo& theEntityInfo,
2057 EEntiteMaillage& theEntity,
2058 TGeom2Size& theGeom2Size,
2061 theEntity = EEntiteMaillage(-1);
2062 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2065 if(theEntityInfo.empty())
2069 }else if(theEntityInfo.empty())
2070 EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
2072 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2074 theGeom2Size.clear();
2075 TInt aNbTimeStamps = 0;
2076 TIdt anId = myFile->Id();
2078 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2079 TValueHolder<TString, char> aFieldName(anInfo.myName);
2080 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2082 // workaround for IPAL13676
2083 MED::TEntityInfo localEntityInfo = theEntityInfo;
2084 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2085 if(anLocalIter != localEntityInfo.end()){
2086 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2089 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2090 for(; anIter != localEntityInfo.end(); anIter++){
2091 med_entity_type anEntity = med_entity_type(anIter->first);
2092 const TGeom2Size& aGeom2Size = anIter->second;
2093 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2094 for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
2095 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2096 char aMeshName[MED_NAME_SIZE+1];
2099 char dtunit[MED_SNAME_SIZE+1];
2100 med_int myNbComp = MEDfieldnComponentByName(anId,&aFieldName);
2101 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2102 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2104 MEDfieldInfoByName(anId,
2121 MEDfieldComputingStepInfo(anId,
2127 char profilename[MED_NAME_SIZE+1];
2128 char locname[MED_NAME_SIZE+1];
2132 // protection from crash (division by zero)
2133 // inside MEDfieldnValueWithProfile function
2134 // caused by the workaround for IPAL13676 (see above)
2135 if( anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0 )
2138 nval = MEDfieldnValueWithProfile(anId,
2143 med_geometry_type(aGeom),
2151 bool anIsSatisfied =(nval > 0);
2154 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2155 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2156 if(anIsPerformAdditionalCheck){
2157 anIsSatisfied = !strcmp(&aMeshName[0],&aMeshInfo.myName[0]);
2160 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2161 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2166 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2167 theEntity = EEntiteMaillage(anEntity);
2168 aNbTimeStamps = aNbStamps;
2171 if(!theGeom2Size.empty())
2174 return aNbTimeStamps;
2177 //----------------------------------------------------------------------------
2180 ::GetTimeStampInfo(TInt theTimeStampId,
2181 MED::TTimeStampInfo& theInfo,
2184 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2186 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2189 if(aGeom2Size.empty())
2193 }else if(aGeom2Size.empty())
2194 EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell");
2196 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2197 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2199 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2200 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2201 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2202 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2203 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2204 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2205 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2206 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2207 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2209 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2211 // just to get a time stamp unit (anUnitDt)
2212 med_field_type aFieldType;
2213 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2214 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2215 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2217 MEDfieldInfoByName(myFile->Id(),
2226 delete [] aCompName;
2227 delete [] aCompUnit;
2229 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2230 for(; anIter != aGeom2Size.end(); anIter++){
2231 const EGeometrieElement& aGeom = anIter->first;
2232 med_int aNbGauss = -1;
2235 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2241 char profilename[MED_NAME_SIZE+1];
2243 char locname[MED_NAME_SIZE+1];
2244 MEDfieldnValueWithProfile(myFile->Id(),
2249 med_geometry_type(aGeom),
2257 static TInt MAX_NB_GAUSS_POINTS = 32;
2258 if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
2261 aGeom2NbGauss[aGeom] = aNbGauss;
2266 EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
2270 //----------------------------------------------------------------------------
2273 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2274 const TMKey2Profile& theMKey2Profile,
2275 const TKey2Gauss& theKey2Gauss,
2278 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2280 if(theErr && *theErr < 0)
2283 TIdt anId = myFile->Id();
2285 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
2286 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2288 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2289 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
2290 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2291 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2293 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2294 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2295 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
2297 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2298 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2300 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2301 TVector<char> aGaussName(GetNOMLength()+1);
2303 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
2304 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
2305 TVector<char> aProfileName(GetNOMLength()+1);
2307 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
2308 TGeom2Size::iterator anIter = aGeom2Size.begin();
2309 for(; anIter != aGeom2Size.end(); anIter++){
2310 EGeometrieElement aGeom = anIter->first;
2311 TInt aNbElem = anIter->second;
2312 med_int profilesize,aNbGauss;
2314 TInt aNbVal = MEDfieldnValueWithProfile(anId,
2319 med_geometry_type(aGeom),
2332 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
2335 TInt aNbComp = aFieldInfo->myNbComp;
2336 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
2337 theTimeStampValue->AllocateValue(aGeom,
2341 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
2344 "TVWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
2345 "; aNbVal = "<<aNbVal<<
2346 "; aNbValue = "<<aNbValue<<
2347 "; aNbGauss = "<<aNbGauss<<
2348 "; aNbComp = "<<aNbComp<<
2351 TErr aRet = MEDfieldValueWithProfileRd(anId,
2356 med_geometry_type(aGeom),
2360 MED_ALL_CONSTITUENT,
2361 theTimeStampValue->GetValuePtr(aGeom));
2364 *theErr = MED_FALSE;
2367 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
2370 MED::PGaussInfo aGaussInfo;
2371 TGaussInfo::TKey aKey(aGeom,&aGaussName[0]);
2372 if(strcmp(&aGaussName[0],"") != 0){
2373 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
2374 if(anIter != theKey2Gauss.end()){
2375 aGaussInfo = anIter->second;
2376 aGeom2Gauss[aGeom] = aGaussInfo;
2380 MED::PProfileInfo aProfileInfo;
2381 if(strcmp(&aProfileName[0],MED_NO_PROFILE) != 0){
2382 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
2383 if(anIter != aKey2Profile.end()){
2384 aProfileInfo = anIter->second;
2385 aGeom2Profile[aGeom] = aProfileInfo;
2389 if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){
2391 *theErr = MED_FALSE;
2394 EXCEPTION(std::runtime_error,"GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
2397 if(aProfileInfo && aProfileInfo->IsPresent()){
2398 TInt aNbSubElem = aProfileInfo->GetSize();
2399 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
2400 if(aProfileSize != aValueSize){
2405 EXCEPTION(std::runtime_error,
2406 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
2407 ") != aValueSize("<<aValueSize<<
2408 "); aNbVal = "<<aNbVal<<
2409 "; anEntity = "<<anEntity<<
2410 "; aGeom = "<<aGeom<<
2411 "; aNbElem = "<<aNbElem<<
2412 "; aNbSubElem = "<<aNbSubElem<<
2413 "; aNbComp = "<<aNbComp<<
2414 "; aNbGauss = "<<aNbGauss<<
2418 if((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)){
2423 EXCEPTION(std::runtime_error,
2424 "GetTimeStampValue - aNbElem("<<aNbElem<<
2425 ") != aNbValue("<<aNbValue<<
2426 "); aNbVal = "<<aNbVal<<
2427 "; anEntity = "<<anEntity<<
2428 "; aGeom = "<<aGeom<<
2429 "; aNbElem = "<<aNbElem<<
2430 "; aNbComp = "<<aNbComp<<
2431 "; aNbGauss = "<<aNbGauss<<
2438 //----------------------------------------------------------------------------
2441 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
2445 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2447 if(theErr && *theErr < 0)
2451 TIdt anId = myFile->Id();
2453 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
2454 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2456 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2457 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
2458 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2459 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2460 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
2461 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
2462 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2464 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2465 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2467 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2468 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2470 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
2471 TGeomSet::const_iterator anIter = aGeomSet.begin();
2472 for(; anIter != aGeomSet.end(); anIter++){
2473 EGeometrieElement aGeom = *anIter;
2475 TVector<char> aGaussName(GetNOMLength()+1);
2476 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
2477 if(aGaussIter != aGeom2Gauss.end()){
2478 MED::PGaussInfo aGaussInfo = aGaussIter->second;
2479 strcpy(&aGaussName[0],&aGaussInfo->myName[0]);
2482 TVector<char> aProfileName(GetNOMLength()+1);
2483 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
2484 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
2485 if(aProfileIter != aGeom2Profile.end()){
2486 MED::PProfileInfo aProfileInfo = aProfileIter->second;
2487 aProfileMode = med_storage_mode(aProfileInfo->myMode);
2488 strcpy(&aProfileName[0],&aProfileInfo->myName[0]);
2491 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
2493 aRet = MEDfieldValueWithProfileWr(anId,
2499 med_geometry_type(aGeom),
2504 MED_ALL_CONSTITUENT,
2506 theTimeStampValue->GetValuePtr(aGeom));
2509 *theErr = MED_FALSE;
2512 EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
2517 INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
2520 //----------------------------------------------------------------------------
2523 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2527 SetTimeStampValue(theTimeStampValue,eLECTURE_ECRITURE,&aRet);
2530 SetTimeStampValue(theTimeStampValue,eLECTURE_AJOUT,&aRet);
2536 //----------------------------------------------------------------------------
2539 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2542 SetGrilleInfo(theInfo,eLECTURE_ECRITURE,theErr);
2545 //----------------------------------------------------------------------------
2548 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2552 if(theInfo.myMeshInfo->myType != eSTRUCTURE)
2554 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2556 if(theErr && *theErr < 0)
2559 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
2561 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2562 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2564 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
2567 aRet = MEDmeshGridTypeRd(myFile->Id(),
2573 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridTypeRd(...)");
2575 if(anInfo.myGrilleType == eGRILLE_STANDARD){
2576 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
2577 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
2578 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
2579 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
2580 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
2581 //med_axis_type aRepere = MED_CARTESIAN;
2583 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
2593 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
2595 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
2596 aRet = MEDmeshGridStructWr(myFile->Id(),
2603 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridStructWr(...)");
2606 for(med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++){
2607 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
2613 anInfo.GetIndexes(aAxis).size(),
2614 &anInfo.GetIndexes(aAxis)[0]);
2617 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
2625 //----------------------------------------------------------------------------
2628 ::GetGrilleInfo(TGrilleInfo& theInfo,
2631 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2633 if(theErr && *theErr < 0)
2636 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2637 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2638 EMaillage aMaillageType = aMeshInfo.myType;
2640 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
2641 EGrilleType aGrilleType = theInfo.myGrilleType;
2644 if(aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
2645 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
2647 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
2648 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2649 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
2650 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
2651 //med_axis_type aRepere;
2653 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
2663 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
2665 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
2666 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
2668 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2678 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
2680 int mySize = (int)theInfo.myFamNumNode.size();
2681 theInfo.myFamNumNode.clear();
2682 theInfo.myFamNumNode.resize(mySize,0);
2686 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
2691 //============================
2694 if(aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD){
2695 ETable aTable = eCOOR_IND1;
2696 for(med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++){
2699 aTable = eCOOR_IND1;
2702 aTable = eCOOR_IND2;
2705 aTable = eCOOR_IND3;
2714 EXCEPTION(std::runtime_error,"GetGrilleInfo - anAxis number out of range(...)");
2716 TInt aNbIndexes = GetNbNodes(aMeshInfo,aTable);
2718 EXCEPTION(std::runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
2720 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
2721 //TValueHolder<ETable, med_data_type > table(aTable);
2722 //char aCompNames[MED_SNAME_SIZE+1];
2723 //char anUnitNames[MED_SNAME_SIZE+1];
2724 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),&aMeshName,
2725 MED_NO_DT,MED_NO_IT,
2729 //theInfo.SetCoordName(anAxis-1, aCompNames);
2730 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
2731 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
2736 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)");
2740 EGeometrieElement aGeom = theInfo.GetGeom();
2741 EEntiteMaillage aEntity = theInfo.GetEntity();
2742 TInt aNbCells = theInfo.GetNbCells();
2744 theInfo.myFamNum.resize(aNbCells);
2745 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
2747 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2748 &aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(aEntity),
2749 med_geometry_type(aGeom),&aFamNum);
2751 if ( aMeshInfo.myDim == 3 )
2753 aGeom = theInfo.GetSubGeom();
2754 aEntity = theInfo.GetSubEntity();
2755 aNbCells = theInfo.GetNbSubCells();
2757 theInfo.myFamSubNum.resize(aNbCells,0);
2758 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
2760 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2761 &aMeshName,MED_NO_DT,MED_NO_IT,
2762 med_entity_type(aEntity),
2763 med_geometry_type(aGeom),&aFamNum);
2767 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
2769 int mySize = (int)theInfo.myFamNumNode.size();
2770 theInfo.myFamNumNode.clear();
2771 theInfo.myFamNumNode.resize(mySize,0);
2775 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
2783 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
2784 EGrilleType& theGridType,
2787 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2789 if(theErr && *theErr < 0)
2790 EXCEPTION(std::runtime_error," GetGrilleType - aFileWrapper (...)");
2792 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2794 if(aMeshInfo.myType == eSTRUCTURE){
2795 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2796 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
2797 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
2802 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridTypeRd(...)");
2808 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
2809 TIntVector& theStruct,
2812 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2814 if(theErr && *theErr < 0)
2818 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2820 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2821 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
2823 aRet = MEDmeshGridStructRd(myFile->Id(),
2831 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridStructRd(...)");