]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Improve Gauss Mesh data structure. Next step
authorapo <apo@opencascade.com>
Thu, 21 Jul 2005 11:42:11 +0000 (11:42 +0000)
committerapo <apo@opencascade.com>
Thu, 21 Jul 2005 11:42:11 +0000 (11:42 +0000)
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_Convertor_impl.hxx
src/CONVERTOR/VISU_MedConvertor.cxx

index f1a7cc744eaa06b40b40544f305e6bad5560e250..bb55d5e630c365c8372beb0a82f66002404db425 100644 (file)
@@ -57,8 +57,8 @@ static float ERR_SIZE_CALC = 1.00;
 static int MYVTKDEBUG = 0;
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
-static int MYDEBUGWITHFILES = 1;
+static int MYDEBUG = 0;
+static int MYDEBUGWITHFILES = 0;
 #else
 static int MYDEBUG = 0;
 static int MYDEBUGWITHFILES = 0;
@@ -67,7 +67,7 @@ static int MYDEBUGWITHFILES = 0;
 
 namespace VISU
 {
-
+  //---------------------------------------------------------------
   TSource::TSource():
     myNbCells(0),
     myCellsSize(0),
@@ -78,6 +78,7 @@ namespace VISU
   }
 
 
+  //---------------------------------------------------------------
   TMeshImpl::TMeshImpl():
     myPoints(vtkPoints::New()),
     myIsInitialized(false),
@@ -86,6 +87,8 @@ namespace VISU
     myPoints->Delete();
   }
 
+
+  //---------------------------------------------------------------
   TSubProfileImpl::TSubProfileImpl():
     myStatus(eNone)
   {
@@ -93,22 +96,7 @@ namespace VISU
   }
 
 
-  bool
-  TGaussSubMeshLess::
-  operator()(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) const
-  {
-    PGaussImpl aLeft(theLeft->myGauss), aRight(theRight->myGauss);
-
-    if(aLeft->myGeom != aRight->myGeom)
-      return aLeft->myGeom < aRight->myGeom;
-
-    if(aLeft->myName != aRight->myName)
-      return aLeft->myName < aRight->myName;
-
-    return TSubProfileLess()(theLeft->mySubProfile,theRight->mySubProfile);
-  }
-
-
+  //---------------------------------------------------------------
   bool
   TSubProfileLess
   ::operator()(const PSubProfile& theLeft, const PSubProfile& theRight) const
@@ -120,6 +108,7 @@ namespace VISU
   }
 
 
+  //---------------------------------------------------------------
   TProfileImpl::TProfileImpl():
     myIsAll(true),
     myIsInitialized(false),
@@ -129,11 +118,37 @@ namespace VISU
   }
 
 
+  //---------------------------------------------------------------
   TGaussSubMeshImpl::TGaussSubMeshImpl():
     myStatus(eNone)
   {}
   
 
+  //---------------------------------------------------------------
+  bool
+  TGaussSubMeshLess::
+  operator()(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) const
+  {
+    PGaussImpl aLeft(theLeft->myGauss), aRight(theRight->myGauss);
+
+    if(aLeft->myGeom != aRight->myGeom)
+      return aLeft->myGeom < aRight->myGeom;
+
+    if(aLeft->myName != aRight->myName)
+      return aLeft->myName < aRight->myName;
+
+    return TSubProfileLess()(theLeft->mySubProfile,theRight->mySubProfile);
+  }
+
+
+  //---------------------------------------------------------------
+  TGaussMeshImpl
+  ::TGaussMeshImpl():
+    myIsInitialized(false)
+  {}
+
+
+  //---------------------------------------------------------------
   pair<int,int> 
   TMeshOnEntityImpl
   ::GetCellsDims(const string& theFamilyName) const
@@ -151,6 +166,7 @@ namespace VISU
   }
   
 
+  //---------------------------------------------------------------
   int
   TValForTimeImpl
   ::GetNbGauss(vtkIdType theGeom) const
@@ -164,6 +180,7 @@ namespace VISU
   }
 
 
+  //---------------------------------------------------------------
   vtkIdType
   VTKGeom2NbNodes(vtkIdType theGeom)
   { 
@@ -184,6 +201,7 @@ namespace VISU
 
 namespace
 {
+  //---------------------------------------------------------------
   template<class T> 
   std::string 
   dtos(const std::string& fmt, T val)
@@ -193,6 +211,8 @@ namespace
     return aString.latin1();
   }
 
+
+  //---------------------------------------------------------------
   enum ECoordName{eX, eY, eZ, eNone};
   typedef VISU::TCoord (*TGetCoord)(const VISU::TMeshImpl::TPointsCoord&, int);
   
index 09a8e3e866708f9fc0c040584ef7416385b018b4..6cadc0ba4111de17b8f6dfefc5cfb26c1b3e6ce0 100644 (file)
@@ -81,6 +81,7 @@ namespace VISU
 
   //---------------------------------------------------------------
   typedef std::map<vtkIdType,PSubProfile> TGeom2SubProfile;
+
   struct TProfileImpl: virtual TProfile
   {
     TProfileImpl();
@@ -117,8 +118,15 @@ namespace VISU
 
 
   //---------------------------------------------------------------
+  typedef std::map<vtkIdType,PGaussSubMesh> TGeom2GaussSubMesh;
+
   struct TGaussMeshImpl: virtual TGaussMesh
-  {};
+  {
+    TGaussMeshImpl();
+
+    bool myIsInitialized;
+    TGeom2GaussSubMesh myGeom2GaussSubMesh;
+  };
 
 
   //---------------------------------------------------------------
index 38c8266061b083f0703726ae11e3686b706d772a..10af20dc2a3bfff41a250f79e6a9522f09c1a3f2 100644 (file)
@@ -179,33 +179,105 @@ namespace{
   }
 
 
+  //---------------------------------------------------------------
+  TProfileKey
+  GetProfileKey(const MED::TTimeStampVal& theTimeStampVal,
+               const VISU::TMEDMeshOnEntity& theMeshOnEntity,
+               const MED::TGeom2Size& theGeom2Size)
+  {
+    INITMSG(MYDEBUG,"GetProfileKey"<<endl);
+    
+    TProfileKey aProfileKey;
+    const TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
+
+    const TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
+    TGeom2Size::const_iterator anIter = aGeom2Size.begin();
+    for(; anIter != aGeom2Size.end(); anIter++){
+      EGeometrieElement aMGeom = anIter->first;
+      PSubProfile aSubProfile = CrSubProfile(aMGeom,theGeom2Size,aGeom2Profile);
+      aProfileKey.insert(aSubProfile);
+    }
+    
+    return aProfileKey;
+  }
+  
+
+  //---------------------------------------------------------------
+  void
+  InitProfile(MED::TTimeStampVal& theTimeStampVal,
+             VISU::TMEDMeshOnEntity& theMeshOnEntity,
+             const MED::TGeom2Size& theGeom2Size,
+             VISU::TMEDValForTime& theValForTime)
+  {
+    INITMSG(MYDEBUG,"InitProfile"<<endl);
+    
+    TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
+    
+    TProfileKey aProfileKey = GetProfileKey(theTimeStampVal,
+                                           theMeshOnEntity,
+                                           theGeom2Size);
+    
+    TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
+    if(anIter != aProfileMap.end()){
+      theValForTime.myProfile = anIter->second;
+    }else{
+      PMEDProfile aProfile(new TMEDProfile());
+      TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+      
+      TProfileKey::const_iterator anIter = aProfileKey.begin();
+      for(; anIter != aProfileKey.end(); anIter++){
+       PMEDSubProfile aSubProfile(*anIter);
+
+       if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll)
+         aProfile->myIsAll = false;
+
+       vtkIdType aVGeom = aSubProfile->myGeom;
+       aGeom2SubProfile[aVGeom] = aSubProfile;
+      }
+      aProfileMap[aProfileKey] = aProfile;
+      theValForTime.myProfile = aProfile;
+    }
+  }
+
+
   //---------------------------------------------------------------
   TGaussKey
   GetGaussKey(const MED::TTimeStampVal& theTimeStampVal,
              const VISU::TMEDMeshOnEntity& theMeshOnEntity,
-             const MED::TGeom2Size& theGeom2Size)
+             const MED::TGeom2Size& theGeom2Size,
+             VISU::TMEDValForTime& theValForTime)
   {
     INITMSG(MYDEBUG,"GetGaussKey"<<endl);
 
+    PMEDProfile aProfile = theValForTime.myProfile;
+    TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+
     TGaussKey aGaussKey;
     const TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
     const TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
     const TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
+
     const TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
     TGeom2Size::const_iterator anIter = aGeom2Size.begin();
     for(; anIter != aGeom2Size.end(); anIter++){
       EGeometrieElement aMGeom = anIter->first;
+      vtkIdType aVGeom = MEDGeomToVTK(aMGeom);
+      vtkIdType aVNbNodes = VTKGeom2NbNodes(aVGeom);
+
       PMEDGaussSubMesh aGaussSubMesh(new TMEDGaussSubMesh());
       aGaussSubMesh->myStatus = eAddAll;
 
-      PSubProfile aSubProfile = CrSubProfile(aMGeom,theGeom2Size,aGeom2Profile);
-      aGaussSubMesh->mySubProfile = aSubProfile;
+      TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aVGeom);
+      if(anIter2 == aGeom2SubProfile.end()){
+       INITMSG(MYDEBUG,"anIter2 == aGeom2SubProfile.end!!"<<endl);
+       continue;
+      }
+
+      aGaussSubMesh->mySubProfile = anIter2->second;
  
       PMEDGauss aGauss(new TMEDGauss());
       aGaussSubMesh->myGauss = aGauss;
 
-      vtkIdType aVGeom = MEDGeomToVTK(aMGeom);
-      vtkIdType aVNbNodes = VTKGeom2NbNodes(aVGeom);
       aGauss->myGeom = aVGeom;
 
       std::string aName;
@@ -252,68 +324,57 @@ namespace{
   }
 
 
-  //---------------------------------------------------------------
-  TProfileKey
-  GetProfileKey(const MED::TTimeStampVal& theTimeStampVal,
-               const VISU::TMEDMeshOnEntity& theMeshOnEntity,
-               const MED::TGeom2Size& theGeom2Size)
-  {
-    INITMSG(MYDEBUG,"GetProfileKey"<<endl);
-    
-    TProfileKey aProfileKey;
-    const TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
-
-    const TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
-    TGeom2Size::const_iterator anIter = aGeom2Size.begin();
-    for(; anIter != aGeom2Size.end(); anIter++){
-      EGeometrieElement aMGeom = anIter->first;
-      PSubProfile aSubProfile = CrSubProfile(aMGeom,theGeom2Size,aGeom2Profile);
-      aProfileKey.insert(aSubProfile);
-    }
-    
-    return aProfileKey;
-  }
-  
-
   //---------------------------------------------------------------
   void
-  InitProfile(MED::TTimeStampVal& theTimeStampVal,
-             VISU::TMEDValForTime& theValForTime,
-             VISU::TMEDMeshOnEntity& theMeshOnEntity,
-             const MED::TGeom2Size& theGeom2Size)
+  InitGaussMesh(MED::TTimeStampVal& theTimeStampVal,
+               VISU::TMEDMeshOnEntity& theMeshOnEntity,
+               const MED::TGeom2Size& theGeom2Size,
+               VISU::TMEDValForTime& theValForTime)
   {
-    INITMSG(MYDEBUG,"InitProfile"<<endl);
+    INITMSG(MYDEBUG,"InitGaussMesh"<<endl);
     
-    TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
+    TGaussMeshMap& aGaussMeshMap = theMeshOnEntity.myGaussMeshMap;
     
-    TProfileKey aProfileKey = GetProfileKey(theTimeStampVal,
-                                           theMeshOnEntity,
-                                           theGeom2Size);
-    
-    TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
-    if(anIter != aProfileMap.end()){
-      theValForTime.myProfile = anIter->second;
+    TGaussKey aGaussKey = GetGaussKey(theTimeStampVal,
+                                     theMeshOnEntity,
+                                     theGeom2Size,
+                                     theValForTime);
+
+    TGaussMeshMap::const_iterator anIter = aGaussMeshMap.find(aGaussKey);
+    if(anIter != aGaussMeshMap.end()){
+      theValForTime.myGaussMesh = anIter->second;
     }else{
-      PMEDProfile aProfile(new TMEDProfile());
-      TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+      PMEDGaussMesh aGaussMesh(new TMEDGaussMesh());
+      TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
       
-      TProfileKey::const_iterator anIter = aProfileKey.begin();
-      for(; anIter != aProfileKey.end(); anIter++){
-       PMEDSubProfile aSubProfile(*anIter);
-
-       if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll)
-         aProfile->myIsAll = false;
-
-       vtkIdType aVGeom = aSubProfile->myGeom;
-       aGeom2SubProfile[aVGeom] = aSubProfile;
+      TGaussKey::const_iterator anIter = aGaussKey.begin();
+      for(; anIter != aGaussKey.end(); anIter++){
+       PMEDGaussSubMesh aGaussSubMesh(*anIter);
+       PMEDGauss aGauss = aGaussSubMesh->myGauss;
+       vtkIdType aVGeom = aGauss->myGeom;
+       aGeom2GaussSubMesh[aVGeom] = aGaussSubMesh;
       }
-      aProfileMap[aProfileKey] = aProfile;
-      theValForTime.myProfile = aProfile;
+      aGaussMeshMap[aGaussKey] = aGaussMesh;
+      theValForTime.myGaussMesh = aGaussMesh;
     }
   }
 
+
+  //---------------------------------------------------------------
+  void
+  InitGaussProfile(MED::TTimeStampVal& theTimeStampVal,
+                  VISU::TMEDMeshOnEntity& theMeshOnEntity,
+                  const MED::TGeom2Size& theGeom2Size,
+                  VISU::TMEDValForTime& theValForTime)
+  {
+    // The order of the function calls is important
+    InitProfile(theTimeStampVal,theMeshOnEntity,theGeom2Size,theValForTime);
+    InitGaussMesh(theTimeStampVal,theMeshOnEntity,theGeom2Size,theValForTime);
+  }
 }
 
+
+//---------------------------------------------------------------
 extern "C"
 VISU_Convertor* 
 CreateConvertor(const string& theFileName)
@@ -328,6 +389,8 @@ VISU_MedConvertor
   myName = myFileInfo.baseName().latin1();
 }
 
+
+//---------------------------------------------------------------
 VISU_Convertor* 
 VISU_MedConvertor
 ::Build()
@@ -666,14 +729,10 @@ VISU_MedConvertor
          aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
          INITMSG(MYDEBUG,"aDt = "<<aDt<<", "<<anUnitDt<<"\n");
 
-         GetGaussKey(aTimeStampVal,
-                     aMeshOnEntity,
-                     aGeom2Size);
-
-         InitProfile(aTimeStampVal,
-                     aValForTime,
-                     aMeshOnEntity,
-                     aGeom2Size);
+         InitGaussProfile(aTimeStampVal,
+                          aMeshOnEntity,
+                          aGeom2Size,
+                          aValForTime);
          
          TGaussMap& aGaussMap = aValForTime->myGaussMap;
          const TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
@@ -697,6 +756,8 @@ VISU_MedConvertor
   return this; 
 }
 
+
+//---------------------------------------------------------------
 int
 VISU_MedConvertor
 ::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, 
@@ -717,6 +778,7 @@ VISU_MedConvertor
 }
 
 
+//---------------------------------------------------------------
 int
 VISU_MedConvertor
 ::LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
@@ -741,6 +803,8 @@ VISU_MedConvertor
   return (isPointsUpdated || isCellsOnEntityUpdated);
 }
 
+
+//---------------------------------------------------------------
 int
 VISU_MedConvertor
 ::LoadFieldOnMesh(VISU::PMeshImpl theMesh, 
@@ -757,6 +821,7 @@ VISU_MedConvertor
 }
 
 
+//---------------------------------------------------------------
 int 
 VISU_MedConvertor
 ::LoadPoints(const MED::PWrapper& theMed,
@@ -818,6 +883,7 @@ VISU_MedConvertor
 }
 
 
+//---------------------------------------------------------------
 int 
 VISU_MedConvertor
 ::LoadCellsOnEntity(const MED::PWrapper& theMed, 
@@ -1015,6 +1081,7 @@ VISU_MedConvertor
 }
 
 
+//---------------------------------------------------------------
 void
 LoadProfile(MED::TTimeStampVal& theTimeStampVal,
            VISU::TMEDValForTime& theValForTime,
@@ -1039,7 +1106,8 @@ LoadProfile(MED::TTimeStampVal& theTimeStampVal,
       PMEDSubProfile aSubProfile = anIter2->second;
       aSubProfile->mySubMeshID = aProfileInfo->myElemNum;
 
-      INITMSG(MYDEBUG,"aVGeom = "<<aVGeom<<
+      INITMSG(MYDEBUG,
+             "- aVGeom = "<<aVGeom<<
              "; aNbCells = "<<aSubProfile->mySubMeshID.size()<<
              endl);
     }
@@ -1047,6 +1115,42 @@ LoadProfile(MED::TTimeStampVal& theTimeStampVal,
 }
 
 
+//---------------------------------------------------------------
+void
+LoadGaussMesh(MED::TTimeStampVal& theTimeStampVal,
+             VISU::TMEDValForTime& theValForTime,
+             VISU::TMEDMeshOnEntity& theMeshOnEntity)
+{
+  INITMSG(MYDEBUG,"LoadGaussMesh"<<endl);
+
+  PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh;
+  if(aGaussMesh->myIsInitialized)
+    return;
+
+  const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
+  const TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
+  const TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
+  TGeom2Gauss::const_iterator anIter = aGeom2Gauss.begin();
+  for(; anIter != aGeom2Gauss.end(); anIter++){
+    MED::PGaussInfo aGaussInfo = anIter->second;
+    MED::EGeometrieElement aMGeom = anIter->first;
+    vtkIdType aVGeom = MEDGeomToVTK(aMGeom);
+
+    TGeom2GaussSubMesh::const_iterator anIter2 = aGeom2GaussSubMesh.find(aVGeom);
+    if(anIter2 != aGeom2GaussSubMesh.end()){
+      PMEDGaussSubMesh aGaussSubMesh = anIter2->second;
+      PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile;
+
+      INITMSG(MYDEBUG,
+             "- aVGeom = "<<aVGeom<<
+             "; aNbCells = "<<aSubProfile->mySubMeshID.size()<<
+             endl);
+    }
+  }
+}
+
+
+//---------------------------------------------------------------
 int 
 VISU_MedConvertor
 ::LoadField(const MED::PWrapper& theMed,
@@ -1092,6 +1196,10 @@ VISU_MedConvertor
              theValForTime,
              theMeshOnEntity);
   
+  LoadGaussMesh(aTimeStampVal,
+               theValForTime,
+               theMeshOnEntity);
+  
   PMEDProfile aProfile = theValForTime->myProfile;
   TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;