Salome HOME
Update Help for VISU module.
[modules/visu.git] / src / VISU_I / VISU_CorbaMedConvertor.cxx
index 58e3d6ebf652058a11986675414de05206b6bd8c..56c39876d4d2fea091de8ace7501fd8a9826bde7 100644 (file)
@@ -542,8 +542,10 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
        VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
        CORBA::String_var aSupportName = aMEDSupport->getName();
        
-       if(aMEDSupport->isOnAllElements()){
-         if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<"' aVEntity = "<<aVEntity);
+       if(aMEDSupport->isOnAllElements() && strcmp(aSupportName.in(),"SupportOnAll_MED_") > 0){
+         if(MYDEBUG) 
+           MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<
+                   "' aVEntity = "<<aVEntity);
          int aNbCells, aCellsSize;
          //Check, if there is any data on the support?
          if(aVEntity == NODE_ENTITY){
@@ -584,15 +586,23 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
        
        SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
        if(!aMEDFamily->_is_nil()) {
-         int aNbCells, aCellsSize;
-         GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
-         if(aNbCells > 0){
-           if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFamily = '"<<aSupportName<<"' aVEntity = "<<aVEntity);
-           TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
-           if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
-             continue;
+         TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
+         if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
+           continue;
+         PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
+
+         int aNbCells = aMeshOnEntity->myNbCells, aCellsSize = aMeshOnEntity->myCellsSize;
+         CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
+         if(!anIsOnAllElements)
+           GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
+
+         if(MYDEBUG) 
+           MESSAGE("VISU_MEDConvertor::Build - aFamily = '"<<aSupportName<<
+                   "'; anIsOnAllElements = "<<anIsOnAllElements<<
+                   "; aVEntity = "<<aVEntity<<
+                   "; aNbCells = "<<aNbCells);
 
-           PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
+         if(aNbCells > 0){
            TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
            PCFamily aFamily = aFamilyMap[aSupportName.in()](new TCFamily());
            aFamily->myName = aSupportName.in();
@@ -625,14 +635,19 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
        
        SALOME_MED::GROUP_var aMEDGroup = SALOME_MED::GROUP::_narrow(aMedSupport);
        if(!aMEDGroup->_is_nil()){
-         if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup = '"<<aSupportName<<"' aVEntity = "<<aVEntity);
-         TGroupMap& aGroupMap = aMesh->myGroupMap;
-         PCGroup aGroup = aGroupMap[aSupportName.in()](new TCGroup());
+         CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
+
+         if(MYDEBUG) 
+           MESSAGE("VISU_MEDConvertor::Build - aGroup = '"<<aSupportName<<
+                   "'; anIsOnAllElements = "<<anIsOnAllElements<<
+                   "; aVEntity = "<<aVEntity);
+
+         PCGroup aGroup(new TCGroup());
          aGroup->myGroup = aMEDGroup;
          aGroup->myName = aSupportName.in();
          aGroup->myMeshName = aMeshName.in();
          VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet;
-
+         
          SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();
          int iFamilyEnd = aFamilies->length();
          for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){
@@ -643,14 +658,20 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
            if(aFamily){
              TFamilyAndEntity aFamilyAndEntity(aFamilyName.in(),aFamily->myEntity);
              aFamilyAndEntitySet.insert(aFamilyAndEntity);
-
+             
              aGroup->myNbCells += aFamily->myNbCells;
              aGroup->myCellsSize += aFamily->myCellsSize;
-
+             
              VISU::TBindGroups& aBindGroups = aFamily->myGroups;
              aBindGroups.insert(aSupportName.in());
            }
          }
+         
+         if(!aGroup->myFamilyAndEntitySet.empty()){
+           TGroupMap& aGroupMap = aMesh->myGroupMap;
+           aGroupMap[aSupportName.in()] = aGroup;
+         }
+
        }
       }
     }
@@ -899,15 +920,21 @@ VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh,
   SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
   int iNumElemEnd = aMedMesh->getNumberOfNodes();
   TMeshImpl::TPointsCoord& aPointsCoord = theMesh->myPointsCoord;
+
   if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<<iNumElemEnd);
-  if (iNumElemEnd <= 0) throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
+
+  if (iNumElemEnd <= 0) 
+    throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
+
   aPointsCoord.resize(theMesh->myDim*iNumElemEnd,0.0);
   SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
   if(!isPointsLoaded){
     for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) 
       for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iNumElem2Dim++)
        aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim];
+
     if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
+
     TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX];
     aConnForCellType.resize(iNumElemEnd);
     for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
@@ -915,20 +942,29 @@ VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh,
   }
   if(aFamily){
     if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh");
+
     SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
+    CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
     TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX];
-    SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
-    SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
-    int iNumElemEndTmp = iNumElemEnd;
-    iNumElemEnd = aCellNumForType->length();
-    for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
-      int tmp = aCellNumForType[iNumElem]-1;
-      if(0 > tmp || tmp >= iNumElemEndTmp) {
-       static QString aString;
-       aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp);
-       throw std::runtime_error(aString.latin1());
+
+    if(!anIsOnAllElements){
+      SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
+      SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
+      int iNumElemEndTmp = iNumElemEnd;
+      iNumElemEnd = aCellNumForType->length();
+      for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
+       int tmp = aCellNumForType[iNumElem]-1;
+       if(0 > tmp || tmp >= iNumElemEndTmp) {
+         static QString aString;
+         aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp);
+         throw std::runtime_error(aString.latin1());
+       }
+       aSubMeshOnCellType.insert(tmp);
+      }
+    }else{
+      for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++){
+       aSubMeshOnCellType.insert(iNumElem);
       }
-      aSubMeshOnCellType.insert(tmp);
     }
   }
   return 1;
@@ -1023,29 +1059,43 @@ VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh,
   //Filling aFamily SubMesh
   if(aFamily){
     SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
-    SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes();
-    iGeomEnd = aGeoms->length();
-    if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomEnd = "<<iGeomEnd);
-    for (int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
-      SALOME_MED::medGeometryElement aGeom = aGeoms[iGeom];
-      SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom);
-      int aVGeom = MEDGeomToVTK(aGeom);
-      TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom]; 
-      int iNumElemEndTmp = theMeshOnEntity->myCellsConn[aVGeom].size();
-      int iNumElemEnd = aCellNumForType->length();
-      int aCounter = theMeshOnEntity->myCellsFirstIndex[aGeom].first;
-      if(MYDEBUG) 
-       MESSAGE("LoadCellsOnEntity - aGeom = "<<aGeom<<
-               "; iNumElemEnd = "<<iNumElemEnd<<
-               "; aCounter = "<<aCounter);
-      for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
-       int tmp = aCellNumForType[iNumElem]-aCounter-1;
-       if(0 > tmp || tmp >= iNumElemEndTmp) {
-         static QString aString;
-         aString.sprintf("LoadCellsOnEntity >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp);
-         throw std::runtime_error(aString.latin1());
+    CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
+    if(!anIsOnAllElements){
+      SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes();
+      iGeomEnd = aGeoms->length();
+      if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomEnd = "<<iGeomEnd);
+      for (int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
+       SALOME_MED::medGeometryElement aGeom = aGeoms[iGeom];
+       SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom);
+       int aVGeom = MEDGeomToVTK(aGeom);
+       TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom]; 
+       int iNumElemEndTmp = theMeshOnEntity->myCellsConn[aVGeom].size();
+       int iNumElemEnd = aCellNumForType->length();
+       int aCounter = theMeshOnEntity->myCellsFirstIndex[aGeom].first;
+       if(MYDEBUG) 
+         MESSAGE("LoadCellsOnEntity - aGeom = "<<aGeom<<
+                 "; iNumElemEnd = "<<iNumElemEnd<<
+                 "; aCounter = "<<aCounter);
+       for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
+         int tmp = aCellNumForType[iNumElem]-aCounter-1;
+         if(0 > tmp || tmp >= iNumElemEndTmp) {
+           static QString aString;
+           aString.sprintf("LoadCellsOnEntity >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp);
+           throw std::runtime_error(aString.latin1());
+         }
+         aSubMeshOnCellType.insert(tmp);
        }
-       aSubMeshOnCellType.insert(tmp);
+      }
+    }else{
+      const TMeshOnEntityImpl::TCellsConn& aCellsConn = theMeshOnEntity->myCellsConn;
+      TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
+      for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
+       int aVGeom = aCellsConnIter->first;
+       const TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConnIter->second;
+       TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom];
+       int iNumElemEnd = aConnForCellType.size();
+       for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
+         aSubMeshOnCellType.insert(iNumElem);
       }
     }
   }