]> 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:12:19 +0000 (05:12 +0000)
committerapo <apo@opencascade.com>
Thu, 28 Jul 2005 05:12:19 +0000 (05:12 +0000)
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_Convertor_impl.hxx
src/VISU_I/VISU_CorbaMedConvertor.cxx
src/VISU_I/VISU_CorbaMedConvertor.hxx

index aab17891cae84e8ccd089c9f2b6b15cea420df00..95381c6da36da1adf547996f5f0138c9f06e6843 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 = 0;
+static int MYDEBUG = 0;
+static int MYDEBUGWITHFILES = 1;
 #else
 static int MYDEBUG = 0;
 static int MYDEBUGWITHFILES = 0;
@@ -68,9 +68,20 @@ static int MYDEBUGWITHFILES = 0;
 namespace VISU
 {
   //---------------------------------------------------------------
-  TSource::TSource():
+  TIsVTKDone::TIsVTKDone(): 
+    myIsVTKDone(false)
+  {}
+
+
+  //---------------------------------------------------------------
+  TSizeCounter::TSizeCounter():
     myNbCells(0),
-    myCellsSize(0),
+    myCellsSize(0)
+  {}
+
+
+  //---------------------------------------------------------------
+  TSource::TSource():
     mySource(vtkUnstructuredGrid::New())
   {
     mySource->Delete();
@@ -78,30 +89,70 @@ namespace VISU
 
 
   //---------------------------------------------------------------
+  TAppendFilter::TAppendFilter():
+    myFilter(vtkAppendFilter::New())
+  {
+    myFilter->Delete();
+  }
+
+
+  //---------------------------------------------------------------
+  TPointCoords
+  ::TPointCoords():
+    myPoints(vtkPoints::New())
+  {
+    myPoints->Delete();
+  }
+
   void
-  TPoints
-  ::Init(vtkIdType theNbCells,
+  TPointCoords
+  ::Init(vtkIdType theNbPoints,
         vtkIdType theDim)
   {
     myDim = theDim;
-    myNbCells = theNbCells;
-    myCoord.resize(theNbCells*theDim);
+    myNbPoints = theNbPoints;
+    myCoord.resize(theNbPoints*theDim);
+    myPoints->SetNumberOfPoints(theNbPoints);
   }
 
-  TCPointSlice 
-  TPoints
-  ::GetPointSlice(vtkIdType theCellId) const
+  TCCoordSlice 
+  TPointCoords
+  ::GetCoordSlice(vtkIdType theNodeId) const
   {
-    return TCPointSlice(myCoord,std::slice(theCellId*myDim,myDim,1));
+    return TCCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
   }
   
-  TPointSlice 
-  TPoints
-  ::GetPointSlice(vtkIdType theCellId)
+  TCoordSlice 
+  TPointCoords
+  ::GetCoordSlice(vtkIdType theNodeId)
+  {
+    return TCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
+  }
+
+
+  //---------------------------------------------------------------
+  void
+  TNamedPointCoords
+  ::Init(vtkIdType theNbPoints,
+        vtkIdType theDim)
   {
-    return TPointSlice(myCoord,std::slice(theCellId*myDim,myDim,1));
+    TPointCoords::Init(theNbPoints,theDim);
+    myPointsDim.resize(theDim);
   }
 
+  std::string&
+  TNamedPointCoords
+  ::GetName(vtkIdType theDim)
+  {
+    return myPointsDim[theDim];
+  }
+
+  const std::string&
+  TNamedPointCoords
+  ::GetName(vtkIdType theDim) const
+  {
+    return myPointsDim[theDim];
+  }
 
   //---------------------------------------------------------------
   TMeshImpl::TMeshImpl():
@@ -135,11 +186,8 @@ namespace VISU
 
   //---------------------------------------------------------------
   TProfileImpl::TProfileImpl():
-    myIsAll(true),
-    myAppendFilter(vtkAppendFilter::New())
-  {
-    myAppendFilter->Delete();
-  }
+    myIsAll(true)
+  {}
 
 
   //---------------------------------------------------------------
@@ -239,20 +287,18 @@ namespace
 
   //---------------------------------------------------------------
   enum ECoordName{eX, eY, eZ, eNone};
-  typedef VISU::TCoord (*TGetCoord)(const VISU::TPointsCoord&, int);
+  typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice);
   
-  template<ECoordName TheCoordId>
+  template<ECoordName TCoordId>
   VISU::TCoord 
-  GetCoord(const VISU::TPointsCoord& thePointsCoord, 
-          int theStartPos)
+  GetCoord(const VISU::TCCoordSlice& theCoordSlice)
   {
-    return thePointsCoord[theStartPos+TheCoordId];
+    return theCoordSlice[TCoordId];
   }
   
   template<>
   VISU::TCoord 
-  GetCoord<eNone>(const VISU::TPointsCoord& thePointsCoord, 
-                 int theStartPos)
+  GetCoord<eNone>(const VISU::TCCoordSlice& theCoordSlice)
   {
     return 0.0;
   }
@@ -304,83 +350,87 @@ namespace
 
   
   class TCoordHelper{
-    const VISU::TPointsCoord& myPointsCoord;
     TGetCoord* myGetCoord;
   public:
-    TCoordHelper(const VISU::TPointsCoord& thePointsCoord,
-                TGetCoord* theGetCoord):
-      myPointsCoord(thePointsCoord),
+    TCoordHelper(TGetCoord* theGetCoord):
       myGetCoord(theGetCoord)
     {}
-    virtual ~TCoordHelper(){}
+
+    virtual
+    ~TCoordHelper()
+    {}
+
     VISU::TCoord 
-    GetCoord(int theStartPos, int theCoodId)
+    GetCoord(VISU::TCCoordSlice& theCoordSlice, 
+            int theCoordId)
     {
-      return (*myGetCoord[theCoodId])(myPointsCoord,theStartPos);
+      return (*myGetCoord[theCoordId])(theCoordSlice);
     }
   };
   typedef std::auto_ptr<TCoordHelper> TCoordHelperPtr;
   
 
+  //---------------------------------------------------------------
   void
   GetPoints(VISU::TVTKSource& theSource, 
            VISU::PMeshImpl theMesh) 
   {
     TVTKPoints& aPoints = theMesh->myPoints;
+    const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
 
     if(!theMesh->myIsVTKDone){
       TCoordHelperPtr aCoordHelperPtr;
-      const VISU::TPointsCoord& anArray = theMesh->myPointsCoord;
       {
        int aMeshDimension = theMesh->myDim;
        bool anIsDimPresent[3] = {false, false, false};
        for(int iDim = 0; iDim < aMeshDimension; iDim++){
-         string aDimName = theMesh->myPointsDim[iDim];
-         if(aDimName == "x" || aDimName == "X")
+         const std::string& aName = aCoords.GetName(iDim);
+         if(aName == "x" || aName == "X")
            anIsDimPresent[eX] = true;
-         else if(aDimName == "y" || aDimName == "Y")
+         else if(aName == "y" || aName == "Y")
            anIsDimPresent[eY] = true;
-         else if(aDimName == "z" || aDimName == "Z")
+         else if(aName == "z" || aName == "Z")
            anIsDimPresent[eZ] = true;
        }
 
        switch(aMeshDimension){
        case 3:
-         aCoordHelperPtr.reset(new TCoordHelper(anArray,aXYZGetCoord));
+         aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord));
          break;
        case 2:
          if(anIsDimPresent[eY] && anIsDimPresent[eZ])
-           aCoordHelperPtr.reset(new TCoordHelper(anArray,aYZGetCoord));
+           aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord));
          else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
-           aCoordHelperPtr.reset(new TCoordHelper(anArray,aXZGetCoord));
+           aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord));
          else
-           aCoordHelperPtr.reset(new TCoordHelper(anArray,aXYGetCoord));
+           aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord));
          break;
        case 1:
          if(anIsDimPresent[eY])
-           aCoordHelperPtr.reset(new TCoordHelper(anArray,aYGetCoord));
+           aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord));
          else if(anIsDimPresent[eZ])
-           aCoordHelperPtr.reset(new TCoordHelper(anArray,aZGetCoord));
+           aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord));
          else
-           aCoordHelperPtr.reset(new TCoordHelper(anArray,aXGetCoord));
+           aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord));
          break;
        }
       }
 
-      vtkIdType iEnd = theMesh->myPointsCoord.size();
-      vtkIdType aNbPoints = iEnd / theMesh->myDim;
+      vtkIdType aNbPoints = aCoords.GetNbPoints();
       aPoints->SetNumberOfPoints(aNbPoints);
-
+      
       INITMSG(MYDEBUG,"GetPoints - aNbPoints = "<<aNbPoints<<
              "; aDim = "<<theMesh->myDim<<
              endl);
 
-      for(vtkIdType i = 0, j = 0; i < iEnd; i += theMesh->myDim, j++) 
-       aPoints->SetPoint(j,
-                         aCoordHelperPtr->GetCoord(i,eX),
-                         aCoordHelperPtr->GetCoord(i,eY),
-                         aCoordHelperPtr->GetCoord(i,eZ));
-
+      for(vtkIdType aNodeId = 0; aNodeId < aNbPoints; aNodeId++){ 
+       TCCoordSlice aCoordSlice = aCoords.GetCoordSlice(aNodeId);
+       aPoints->SetPoint(aNodeId,
+                         aCoordHelperPtr->GetCoord(aCoordSlice,eX),
+                         aCoordHelperPtr->GetCoord(aCoordSlice,eY),
+                         aCoordHelperPtr->GetCoord(aCoordSlice,eZ));
+      }
+      
       theMesh->myIsVTKDone = true;
       if(MYVTKDEBUG) aPoints->DebugOn();
     }
@@ -389,6 +439,7 @@ namespace
   }
   
   
+  //---------------------------------------------------------------
   void
   PrintCells(int& theStartId,
             vtkCellArray* theConnectivity, 
@@ -403,6 +454,8 @@ namespace
     anIdList->Delete();
   }
 
+
+  //---------------------------------------------------------------
   void
   GetCellsOnEntity(VISU::TVTKSource& theSource,
                   const VISU::PMeshOnEntityImpl theMeshOnEntity, 
@@ -469,6 +522,7 @@ namespace
   } 
   
   
+  //---------------------------------------------------------------
   void
   GetCellsOnGroup(VISU::TVTKSource& theSource,
                  VISU::PMeshImpl theMesh,
@@ -536,12 +590,13 @@ namespace
   } 
   
   
+  //---------------------------------------------------------------
   void
-  GetTimeStamp3(vtkFloatArray *theFloatArray, 
-               const vtkIdType& theNumberOfTuples,
-               const std::string& theFieldName,
-               VISU::PFieldImpl theField,
-               VISU::PValForTimeImpl theValForTime)
+  GetTimeStampOnProfile2(vtkFloatArray *theFloatArray, 
+                        const vtkIdType& theNumberOfTuples,
+                        const std::string& theFieldName,
+                        VISU::PFieldImpl theField,
+                        VISU::PValForTimeImpl theValForTime)
   {
     //theFloatArray->DebugOn();
     theFloatArray->SetNumberOfTuples(theNumberOfTuples);
@@ -558,7 +613,7 @@ namespace
       int aStep = aNbComp*aNbGauss;
       int aNbElem = anArray.size()/aStep;
 
-      INITMSG(MYDEBUG,"GetTimeStamp3 - aGeom = "<<aGeom<<
+      INITMSG(MYDEBUG,"GetTimeStampOnProfile2 - aGeom = "<<aGeom<<
              "; aNbElem = "<<aNbElem<<
              "; aNbComp = "<<aNbComp<<
              "; aNbGauss = "<<aNbGauss<<
@@ -630,12 +685,14 @@ namespace
            theFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],aValue[2]);
          }
        else
-         EXCEPTION(runtime_error,"GetTimeStamp3 - There is no an algorithm for representation of the field !!!");
+         EXCEPTION(runtime_error,"GetTimeStampOnProfile2 - There is no an algorithm for representation of the field !!!");
        break;
       }
     }
   }
 
+
+  //---------------------------------------------------------------
   std::string
   GenerateFieldName(const VISU::PFieldImpl theField,
                    const VISU::PValForTimeImpl theValForTime)
@@ -646,14 +703,16 @@ namespace
     return aFieldName;
   }
 
+
+  //---------------------------------------------------------------
   void 
-  GetTimeStamp2(VISU::TVTKSource& theSource,
-               const VISU::PFieldImpl theField, 
-               const VISU::PValForTimeImpl theValForTime)
+  GetTimeStampOnProfile(VISU::TVTKSource& theSource,
+                       const VISU::PFieldImpl theField, 
+                       const VISU::PValForTimeImpl theValForTime)
   {
     int aNbTuples = theField->myDataSize/theField->myNbComp;
     string aFieldName = GenerateFieldName(theField,theValForTime);
-    INITMSG(MYDEBUG,"GetTimeStamp2 - aNbTuples = "<<aNbTuples<<endl);
+    INITMSG(MYDEBUG,"GetTimeStampOnProfile - aNbTuples = "<<aNbTuples<<endl);
     
     vtkDataSetAttributes* aDataSetAttributes;
     switch(theField->myEntity){
@@ -675,25 +734,261 @@ namespace
       aDataSetAttributes->SetVectors(aFloatArray);
     }
 
-    GetTimeStamp3(aFloatArray,
-                 aNbTuples,
-                 aFieldName,
-                 theField,
-                 theValForTime);
+    GetTimeStampOnProfile2(aFloatArray,
+                          aNbTuples,
+                          aFieldName,
+                          theField,
+                          theValForTime);
+  }
+
+
+  //---------------------------------------------------------------
+  void
+  GetCells(VISU::TVTKSource& theSource,
+          PSubProfileImpl theSubProfile,
+          PMeshOnEntityImpl theMeshOnEntity)
+  {
+    vtkIdType aNbCells = theSubProfile->myNbCells;
+    vtkIdType aCellsSize = theSubProfile->myCellsSize;
+    vtkIdType aGeom = theSubProfile->myGeom;
+    vtkIdType aNbNodes = VTKGeom2NbNodes(aGeom);
+    
+    const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
+    const TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect;
+    TGeom2Cell2Connect::const_iterator aConnectIter = aGeom2Cell2Connect.find(aGeom);
+    if(aConnectIter == aGeom2Cell2Connect.end())
+      EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<<aGeom<<")");
+    
+    const TCell2Connect& aCell2Connect = aConnectIter->second;
+    
+    vtkCellArray* aConnectivity = vtkCellArray::New();
+    aConnectivity->Allocate(aCellsSize,0);
+    vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+    aCellTypesArray->SetNumberOfComponents(1);
+    aCellTypesArray->SetNumberOfTuples(aNbCells);
+    
+    if(theSubProfile->myStatus == eAddAll){
+      VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
+      for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
+       const TConnect& anArray = aCell2Connect[anId];
+       PrintCells(aConnId,aConnectivity,anArray);
+       aCellTypesArray->SetValue(anId,(unsigned char)aGeom);
+       aConnId += aNbNodes;
+       anId++;
+      }
+    }else{
+      VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin();
+      for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){
+       vtkIdType aSubId = *anIter;
+       const TConnect& anArray = aCell2Connect[aSubId];
+       PrintCells(aConnId,aConnectivity,anArray);
+       aCellTypesArray->SetValue(anId,(unsigned char)aGeom);
+       aConnId += aNbNodes;
+       anId++;
+      }
+    }
+    
+    vtkIdType *pts = 0, npts = 0;
+    vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+    
+    aCellLocationsArray->SetNumberOfComponents(1);
+    aCellLocationsArray->SetNumberOfTuples(aNbCells);
+    aConnectivity->InitTraversal();
+    for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
+      aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
+    theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+    
+    aCellLocationsArray->Delete();
+    aCellTypesArray->Delete();
+    aConnectivity->Delete();
+  }
+  
+  
+  //---------------------------------------------------------------
+  void
+  GetMeshOnSubProfile(PMeshImpl theMesh,
+                     PMeshOnEntityImpl theMeshOnEntity,
+                     PProfileImpl theProfile,
+                     PSubProfileImpl theSubProfile)
+  {
+    INITMSG(MYDEBUG,"GetMeshOnSubProfile - aGeom = "<<theSubProfile->myGeom<<endl);
+    
+    TVTKSource& aSource = theSubProfile->mySource;
+    if(theSubProfile->myIsVTKDone)
+      return;
+    
+    GetPoints(aSource,theMesh);
+    INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
+    GetCells(aSource,theSubProfile,theMeshOnEntity);
+    BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
+    
+    theSubProfile->myIsVTKDone = true;
+  }
+  
+  
+  //---------------------------------------------------------------
+  void
+  GetMeshOnProfile(PMeshImpl theMesh,
+                  PMeshOnEntityImpl theMeshOnEntity,
+                  PProfileImpl theProfile)
+  {
+    if(theProfile->myIsVTKDone)
+      return;
+    
+    TVTKAppendFilter& anAppendFilter = theProfile->myFilter;
+    if(theProfile->myIsAll){
+      TVTKSource& aSource = theMeshOnEntity->mySource;
+      anAppendFilter->AddInput(aSource.GetPointer());
+    }else{
+      const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
+      TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
+      for(; anIter != aGeom2SubProfile.end(); anIter++){
+       PSubProfileImpl aSubProfile = anIter->second;
+       if(aSubProfile->myStatus == eRemoveAll)
+         continue;
+       
+       GetMeshOnSubProfile(theMesh,
+                           theMeshOnEntity,
+                           theProfile,
+                           aSubProfile);
+       
+       TVTKSource& aSource = aSubProfile->mySource;
+       anAppendFilter->AddInput(aSource.GetPointer());
+      }
+    }
+    anAppendFilter->Update(); // Fix on VTK
+    
+    theProfile->myIsVTKDone = true;
+  }
+  
+  
+  //---------------------------------------------------------------
+  void
+  GetSource(VISU::TVTKSource& theSource,
+           PGaussSubMeshImpl theGaussSubMesh,
+           PMeshOnEntityImpl theMeshOnEntity)
+  {
+    const TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
+    vtkIdType aNbPoints = aCoords.GetNbPoints();
+    vtkIdType aDim = aCoords.GetDim();
+    
+    vtkIdType aNbCells = theGaussSubMesh->myNbCells;
+    vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
+    
+    vtkCellArray* aConnectivity = vtkCellArray::New();
+    aConnectivity->Allocate(aCellsSize,0);
+    vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+    aCellTypesArray->SetNumberOfComponents(1);
+    aCellTypesArray->SetNumberOfTuples(aNbCells);
+    
+    const TVTKPoints& aPoints = aCoords.GetPoints();
+    vtkIdList *anIdList = vtkIdList::New();
+    anIdList->SetNumberOfIds(1);
+    for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
+      TCCoordSlice aSlice = aCoords.GetCoordSlice(aPointId);
+      
+      float aCoords[3] = {0.0, 0.0, 0.0};
+      for(vtkIdType aDimId = 0; aDimId < aDim; aDimId++)
+       aCoords[aDimId] = aSlice[aDimId];
+      
+      aPoints->SetPoint(aPointId,aCoords);
+      
+      anIdList->SetId(0,aPointId);
+      aConnectivity->InsertNextCell(anIdList);
+      aCellTypesArray->SetValue(aPointId,(unsigned char)VTK_VERTEX);
+    }
+    anIdList->Delete();
+    
+    vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+    aCellLocationsArray->SetNumberOfComponents(1);
+    aCellLocationsArray->SetNumberOfTuples(aNbCells);
+    
+    vtkIdType *pts = 0, npts = 0;
+    aConnectivity->InitTraversal();
+    for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++)
+      aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
+    
+    TVTKSource& aSource = theGaussSubMesh->mySource;
+    aSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+    aSource->SetPoints(aPoints.GetPointer());
+    
+    aCellLocationsArray->Delete();
+    aCellTypesArray->Delete();
+    aConnectivity->Delete();
+  }
+  
+  
+  //---------------------------------------------------------------
+  void
+  GetGaussSubMesh(PMeshImpl theMesh,
+                 PMeshOnEntityImpl theMeshOnEntity,
+                 PGaussMeshImpl theGaussMesh,
+                 PGaussSubMeshImpl theGaussSubMesh)
+  {
+    PGaussImpl aGauss = theGaussSubMesh->myGauss;
+    INITMSG(MYDEBUG,"GetGaussSubMesh - aGeom = "<<aGauss->myGeom<<endl);
+    
+    TVTKSource& aSource = theGaussSubMesh->mySource;
+    if(theGaussSubMesh->myIsVTKDone)
+      return;
+    
+    GetSource(aSource,theGaussSubMesh,theMeshOnEntity);
+    INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
+    BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
+    
+    theGaussSubMesh->myIsVTKDone = true;
+  }
+  
+  
+  //---------------------------------------------------------------
+  void
+  GetGaussMesh(PMeshImpl theMesh,
+              PMeshOnEntityImpl theMeshOnEntity,
+              PGaussMeshImpl theGaussMesh)
+  {
+    if(theGaussMesh->myIsVTKDone)
+      return;
+    
+    TVTKAppendFilter& anAppendFilter = theGaussMesh->myFilter;
+    const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
+    TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
+    for(; anIter != aGeom2GaussSubMesh.end(); anIter++){
+      PGaussSubMeshImpl aGaussSubMesh = anIter->second;
+      if(aGaussSubMesh->myStatus == eRemoveAll)
+       continue;
+      
+      GetGaussSubMesh(theMesh,
+                     theMeshOnEntity,
+                     theGaussMesh,
+                     aGaussSubMesh);
+      
+      TVTKSource& aSource = aGaussSubMesh->mySource;
+      anAppendFilter->AddInput(aSource.GetPointer());
+    }
+    anAppendFilter->Update(); // Fix on VTK
+    
+    theGaussMesh->myIsVTKDone = true;
   }
+  
+  
 }
 
 
+//---------------------------------------------------------------
 VISU_Convertor_impl
 ::VISU_Convertor_impl() 
 {
   myIsDone = false;
 }
 
+
+//---------------------------------------------------------------
 VISU_Convertor_impl
 ::~VISU_Convertor_impl() 
 {}
 
+
+//---------------------------------------------------------------
 VISU_Convertor::TOutput* 
 VISU_Convertor_impl
 ::GetMeshOnEntity(const string& theMeshName, 
@@ -764,6 +1059,8 @@ VISU_Convertor_impl
   return aSource.GetPointer();
 }
 
+
+//---------------------------------------------------------------
 VISU_Convertor::TOutput* 
 VISU_Convertor_impl
 ::GetMeshOnGroup(const string& theMeshName, 
@@ -808,122 +1105,7 @@ VISU_Convertor_impl
 }
 
 
-void
-GetCells(VISU::TVTKSource& theSource,
-        PSubProfileImpl theSubProfile,
-        PMeshOnEntityImpl theMeshOnEntity)
-{
-  vtkIdType aNbCells = theSubProfile->myNbCells;
-  vtkIdType aCellsSize = theSubProfile->myCellsSize;
-  vtkIdType aGeom = theSubProfile->myGeom;
-  vtkIdType aNbNodes = VTKGeom2NbNodes(aGeom);
-
-  const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
-  const TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect;
-  TGeom2Cell2Connect::const_iterator aConnectIter = aGeom2Cell2Connect.find(aGeom);
-  if(aConnectIter == aGeom2Cell2Connect.end())
-    EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<<aGeom<<")");
-  
-  const TCell2Connect& aCell2Connect = aConnectIter->second;
-    
-  vtkCellArray* aConnectivity = vtkCellArray::New();
-  aConnectivity->Allocate(aCellsSize,0);
-  vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
-  aCellTypesArray->SetNumberOfComponents(1);
-  aCellTypesArray->SetNumberOfTuples(aNbCells);
-
-  if(theSubProfile->myStatus == eAddAll){
-    VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
-    for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
-      const TConnect& anArray = aCell2Connect[anId];
-      PrintCells(aConnId,aConnectivity,anArray);
-      aCellTypesArray->SetValue(anId,(unsigned char)aGeom);
-      aConnId += aNbNodes;
-      anId++;
-    }
-  }else{
-    VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin();
-    for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){
-      vtkIdType aSubId = *anIter;
-      const TConnect& anArray = aCell2Connect[aSubId];
-      PrintCells(aConnId,aConnectivity,anArray);
-      aCellTypesArray->SetValue(anId,(unsigned char)aGeom);
-      aConnId += aNbNodes;
-      anId++;
-    }
-  }
-
-  vtkIdType *pts = 0, npts = 0;
-  vtkIntArray* aCellLocationsArray = vtkIntArray::New();
-
-  aCellLocationsArray->SetNumberOfComponents(1);
-  aCellLocationsArray->SetNumberOfTuples(aNbCells);
-  aConnectivity->InitTraversal();
-  for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
-    aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
-  theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
-
-  aCellLocationsArray->Delete();
-  aCellTypesArray->Delete();
-  aConnectivity->Delete();
-}
-
-
-void
-GetMeshOnSubProfile(PMeshImpl theMesh,
-                   PMeshOnEntityImpl theMeshOnEntity,
-                   PProfileImpl theProfile,
-                   PSubProfileImpl theSubProfile)
-{
-  INITMSG(MYDEBUG,"GetMeshOnSubProfile - aGeom = "<<theSubProfile->myGeom<<endl);
-
-  TVTKSource& aSource = theSubProfile->mySource;
-  if(theSubProfile->myIsVTKDone)
-    return;
-
-  GetPoints(aSource,theMesh);
-  INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
-  GetCells(aSource,theSubProfile,theMeshOnEntity);
-  BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
-
-  theSubProfile->myIsVTKDone = true;
-}
-
-
-void
-GetMeshOnProfile(PMeshImpl theMesh,
-                PMeshOnEntityImpl theMeshOnEntity,
-                PProfileImpl theProfile)
-{
-  if(theProfile->myIsVTKDone)
-    return;
-
-  TVTKAppendFilter& anAppendFilter = theProfile->myAppendFilter;
-  if(theProfile->myIsAll){
-    TVTKSource& aSource = theMeshOnEntity->mySource;
-    anAppendFilter->AddInput(aSource.GetPointer());
-  }else{
-    const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
-    TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
-    for(; anIter != aGeom2SubProfile.end(); anIter++){
-      PSubProfileImpl aSubProfile = anIter->second;
-      if(aSubProfile->myStatus == eRemoveAll)
-       continue;
-      
-      GetMeshOnSubProfile(theMesh,
-                         theMeshOnEntity,
-                         theProfile,
-                         aSubProfile);
-
-      TVTKSource& aSource = aSubProfile->mySource;
-      anAppendFilter->AddInput(aSource.GetPointer());
-    }
-  }
-  anAppendFilter->Update(); // Fix on VTK
-  theProfile->myIsVTKDone = true;
-}
-
-
+//---------------------------------------------------------------
 VISU_Convertor::TOutput* 
 VISU_Convertor_impl
 ::GetTimeStampOnMesh(const string& theMeshName, 
@@ -937,9 +1119,13 @@ VISU_Convertor_impl
          "; theFieldName = '"<<theFieldName<<"'"<<
          "; theStampsNum = "<<theStampsNum<<
          endl);
+
   //Cheching possibility do the query
-  TFindTimeStamp aFindTimeStamp = 
-    FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
+  TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
+                                               theEntity,
+                                               theFieldName,
+                                               theStampsNum);
+
   PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
   PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
   PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
@@ -967,12 +1153,22 @@ VISU_Convertor_impl
       GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity);
       
       PProfileImpl aProfile = aValForTime->myProfile;
-      GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
+      PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
+      const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
+      INITMSG(MYDEBUG,"aGeom2GaussSubMesh.size() = "<<aGeom2GaussSubMesh.size()<<endl);
+      if(aGeom2GaussSubMesh.empty()){
+       GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
      
-      TVTKAppendFilter& anAppendFilter = aProfile->myAppendFilter;
-
-      aSource->ShallowCopy(anAppendFilter->GetOutput());
-      GetTimeStamp2(aSource,aField,aValForTime);
+       TVTKAppendFilter& anAppendFilter = aProfile->myFilter;
+       aSource->ShallowCopy(anAppendFilter->GetOutput());
+       GetTimeStampOnProfile(aSource,aField,aValForTime);
+      }else{
+       GetGaussMesh(aMesh,aVTKMeshOnEntity,aGaussMesh);
+     
+       TVTKAppendFilter& anAppendFilter = aGaussMesh->myFilter;
+       aSource->ShallowCopy(anAppendFilter->GetOutput());
+       //GetTimeStampOnProfile(aSource,aField,aValForTime);
+      }
 
       aValForTime->myIsVTKDone = true;
 
@@ -1005,6 +1201,8 @@ VISU_Convertor_impl
   return aSource.GetPointer();
 }
 
+
+//---------------------------------------------------------------
 VISU::PMeshImpl 
 VISU_Convertor_impl
 ::FindMesh(const string& theMeshName)
@@ -1019,6 +1217,7 @@ VISU_Convertor_impl
 }
 
 
+//---------------------------------------------------------------
 VISU_Convertor_impl::TFindMeshOnEntity
 VISU_Convertor_impl
 ::FindMeshOnEntity(const string& theMeshName,
@@ -1039,6 +1238,7 @@ VISU_Convertor_impl
 }
 
 
+//---------------------------------------------------------------
 float
 VISU_Convertor_impl
 ::GetSize() 
index 754060f94841e33a892e6ee1c45376c78a4d3420..ceb2b99e4a5554654b209151949b328faa7c22a3 100644 (file)
@@ -37,68 +37,101 @@ namespace VISU
   //---------------------------------------------------------------
   struct TIsVTKDone: virtual TBaseStructure
   {
+    TIsVTKDone();
     bool myIsVTKDone;
-    TIsVTKDone(): 
-      myIsVTKDone(false)
-    {}
   };
 
   
   //---------------------------------------------------------------
-  struct TSource: virtual TIsVTKDone
+  struct TSizeCounter: virtual TIsVTKDone
   {
-    TSource();
-
+    TSizeCounter();
     vtkIdType myNbCells;
     vtkIdType myCellsSize;
+  };
+
 
+  //---------------------------------------------------------------
+  struct TSource: virtual TSizeCounter
+  {
+    TSource();
     TVTKSource mySource;
   };
 
-  
+
+  //---------------------------------------------------------------
+  struct TAppendFilter: virtual TIsVTKDone
+  {
+    TAppendFilter();
+    TVTKAppendFilter myFilter;
+  };
+
+
   //---------------------------------------------------------------
-  typedef std::vector<TCoord> TPointsCoord;
-  typedef TSlice<TPointsCoord> TPointSlice;
-  typedef TCSlice<TPointsCoord> TCPointSlice;
+  typedef std::vector<TCoord> TCoordArray;
+  typedef TSlice<TCoordArray> TCoordSlice;
+  typedef TCSlice<TCoordArray> TCCoordSlice;
 
-  struct TPoints: virtual TBaseStructure
+  class TPointCoords: public virtual TBaseStructure
   {
     vtkIdType myDim;
-    vtkIdType myNbCells;
+    vtkIdType myNbPoints;
 
-    TPointsCoord myCoord;
+    TCoordArray myCoord;
+    TVTKPoints myPoints;
 
   public:
-
-    TCPointSlice
-    GetPointSlice(vtkIdType theCellId) const;
-
-    TPointSlice 
-    GetPointSlice(vtkIdType theCellId);
+    TPointCoords();
 
     void
-    Init(vtkIdType theNbCells,
+    Init(vtkIdType theNbPoints,
         vtkIdType theDim);
 
+    TCCoordSlice
+    GetCoordSlice(vtkIdType theNodeId) const;
+
+    TCoordSlice 
+    GetCoordSlice(vtkIdType theNodeId);
+
     vtkIdType
-    GetNbCells() const { return myNbCells; }
+    GetNbPoints() const { return myNbPoints; }
 
     vtkIdType
     GetDim() const { return myDim; }
 
     vtkIdType
-    size() const { return GetNbCells(); }
+    size() const { return GetNbPoints(); }
+
+    const TVTKPoints&
+    GetPoints() const { return myPoints;}
   };
 
 
   //---------------------------------------------------------------
-  struct TMeshImpl: virtual TMesh, virtual TIsVTKDone
+  class TNamedPointCoords: public virtual TPointCoords
   {
-    TPointsCoord myPointsCoord;
-
     typedef std::vector<std::string> TPointsDim;
     TPointsDim myPointsDim;
 
+  public:
+
+    void
+    Init(vtkIdType theNbPoints,
+        vtkIdType theDim);
+    
+    std::string&
+    GetName(vtkIdType theDim);
+    
+    const std::string&
+    GetName(vtkIdType theDim) const;
+  };
+
+
+  //---------------------------------------------------------------
+  struct TMeshImpl: virtual TMesh, virtual TIsVTKDone
+  {
+    TNamedPointCoords myNamedPointCoords;
+
     TVTKPoints myPoints;
     vtkIdType myNbPoints;
 
@@ -128,15 +161,10 @@ namespace VISU
   //---------------------------------------------------------------
   typedef std::map<vtkIdType,PSubProfile> TGeom2SubProfile;
 
-  struct TProfileImpl: virtual TProfile, virtual TIsVTKDone
+  struct TProfileImpl: virtual TProfile, virtual TAppendFilter
   {
     TProfileImpl();
-
-    vtkIdType myNbCells;
-    vtkIdType myCellsSize;
-
     bool myIsAll;
-    TVTKAppendFilter myAppendFilter;
     TGeom2SubProfile myGeom2SubProfile;
   };
   typedef SharedPtr<TProfileImpl> PProfileImpl;
@@ -147,7 +175,6 @@ namespace VISU
   {
     vtkIdType myGeom;
     std::string myName;
-
     vtkIdType myNbPoints;
   };
   typedef SharedPtr<TGaussImpl> PGaussImpl;
@@ -157,8 +184,7 @@ namespace VISU
   struct TGaussSubMeshImpl: virtual TGaussSubMesh, virtual TSource
   {
     TGaussSubMeshImpl();
-
-    TPoints myPoints;
+    TPointCoords myPointCoords;
     ESubMeshStatus myStatus;
   };
   typedef SharedPtr<TGaussSubMeshImpl> PGaussSubMeshImpl;
@@ -167,10 +193,9 @@ namespace VISU
   //---------------------------------------------------------------
   typedef std::map<vtkIdType,PGaussSubMesh> TGeom2GaussSubMesh;
 
-  struct TGaussMeshImpl: virtual TGaussMesh, virtual TIsVTKDone
+  struct TGaussMeshImpl: virtual TGaussMesh, virtual TAppendFilter
   {
     TGaussMeshImpl();
-
     TGeom2GaussSubMesh myGeom2GaussSubMesh;
   };
   typedef SharedPtr<TGaussMeshImpl> PGaussMeshImpl;
index 49431184c2c643b8c8a0f0e9185f3fbca8437f82..e8ad9995ff9c9323d99be0ee83fdce87c4293862 100644 (file)
@@ -58,7 +58,8 @@ extern "C" {
   }
 }
 
-namespace{
+namespace
+{
   using namespace SALOME_MED;
   
   const int MED_NBR_GEOMETRIE_MAILLE = 15;
@@ -107,7 +108,10 @@ namespace{
     MED_POINT1,
   };
   
-  int GetEntity2Geom(const VISU::TEntity& theEntity, medGeometryElement*& theVector)
+
+  //---------------------------------------------------------------
+  int
+  GetEntity2Geom(const VISU::TEntity& theEntity, medGeometryElement*& theVector)
   {
     switch(theEntity){
     case CELL_ENTITY: theVector = CELLGEOM; return MED_NBR_GEOMETRIE_MAILLE; break;
@@ -118,7 +122,10 @@ namespace{
     return -1;
   }
   
-  int MEDGeom2NbNodes(int theMEDGeomType)
+
+  //---------------------------------------------------------------
+  int
+  MEDGeom2NbNodes(int theMEDGeomType)
   { 
     switch(theMEDGeomType){
     case MED_NONE: return 0;
@@ -141,7 +148,10 @@ namespace{
     return -1;
   }
   
-  int MEDGeomToVTK(medGeometryElement theMEDGeomType)
+
+  //---------------------------------------------------------------
+  int
+  MEDGeomToVTK(medGeometryElement theMEDGeomType)
   { 
     switch(theMEDGeomType){
     case MED_NONE: return VTK_EMPTY_CELL;
@@ -164,7 +174,10 @@ namespace{
     return -1;
   }
   
-  medGeometryElement VTKGeomToMED(int theVTKGeomType)
+
+  //---------------------------------------------------------------
+  medGeometryElement 
+  VTKGeomToMED(int theVTKGeomType)
   { 
     switch(theVTKGeomType){
     case VTK_VERTEX: return MED_POINT1;
@@ -179,7 +192,9 @@ namespace{
     return medGeometryElement(-1);
   }
   
-  VISU::TEntity MEDEntityToVTK(medEntityMesh theMEDEntity)
+  //---------------------------------------------------------------
+  VISU::TEntity
+  MEDEntityToVTK(medEntityMesh theMEDEntity)
   {
     switch(theMEDEntity){
     case MED_NODE: return NODE_ENTITY;
@@ -190,7 +205,9 @@ namespace{
     return VISU::TEntity(-1);
   }
   
-  medEntityMesh VTKEntityToMED(VISU::TEntity theVTKEntity)
+  //---------------------------------------------------------------
+  medEntityMesh 
+  VTKEntityToMED(VISU::TEntity theVTKEntity)
   {
     switch(theVTKEntity){
     case NODE_ENTITY: return MED_NODE;
@@ -200,8 +217,12 @@ namespace{
     }
     return medEntityMesh(-1);
   }
+
   
-  string GetSObjectName(SALOMEDS::SObject_ptr aSObject){
+  //---------------------------------------------------------------
+  std::string 
+  GetSObjectName(SALOMEDS::SObject_ptr aSObject)
+  {
     SALOMEDS::GenericAttribute_var anAttr;
     if (aSObject->FindAttribute(anAttr,"AttributeName")) {
       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
@@ -211,6 +232,8 @@ namespace{
     return "";
   }
   
+
+  //---------------------------------------------------------------
   void 
   GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
               SALOME_MED::MESH_ptr theMEDMesh,
@@ -233,6 +256,7 @@ namespace{
   }
   
   
+  //---------------------------------------------------------------
   void 
   GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
               SALOME_MED::FAMILY_ptr theMEDFamily)
@@ -254,6 +278,7 @@ namespace{
   }
   
   
+  //---------------------------------------------------------------
   void
   GetCellsSize(VISU::PCMesh theMesh, 
               SALOME_MED::MESH_ptr theMEDMesh, 
@@ -262,17 +287,14 @@ namespace{
     TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
     VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity];
     if(theEntity == NODE_ENTITY){
-      theMesh->myNbPoints = theMEDMesh->getNumberOfNodes();
       aMeshOnEntity->myNbCells = theMesh->myNbPoints;
       aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
       vtkIdType aNbCells, aCellsSize;
       GetCellsSize(aNbCells,aCellsSize,theMEDMesh,CELL_ENTITY);
       if(aNbCells > 0){
-       
        TMeshOnEntityMap::iterator aIter = aMeshOnEntityMap.find(CELL_ENTITY);
        if (aIter != aMeshOnEntityMap.end()){
          VISU::PCMeshOnEntity aMeshOnCells = aIter->second;
-       
          aMeshOnCells->myEntity = VISU::CELL_ENTITY;
          aMeshOnCells->myMeshName = theMesh->myName;
          aMeshOnCells->myNbCells = aNbCells;
@@ -287,6 +309,7 @@ namespace{
 }
 
 
+//---------------------------------------------------------------
 VISU_Convertor* 
 VISU_MEDFieldConvertor::Build()
 {
@@ -307,11 +330,14 @@ VISU_MEDFieldConvertor::Build()
   CORBA::String_var aFieldName = myField->getName();
 
   PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
+  aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
   aMesh->myDim = aMEDMesh->getSpaceDimension();
-  aMesh->myPointsDim.resize(aMesh->myDim);
   aMesh->myName = aMeshName.in();
   aMesh->myMesh = aMEDMesh;
 
+  TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
+  aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
+
   if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
 
   TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
@@ -362,6 +388,7 @@ VISU_MEDFieldConvertor::Build()
 }
 
 
+//---------------------------------------------------------------
 VISU_Convertor* 
 VISU_MEDConvertor::Build() 
 {
@@ -379,11 +406,14 @@ VISU_MEDConvertor::Build()
   return Build(aTimeStampIterator);
 }
 
+
 namespace{
 
   using namespace boost;
 
-  struct TSObjectByName{
+  //---------------------------------------------------------------
+  struct TSObjectByName
+  {
     std::string myName;
     typedef tuple<SALOMEDS::SObject_var> TRet;
 
@@ -406,7 +436,10 @@ namespace{
 
   };
 
-  struct TMeshByName{
+
+  //---------------------------------------------------------------
+  struct TMeshByName
+  {
     std::string myName;
     typedef tuple<SALOME_MED::MESH_var,SALOMEDS::SObject_var> TRet;
 
@@ -430,6 +463,8 @@ namespace{
     }
   };
 
+
+  //---------------------------------------------------------------
   template<typename TFun>
   typename TFun::TRet
   Find(SALOMEDS::SObject_ptr theStartSObj, 
@@ -451,6 +486,8 @@ namespace{
 
 }
 
+
+//---------------------------------------------------------------
 VISU_Convertor* 
 VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
 {
@@ -483,11 +520,14 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
 
       PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
       SALOME_MED::MESH_var aMEDMesh = boost::get<0>(aMeshByNameRet);
+      aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
       aMesh->myDim = aMEDMesh->getSpaceDimension();
       aMesh->myName = aMeshName.in();
-      aMesh->myPointsDim.resize(aMesh->myDim);
       aMesh->myMesh = aMEDMesh;
 
+      TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
+      aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
+
       if(MYDEBUG) 
        MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
 
@@ -742,6 +782,7 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
 }
  
 
+//---------------------------------------------------------------
 VISU_Convertor* 
 VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
 {
@@ -770,11 +811,14 @@ VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
     CORBA::String_var aFieldName = aMEDField->getName();
 
     PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
+    aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
     aMesh->myDim = aMEDMesh->getSpaceDimension();
-    aMesh->myPointsDim.resize(aMesh->myDim);
     aMesh->myName = aMeshName.in();
-    aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
     aMesh->myMesh = aMEDMesh;
+
+    TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
+    aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
+
     if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<"'; myDim = "<<aMesh->myDim);
 
     TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
@@ -826,6 +870,7 @@ VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
 }
 
 
+//---------------------------------------------------------------
 int
 VISU_MEDConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, 
                                    const string& theFamilyName)
@@ -845,6 +890,7 @@ VISU_MEDConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity,
 }
  
  
+//---------------------------------------------------------------
 int 
 VISU_MEDConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
                                   const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
@@ -870,6 +916,7 @@ VISU_MEDConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
 }
 
 
+//---------------------------------------------------------------
 int 
 VISU_MEDConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh, 
                                   VISU::PMeshOnEntityImpl theMeshOnEntity, 
@@ -884,6 +931,8 @@ VISU_MEDConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh,
   return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
 }
 
+
+//---------------------------------------------------------------
 int 
 VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh, 
                              const string& theFamilyName)
@@ -891,71 +940,82 @@ VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh,
   //Check on existing family
   PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
   PCFamily aFamily = GetFamily(aMeshOnEntity,theFamilyName);
+
   //Check on loading already done
-  bool isPointsLoaded = !theMesh->myPointsCoord.empty();
-  if(isPointsLoaded) 
+  if(theMesh->myIsCDone) 
     if(!aFamily) 
       return 0;
-    else if(!aFamily->myGeom2SubMeshID.empty()
+    else if(!aFamily->myIsCDone
       return 0;
 
   if(MYDEBUG) 
-    MESSAGE("LoadPoints - isPointsLoaded = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'");
+    MESSAGE("LoadPoints - theFamilyName = '"<<theFamilyName<<"'");
 
   SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
-  int iNumElemEnd = aMedMesh->getNumberOfNodes();
-  TPointsCoord& aPointsCoord = theMesh->myPointsCoord;
+  int aDim = theMesh->myDim;
+  TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+  int aNbElem = aCoords.GetNbPoints();
 
-  if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<<iNumElemEnd);
+  if(MYDEBUG) MESSAGE("LoadPoints - aNbElem = "<<aNbElem);
 
-  if (iNumElemEnd <= 0) 
+  if(aNbElem <= 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];
+  SALOME_MED::double_array_var aCCoord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
+  if(!theMesh->myIsCDone){
+    for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++){
+      VISU::TCoordSlice aCoordSlice = aCoords.GetCoordSlice(iElem);
+      for(int iDim = 0; iDim < aDim; iDim++)
+       aCoordSlice[iDim] = aCCoord[anId++];
+    }
 
     if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
 
     TCell2Connect& aCell2Connect = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX];
-    aCell2Connect.resize(iNumElemEnd);
-    for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
-      aCell2Connect[iNumElem] = TConnect(1,iNumElem);
+    aCell2Connect.resize(aNbElem);
+    for(int iElem = 0; iElem < aNbElem; iElem++)
+      aCell2Connect[iElem] = TConnect(1,iElem);
+    
+    theMesh->myIsCDone = true;
   }
-  if(aFamily){
-    if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily Geom2SubMeshID");
-
-    SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
-    CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
-    TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX];
 
-    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());
+  if(aFamily){
+    if(!aFamily->myIsCDone){
+      if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily Geom2SubMeshID");
+
+      SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
+      CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
+      TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX];
+
+      if(!anIsOnAllElements){
+       SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
+       SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
+       int aMaxElemId = aNbElem;
+       aNbElem = aCellNumForType->length();
+       for(int iElem = 0; iElem < aNbElem; iElem++){
+         int aTmp = aCellNumForType[iElem]-1;
+         if(0 > aTmp || aTmp >= aMaxElemId){
+           static QString aString;
+           aString.sprintf("LoadPoints - aMaxElemId(%d) <= aCellNumForType[%d]=%d < 0",aMaxElemId,iElem,aTmp);
+           throw std::runtime_error(aString.latin1());
+         }
+         aSubMeshID.push_back(aTmp);
+       }
+      }else{
+       for(int iElem = 0; iElem < aNbElem; iElem++){
+         aSubMeshID.push_back(iElem);
        }
-       aSubMeshID.push_back(tmp);
-      }
-    }else{
-      for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++){
-       aSubMeshID.push_back(iNumElem);
       }
+
+      aFamily->myIsCDone = true;
     }
   }
+
   return 1;
 }
 
 
+//---------------------------------------------------------------
 int 
 VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh,
                                     VISU::PCMeshOnEntity theMeshOnEntity, 
@@ -983,7 +1043,8 @@ VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh,
   const TEntity& aVEntity = theMeshOnEntity->myEntity;
   int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
   const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
-  int aNbPoints = theMesh->myPointsCoord.size()/theMesh->myDim;
+  const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+  int aNbPoints = aCoords.GetNbPoints();
   if(!isCellsLoaded){
     for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++){
       SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom];
@@ -1098,7 +1159,10 @@ ImportField(TArray& theArray,
   if(theField->myEntity == NODE_ENTITY){
     TValForCellsWithType& aValForCellsWithType = 
       theValForTime->myValForCells[VTK_VERTEX];
-    int iNumElemEnd = theMesh->myPointsCoord.size()/theMesh->myDim*theField->myNbComp;
+
+    const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+    int aNbPoints = aCoords.GetNbPoints();
+    int iNumElemEnd = aNbPoints*theField->myNbComp;
     if(MYDEBUG) MESSAGE("ImportField - iNumElemEnd = "<<iNumElemEnd);
     aValForCellsWithType.resize(iNumElemEnd);
     for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) 
index 83028671612d82a12c9c3ad3d813eb7ecb56ddb4..bbf41cefaae5f51871c175b3c05043b66bf836ee 100644 (file)
 
 #include <string>      
 
-namespace VISU{
+namespace VISU
+{
+  //---------------------------------------------------------------
+  struct TIsCDone: virtual TBaseStructure
+  {
+    bool myIsCDone;
+    TIsCDone(): 
+      myIsCDone(false)
+    {}
+  };
 
-  struct TCMesh: TMeshImpl{
+  
+  //---------------------------------------------------------------
+  struct TCMesh: virtual TMeshImpl, virtual TIsCDone
+  {
     SALOME_MED::MESH_var myMesh;
   };
   typedef SharedPtr<TCMesh> PCMesh;
 
-  struct TCMeshOnEntity: TMeshOnEntityImpl{
+
+  //---------------------------------------------------------------
+  struct TCMeshOnEntity: virtual TMeshOnEntityImpl, virtual TIsCDone
+  {
     SALOME_MED::SUPPORT_var mySupport;
     typedef std::pair<int,int> TIndexAndSize;
     typedef std::map<int,TIndexAndSize> TCellsFirstIndex;
@@ -50,21 +65,32 @@ namespace VISU{
   };
   typedef SharedPtr<TCMeshOnEntity> PCMeshOnEntity;
   
-  struct TCFamily: TFamilyImpl{
+
+  //---------------------------------------------------------------
+  struct TCFamily: virtual TFamilyImpl, virtual TIsCDone
+  {
     SALOME_MED::FAMILY_var myFamily;
   };
   typedef SharedPtr<TCFamily> PCFamily;
   
-  struct TCGroup: TGroupImpl{
+
+  //---------------------------------------------------------------
+  struct TCGroup: virtual TGroupImpl
+  {
     SALOME_MED::GROUP_var myGroup;
   };
   typedef SharedPtr<TCGroup> PCGroup;
 
-  struct TCField: TFieldImpl{
-  };
+
+  //---------------------------------------------------------------
+  struct TCField: virtual TFieldImpl
+  {};
   typedef SharedPtr<TCField> PCField;
 
-  struct TCValForTime: TValForTimeImpl{
+
+  //---------------------------------------------------------------
+  struct TCValForTime: virtual TValForTimeImpl
+  {
     SALOME_MED::FIELD_var myField;
   };
   typedef SharedPtr<TCValForTime> PCValForTime;