]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for IPAL 17888
authorenk <enk@opencascade.com>
Thu, 6 Dec 2007 13:15:37 +0000 (13:15 +0000)
committerenk <enk@opencascade.com>
Thu, 6 Dec 2007 13:15:37 +0000 (13:15 +0000)
src/CONVERTOR/VISU_ConvertorDef_impl.hxx
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_Convertor_impl.hxx
src/CONVERTOR/VISU_Structures.hxx
src/CONVERTOR/VISU_Structures_impl.cxx
src/CONVERTOR/VISU_Structures_impl.hxx

index 9d3101215fe3e250f58a08276c3953136b0fe861..eb7fbcd0d484b68ed14644e5137210cebb4cd9de 100644 (file)
@@ -46,13 +46,18 @@ class vtkUnstructuredGrid;
 class VISU_AppendFilter;
 
 class VISU_MergeFilter;
+class VISU_CommonCellsFilter;
 
 namespace VISU
 {
   //---------------------------------------------------------------
   typedef vtkSmartPointer<VISU_MergeFilter> PMergeFilter;
-
-
+  typedef vtkSmartPointer<VISU_CommonCellsFilter> PCommonCellsFilter;
+  
+  struct TCommonCellsFilterHolder;
+  typedef MED::SharedPtr<TCommonCellsFilterHolder> PCommonCellsFilterHolder; 
+  
   //---------------------------------------------------------------
   typedef vtkSmartPointer<vtkPolyData> PPolyData;
   typedef vtkSmartPointer<VISU_AppendPolyData> PAppendPolyData;
index 66f53771f3ea86b0068b20c1941a2e8512c47397..fb2c0db1bb0cbcf52c89763ee86d85b243bca8de 100644 (file)
@@ -32,6 +32,7 @@
 #include "VISU_AppendFilter.hxx"
 #include "VISU_AppendPolyData.hxx"
 #include "VTKViewer_CellLocationsArray.h"
+#include "VISU_CommonCellsFilter.hxx"
 
 #include "VISU_ConvertorUtils.hxx"
 
@@ -873,17 +874,66 @@ VISU_Convertor_impl
                        const VISU::PProfileImpl& theProfile,
                        const VISU::TEntity& theEntity)
 {
+  vtkUnstructuredGrid* anOutput = NULL;
+  
   LoadMeshOnEntity(theMesh, theMeshOnEntity);
   GetMeshOnEntity(theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity);
   GetMeshOnProfile(theMesh, theMeshOnEntity, theProfile);
-
+  
+  bool isNeedInCells = false;
+  
   theUnstructuredGridIDMapper->myIDMapper = theProfile;
+  if(theMeshOnEntity->myEntity == VISU::NODE_ENTITY){
+    // add geometry elements to output,
+    // if timestamp on NODE_ENTITY and
+    // on profiles with status eAddPart
+    VISU::TGeom2SubProfile::const_iterator anIter = theProfile->myGeom2SubProfile.begin();
+    for(; anIter != (theProfile->myGeom2SubProfile).end(); anIter++){
+      const VISU::EGeometry aGeom = anIter->first;
+      const VISU::PSubProfileImpl aSubProfile = anIter->second;
+      if(aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1){
+       isNeedInCells = true;
+       break;
+      }
+    }
+    if(isNeedInCells){
+      theUnstructuredGridIDMapper->myIsSpecialKey = true;
+      GetTimeStampOnNodalProfile(theMesh,theUnstructuredGridIDMapper,theField,theValForTime,theEntity);
+      anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
+    }
+  }
+  /*
   vtkUnstructuredGrid* anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
   const VISU::PUnstructuredGrid& aSource = theUnstructuredGridIDMapper->mySource.GetSource();
   VISU::GetTimeStampOnProfile(aSource, theField, theValForTime, theEntity);
+  */
   return anOutput;
 }
 
+void
+VISU_Convertor_impl
+::GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh,
+                             const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
+                             const VISU::PFieldImpl& theField, 
+                             const VISU::PValForTimeImpl& theValForTime,
+                             const VISU::TEntity& theEntity)
+{
+  const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+  VISU::TMeshOnEntityMap::const_iterator aIter = aMeshOnEntityMap.begin();
+  for(;aIter!=aMeshOnEntityMap.end();aIter++){
+    VISU::TEntity aEntity = aIter->first;
+    if(aEntity != VISU::NODE_ENTITY){
+      VISU::PNamedIDMapper aMapper = GetMeshOnEntity(theMesh->myName,aEntity);
+      if(aMapper)
+        theIDMapperFilter->myMappers[aEntity] = aMapper;
+    }
+  }
+
+  theIDMapperFilter->GetUnstructuredGridOutput();
+  const VISU::PUnstructuredGrid& aSource = theIDMapperFilter->mySource.GetSource();
+  VISU::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
+}
+
 //---------------------------------------------------------------
 VISU::PUnstructuredGridIDMapper 
 VISU_Convertor_impl
index 403ef72fe95de1cb3a53d74cca9711d96d848208..f6cffc0e99736c3b61e37c867ef605327d311c19 100644 (file)
@@ -230,6 +230,13 @@ protected:
                        const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
                        const VISU::PProfileImpl& theProfile,
                        const VISU::TEntity& theEntity);
+
+  void
+  GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh,
+                             const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
+                             const VISU::PFieldImpl& theField, 
+                             const VISU::PValForTimeImpl& theValForTime,
+                             const VISU::TEntity& theEntity);
   
 protected:
   //! Implemention of the VISU_Convertor::GetTimeStampSize
index 221465046555ec9ad157a0be60d5c38381924135..7c2257ff3584df436a1cdf76c18d621df3fea921 100644 (file)
@@ -99,6 +99,8 @@ namespace VISU
   typedef std::map<std::string, PMesh> TMeshMap;
 
 
+  typedef std::map<VISU::TEntity,VISU::PNamedIDMapper> PNamedIDMapperMap;
+
   //---------------------------------------------------------------
   //! Define a basic class which corresponds to MED PROFILE entity
   struct VISU_CONVERTOR_EXPORT TSubProfile: virtual TBaseStructure
index 34e202e8cbfb8e8844af459a3ad6d14b650b5f92..8a922fc05d6373ab458c2cdfae7bb1b47f2aaa51 100644 (file)
@@ -33,6 +33,7 @@
 #include "VISU_MergeFilter.hxx"
 
 #include "VISU_ConvertorUtils.hxx"
+#include "VISU_CommonCellsFilter.hxx"
 
 #include <vtkUnstructuredGrid.h>
 #include <vtkPolyData.h>
@@ -157,7 +158,6 @@ namespace VISU
     return 0;
   }
 
-
   //---------------------------------------------------------------
   unsigned long int
   TMemoryCheckIDMapper
@@ -416,6 +416,18 @@ namespace VISU
 
 
   //---------------------------------------------------------------
+  
+  
+  TUnstructuredGridIDMapperImpl
+  ::TUnstructuredGridIDMapperImpl():
+    myIsSpecialKey(false)
+  {
+    if(!myCommonCellsFilter.GetPointer()){
+      myCommonCellsFilter = VISU_CommonCellsFilter::New();
+      myCommonCellsFilter->Delete();
+    }
+  }
+
   vtkIdType
   TUnstructuredGridIDMapperImpl
   ::GetNodeObjID(vtkIdType theID) const
@@ -463,13 +475,31 @@ namespace VISU
   ::GetUnstructuredGridOutput()
   {
     if(!myFilter.GetPointer()){
-      const PAppendFilter& anAppendFilter = myIDMapper->GetFilter();
-      vtkUnstructuredGrid* aGeometry = anAppendFilter->GetOutput();
       
+      const PAppendFilter& anAppendFilter = myIDMapper->GetFilter();
+      vtkUnstructuredGrid* aGeometry;
+
       const PUnstructuredGrid& aSource = mySource.GetSource();
-      vtkUnstructuredGrid* aDataSet = aSource.GetPointer();
-      aDataSet->ShallowCopy(aGeometry);
+      vtkUnstructuredGrid* aDataSet;
       
+      if(myIsSpecialKey){
+        PNamedIDMapperMap::iterator aIter;
+        aIter = myMappers.find(VISU::CELL_ENTITY);
+        if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput());
+        else {
+          aIter = myMappers.find(VISU::FACE_ENTITY);
+          if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput());
+          else {
+            aIter = myMappers.find(VISU::EDGE_ENTITY);
+            if(aIter!=myMappers.end()) myCommonCellsFilter->SetCellsUG((aIter->second)->GetUnstructuredGridOutput());
+          }
+        }
+      }
+      
+      aGeometry = anAppendFilter->GetOutput();
+      aDataSet = aSource.GetPointer();
+      aDataSet->ShallowCopy(aGeometry);
+
       const PMergeFilter& aFilter = GetFilter();
       aFilter->SetGeometry(aGeometry);
       aFilter->SetScalars(aDataSet);
@@ -477,8 +507,10 @@ namespace VISU
       aFilter->AddField("VISU_FIELD",aDataSet);
       aFilter->AddField("VISU_CELLS_MAPPER",aDataSet);
       aFilter->AddField("VISU_POINTS_MAPPER",aDataSet);
-    }
-    return myFilter->GetUnstructuredGridOutput();
+
+      myCommonCellsFilter->SetProfileUG(aFilter->GetUnstructuredGridOutput());
+    } 
+    return myCommonCellsFilter->GetOutput();
   }
 
   vtkDataSet* 
@@ -494,10 +526,14 @@ namespace VISU
   {
     size_t aSize = myIDMapper->GetMemorySize();
     aSize += mySource.GetMemorySize();
+    if(vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput())
+      aSize += anOutput->GetActualMemorySize() * 1024;
+    PNamedIDMapperMap::const_iterator aIter = myMappers.begin();
+    for(;aIter!=myMappers.end();aIter++)
+      aSize += (aIter->second)->GetMemorySize();
     return aSize;
   }
 
-
   //---------------------------------------------------------------
   vtkIdType
   TPolyDataIDMapperImpl
index baf47957503d50fe5b2e7897a33b92d0e30a103f..08461db1f8a4f0075516b0392f19bb072c319590 100644 (file)
@@ -134,6 +134,38 @@ namespace VISU
     GetUnstructuredGridOutput();
   };
 
+  /*!
+    This container allow to combine other VTK representation into single one.
+  */
+  class VISU_CONVERTOR_EXPORT TCommonCellsFilterHolder: public virtual TMemoryCheckIDMapper
+  {
+  protected:
+    mutable PCommonCellsFilter myFilter;
+    mutable PMergeFilter myMergeFilter;
+  public:
+    TCommonCellsFilterHolder();
+
+    //! This method allow to create corresponding VTK filter by demand (not at once)
+    const PCommonCellsFilter& 
+    GetFilter() const;
+
+    //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
+    virtual
+    vtkUnstructuredGrid* 
+    GetUnstructuredGridOutput();
+
+    virtual
+    unsigned long int
+    GetMemorySize();
+
+    //! if false, TIDCommonCellsFilter - same as TIDMapperFilter
+    //! if true, TIDCommonCellsFilter - use VISU_CommonCellsFilter
+    bool myIsSpecialKey;
+
+    //! Vector of id mappers, which consist of meshonentity in next sequence:
+    //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY
+    PNamedIDMapperMap myMappers;
+  };
 
   //---------------------------------------------------------------
   //! Define a container for VTK representation
@@ -311,9 +343,12 @@ namespace VISU
   struct TUnstructuredGridIDMapperImpl: virtual TMergeFilterHolder,
                                        virtual TUnstructuredGridIDMapper
   {
-    PAppendFilterHolder myIDMapper; //!< Responsible for numbering
-    TUnstructuredGridHolder mySource; //!< Keeps assigned data
+    PAppendFilterHolder       myIDMapper; //!< Responsible for numbering
+    PCommonCellsFilter        myCommonCellsFilter;
+    TUnstructuredGridHolder   mySource; //!< Keeps assigned data
 
+    TUnstructuredGridIDMapperImpl();
+    
     //! Reimplement the TIDMapper::GetNodeObjID
     virtual 
     vtkIdType 
@@ -358,8 +393,15 @@ namespace VISU
     virtual
     unsigned long int
     GetMemorySize();
-  };
+    
+    //! if false, Not using CommonCellsFilter
+    //! if true,  Using CommonCellsFilter
+    bool myIsSpecialKey;
 
+    //! Vector of id mappers, which consist of meshonentity in next sequence:
+    //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY
+    PNamedIDMapperMap myMappers;
+  };
 
   //---------------------------------------------------------------
   //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh