]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To introduce new way of points coordinates handling - special structures TPointCoords...
authorapo <apo@opencascade.com>
Thu, 28 Jul 2005 05:11:36 +0000 (05:11 +0000)
committerapo <apo@opencascade.com>
Thu, 28 Jul 2005 05:11:36 +0000 (05:11 +0000)
Also, corresponding Gauss Points structures will be created only when there is a corresponding MED::GaussInfo for the TimeStampInfo

src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.hxx

index 4a9002340c0a887891ed510e319540dd63782c49..c48b9233e35c133d48588615cd1d3fe543a18db9 100644 (file)
@@ -270,9 +270,6 @@ namespace
     for(; anIter != aGeom2Size.end(); anIter++){
       EGeometrieElement aMGeom = anIter->first;
       vtkIdType aVGeom = MEDGeomToVTK(aMGeom);
-      vtkIdType aVNbNodes = VTKGeom2NbNodes(aVGeom);
-
-      PMEDGaussSubMesh aGaussSubMesh(new TMEDGaussSubMesh());
 
       TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aVGeom);
       if(anIter2 == aGeom2SubProfile.end()){
@@ -280,30 +277,28 @@ namespace
        continue;
       }
 
-      PMEDSubProfile aSubProfile = anIter2->second;
-      aGaussSubMesh->mySubProfile = aSubProfile;
-      aGaussSubMesh->myStatus = aSubProfile->myStatus;
-
-      PMEDGauss aGauss(new TMEDGauss());
-      aGaussSubMesh->myGauss = aGauss;
-      aGauss->myGeom = aVGeom;
-
-      std::string aName;
-      TInt aNbGauss = 0;
-
       TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(aMGeom);
       if(aTimeStampIter != theGeom2Size.end()){
        TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
-       TInt aNbCells = aTimeStampIter->second;
        if(aGaussIter != aGeom2Gauss.end()){
-         PGaussInfo aGaussInfo = aGaussIter->second;
+         PMEDGaussSubMesh aGaussSubMesh(new TMEDGaussSubMesh());
+         
+         PMEDSubProfile aSubProfile = anIter2->second;
+         aGaussSubMesh->mySubProfile = aSubProfile;
+         aGaussSubMesh->myStatus = aSubProfile->myStatus;
+         
+         PMEDGauss aGauss(new TMEDGauss());
+         aGaussSubMesh->myGauss = aGauss;
+         aGauss->myGeom = aVGeom;
 
+         PGaussInfo aGaussInfo = aGaussIter->second;
          aGauss->myGaussInfo = aGaussInfo;
 
-         aName = aGaussInfo->GetName();
+         std::string aName = aGaussInfo->GetName();
          aGauss->myName = aName;
 
-         aNbGauss = aGaussInfo->GetNbGauss();
+         TInt aNbCells = aTimeStampIter->second;
+         TInt aNbGauss = aGaussInfo->GetNbGauss();
          aGauss->myNbPoints = aNbGauss;
 
          aGaussSubMesh->myNbCells = aNbCells*aNbGauss;
@@ -714,7 +709,7 @@ VISU_MedConvertor
            const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
            const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
            TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
-           for (; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
+           for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
              const string& aName = aFamilyMapIter->first;
              aFamily = aFamilyMapIter->second;
              if(aName == aFamilyName){
@@ -831,52 +826,64 @@ VISU_MedConvertor
     VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
     aMeshOnEntity->myEntity = VISU::NODE_ENTITY;
     aMeshOnEntity->myMeshName = theMesh->myName;
-    PFamilyImpl aFamily = GetFamily(aMeshOnEntity,theFamilyName);
+    PMEDFamily aFamily = GetFamily(aMeshOnEntity,theFamilyName);
+
     //Check on loading already done
-    bool isPointsLoaded = !theMesh->myPointsCoord.empty();
-    if(isPointsLoaded) 
+    if(theMesh->myIsMEDDone)
       if(!aFamily) 
        return 0;
-      else if(!aFamily->myGeom2SubMeshID.empty()
+      else if(!aFamily->myIsMEDDone
        return 0;
 
-    INITMSG(MYDEBUG,"LoadPoints - isPointsLoaded = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'\n");
+    INITMSG(MYDEBUG,"LoadPoints - theMesh->myIsMEDDone = "<<theMesh->myIsMEDDone<<
+           "; theFamilyName = '"<<theFamilyName<<"'\n");
 
     //Main part of code
     PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
     TInt aNbElem = aNodeInfo->GetNbElem();
 
-    if(!isPointsLoaded){
-      VISU::TMeshImpl::TPointsDim&  aPointsDim = theMesh->myPointsDim;
-      aPointsDim.resize(theMesh->myDim);
-      for(int iDim = 0; iDim < theMesh->myDim; iDim++)
-       aPointsDim[iDim] = aNodeInfo->GetCoordName(iDim);
-      
-      VISU::TPointsCoord& aPointsCoord = theMesh->myPointsCoord;
-      aPointsCoord.resize(aNbElem*theMesh->myDim);
-      for (int iElem = 0; iElem < aNbElem; iElem++) 
-       for(int iDim = 0, iElem2Dim = iElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iElem2Dim++)
-         aPointsCoord[iElem2Dim] = aNodeInfo->GetNodeCoord(iElem,iDim);
+    if(!theMesh->myIsMEDDone){
+      TInt aDim = theMesh->myDim;
+
+      TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+      aCoords.Init(aNbElem,aDim);
+
+      for(int iDim = 0; iDim < aDim; iDim++)
+       aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim);
       
+      for(int iElem = 0; iElem < aNbElem; iElem++){
+       VISU::TCoordSlice aCoordSlice = aCoords.GetCoordSlice(iElem);
+       for(int iDim = 0; iDim < aDim; iDim++)
+         aCoordSlice[iDim] = aNodeInfo->GetNodeCoord(iElem,iDim);
+      }
+
       VISU::TCell2Connect& aConnForCellType = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX];
       aConnForCellType.resize(aNbElem);
       for (int iElem = 0; iElem < aNbElem; iElem++)
-       aConnForCellType[iElem] = VISU::TConnect(1,iElem);
+       aConnForCellType[iElem] = VISU::TConnect(1,iElem);
+      
+      theMesh->myIsMEDDone = true;
     }
-    if(aFamily && aNbElem > 0){
-      VISU::TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX];
-      for (int iElem = 0; iElem < aNbElem; iElem++) 
-       if(aNodeInfo->GetFamNum(iElem) == aFamily->myId)
-         aSubMeshID.push_back(iElem);
+
+    if(aFamily){
+      if(!aFamily->myIsMEDDone){
+       if(aNbElem > 0){
+         VISU::TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX];
+         for (int iElem = 0; iElem < aNbElem; iElem++) 
+           if(aNodeInfo->GetFamNum(iElem) == aFamily->myId)
+             aSubMeshID.push_back(iElem);
+       }
+       aFamily->myIsMEDDone = true;
+      }
     }
+
     return 1;
   }catch(std::exception& exc){
-    theMesh->myPointsCoord.clear();
     throw;
   }catch(...){
-    theMesh->myPointsCoord.clear();
     EXCEPTION(runtime_error,"Unknown exception !!!");
   }
+
   return 0;
 }
 
@@ -1185,18 +1192,18 @@ LoadGaussMesh(const MED::PWrapper& theMed,
                               aGaussCoord);
 
        if(TInt aNbGauss = aGaussCoord.GetNbGauss()){
-         TPoints& aPoints = aGaussSubMesh->myPoints;
+         TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
          TInt aNbElem = aGaussCoord.GetNbElem();
          TInt aDim = aGaussCoord.GetDim();
          vtkIdType aNbCells = aNbElem*aNbGauss;
-         aPoints.Init(aNbCells,aDim);
-         for(TInt anElemId = 0, aCellId = 0; anElemId < aNbElem; anElemId++){
+         aCoords.Init(aNbCells,aDim);
+         for(TInt anElemId = 0, aNodeId = 0; anElemId < aNbElem; anElemId++){
            TCoordSliceArr aCoordSliceArr = aGaussCoord.GetCoordSliceArr(anElemId);
-           for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++, aCellId++){
-             TPointSlice aPointSlice = aPoints.GetPointSlice(aCellId);
-             TCoordSlice aCoordSlice = aCoordSliceArr[aGaussId];
+           for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++, aNodeId++){
+             VISU::TCoordSlice aSlice = aCoords.GetCoordSlice(aNodeId);
+             MED::TCoordSlice aCoordSlice = aCoordSliceArr[aGaussId];
              for(TInt aDimId = 0; aDimId < aDim; aDimId++)
-               aPointSlice[aDimId] = aCoordSlice[aDimId];
+               aSlice[aDimId] = aCoordSlice[aDimId];
            }
          }
 
index 557e1b240f1d6b6154caef6568e97706ce3ea945..ffa3c24c83aa79084e3c1ccb0f1a1c42e011165c 100644 (file)
@@ -15,8 +15,8 @@
 
 #include <qfileinfo.h>
 
-namespace VISU{
-
+namespace VISU
+{
   //---------------------------------------------------------------
   struct TIsMEDDone: virtual TBaseStructure
   {
@@ -28,7 +28,7 @@ namespace VISU{
 
   
   //---------------------------------------------------------------
-  struct TMEDMesh: virtual TMeshImpl
+  struct TMEDMesh: virtual TMeshImpl, virtual TIsMEDDone
   {
     MED::PMeshInfo myMeshInfo;
     MED::TEntityInfo myEntityInfo;
@@ -79,7 +79,7 @@ namespace VISU{
 
 
   //---------------------------------------------------------------
-  struct TMEDFamily: virtual TFamilyImpl
+  struct TMEDFamily: virtual TFamilyImpl, virtual TIsMEDDone
   {};
   typedef SharedPtr<TMEDFamily> PMEDFamily;