]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
CEA DEN - PAL/SALOME 2005 - L1.4.1 - Polyhedral elements
authorenk <enk@opencascade.com>
Fri, 21 Jan 2005 11:51:51 +0000 (11:51 +0000)
committerenk <enk@opencascade.com>
Fri, 21 Jan 2005 11:51:51 +0000 (11:51 +0000)
src/CONVERTOR/VISUConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.cxx

index 47cdbeeabe663ae2faf63086afa8ffa8d8a5f08b..c81e39e099d4ad76498499be833e56ac746dd95f 100644 (file)
@@ -104,11 +104,11 @@ void parseFile(const char* theFileName) {
       }
     }
     MSG(MYDEBUG,"OK");
-  //}catch(std::exception& exc){
-  //  MSG(MYDEBUG,"Follow exception was occured in file:"<<theFileName<<"\n"<<exc.what());
-  //}catch(...){
-  //  MSG(MYDEBUG,"Unknown exception was occured in VISU_Convertor_impl in file:"<<theFileName);
-  //
+//   }catch(std::exception& exc){
+//    MSG(MYDEBUG,"Follow exception was occured in file:"<<theFileName<<"\n"<<exc.what());
+//   }catch(...){
+//    MSG(MYDEBUG,"Unknown exception was occured in VISU_Convertor_impl in file:"<<theFileName);
+//   
 }
 
 int main(int argc, char** argv){ 
index a861616ac9aad35d83f953c7fbf295566e1ef771..8c264cb87f4740df0528e4a0611552dd5b30ba91 100644 (file)
@@ -76,6 +76,8 @@ namespace{
     case ePENTA15: return VTK_WEDGE;
     case ePYRA5: return VTK_PYRAMID;
     case ePYRA13: return VTK_PYRAMID;
+    case ePOLYGONE: return VTK_POLYGON;
+//     case ePOLYEDRE: return VTK_POLYEDRE;
     }
     return -1;
   }
@@ -106,6 +108,7 @@ namespace{
     case VTK_HEXAHEDRON: return eHEXA8;
     case VTK_WEDGE: return ePENTA6;
     case VTK_PYRAMID: return ePYRA5;
+    case VTK_POLYGON: return ePOLYGONE;
     }
     return EGeometrieElement(-1);
   }
@@ -153,25 +156,26 @@ VISU_Convertor* VISU_MedConvertor::Build()  {
   MSG(MYDEBUG,"VISU_MedConvertor::Build()");
   INITMSG(MYDEBUG,"GetNbMeshes() = "<<aNbMeshes<<"\n");
 
-  for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
-
+  for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++)
+    try{
     PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
-  
-    PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
 
+    PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
+    
     MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
     
-    TCellGroup aCellGroup = GetCellsByEntity(aMed,aMeshInfo,aEntityInfo);
+    TElemGroup aElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo);
 
     TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo);
 
-    TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aNodeInfo,aCellGroup,aFamilyGroup);
+    TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aNodeInfo,aElemGroup,aFamilyGroup);
 
     TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup);
 
     // creating TMesh structure and TMeshOnEntityMap
     typedef map<TInt,TInt> TFamilyCounterMap;
     TFamilyCounterMap aFamilyNbCellsCounterMap, aFamilyCellsSizeCounterMap;
+    TFamilyCounterMap aFamilyNbPolygonesCounterMap, aFamilyPolygonesSizeCounterMap;
 
     TInt aDim = aMeshInfo->GetDim();
     const string& aMeshName = aMeshInfo->GetName();
@@ -224,22 +228,60 @@ VISU_Convertor* VISU_MedConvertor::Build()  {
        aMeshOnEntity->myCellsSize = 0;
        for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
          const EGeometrieElement& aGeom = anTGeomIter->first;
-         int aVNbNodes = VTKGeom2NbNodes(MEDGeomToVTK(aGeom));
-         PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom);
-         TInt aNbElem = aCellInfo->GetNbElem();
-         aMeshOnEntity->myNbCells += aNbElem;
-         aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
-         INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<
-                 "; myNbCells = "<<aMeshOnEntity->myNbCells<<
-                 "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<"\n");
-
-         for(TInt iElem = 0; iElem < aMesh->myNbPoints; iElem++){
-           TInt aFamId = aCellInfo->GetFamNum(iElem);
-           if(aFamId != 0){
-             aFamilyNbCellsCounterMap[aFamId] += 1;
-             aFamilyCellsSizeCounterMap[aFamId] += aVNbNodes + 1;
+
+         switch(aGeom){
+         case ePOLYGONE:
+           {
+             PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom);
+             TInt aNbElem = aPolygoneInfo->GetNbElem();
+             TElemNum aConn  = aPolygoneInfo->GetConnectivite();
+             TElemNum aIndex = aPolygoneInfo->GetIndex();
+             TInt aNbIndex = aIndex.size();
+             TInt aNbConn  = aConn.size();
+
+             aMeshOnEntity->myNbCells += aNbElem;
+             
+             for (int ii = 0; ii<aNbElem ; ii++){
+               int aNbConnii = aPolygoneInfo->GetNbConn(ii);
+               aMeshOnEntity->myCellsSize += aNbConnii;
+             }
+             INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<
+                     "; myNbPolygones = "<<aNbElem<<
+                     "; nbConn= "<<aNbConn<<"\n");
+             
+             for(TInt iElem = 0; iElem < aNbElem; iElem++){
+               TInt aFamId = aPolygoneInfo->GetFamNum(iElem);
+               if(aFamId != 0){
+                 aFamilyNbCellsCounterMap[aFamId] += 1;
+                 ADDMSG(MYDEBUG,"aFamId = "<<aFamId<<" ");
+                 aFamilyCellsSizeCounterMap[aFamId] += aPolygoneInfo->GetNbConn(iElem) + 1;
+               }
+             }
+             ADDMSG(MYDEBUG,endl);
+             break;
            }
-         }
+         default:
+           {
+             int aVNbNodes = VTKGeom2NbNodes(MEDGeomToVTK(aGeom));
+             PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom);
+             TInt aNbElem = aCellInfo->GetNbElem();
+             aMeshOnEntity->myNbCells += aNbElem;
+             aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
+             INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<
+                     "; myNbCells = "<<aMeshOnEntity->myNbCells<<
+                     "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<"\n");
+             
+             for(TInt iElem = 0; iElem < aNbElem; iElem++){
+               TInt aFamId = aCellInfo->GetFamNum(iElem);
+               if(aFamId != 0){
+                 aFamilyNbCellsCounterMap[aFamId] += 1;
+                 ADDMSG(MYDEBUG,"aFamId = "<<aFamId<<" ");
+                 aFamilyCellsSizeCounterMap[aFamId] += aVNbNodes + 1;
+               }
+             }
+             ADDMSG(MYDEBUG,endl);
+           }
+         } // end switch(...)
        }
       }
     }
@@ -253,6 +295,9 @@ VISU_Convertor* VISU_MedConvertor::Build()  {
       TEntity aVEntity = MEDEntityToVTK(aMEntity);
       VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
       VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+      
+      if(aFamilyGroup.empty())
+       continue;
 
       INITMSG(MYDEBUG,"aMEntity = "<<aMEntity<<"; aVEntity = "<<aVEntity<<"\n");
       TFamilyGroup::const_iterator aFamilyGroupIter = aFamilyGroup.begin();
@@ -317,24 +362,18 @@ VISU_Convertor* VISU_MedConvertor::Build()  {
          const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
          TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
          for (; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
-           const string& aFamilyName = aFamilyMapIter->first;
+           const string& aName = aFamilyMapIter->first;
            aFamily = aFamilyMapIter->second;
-           if(aFamily){
-             TFamilyGroup::const_iterator aGroupInfoIter = aFamilyGroup.begin();
-             for(; aGroupInfoIter != aFamilyGroup.end(); aGroupInfoIter++){
-               const PFamilyInfo& aFamilyInfo = *aGroupInfoIter;
-               if(aFamilyInfo->GetName() == aFamilyName){
-                 aVEntity = aFamily->myEntity;
-                 goto exit_lable;
-               }
-             }
+           if(aName == aFamilyName){
+             aVEntity = aFamily->myEntity;
+             goto exit_lable;
            }
          }
        }
       exit_lable:
        if(aFamily && aVEntity >= 0){
          aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity));
-         INITMSG(MYDEBUG,"aFamilyName = '"<<aFamilyName<<"'; aVEntity = "<<aVEntity<<"\n");
+         INITMSG(MYDEBUG,"aFamilyName = '"<<aFamilyName<<"'; '"<<aFamily->myName<<"'; aVEntity = "<<aVEntity<<"\n");
          
          aGroup->myNbCells += aFamily->myNbCells;
          aGroup->myCellsSize += aFamily->myCellsSize;
@@ -347,9 +386,8 @@ VISU_Convertor* VISU_MedConvertor::Build()  {
       }
     }
     
-    BEGMSG(MYDEBUG,"VISU::TField:\n");
-
     TInt aNbFields = aMed->GetNbFields(); 
+    BEGMSG(MYDEBUG,"VISU::TField: NbFields="<<aNbFields<<"\n");
     for(TInt iField = 1; iField <= aNbFields; iField++){
       PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField);
       TInt aNbComp = aFieldInfo->GetNbComp();
@@ -358,7 +396,6 @@ VISU_Convertor* VISU_MedConvertor::Build()  {
       MED::TGeom aTGeom;
       EEntiteMaillage aMEntity;
       TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,aMEntity,aTGeom);
-
       TEntity aVEntity = MEDEntityToVTK(aMEntity);
       VISU::PMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
       TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
@@ -402,6 +439,10 @@ VISU_Convertor* VISU_MedConvertor::Build()  {
        INITMSG(MYDEBUG,"aDt = "<<aDt<<", "<<anUnitDt<<"\n");
       }
     }
+  } catch (std::runtime_error& exc){
+    MSG(MYDEBUG,"Follow exception wqs occured in:\n"<<exc.what());
+  } catch(...){
+    EXCEPTION(runtime_error,"Unknown exception !!!");
   }
 
   return this; 
@@ -417,7 +458,7 @@ int VISU_MedConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity,
   int isPointsUpdated;
   if(anEntity == VISU::NODE_ENTITY) 
     isPointsUpdated = LoadPoints(aMed,aMesh,theFamilyName);
-  else 
+  else
     isPointsUpdated = LoadPoints(aMed,aMesh);
   int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,aMesh,theMeshOnEntity,theFamilyName);
 
@@ -531,7 +572,7 @@ VISU_MedConvertor::LoadCellsOnEntity(const MED::PWrapper& theMed,
     PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName);
     //Check on loading already done
     bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty();
-    if(isCellsLoaded) 
+    if(isCellsLoaded)
       if(!aFamily) 
        return 0;
       else if(!aFamily->mySubMesh.empty()) 
@@ -566,67 +607,108 @@ VISU_MedConvertor::LoadCellsOnEntity(const MED::PWrapper& theMed,
     for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
       const EGeometrieElement& aGeom = anTGeomIter->first;
       int aVTKGeomType = MEDGeomToVTK(aGeom);
-      int aVNbNodes = VTKGeom2NbNodes(aVTKGeomType);
-
-      PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom);
-      TInt aNbElem = aCellInfo->GetNbElem();
-
-      if(!isCellsLoaded){
-       VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConn[aVTKGeomType];
-       aConnForCellType.resize(aNbElem);
-       
-       int aMNbNodes = MEDGeom2NbNodes(aGeom);
-       vector<TInt> aConnect(aMNbNodes);
-
-       for (int iElem = 0; iElem < aNbElem; iElem++) {
-         VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForCellType[iElem];
-         anArray.resize(aVNbNodes);
-
-         if(anIsNodeNum){
-           for(int i = 0; i < aMNbNodes; i++){
-             aConnect[i] = aNodeIdMap[aCellInfo->GetConn(iElem,i)-1];
+      ADDMSG(MYDEBUG,"LoadCellsOnEntity aGeom="<<aGeom<<"\n");
+      switch(aGeom){
+      case ePOLYGONE:
+       {
+         PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom);
+         TInt aNbElem = aPolygoneInfo->GetNbElem();
+         
+         if(!isCellsLoaded){
+           VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolygoneType = aCellsConn[aVTKGeomType];
+           aConnForPolygoneType.resize(aNbElem);
+           
+           int aMNbNodes = aPolygoneInfo->GetConnDim();
+           
+           vector<TInt> aConnect(aMNbNodes);
+           vector<TInt> aIndex = aPolygoneInfo->GetIndex();
+
+           for (int iElem = 0; iElem < aNbElem; iElem++) {
+             VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForPolygoneType[iElem];
+             int aNbConn = aPolygoneInfo->GetNbConn(iElem);
+
+             anArray.resize(aNbConn);
+             
+             aConnect = aPolygoneInfo->GetConnectivite();
+             
+             for (int i=0;i<aNbConn;i++){
+               anArray[i] = aConnect[aIndex[iElem]-1+i]-1;
+             }
            }
-         }else{
-           for(int i = 0; i < aMNbNodes; i++){
-             aConnect[i] = aCellInfo->GetConn(iElem,i)-1;
+         }
+         if(aFamily){
+           VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType];
+           for(int iElem = 0; iElem < aNbElem; iElem++) 
+             if(aPolygoneInfo->GetFamNum(iElem) == aFamily->myId)
+               aSubMeshOnCellType.insert(iElem);
+         }
+         break;
+       }
+      default:
+       {
+         int aVNbNodes = VTKGeom2NbNodes(aVTKGeomType);
+         
+         PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom);
+         TInt aNbElem = aCellInfo->GetNbElem();
+         
+         if(!isCellsLoaded){
+           VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConn[aVTKGeomType];
+           aConnForCellType.resize(aNbElem);
+           
+           int aMNbNodes = MEDGeom2NbNodes(aGeom);
+           vector<TInt> aConnect(aMNbNodes);
+         
+           for (int iElem = 0; iElem < aNbElem; iElem++) {
+             VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForCellType[iElem];
+             anArray.resize(aVNbNodes);
+             
+             if(anIsNodeNum){
+               for(int i = 0; i < aMNbNodes; i++){
+                 aConnect[i] = aNodeIdMap[aCellInfo->GetConn(iElem,i)-1];
+               }
+             }else{
+               for(int i = 0; i < aMNbNodes; i++){
+                 aConnect[i] = aCellInfo->GetConn(iElem,i)-1;
+               }
+             }
+             
+             switch(aGeom){
+             case eTETRA4:
+             case eTETRA10:
+               anArray[0] = aConnect[0];
+               anArray[1] = aConnect[1];
+               anArray[2] = aConnect[3];  
+               anArray[3] = aConnect[2];  
+               break;
+             case ePYRA5:
+             case ePYRA13:
+               anArray[0] = aConnect[0];
+               anArray[1] = aConnect[3];  
+               anArray[2] = aConnect[2];
+               anArray[3] = aConnect[1];  
+               anArray[4] = aConnect[4];
+               break;
+             default:
+               for(int iNode = 0; iNode < aVNbNodes; iNode++) 
+                 anArray[iNode] = aConnect[iNode];
+             }
+             for(int iNode = 0; iNode < aVNbNodes; iNode++) 
+               if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
+                 EXCEPTION(runtime_error,"ImportCells >> aNbPoints("<<aNbPoints<<") "<<
+                           "<= anArray["<<iElem<<"]"<<
+                           "["<<iNode<<"]"<<
+                           "("<<anArray[iNode]<<") < 0");
            }
          }
-
-         switch(aGeom){
-         case eTETRA4:
-         case eTETRA10:
-           anArray[0] = aConnect[0];
-           anArray[1] = aConnect[1];
-           anArray[2] = aConnect[3];  
-           anArray[3] = aConnect[2];  
-           break;
-         case ePYRA5:
-         case ePYRA13:
-           anArray[0] = aConnect[0];
-           anArray[1] = aConnect[3];  
-           anArray[2] = aConnect[2];
-           anArray[3] = aConnect[1];  
-           anArray[4] = aConnect[4];
-           break;
-         default:
-           for(int iNode = 0; iNode < aVNbNodes; iNode++) 
-             anArray[iNode] = aConnect[iNode];
+         //Filling aFamily SubMesh
+         if(aFamily){
+           VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType];
+           for(int iElem = 0; iElem < aNbElem; iElem++) 
+             if(aCellInfo->GetFamNum(iElem) == aFamily->myId)
+               aSubMeshOnCellType.insert(iElem);
          }
-         for(int iNode = 0; iNode < aVNbNodes; iNode++) 
-           if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
-             EXCEPTION(runtime_error,"ImportCells >> aNbPoints("<<aNbPoints<<") "<<
-                       "<= anArray["<<iElem<<"]"<<
-                       "["<<iNode<<"]"<<
-                       "("<<anArray[iNode]<<") < 0");
        }
       }
-      //Filling aFamily SubMesh
-      if(aFamily){
-       VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType];
-       for(int iElem = 0; iElem < aNbElem; iElem++) 
-         if(aCellInfo->GetFamNum(iElem) == aFamily->myId)
-           aSubMeshOnCellType.insert(iElem);
-      }
     }
     return 1;
   }catch(std::runtime_error& exc){