]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug NPAL14169:
authorenk <enk@opencascade.com>
Tue, 10 Apr 2007 13:12:57 +0000 (13:12 +0000)
committerenk <enk@opencascade.com>
Tue, 10 Apr 2007 13:12:57 +0000 (13:12 +0000)
EDF VISU 256 : No continuum on a scalarmap

src/CONVERTOR/Makefile.in
src/CONVERTOR/VISU_CommonCellsFilter.cxx [new file with mode: 0644]
src/CONVERTOR/VISU_CommonCellsFilter.hxx [new file with mode: 0644]
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_Convertor_impl.hxx
src/CONVERTOR/VISU_MedConvertor.cxx

index 19d33a5ad94c960e66437411c6ad1063529269eb..66e5700845a84095c9e17316255f8c23a141f5d4 100644 (file)
@@ -40,7 +40,8 @@ EXPORT_HEADERS = \
        VISU_ConvertorUtils.hxx  \
        VISU_MergeFilter.hxx \
        VISU_AppendFilter.hxx \
-       VISU_ExtractUnstructuredGrid.hxx
+       VISU_ExtractUnstructuredGrid.hxx \
+       VISU_CommonCellsFilter.hxx
 
 # Libraries targets
 
@@ -53,7 +54,8 @@ LIB_SRC = \
        VISU_ExtractUnstructuredGrid.cxx \
        VISU_MergeFilter.cxx \
        VISU_AppendFilter.cxx \
-       VISU_MedConvertor.cxx
+       VISU_MedConvertor.cxx \
+       VISU_CommonCellsFilter.cxx
 
 # Executables targets
 BIN = VISUConvertor
diff --git a/src/CONVERTOR/VISU_CommonCellsFilter.cxx b/src/CONVERTOR/VISU_CommonCellsFilter.cxx
new file mode 100644 (file)
index 0000000..6ca4275
--- /dev/null
@@ -0,0 +1,269 @@
+// File      : VISU_CommonCellsFilter.cxx
+// Created   : Wed Apr  4 08:45:07 2007
+// Author    : Eugeny NIKOLAEV (enk)
+// Copyright : Open CASCADE
+
+#include "VISU_CommonCellsFilter.hxx"
+
+// VTK product headers
+#include <vtkUnstructuredGrid.h>
+#include <vtkSetGet.h>
+#include <vtkObjectFactory.h>
+#include <vtkDataSet.h>
+#include <vtkCellTypes.h>
+#include <vtkPointData.h>
+#include <vtkCellData.h>
+#include <vtkIdList.h>
+#include <vtkFloatArray.h>
+#include <vtkCell.h>
+
+// STL
+#include <algorithm>
+#include <vector>
+#include <map>
+
+namespace
+{
+  typedef std::vector<int> TSortedArray;
+  typedef std::map<int,int> TId2IdMap;
+
+  inline
+  void
+  GetSortedArray(vtkIntArray *theArray, 
+                TSortedArray& theSortedArray)
+  {
+    int aMaxId = theArray->GetMaxId();
+    int* aPointer = theArray->GetPointer(0);
+    int* anEndPointer = theArray->GetPointer(aMaxId + 1);
+    TSortedArray aSortedArray(aPointer, anEndPointer);
+    std::sort(aSortedArray.begin(), aSortedArray.end());
+    theSortedArray.swap(aSortedArray);
+  }
+
+  inline
+  void
+  GetIdsForCopy(vtkUnstructuredGrid *inputUGrid, 
+                vtkIntArray* inputPointIds,
+                TSortedArray& outputSortedArray)
+  {
+    if(inputUGrid){
+      TSortedArray aSortedPointIds;
+      TSortedArray aOutputCellIds;
+      GetSortedArray(inputPointIds,aSortedPointIds);
+      
+      int nbInputCells = inputUGrid->GetNumberOfCells();
+
+      TSortedArray aPointCellIds;
+      for(int idCell=0;idCell<nbInputCells;idCell++){
+        aPointCellIds.clear();
+        vtkCell*   aCell = inputUGrid->GetCell(idCell);
+        vtkIdList* ptIds = aCell->GetPointIds();
+        int aMaxId = ptIds->GetNumberOfIds();
+        int* aPointer = ptIds->GetPointer(0);
+        int* anEndPointer = ptIds->GetPointer(aMaxId + 1);
+        TSortedArray aSortedArray(aPointer, anEndPointer);
+        std::sort(aSortedArray.begin(), aSortedArray.end());
+
+        int aMaxLength = std::max(aSortedArray.size(), aSortedPointIds.size());
+        TSortedArray anIntersectionArray(aMaxLength);
+        TSortedArray::iterator anArrayIter = anIntersectionArray.begin();
+        anArrayIter = std::set_intersection(aSortedArray.begin(),
+                                            aSortedArray.end(),
+                                            aSortedPointIds.begin(),
+                                            aSortedPointIds.end(),
+                                            anArrayIter);
+        anIntersectionArray.erase(anArrayIter, anIntersectionArray.end());
+        if(anIntersectionArray.size() == aSortedArray.size())
+          aOutputCellIds.push_back(idCell);
+      }
+
+      outputSortedArray.swap(aOutputCellIds);
+    }
+  }
+
+  inline
+  void
+  CopyElementsToOutput(vtkUnstructuredGrid* theInputUG,
+                       int& theNbElements,
+                       TSortedArray& theElementIdsForCopy,
+                       TId2IdMap& theOldId2NewIdPointsMap,
+                       vtkIntArray* theOuputIDSArray,
+                       vtkUnstructuredGrid* theOutputUG)
+  {
+    vtkIntArray* aInputCellsMapper =
+      dynamic_cast<vtkIntArray*>(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER"));
+    int* aInputCellsMapperPointer = aInputCellsMapper->GetPointer(0);
+    for(int aCellIndex=0;aCellIndex<theNbElements;aCellIndex++){
+      int aCellId = theElementIdsForCopy[aCellIndex];
+      vtkIdList* aOldPointIds = theInputUG->GetCell(aCellId)->GetPointIds();
+      vtkIdList* aNewPointIds = vtkIdList::New();
+      int nbPointIds = aOldPointIds->GetNumberOfIds();
+      aNewPointIds->SetNumberOfIds(nbPointIds);
+      for(int j=0;j<nbPointIds;j++){
+        int aOldId = aOldPointIds->GetId(j);
+        int aNewId = theOldId2NewIdPointsMap[aOldId];
+        aNewPointIds->SetId(j,aNewId);
+      }
+      const int aOldCellId = theElementIdsForCopy[aCellIndex];
+      theOutputUG->InsertNextCell(theInputUG->GetCellType(aOldCellId),
+                                  aNewPointIds);
+      if(aInputCellsMapperPointer)
+        theOuputIDSArray->InsertNextValue(aInputCellsMapperPointer[aOldCellId]);
+      else
+        theOuputIDSArray->InsertNextValue(aOldCellId);
+      
+      aNewPointIds->Delete();
+    }
+  }
+}
+
+vtkStandardNewMacro(VISU_CommonCellsFilter);
+
+VISU_CommonCellsFilter
+::VISU_CommonCellsFilter()
+{}
+
+VISU_CommonCellsFilter
+::~VISU_CommonCellsFilter()
+{}
+
+void
+VISU_CommonCellsFilter
+::SetProfileUG(vtkUnstructuredGrid *input)
+{
+  this->SetInput(input);
+}
+
+vtkUnstructuredGrid*
+VISU_CommonCellsFilter
+::GetProfileUG()
+{
+  return dynamic_cast<vtkUnstructuredGrid*>(this->GetInput());
+}
+
+void
+VISU_CommonCellsFilter
+::SetCellsUG(vtkUnstructuredGrid *input)
+{
+  this->vtkProcessObject::SetNthInput(1, input);
+}
+
+vtkUnstructuredGrid*
+VISU_CommonCellsFilter
+::GetCellsUG()
+{
+  if (this->NumberOfInputs < 2)
+  {
+    return NULL;
+  }
+  return dynamic_cast<vtkUnstructuredGrid*>(this->Inputs[1]);
+}
+
+void
+VISU_CommonCellsFilter
+::Execute()
+{
+  vtkUnstructuredGrid* anInputProfileUG = this->GetProfileUG();
+  vtkUnstructuredGrid* anInputCellsUG   = this->GetCellsUG();
+
+  vtkUnstructuredGrid* anOutput         = this->GetOutput();
+  
+  if(anInputCellsUG == NULL){
+    anOutput->ShallowCopy(anInputProfileUG);
+  }
+  else{
+    // check if anInputProfileUG already have cells types not equal VTK_VERTEX
+    vtkCellTypes* aCellTypes = vtkCellTypes::New();
+
+    anInputProfileUG->GetCellTypes(aCellTypes);
+    if(aCellTypes){
+      if (aCellTypes->GetNumberOfTypes()!=1 )
+        anOutput->ShallowCopy(anInputProfileUG);
+      else{
+        if(aCellTypes->GetCellType(0) != VTK_VERTEX)
+          anOutput->DeepCopy(anInputProfileUG);
+        else{
+
+          vtkCellData* aInputCellData = anInputProfileUG->GetCellData();
+
+          //
+          // Calculate output points
+          //
+          vtkIdList* aPointIdsForCopy = vtkIdList::New();
+          vtkPoints* aOutputPointSet = vtkPoints::New();
+          TId2IdMap  aOldId2NewIdPointsMap;
+          
+          aOutputPointSet->Reset();
+          
+          vtkIntArray* aPointIDS =
+            dynamic_cast<vtkIntArray*>(aInputCellData->GetArray("VISU_CELLS_MAPPER"));
+          if(aPointIDS){
+            aPointIdsForCopy->SetNumberOfIds(aPointIDS->GetNumberOfTuples());
+            for(int i=0;i<aPointIDS->GetNumberOfTuples();i++){
+              aPointIdsForCopy->SetId(i,aPointIDS->GetValue(i));
+            }
+            aOutputPointSet->SetNumberOfPoints(aPointIdsForCopy->GetNumberOfIds());
+            // aOutputPointSet copy points from anInputProfileUG to aOutputPointSet, which
+            // in aPointIdsForCopy ids list
+            anInputProfileUG->GetPoints()->GetPoints(aPointIdsForCopy,aOutputPointSet);
+            for(int i=0;i<aPointIdsForCopy->GetNumberOfIds();i++)
+              aOldId2NewIdPointsMap[aPointIdsForCopy->GetId(i)] = i;
+            anOutput->SetPoints(aOutputPointSet);
+          }
+          aOutputPointSet->Delete();
+          // applay scalar,vector,normal,tensor ... values
+          anOutput->GetPointData()->CopyFieldOff("VISU_CELLS_MAPPER");
+          anOutput->GetPointData()->CopyFieldOff("VISU_POINTS_MAPPER");
+          anOutput->GetPointData()->PassData(aInputCellData);
+          //anOutput->GetPointData()->GetArray("VISU_CELLS_MAPPER")->SetName("VISU_POINTS_MAPPER");
+
+          // apply VISU_POINTS_MAPPER
+          vtkIntArray*  aNewPointsIdsArray = vtkIntArray::New();
+          aNewPointsIdsArray->SetName("VISU_POINTS_MAPPER");
+          aNewPointsIdsArray->SetNumberOfComponents(1);
+          aNewPointsIdsArray->SetNumberOfTuples(aPointIdsForCopy->GetNumberOfIds());
+          for(int i=0;i<aPointIdsForCopy->GetNumberOfIds();i++)
+            aNewPointsIdsArray->SetValue(i,aPointIdsForCopy->GetId(i));
+          anOutput->GetPointData()->AddArray(aNewPointsIdsArray);
+
+          
+            
+          aNewPointsIdsArray->Delete();
+          
+          
+          // Calculate output cells
+          int nbCells=0;
+
+          TSortedArray aCellIdsForCopy;
+          
+          GetIdsForCopy(anInputCellsUG,aPointIDS,aCellIdsForCopy);
+          nbCells = aCellIdsForCopy.size();
+
+          // copy cells to output
+          int aAllocMem = nbCells;
+          anOutput->Allocate(aAllocMem);
+          vtkIntArray* theOuputIDSArray = vtkIntArray::New();
+          theOuputIDSArray->SetName("VISU_CELLS_MAPPER");
+          theOuputIDSArray->SetNumberOfComponents(1);
+          theOuputIDSArray->SetNumberOfTuples(aAllocMem);
+          
+          if(nbCells>0 && anInputCellsUG)
+            CopyElementsToOutput(anInputCellsUG,
+                                 nbCells,
+                                 aCellIdsForCopy,
+                                 aOldId2NewIdPointsMap,
+                                 theOuputIDSArray,
+                                 anOutput);
+          
+          anOutput->GetCellData()->AddArray(theOuputIDSArray);
+
+          theOuputIDSArray->Delete();
+          aPointIdsForCopy->Delete();
+        }
+      }
+      
+    }
+    else
+      anOutput->ShallowCopy(anInputProfileUG);
+  }
+}
diff --git a/src/CONVERTOR/VISU_CommonCellsFilter.hxx b/src/CONVERTOR/VISU_CommonCellsFilter.hxx
new file mode 100644 (file)
index 0000000..1113ea4
--- /dev/null
@@ -0,0 +1,41 @@
+// File      : VISU_CommonCellsFilter.hxx
+// Created   : Tue Apr  3 16:16:53 2007
+// Author    : Eugeny NIKOLAEV (enk)
+// Copyright : Open CASCADE
+
+
+#ifndef VISU_CommonCellsFilter_HeaderFile
+#define VISU_CommonCellsFilter_HeaderFile
+
+#include <vtkUnstructuredGridToUnstructuredGridFilter.h>
+
+class VISU_CommonCellsFilter: public vtkUnstructuredGridToUnstructuredGridFilter
+{
+public:
+  static VISU_CommonCellsFilter *New();
+  vtkTypeMacro(VISU_CommonCellsFilter,vtkUnstructuredGridToUnstructuredGridFilter);
+
+  // Description:
+  // Specify the Unstructured Grid which overview
+  // nodal profile.
+  void SetProfileUG(vtkUnstructuredGrid *input);
+  vtkUnstructuredGrid* GetProfileUG();
+
+  // Description:
+  // Specify the Unstructured Grid which overview
+  // cells data on CELL_ENTITY.
+  void SetCellsUG(vtkUnstructuredGrid *input);
+  vtkUnstructuredGrid* GetCellsUG();
+
+protected:
+  VISU_CommonCellsFilter();
+  ~VISU_CommonCellsFilter();
+
+  void Execute(); //generate output data
+
+private:
+  VISU_CommonCellsFilter(const VISU_CommonCellsFilter&); // Lock copy
+  void operator=(const VISU_CommonCellsFilter&); // Lock copy
+};
+
+#endif
index 22270f1dc00a76928db42519b846b0c83b40ced3..aa52822c4a54bfd369db3cf7f3d019a30087aa40 100644 (file)
@@ -29,6 +29,7 @@
 #include "VTKViewer_AppendFilter.h"
 #include "VISU_MergeFilter.hxx"
 #include "VTKViewer_CellLocationsArray.h"
+#include "VISU_CommonCellsFilter.hxx"
 
 #include <vtkPoints.h>
 #include <vtkUnstructuredGrid.h>
@@ -460,6 +461,66 @@ namespace VISU
     return myIDMapper->GetElemCell(theObjID);
   }
   
+  //---------------------------------------------------------------
+  TIDCommonCellsFilter
+  ::TIDCommonCellsFilter():
+    myIsSpecialKey(false)
+  {}
+  
+  const TVTKCommonCellsFilter&
+  TIDCommonCellsFilter
+  ::GetFilter() const
+  {
+    if(!myFilter.GetPointer()){
+      myFilter = VISU_CommonCellsFilter::New();
+      myFilter->Delete();
+      myMergeFilter = VISU_MergeFilter::New();
+      myMergeFilter->Delete();
+    }
+    return myFilter;
+  }
+
+  TVTKOutput* 
+  TIDCommonCellsFilter
+  ::GetVTKOutput()
+  {
+    if(!myFilter.GetPointer()){
+      const TVTKAppendFilter& anAppendFilter = myIDMapper->GetFilter();
+      TVTKOutput* aGeometry;
+
+      const TVTKSource& aSource = mySource.GetSource();
+      TDataSet* aDataSet;
+      const TVTKCommonCellsFilter& aFilter = GetFilter();
+      
+      if(myIsSpecialKey){
+        PNamedIDMapperMap::iterator aIter;
+        aIter = myMappers.find(VISU::CELL_ENTITY);
+        if(aIter!=myMappers.end()) aFilter->SetCellsUG((aIter->second)->GetVTKOutput());
+        else {
+          aIter = myMappers.find(VISU::FACE_ENTITY);
+          if(aIter!=myMappers.end()) aFilter->SetCellsUG((aIter->second)->GetVTKOutput());
+          else {
+            aIter = myMappers.find(VISU::EDGE_ENTITY);
+            if(aIter!=myMappers.end()) aFilter->SetCellsUG((aIter->second)->GetVTKOutput());
+          }
+        }
+      }
+      
+      aGeometry = anAppendFilter->GetOutput();
+      aDataSet = aSource.GetPointer();
+      aDataSet->ShallowCopy(aGeometry);
+      
+      myMergeFilter->SetGeometry(aGeometry);
+      myMergeFilter->SetScalars(aDataSet);
+      myMergeFilter->SetVectors(aDataSet);
+      myMergeFilter->AddField("VISU_FIELD",aDataSet);
+      myMergeFilter->AddField("VISU_CELLS_MAPPER",aDataSet);
+      myMergeFilter->AddField("VISU_POINTS_MAPPER",aDataSet);
+
+      aFilter->SetProfileUG(myMergeFilter->GetOutput());
+    } 
+    return myFilter->GetOutput();
+  }
 
   //---------------------------------------------------------------
   void
@@ -827,7 +888,7 @@ namespace VISU
   TValForTimeImpl
   ::TValForTimeImpl():
     myGaussPtsIDFilter(new TGaussPtsIDFilter()),
-    myIDMapperFilter(new TIDMapperFilter())
+    myIDMapperFilter(new TIDCommonCellsFilter())
   {}
 
   const TMeshValue& 
@@ -2119,27 +2180,85 @@ VISU_Convertor_impl
                        const VISU::PMeshOnEntityImpl& theMeshOnEntity,
                        const VISU::PFieldImpl& theField,
                        const VISU::PValForTimeImpl& theValForTime,
-                       const VISU::PIDMapperFilter& theIDMapperFilter,
+                       const VISU::PIDCommonCellsFilter& theIDMapperFilter,
                        const VISU::PProfileImpl& theProfile,
                        const VISU::TEntity& theEntity)
 {
   TVTKOutput* anOutput = NULL;
+#ifndef _DEXCEPT_
   try{
+#endif
+    // load points if theMeshOnEntity->myEntity == NODE_ENTITY
+    // load all coordinates itc.
+    
     LoadMeshOnEntity(theMesh,theMeshOnEntity);
     GetMeshOnEntity(theMeshOnEntity->myMeshName,theMeshOnEntity->myEntity);
     if(GetMeshOnProfile(theMesh,theMeshOnEntity,theProfile)){
+
+      bool isNeedInCells = false;
       theIDMapperFilter->myIDMapper = theProfile;
-      anOutput = theIDMapperFilter->GetVTKOutput();
-      const TVTKSource& aSource = theIDMapperFilter->mySource.GetSource();
-      ::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
+      
+      if(theMeshOnEntity->myEntity == VISU::NODE_ENTITY){
+
+        // add geometry elements to output,
+        // if timestamp on NODE_ENTITY and
+        // on profiles with status eAddPart
+        TGeom2SubProfile::const_iterator anIter = theProfile->myGeom2SubProfile.begin();
+        for(; anIter != (theProfile->myGeom2SubProfile).end(); anIter++){
+          const EGeometry aGeom = anIter->first;
+          const PSubProfileImpl aSubProfile = anIter->second;
+          if(aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1){
+            isNeedInCells = true;
+            break;
+          }
+        }
+        if(isNeedInCells){
+          theIDMapperFilter->myIsSpecialKey = true;
+          GetTimeStampOnNodalProfile(theMesh,theIDMapperFilter,theField,theValForTime,theEntity);
+          anOutput = theIDMapperFilter->GetVTKOutput();
+        }
+      }
+
+      if(!isNeedInCells){
+        anOutput = theIDMapperFilter->GetVTKOutput();
+        const TVTKSource& aSource = theIDMapperFilter->mySource.GetSource();
+        ::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
+      }
     }
+#ifndef _DEXCEPT_
   }catch(std::exception& exc){
     MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
     return NULL;
   }
+#endif  
   return anOutput;
 }
 
+void
+VISU_Convertor_impl
+::GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh,
+                             const VISU::PIDCommonCellsFilter& theIDMapperFilter,
+                             const VISU::PFieldImpl& theField, 
+                             const VISU::PValForTimeImpl& theValForTime,
+                             const VISU::TEntity& theEntity)
+{
+  INITMSG(MYDEBUG,"GetTimeStampOnNodalProfile");
+  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 != NODE_ENTITY){
+      VISU::PNamedIDMapper aMapper = GetMeshOnEntity(theMesh->myName,aEntity);
+      if(aMapper)
+        theIDMapperFilter->myMappers[aEntity] = aMapper;
+    }
+  }
+
+  theIDMapperFilter->GetVTKOutput();
+  const TVTKSource& aSource = theIDMapperFilter->mySource.GetSource();
+  ::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
+
+}
 
 //---------------------------------------------------------------
 VISU::PIDMapper 
@@ -2169,7 +2288,7 @@ VISU_Convertor_impl
   PFieldImpl aField = boost::get<3>(aFindTimeStamp);
 
   //Main part of code
-  PIDMapperFilter anIDMapperFilter = aValForTime->myIDMapperFilter;
+  PIDCommonCellsFilter anIDMapperFilter = aValForTime->myIDMapperFilter;
 #ifndef _DEXCEPT_
   try{
 #endif
@@ -2334,15 +2453,22 @@ VISU_Convertor_impl
 VISU_Convertor_impl::TFindMeshOnEntity
 VISU_Convertor_impl
 ::FindMeshOnEntity(const string& theMeshName,
-                  const VISU::TEntity& theEntity)
+                  const VISU::TEntity& theEntity,
+                   bool checkExists)
 {
+  PMeshOnEntityImpl aMeshOnEntity;
   PMeshImpl aMesh = FindMesh(theMeshName);
   VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
   VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
-  if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
-    EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
+  if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()){
+    if(!checkExists){
+      EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
+    } else {
+      return TFindMeshOnEntity(aMesh,aMeshOnEntity);
+    }
+  }
 
-  PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
+  aMeshOnEntity = aMeshOnEntityMapIter->second;
   
   return TFindMeshOnEntity(aMesh,
                           aMeshOnEntity);
index 4d77ada8eb301ce84d2bb1929c0df9fa6e7d99b7..f9f6b15722a43002db88357675a85667fdc16c41 100644 (file)
@@ -38,6 +38,7 @@ class vtkPoints;
 class vtkUnstructuredGrid;
 class VTKViewer_AppendFilter;
 class VISU_MergeFilter;
+class VISU_CommonCellsFilter;
 
 #include "VISU_Convertor.hxx"
 #include "MED_SliceArray.hxx"
@@ -73,6 +74,7 @@ namespace VISU
   typedef vtkSmartPointer<TDataSet> TVTKSource;
   typedef vtkSmartPointer<vtkPoints> TVTKPoints;
   typedef vtkSmartPointer<VISU_MergeFilter> TVTKMergeFilter;
+  typedef vtkSmartPointer<VISU_CommonCellsFilter> TVTKCommonCellsFilter;
 
   typedef vtkSmartPointer<VTKViewer_AppendFilter> TVTKAppendFilter;
 
@@ -165,7 +167,7 @@ namespace VISU
     TVTKOutput* 
     GetVTKOutput();
   };
-  typedef SharedPtr<TAppendFilter> PAppendFilter;
+  typedef SharedPtr<TMergeFilter> PMergeFilter;
 
 
   //---------------------------------------------------------------
@@ -428,7 +430,37 @@ namespace VISU
   };
   typedef SharedPtr<TIDMapperFilter> PIDMapperFilter;
 
+  typedef std::map<VISU::TEntity,VISU::PNamedIDMapper> PNamedIDMapperMap;
+  //---------------------------------------------------------------
+  //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
+  struct TIDCommonCellsFilter: virtual TIDMapperFilter
+  {
+  protected:
+    mutable TVTKCommonCellsFilter myFilter;
+    mutable TVTKMergeFilter myMergeFilter;
+  public:
+    
+    TIDCommonCellsFilter();
+
+    //! This method allow to create corresponding VTK filter by demand (not at once)
+    const TVTKCommonCellsFilter& 
+    GetFilter() const;
+
+    //! 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;
+    //! Reimplement the TIDMapperFilter::GetVTKOutput
+    virtual
+    TVTKOutput* 
+    GetVTKOutput();
+  };
+  typedef SharedPtr<TIDCommonCellsFilter> PIDCommonCellsFilter;
 
+  
   //---------------------------------------------------------------
   struct TGaussImpl;
   typedef SharedPtr<TGaussImpl> PGaussImpl;
@@ -754,7 +786,7 @@ namespace VISU
   struct TValForTimeImpl: virtual TValForTime
   {
     PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
-    PIDMapperFilter myIDMapperFilter; //!< Keep VTK representation for ordinary mesh and data
+    PIDCommonCellsFilter myIDMapperFilter; //!< Keep VTK representation for ordinary mesh and data
     TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh
     TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points
    
@@ -913,7 +945,8 @@ protected:
   typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl> TFindMeshOnEntity;
   TFindMeshOnEntity
   FindMeshOnEntity(const std::string& theMeshName,
-                  const VISU::TEntity& theEntity);
+                  const VISU::TEntity& theEntity,
+                   bool checkExists=false);
 
   //! An utility method to find TFamily by name of its parent mesh, corresponding entity and its name
   typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindFamilyOnEntity;
@@ -955,9 +988,17 @@ protected:
                        const VISU::PMeshOnEntityImpl& theMeshOnEntity,
                        const VISU::PFieldImpl& theField,
                        const VISU::PValForTimeImpl& theValForTime,
-                       const VISU::PIDMapperFilter& theIDMapperFilter,
+                       const VISU::PIDCommonCellsFilter& theIDMapperFilter,
                        const VISU::PProfileImpl& theProfile,
                        const VISU::TEntity& theEntity);
+
+  void
+  GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh,
+                             const VISU::PIDCommonCellsFilter& theIDMapperFilter,
+                             const VISU::PFieldImpl& theField, 
+                             const VISU::PValForTimeImpl& theValForTime,
+                             const VISU::TEntity& theEntity);
+  
   
 protected:
   //! To fill intermeiate representation of TMeshOnEntity from a MED source
index f0b3b05b4e2c0975bd7ac0f36d1196a7254f21f9..607446638c6941c8e395e5c3082e7d427969b40c 100644 (file)
@@ -736,7 +736,7 @@ static int MY_GROUP_DEBUG = 0;
          const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
          VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
          vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
-         TInt aNbElem = theGrilleInfo->GetNbCells();
+         TInt aNbElem = aGeom2SizeIter->second;//theGrilleInfo->GetNbCells();
          aMeshOnEntity->myNbCells += aNbElem;
          aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
          
@@ -1083,10 +1083,12 @@ static int MY_GROUP_DEBUG = 0;
   TMEDSubProfile
   ::GetElemObjID(vtkIdType theID) const
   {
-    if(myIsElemNum)
-      return myElemNum[theID];
-    else
-      return theID;
+    if(mySubMeshID.empty())
+      if(myIsElemNum)
+        return myElemNum[theID];
+      else
+        return theID;
+    return mySubMeshID[theID];
   }
   
 
@@ -1978,7 +1980,7 @@ VISU_MedConvertor
          vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
          INITMSG(MYDEBUG,"aVNbNodes = "<<aVNbNodes<<"\n");
        
-         TInt aNbElem = aGrilleInfo->GetNbCells();
+         TInt aNbElem = aGeom2SizeIter->second;//aGrilleInfo->GetNbCells();
          
          if(aNbElem > 0){
            PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());