#endif
static med_err ret = 0;
-static med_entite_maillage MEDENTITY[4] = {
- MED_MAILLE, MED_NOEUD, MED_ARETE, MED_FACE
- };
typedef map<VISU::TEntity,med_entite_maillage> TVisu2MedEntity;
static TVisu2MedEntity aVisu2MedEntity;
static int INIT = (
MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10,
MED_PYRA13, MED_PENTA15, MED_HEXA20
};
-void GetEntity2Geom(const VISU::TEntity& theEntity, med_geometrie_element*& theVector, int* theEnd) {
+void GetEntity2Geom(const VISU::TEntity& theEntity, med_geometrie_element*& theVector, int* theEnd)
+ throw (std::runtime_error&)
+{
switch(theEntity){
case VISU::CELL_ENTITY: theVector = CELLGEOM; *theEnd = MED_NBR_GEOMETRIE_MAILLE; break;
case VISU::FACE_ENTITY: theVector = FACEGEOM; *theEnd = MED_NBR_GEOMETRIE_FACE; break;
case VISU::EDGE_ENTITY: theVector = EDGEGEOM; *theEnd = MED_NBR_GEOMETRIE_ARETE; break;
case VISU::NODE_ENTITY: theVector = NODEGEOM; *theEnd = 1; break;
+ default:
+ throw std::runtime_error("GetEntity2Geom >> theEntity is uncorrect");
}
}
extern "C"
VISU_Convertor* CreateMedConvertor(const string& theFileName) throw(std::runtime_error&){
- VISU_MedConvertor* aConvertor = new VISU_MedConvertor(theFileName);
- aConvertor->Build();
- return aConvertor;
+ return new VISU_MedConvertor(theFileName);
}
int med2vtkCellType(int medType){
myFileInfo.setFile(QString(theFileName.c_str()));
myName = (const char*)(myFileInfo.baseName());
}
-
VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) {
MedFile aMedFile(myFileInfo.absFilePath());
med_idt fid = aMedFile.GetFid();
med_int iMeshEnd = MEDnMaa(fid); //Get number of meshes
- if(MYDEBUG) MESSAGE("ImportInfo - MEDnMaa = "<<iMeshEnd);
+ if(MYDEBUG) MESSAGE("ImportInfo - MEDnMaa = "<<iMeshEnd<<"; myFileInfo = "<<myFileInfo.filePath());
for(int iMesh = 1; iMesh <= iMeshEnd; iMesh++){
med_int aMeshDim;
char aMeshName[MED_TAILLE_NOM+1] = "";
VISU::TMesh &aMesh = myMeshMap[aMeshName];
aMesh.myDim = aMeshDim;
aMesh.myName = aMeshName;
- //Create aMeshOnEntity for entity with type of NODE_ENTITY at any case
- //VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[VISU::NODE_ENTITY];
- //aMeshOnEntity.myEntity = VISU::NODE_ENTITY;
- //aMeshOnEntity.myMeshName = aMeshName;
typedef map<int,VISU::TEntity> TFamily2EntityMap;
TFamily2EntityMap aFamily2EntityMap;
TVisu2MedEntity::const_iterator aVisu2MedEntityIter = aVisu2MedEntity.begin();
int medId = getIdMedType(aGeomElemVector[iGeomElem]);
int aVtkType = med2vtk[medId].vtkType;
med_geometrie_element aMedType = med2vtk[medId].medType;
- //Get number of connectivities
- med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_CONN,aMedEntity,aMedType,MED_NOD);
- if (iNumElemEnd > 0) {
- VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
- aMeshOnEntity.myEntity = anEntity;
- aMeshOnEntity.myMeshName = aMeshName;
- if(MYDEBUG)
- MESSAGE("ImportInfo -\t anEntity = "<<anEntity<<"; medName = "<<med2vtk[medId].medName<<
- "; iNumElemEnd = "<<iNumElemEnd);
- med_booleen iname_elem, inum_elem;
- valarray<med_int> num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd);
- valarray<char> name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1);
- if(aMedEntity == MED_NOEUD){
+ if(aMedEntity == MED_NOEUD){
+ med_geometrie_element typgeo = (med_geometrie_element)0;
+ med_connectivite typco = (med_connectivite)0;
+ med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_COOR,MED_NOEUD,typgeo,typco);
+ if(iNumElemEnd > 0){
+ VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
+ aMeshOnEntity.myEntity = anEntity;
+ aMeshOnEntity.myMeshName = aMeshName;
+ if(MYDEBUG)
+ MESSAGE("ImportInfo -\t anEntity = "<<anEntity<<"; iNumElemEnd = "<<iNumElemEnd<<
+ "; medName = "<<med2vtk[medId].medName<<"; medId = "<<medId);
+ med_booleen iname_elem, inum_elem;
+ valarray<med_int> num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd);
+ valarray<char> name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1);
med_repere rep;
valarray<char> name_coord('\0',aMesh.myDim*MED_TAILLE_PNOM+1);
valarray<char> unit_coord('\0',aMesh.myDim*MED_TAILLE_PNOM+1);
&name_coord[0],&unit_coord[0],&name_elem[0],&iname_elem,
&num_elem[0],&inum_elem,&num_fam_elem[0],iNumElemEnd);
if(ret < 0) throw std::runtime_error("ImportInfo >> MEDnoeudsLire(...)");
- }else{
- med_int aNbConnForElem = getNbMedConnect(aMedType,anEntity,aMesh.myDim);
- valarray<med_int> conn(aNbConnForElem*iNumElemEnd);
- ret = MEDelementsLire(fid,aMeshName,aMesh.myDim,&conn[0],MED_FULL_INTERLACE,
- &name_elem[0],&iname_elem,&num_elem[0],&inum_elem,
- &num_fam_elem[0],iNumElemEnd,aMedEntity,aMedType,MED_NOD);
- if (ret < 0) throw std::runtime_error("ImportInfo >> MEDelementsLire(...)");
+ for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
+ if(num_fam_elem[iNumElem] != 0)
+ aFamily2EntityMap[num_fam_elem[iNumElem]] = anEntity;
}
+ }
+ //Get number of connectivities
+ med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_CONN,aMedEntity,aMedType,MED_NOD);
+ if (iNumElemEnd > 0) {
+ VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
+ aMeshOnEntity.myEntity = anEntity;
+ aMeshOnEntity.myMeshName = aMeshName;
+ med_booleen iname_elem, inum_elem;
+ valarray<med_int> num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd);
+ valarray<char> name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1);
+ med_int aNbConnForElem = getNbMedConnect(aMedType,anEntity,aMesh.myDim);
+ if(MYDEBUG)
+ MESSAGE("ImportInfo -\t anEntity = "<<anEntity<<"; iNumElemEnd = "<<iNumElemEnd<<
+ "; medName = "<<med2vtk[medId].medName<<"; aNbConnForElem = "<<aNbConnForElem);
+ valarray<med_int> conn(0,aNbConnForElem*iNumElemEnd);
+ ret = MEDelementsLire(fid,aMeshName,aMesh.myDim,&conn[0],MED_FULL_INTERLACE,
+ &name_elem[0],&iname_elem,&num_elem[0],&inum_elem,
+ &num_fam_elem[0],iNumElemEnd,aMedEntity,aMedType,MED_NOD);
+ if (ret < 0) throw std::runtime_error("ImportInfo >> MEDelementsLire(...)");
for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
if(num_fam_elem[iNumElem] != 0)
aFamily2EntityMap[num_fam_elem[iNumElem]] = anEntity;
"; myName = '"<<aFamilyName<<"'; myId = "<<aFamilyNum);
VISU::TBindGroups& aBindGroups = aFamily.myGroups;
for(int iGroup = 0, iPos = 0; iGroup < aNbGroup; iGroup++, iPos += MED_TAILLE_LNOM){
- string aGroupName(&aGroupNames[iPos]);
+ char aGroupName[MED_TAILLE_LNOM+1];
+ strncpy(aGroupName,&aGroupNames[iPos],MED_TAILLE_LNOM);
+ aGroupName[MED_TAILLE_LNOM] = '\0';
if(MYDEBUG) MESSAGE("ImportInfo - aGroupName["<<iGroup<<"] = '"<<aGroupName<<"'");
aBindGroups.insert(aGroupName);
}
return 1;
}
-int VISU_Convertor_impl::ToMedFile(const string& theFileName) throw(std::runtime_error&){}
+