]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug NPAL14169: EDF VISU 256 : No continuum on a scalarmap
authorenk <enk@opencascade.com>
Fri, 20 Apr 2007 13:01:32 +0000 (13:01 +0000)
committerenk <enk@opencascade.com>
Fri, 20 Apr 2007 13:01:32 +0000 (13:01 +0000)
On comment 2007-04-18 14:22

src/CONVERTOR/VISU_AppendFilter.cxx
src/CONVERTOR/VISU_CommonCellsFilter.cxx
src/CONVERTOR/VISU_ConvertorUtils.cxx
src/CONVERTOR/VISU_ConvertorUtils.hxx
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_MergeFilter.cxx
src/CONVERTOR/VISU_MergeFilter.hxx
src/OBJECT/VISU_Actor.cxx

index b99e7d869c9222f239cf89e19e640e864d79616d..4814305d281f66d2e491626b1704d17d8424ec69 100644 (file)
 #include <vector>
 #include <map>
 
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+// TTimerLog
+#include "VISU_ConvertorUtils.hxx"
+
 vtkCxxRevisionMacro(VISU_AppendFilter, "$Revision$");
 vtkStandardNewMacro(VISU_AppendFilter);
 
@@ -99,7 +107,8 @@ namespace
   typedef vtkIdType TInputId;
   typedef std::pair<TInputId, TCellId> TInputCellId;
 
-  typedef vtkIdType TObjectId;
+  // <ObjectId, Entity>
+  typedef std::pair<vtkIdType,vtkIdType> TObjectId; 
   typedef std::map<TObjectId, TInputCellId> TObject2InputIdMap;
   
   void
@@ -109,14 +118,19 @@ namespace
   {
     if(vtkDataArray *aDataArray = theCellData->GetArray("VISU_CELLS_MAPPER")){
       if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(aDataArray)){
-       int aMaxId = anIntArray->GetMaxId();
-       int* aPointer = anIntArray->GetPointer(0);
-       int* anEndPointer = anIntArray->GetPointer(aMaxId + 1);
-       for(vtkIdType aCellId = 0; aPointer != anEndPointer; aPointer++, aCellId++){
-         TObjectId anObjectId = *aPointer;
+        int aNbTuples = anIntArray->GetNumberOfTuples();
+        int *aPtr = anIntArray->GetPointer(0);
+       for(vtkIdType aCellId = 0; aCellId<aNbTuples;aCellId++){
+          int aObjId = *aPtr;
+          aPtr++;
+          int aEntity = *aPtr;
+          aPtr++;
+         TObjectId anObjectId(aObjId,aEntity);
+            
          TObject2InputIdMap::iterator anIter = theResult.find(anObjectId);
-         if(anIter != theResult.end())
+         if(anIter != theResult.end()){
            continue;
+          }
          TInputCellId anInputCellId(theInputId, aCellId);
          theResult.insert(anIter, TObject2InputIdMap::value_type(anObjectId, anInputCellId));
        }
@@ -219,12 +233,19 @@ void
 VISU_AppendFilter
 ::Execute()
 {
+  VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_AppendFilter::Execute");
+  vtkUnstructuredGrid *anOutput = this->GetOutput(); 
+  if(this->NumberOfInputs == 1){
+    anOutput->ShallowCopy(this->Inputs[0]);
+    return;
+  }
+  
+    
   if(GetSharedPointsDataSet()){
     vtkPoints* aPoints = GetSharedPointsDataSet()->GetPoints();
     if(aPoints->GetNumberOfPoints() < 1)
       return;
   
-    vtkUnstructuredGrid *anOutput = this->GetOutput(); 
     if(IsMergingInputs()){
       TCellIdMerger aFunctor(this->NumberOfInputs);
       ForEachInput<TCellIdMerger>(this->Inputs, this->NumberOfInputs, aFunctor);
index 6be2c3e2ebcc3c2bb7d28613e831c1ff33eb3238..2473ea64f5125f640d478d8c43be95caff2a4cbb 100644 (file)
@@ -4,6 +4,7 @@
 // Copyright : Open CASCADE
 
 #include "VISU_CommonCellsFilter.hxx"
+#include "VISU_ConvertorDef.hxx"
 
 // VTK product headers
 #include <vtkUnstructuredGrid.h>
@@ -21,6 +22,7 @@
 #include <algorithm>
 #include <vector>
 #include <map>
+#include <set>
 
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
@@ -33,18 +35,57 @@ static int MYDEBUG = 0;
 
 namespace
 {
-  typedef std::vector<int> TSortedArray;
+  typedef std::pair<int,int> TPair;// pair first - object id, second - entity
+  //
+  typedef std::vector<int>  TSortedArrayOne;
+  typedef std::set<TPair>   TSortedArrayPair;
+  typedef std::set<int>     TIdSet;
   typedef std::map<int,int> TId2IdMap;
 
   inline
   void
-  GetSortedArray(vtkIntArray *theArray, 
-                TSortedArray& theSortedArray)
+  GetSortedArrayAsPair(vtkIntArray *theArray, 
+                       TSortedArrayPair& theSortedArray)
+  {
+    TSortedArrayPair aSortedArray;
+    int nbComp = theArray->GetNumberOfComponents();
+    if(nbComp == 2){
+      int aMaxId = theArray->GetNumberOfTuples()*theArray->GetNumberOfComponents();
+      int* aPointer = theArray->GetPointer(0);
+      int* anEndPointer = theArray->GetPointer(aMaxId + 1);
+      for(;aPointer<anEndPointer;){
+        TPair aPair;
+        aPair.first = *aPointer;
+        aPointer++;
+        aPair.second = *aPointer;
+        aPointer++;
+        aSortedArray.insert(aPair);
+      }
+    } else if (nbComp == 1) {
+      int aMaxId = theArray->GetNumberOfTuples();
+      int* aPointer = theArray->GetPointer(0);
+      int* anEndPointer = theArray->GetPointer(aMaxId + 1);
+      for(;aPointer<anEndPointer;){
+        TPair aPair;
+        aPair.first = *aPointer;
+        aPointer++;
+        aPair.second = (int)VISU::NODE_ENTITY;
+        aSortedArray.insert(aPair);
+      }
+      
+    }
+    theSortedArray.swap(aSortedArray);
+  }
+
+  inline
+  void
+  GetSortedArrayOne(vtkIntArray *theArray, 
+                    TSortedArrayOne& theSortedArray)
   {
     int aMaxId = theArray->GetMaxId();
     int* aPointer = theArray->GetPointer(0);
     int* anEndPointer = theArray->GetPointer(aMaxId + 1);
-    TSortedArray aSortedArray(aPointer, anEndPointer);
+    TSortedArrayOne aSortedArray(aPointer, anEndPointer);
     std::sort(aSortedArray.begin(), aSortedArray.end());
     theSortedArray.swap(aSortedArray);
   }
@@ -53,27 +94,37 @@ namespace
   void
   GetIdsForCopy(vtkUnstructuredGrid *inputUGrid, 
                 vtkIntArray* inputPointIds,
-                TSortedArray& outputSortedArray)
+                TSortedArrayOne& outputSortedArray)
   {
-    VISU::TTimerLog aTimerLog(MYDEBUG,"GetIdsForCopy");
     if(inputUGrid){
-      TSortedArray aSortedPointIds;
-      TSortedArray aOutputCellIds;
-      GetSortedArray(inputPointIds,aSortedPointIds);
-      
+      TSortedArrayOne aSortedPointIds;
+      TSortedArrayOne aOutputCellIds;
+      TIdSet aMapForSearch;
+      int nbTuples = inputPointIds->GetNumberOfTuples();
+      int nbComp = inputPointIds->GetNumberOfComponents();
+      int * aPtr = inputPointIds->GetPointer(0);
+      int * aPtrEnd = inputPointIds->GetPointer(nbTuples*nbComp+1);
+      if(nbComp == 1)
+        while(aPtr<aPtrEnd){
+          aMapForSearch.insert(*aPtr);
+          aPtr++;
+        }
+      else if (nbComp == 2)
+        while(aPtr<aPtrEnd){
+          aMapForSearch.insert(*aPtr);
+          aPtr++;aPtr++;
+        }
       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 nbPointsInCell = ptIds->GetNumberOfIds();
         bool aGoodCell = true;
         for(int i=0;i<nbPointsInCell;i++){
           int aSearchingId = ptIds->GetId(i);
-          TSortedArray::iterator aResult = find(aSortedPointIds.begin(),aSortedPointIds.end(),aSearchingId);
-          if(aResult == aSortedPointIds.end()){
+          TIdSet::iterator aResult = aMapForSearch.find(aSearchingId);
+          if(aResult == aMapForSearch.end()){
             aGoodCell = false;
             break;
           }
@@ -93,11 +144,16 @@ namespace
   void
   CopyElementsToOutput(vtkUnstructuredGrid* theInputUG,
                        int& theNbElements,
-                       TSortedArray& theElementIdsForCopy,
+                       TSortedArrayOne& theElementIdsForCopy,
                        TId2IdMap& theOldId2NewIdPointsMap,
-                       vtkIntArray* theOuputIDSArray,
                        vtkUnstructuredGrid* theOutputUG)
   {
+    vtkIntArray* theOuputIDSArray = vtkIntArray::New();
+    theOuputIDSArray->SetName("VISU_CELLS_MAPPER");
+    theOuputIDSArray->SetNumberOfComponents(2);
+    theOuputIDSArray->SetNumberOfTuples(theNbElements);
+    int* aOuputIDSPtr = theOuputIDSArray->GetPointer(0);
+    
     vtkIntArray* aInputCellsMapper =
       dynamic_cast<vtkIntArray*>(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER"));
     int* aInputCellsMapperPointer = aInputCellsMapper->GetPointer(0);
@@ -115,13 +171,18 @@ namespace
       const int aOldCellId = theElementIdsForCopy[aCellIndex];
       theOutputUG->InsertNextCell(theInputUG->GetCellType(aOldCellId),
                                   aNewPointIds);
-      if(aInputCellsMapperPointer)
-        theOuputIDSArray->InsertNextValue(aInputCellsMapperPointer[aOldCellId]);
-      else
-        theOuputIDSArray->InsertNextValue(aOldCellId);
+
+      *aOuputIDSPtr = aInputCellsMapperPointer[2*aOldCellId];
+      aOuputIDSPtr++;
+      *aOuputIDSPtr = aInputCellsMapperPointer[2*aOldCellId+1];
+      aOuputIDSPtr++;
       
       aNewPointIds->Delete();
     }
+
+    theOutputUG->GetCellData()->AddArray(theOuputIDSArray);
+    
+    theOuputIDSArray->Delete();
   }
 }
 
@@ -171,6 +232,7 @@ void
 VISU_CommonCellsFilter
 ::Execute()
 {
+  VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_CommonCellsFilter::Execute");
   vtkUnstructuredGrid* anInputProfileUG = this->GetProfileUG();
   vtkUnstructuredGrid* anInputCellsUG   = this->GetCellsUG();
 
@@ -206,9 +268,11 @@ VISU_CommonCellsFilter
           vtkIntArray* aPointIDS =
             dynamic_cast<vtkIntArray*>(aInputCellData->GetArray("VISU_CELLS_MAPPER"));
           if(aPointIDS){
+            int* aPtr = aPointIDS->GetPointer(0);
             aPointIdsForCopy->SetNumberOfIds(aPointIDS->GetNumberOfTuples());
             for(int i=0;i<aPointIDS->GetNumberOfTuples();i++){
-              aPointIdsForCopy->SetId(i,aPointIDS->GetValue(i));
+              aPointIdsForCopy->SetId(i,*aPtr);
+              aPtr++;aPtr++;
             }
             aOutputPointSet->SetNumberOfPoints(aPointIdsForCopy->GetNumberOfIds());
             // aOutputPointSet copy points from anInputProfileUG to aOutputPointSet, which
@@ -242,7 +306,7 @@ VISU_CommonCellsFilter
           // Calculate output cells
           int nbCells=0;
 
-          TSortedArray aCellIdsForCopy;
+          TSortedArrayOne aCellIdsForCopy;
           
           GetIdsForCopy(anInputCellsUG,aPointIDS,aCellIdsForCopy);
           nbCells = aCellIdsForCopy.size();
@@ -250,22 +314,15 @@ VISU_CommonCellsFilter
           // 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();
         }
       }
index d1334e0213c903e89fe484c05b3ac343725aadf1..7839fab88c88abd85e7ed1abec1ed4034e084122 100644 (file)
@@ -83,17 +83,26 @@ namespace VISU
 
   //---------------------------------------------------------------
   vtkIdType
-  GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID)
+  GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity)
   {
     theDataSet->Update();
     vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData();
     if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){
       if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(aDataArray)){
-       int aMaxId = anIntArray->GetMaxId();
+        int nbTuples = anIntArray->GetNumberOfTuples();
+        int aMaxId = nbTuples * anIntArray->GetNumberOfComponents();
        int* aPointer = anIntArray->GetPointer(0);
-       int* anEndPointer = anIntArray->GetPointer(aMaxId + 1);
-       int* aPtr = std::find(aPointer, anEndPointer, theID);
-       return aPtr - aPointer;
+        for(int i=0;i<nbTuples;i++){
+          if ( *aPointer == theID ){
+            aPointer++;
+            if( *aPointer == theEntity)
+              return i;
+            aPointer++;
+            continue;
+          }
+          aPointer++;aPointer++;
+        }
+       return -1;
       }
     }
     return -1;
@@ -108,7 +117,8 @@ namespace VISU
     vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData();
     if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){
       if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(aDataArray)){
-       return anIntArray->GetValue(theID);
+        int nbComp = anIntArray->GetNumberOfComponents();
+       return *anIntArray->GetPointer(theID*nbComp);
       }
     }
     return -1;
index 6c952733c00c0835fe77381e70ddf4942fe3b2ac..f70b69f55b141ad2ddeeb4bb83addf5160c2e3c0 100644 (file)
@@ -56,7 +56,7 @@ namespace VISU
   IsDataOnPoints(vtkDataSet* theDataSet);
 
   vtkIdType
-  GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID);
+  GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity);
 
   vtkIdType
   GetElemObjID(vtkDataSet *theDataSet, vtkIdType theID);
index 1a91c358a37ad2bad568cdf67a19a1bbfe232f05..fa80167575edbdf4d0685086b21607909e1e4e27 100644 (file)
@@ -657,7 +657,7 @@ namespace VISU
   ::GetElemVTKID(vtkIdType theID) const
   {
     VISU::TVTKOutput* anOutput = GetFilter()->GetOutput();
-    return VISU::GetElemVTKID(anOutput, theID);
+    return VISU::GetElemVTKID(anOutput, theID, (int)myEntity);
   }
 
   vtkIdType
@@ -1284,16 +1284,22 @@ namespace
       int aNbTuples = aNbCells;
       vtkIntArray *aDataArray = vtkIntArray::New();
       aDataArray->SetName("VISU_CELLS_MAPPER");
-      aDataArray->SetNumberOfComponents(1);
+      // the [0] component is element object ID
+      // the [1] component is entity type
+      aDataArray->SetNumberOfComponents(2);
       aDataArray->SetNumberOfTuples(aNbTuples);
+      int *aPtr = aDataArray->GetPointer(0);
       for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
        int anObjID = theSubMesh->GetElemObjID(aTupleId);
-       aDataArray->SetValue(aTupleId, anObjID);
+        *aPtr = anObjID;
+        aPtr++;
+        *aPtr = (int)theMeshOnEntity->myEntity;
+        aPtr++;
       }
       theSource->GetCellData()->AddArray(aDataArray);
+      
       aDataArray->Delete();
     }
-
     vtkIdType *pts = 0, npts = 0;
     VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
     aCellLocationsArray->SetNumberOfComponents(1);
@@ -1332,10 +1338,14 @@ namespace
     aMeshID.resize(aNbCells);
 
     vtkIntArray *aDataArray = vtkIntArray::New();
+
     aDataArray->SetName("VISU_CELLS_MAPPER");
-    aDataArray->SetNumberOfComponents(1);
+    // the [0] component is element object ID
+    // the [1] component is entity type
+    aDataArray->SetNumberOfComponents(2);
     aDataArray->SetNumberOfTuples(aNbCells);
-
+    int *aPtr = aDataArray->GetPointer(0);
+    
     VISU::TID2ID& anElemObj2VTKID = theFamily->myElemObj2VTKID;
 
     const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
@@ -1343,7 +1353,7 @@ namespace
     for(vtkIdType aCellId = 0; anIter != aGeom2SubMesh.end(); anIter++){
       VISU::EGeometry aEGeom = anIter->first;
       vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
-
+      
       const VISU::TSubMeshImpl& aSubMesh = anIter->second;
       const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect;
 
@@ -1369,12 +1379,14 @@ namespace
        PrintCells(aCellId, aConnectivity, anArray[anID]);
        aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom);
        vtkIdType anObjID = aSubMesh.GetElemObjID(anID);
-       aDataArray->SetValue(aCellId, anObjID);
+        *aPtr = anObjID;
+        aPtr++;
+        *aPtr = (int)theMeshOnEntity->myEntity;
+        aPtr++;
        anElemObj2VTKID[anObjID] = aCellId;
        aMeshID[aCellId] = anObjID;
       }
     }
-
     theSource->GetCellData()->AddArray(aDataArray);
     aDataArray->Delete();
 
@@ -1501,7 +1513,7 @@ namespace
     VISU::EGeometry aEGeom = theSubProfile->myGeom;
     vtkIdType aNbNodes = VISUGeom2NbNodes(aEGeom);
     vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
-
+    
     INITMSG(MYDEBUG,"GetCells - aVGeom = "<<aVGeom<<endl);
 
     const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
@@ -1555,16 +1567,22 @@ namespace
       int aNbTuples = aNbCells;
       vtkIntArray *aDataArray = vtkIntArray::New();
       aDataArray->SetName("VISU_CELLS_MAPPER");
-      aDataArray->SetNumberOfComponents(1);
+      // the [0] component is element object ID
+      // the [1] component is entity type
+      aDataArray->SetNumberOfComponents(2);
       aDataArray->SetNumberOfTuples(aNbTuples);
+      int *aPtr = aDataArray->GetPointer(0);
+      
       for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
        int anObjID = theSubProfile->GetElemObjID(aTupleId);
-       aDataArray->SetValue(aTupleId, anObjID);
+        *aPtr = anObjID;
+        aPtr++;
+        *aPtr = (int)theMeshOnEntity->myEntity;
+        aPtr++;
       }
       theSource->GetCellData()->AddArray(aDataArray);
       aDataArray->Delete();
     }
-    
     aCellLocationsArray->Delete();
     aCellTypesArray->Delete();
     aConnectivity->Delete();
index 138db50470e0d85ae87dbdba4cc60bf4b8718688..2b841cf193784b2e7320fa2339f20d948dbc8213 100644 (file)
 #include <algorithm>
 #include <vector>
 #include <map>
+#include <set>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+// TTimerLog
+#include "VISU_ConvertorUtils.hxx"
 
 namespace VISU
 {
@@ -263,6 +272,7 @@ namespace
   }
 
   typedef std::map<int,int> TId2IdMap;
+  typedef std::set<int> TIdSet;
 
   template <class TNumericType>
   void DeepCopySwitchOnOutput(TNumericType *theInputPtr, 
@@ -502,21 +512,33 @@ namespace
     if(inputUGrid){
       TSortedArray aSortedPointIds;
       TSortedArray aOutputCellIds;
-      GetSortedArray(inputPointIds,aSortedPointIds);
-      
+
+      TIdSet aMapForSearch;
+      int nbTuples = inputPointIds->GetNumberOfTuples();
+      int nbComp = inputPointIds->GetNumberOfComponents();
+      int * aPtr = inputPointIds->GetPointer(0);
+      int * aPtrEnd = inputPointIds->GetPointer(nbTuples*nbComp+1);
+      if(nbComp == 1)
+        while(aPtr<aPtrEnd){
+          aMapForSearch.insert(*aPtr);
+          aPtr++;
+        }
+      else if (nbComp == 2)
+        while(aPtr<aPtrEnd){
+          aMapForSearch.insert(*aPtr);
+          aPtr++;aPtr++;
+        }
       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 nbPointsInCell = ptIds->GetNumberOfIds();
         bool aGoodCell = true;
         for(int i=0;i<nbPointsInCell;i++){
           int aSearchingId = ptIds->GetId(i);
-          TSortedArray::iterator aResult = find(aSortedPointIds.begin(),aSortedPointIds.end(),aSearchingId);
-          if(aResult == aSortedPointIds.end()){
+          TIdSet::iterator aResult = aMapForSearch.find(aSearchingId);
+          if(aResult == aMapForSearch.end()){
             aGoodCell = false;
             break;
           }
@@ -525,6 +547,7 @@ namespace
           aOutputCellIds.push_back(idCell);
         else
           continue;
+        
       }
 
       outputSortedArray.swap(aOutputCellIds);
@@ -537,9 +560,16 @@ namespace
                        int& theNbElements,
                        TSortedArray& theElementIdsForCopy,
                        TId2IdMap& theOldId2NewIdPointsMap,
-                       vtkIntArray* theOuputIDSArray,
                        vtkUnstructuredGrid* theOutputUG)
   {
+    vtkIntArray* theOuputIDSArray = vtkIntArray::New();
+    theOuputIDSArray->SetName("VISU_CELLS_MAPPER");
+    // the [0] component is element object ID
+    // the [1] component is entity type
+    theOuputIDSArray->SetNumberOfComponents(2);
+    theOuputIDSArray->SetNumberOfTuples(theNbElements);
+    int* aOuputIDSPtr = theOuputIDSArray->GetPointer(0);
+    
     vtkIntArray* aInputCellsMapper =
       dynamic_cast<vtkIntArray*>(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER"));
     
@@ -559,17 +589,333 @@ namespace
       const int aOldCellId = theElementIdsForCopy[aCellIndex];
       theOutputUG->InsertNextCell(theInputUG->GetCellType(aOldCellId),
                                   aNewPointIds);
-      if(aInputCellsMapperPointer)
-        theOuputIDSArray->InsertNextValue(aInputCellsMapperPointer[aOldCellId]);
-      else
-        theOuputIDSArray->InsertNextValue(aOldCellId);
+
+      *aOuputIDSPtr = aInputCellsMapperPointer[2*aOldCellId];
+      aOuputIDSPtr++;
+      *aOuputIDSPtr = aInputCellsMapperPointer[2*aOldCellId+1];
+      aOuputIDSPtr++;
       
       aNewPointIds->Delete();
     }
     theOutputUG->GetCellData()->AddArray(theOuputIDSArray);
+    theOuputIDSArray->Delete();
+  }
+  
+  
+}
+
+bool 
+VISU_MergeFilter
+::MergeGeometryCellsAndDataOnCells()
+{
+  if(MYDEBUG) cout << "MergeGeometryCellsAndDataOnCells" << endl;
+  vtkUnstructuredGrid *anInput = this->GetInput();
+  vtkUnstructuredGrid *anOutput = this->GetOutput();
+  vtkCellData *aCellData = anInput->GetCellData();
+  vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); // 1
+  vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper); // 1->2
+  
+  // The situation for merging CELLS from anInput as Geometry
+  // and scalars on cell data
+  vtkIntArray* aDataCellMapper = NULL;
+  VISU::TFieldListIterator anIter(this->FieldList);
+  for(anIter.Begin(); !anIter.End() ; anIter.Next()){
+    vtkCellData *aCellData = anIter.Get()->Ptr->GetCellData();
+    const char* aFieldName = anIter.Get()->GetName();
+    if(strcmp(aFieldName, "VISU_CELLS_MAPPER") == 0){
+      vtkDataArray *aCellMapper_tmp = aCellData->GetArray(aFieldName);
+      aDataCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper_tmp);
+      break;
+    }
+  }
+  
+  bool anIsDifferent = aDataCellMapper &&
+    aDataCellMapper->GetNumberOfTuples() != aGeometryCellMapper->GetNumberOfTuples();
+  
+  if(anIsDifferent || IsMergingInputs() ){
+    TSortedArray aGeometryCellArray;
+    GetSortedArray(aGeometryCellMapper, aGeometryCellArray);
+    
+    TSortedArray aDataCellArray;
+    GetSortedArray(aDataCellMapper, aDataCellArray);
+    
+    int aMaxLength = std::max(aGeometryCellArray.size(), aDataCellArray.size());
+    TSortedArray anIntersectionArray(aMaxLength);
+    TSortedArray::iterator anArrayIter = anIntersectionArray.begin();
+    anArrayIter = std::set_intersection(aGeometryCellArray.begin(),
+                                        aGeometryCellArray.end(),
+                                        aDataCellArray.begin(),
+                                        aDataCellArray.end(),
+                                        anArrayIter);
+    
+    anIntersectionArray.erase(anArrayIter, anIntersectionArray.end());
+    
+    bool anIsCompletelyCoincide = 
+      anIntersectionArray.size() == aGeometryCellArray.size() && 
+      anIntersectionArray.size() == aDataCellArray.size();
+
+    if(!anIsCompletelyCoincide || IsMergingInputs()){
+      {
+        TId2IdMap anObj2VTKGeometryMap;
+        vtkIdType aNbCells = aGeometryCellMapper->GetNumberOfTuples();
+        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+          vtkIdType anObjID = aGeometryCellMapper->GetValue(aCellId);
+          anObj2VTKGeometryMap[anObjID] = aCellId;
+        }
+        
+        vtkIdType aNbTuples = anIntersectionArray.size();
+        anOutput->Allocate(aNbTuples);
+        vtkIdList *aCellIds = vtkIdList::New();
+        for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
+          vtkIdType anObjID = anIntersectionArray[aTupleId];
+          vtkIdType aCellId = anObj2VTKGeometryMap[anObjID];
+          vtkCell *aCell = anInput->GetCell(aCellId);
+          aCellIds->Reset();
+          vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
+          for(vtkIdType aPointId = 0; aPointId < aNbPointIds; aPointId++)
+            aCellIds->InsertNextId(aCell->GetPointIds()->GetId(aPointId));
+          anOutput->InsertNextCell(anInput->GetCellType(aCellId), aCellIds);
+        }
+        aCellIds->Delete();
+        anOutput->SetPoints(anInput->GetPoints());
+       }
+      {
+        TId2IdMap anObj2VTKDataMap;
+        vtkIdType aNbCells = aDataCellMapper->GetNumberOfTuples();
+        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+          vtkIdType anObjID = aDataCellMapper->GetValue(aCellId);
+          anObj2VTKDataMap[anObjID] = aCellId;
+        }
+       
+        DeepCopyDataSetAttributes(this, 
+                                  anOutput, 
+                                  this->FieldList,
+                                  anIntersectionArray, 
+                                  anObj2VTKDataMap);
+      }
+      return true;
+    }
   }
+  return false;
+}
+
+bool
+VISU_MergeFilter
+::MergeGeometryCellsAndDataOnAllPoints()
+{
+  if(MYDEBUG) cout << "MergeGeometryCellsAndDataOnAllPoints" << endl;
+  // The situation for merging CELLS from anInput as Geometry
+  // and scalars on point data
+  vtkUnstructuredGrid *anInput = this->GetInput();
+  vtkUnstructuredGrid *anOutput = this->GetOutput();
+
+  vtkPointData *aPointData   = anInput->GetPointData();
+  vtkCellData *aCellData = anInput->GetCellData();
+  vtkDataSet*  aInputScalars = this->GetScalars();
+  vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData();
+  vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER");
+  vtkIntArray *aGeometryPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
+  vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); // 1
+  vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper); // 1->2
   
+  vtkIntArray* aDataPointMapper = NULL;
+  VISU::TFieldListIterator anIter(this->FieldList);
+  for(anIter.Begin(); !anIter.End() ; anIter.Next()){
+    const char* aFieldName = anIter.Get()->GetName();
+    if(strcmp(aFieldName, "VISU_POINTS_MAPPER") == 0){
+      vtkDataArray *aPointMapper = aInputScalarsPointData->GetArray(aFieldName);
+      aDataPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
+      break;
+    }
+  }
   
+  if(aDataPointMapper){
+    TSortedArray aGeometryPointArray;
+    GetSortedArray(aGeometryPointMapper, aGeometryPointArray);
+    
+    TSortedArray aDataPointArray;
+    GetSortedArray(aDataPointMapper, aDataPointArray);
+    
+    {
+      TId2IdMap anObj2VTKGeometryPointsMap;
+      vtkIdType aNbCells = aDataPointMapper->GetNumberOfTuples();
+      vtkIdType aNbComp = aDataPointMapper->GetNumberOfComponents();
+      int * aPtr = aDataPointMapper->GetPointer(0);
+      if(aNbComp==2){
+        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+          vtkIdType anObjID = *aPtr;
+          aPtr++;aPtr++;
+          anObj2VTKGeometryPointsMap[anObjID] = aCellId;
+        }
+      } else if (aNbComp == 1 ){
+        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+          vtkIdType anObjID = *aPtr;
+          aPtr++;
+          anObj2VTKGeometryPointsMap[anObjID] = aCellId;
+        }
+      }
+
+      TId2IdMap anObj2VTKGeometryCellsMap;
+      aNbCells = aGeometryCellMapper->GetNumberOfTuples();
+      aNbComp  = aGeometryCellMapper->GetNumberOfComponents();
+      aPtr = aGeometryCellMapper->GetPointer(0);
+      if(aNbComp == 1)
+        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+          vtkIdType anObjID = *aPtr;
+          aPtr++;
+          anObj2VTKGeometryCellsMap[anObjID] = aCellId;
+        }
+      else if (aNbComp == 2){
+        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+          vtkIdType anObjID = *aPtr;
+          aPtr++;aPtr++;
+          anObj2VTKGeometryCellsMap[anObjID] = aCellId;
+        }
+      }
+      
+      // copy points to output
+      vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast<vtkUnstructuredGrid*>(aInputScalars);
+      if(aUnstructuredScalars)
+        anOutput->SetPoints(aUnstructuredScalars->GetPoints());
+      anOutput->GetPointData()->ShallowCopy(aInputScalars->GetPointData());
+      
+      // Calculate output cells
+      int nbCells=0;
+      TSortedArray aCellIdsForCopy_fromCellMapper;
+      GetSortedArray(aGeometryCellMapper, aCellIdsForCopy_fromCellMapper);
+      nbCells = aCellIdsForCopy_fromCellMapper.size();
+      
+      TSortedArray aCellIdsForCopy;
+      for(int i=0;i<nbCells;i++)
+        aCellIdsForCopy.push_back(anObj2VTKGeometryCellsMap[aCellIdsForCopy_fromCellMapper[i]]);
+      
+      // copy cells to output
+      anOutput->Allocate(nbCells);
+      
+      
+      if(nbCells>0)
+        CopyElementsToOutput(anInput,
+                             nbCells,
+                             aCellIdsForCopy,
+                             anObj2VTKGeometryPointsMap,
+                             anOutput);
+      
+      return true;
+    }
+  }
+  return false;
+}
+
+bool
+VISU_MergeFilter
+::MergeGeometryCellsAndDataOnNotAllPoints()
+{
+  if(MYDEBUG) cout << "MergeGeometryCellsAndDataOnNotAllPoints" << endl;
+  // The situation for merging CELLS from anInput as Geometry
+  // and scalars on point data (there the number of points of point data less than
+  // number of points of Geometry)
+  
+  vtkUnstructuredGrid *anInput = this->GetInput();
+  vtkUnstructuredGrid *anOutput = this->GetOutput();
+  vtkDataSet*  aInputScalars = this->GetScalars();
+  vtkPointData *aPointData   = anInput->GetPointData();
+
+  vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData();
+  vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER");
+  vtkIntArray *aGeometryPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
+  
+  vtkIntArray* aDataPointMapper = NULL;
+  VISU::TFieldListIterator anIter(this->FieldList);
+  for(anIter.Begin(); !anIter.End() ; anIter.Next()){
+    const char* aFieldName = anIter.Get()->GetName();
+    if(strcmp(aFieldName, "VISU_POINTS_MAPPER") == 0){
+      vtkDataArray *aPointMapper = aInputScalarsPointData->GetArray(aFieldName);
+      aDataPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
+      break;
+    }
+  }
+  vtkIntArray* aDataCellMapper = NULL;
+  VISU::TFieldListIterator anIter2(this->FieldList);
+  for(anIter2.Begin(); !anIter2.End() ; anIter2.Next()){
+    const char* aFieldName = anIter2.Get()->GetName();
+    if(strcmp(aFieldName, "VISU_CELLS_MAPPER") == 0){
+      vtkDataArray *aCellMapper_tmp = aInputScalarsPointData->GetArray(aFieldName);
+      aDataCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper_tmp);
+      break;
+    }
+  }
+  
+  vtkIntArray* aDataArray = NULL;
+  VISU::TFieldListIterator anIter3(this->FieldList);
+  for(anIter2.Begin(); !anIter3.End() ; anIter3.Next()){
+    const char* aFieldName = anIter3.Get()->GetName();
+    if(strcmp(aFieldName, "VISU_FIELD") == 0){
+      vtkDataArray *aPointMapper_tmp = aInputScalarsPointData->GetArray(aFieldName);
+      aDataArray = dynamic_cast<vtkIntArray*>(aPointMapper_tmp);
+      break;
+    }
+  }
+  
+  
+  bool anIsDifferent = aDataPointMapper &&
+    aDataPointMapper->GetNumberOfTuples() != aGeometryPointMapper->GetNumberOfTuples();
+  if(anIsDifferent){
+    {
+      vtkIntArray* aPointsIds = vtkIntArray::New();
+      
+      TId2IdMap anObj2VTKGeometryMap;
+      vtkIdType aNbCells = aDataPointMapper->GetNumberOfTuples();
+      aPointsIds->SetNumberOfTuples(aNbCells);
+      aPointsIds->SetNumberOfComponents(1);
+      vtkIdType aNbComp = aDataPointMapper->GetNumberOfComponents();
+      int * aPtr = aDataPointMapper->GetPointer(0);
+      int * aPtrOut = aPointsIds->GetPointer(0);
+      if(aNbComp==2){
+        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+          vtkIdType anObjID = *aPtr;
+          aPtr++;aPtr++;
+          *aPtrOut = anObjID;
+          aPtrOut++;
+          anObj2VTKGeometryMap[anObjID] = aCellId;
+        }
+      } else if (aNbComp == 1 ){
+        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+          vtkIdType anObjID = *aPtr;
+          aPtr++;
+          *aPtrOut = anObjID;
+          aPtrOut++;
+          anObj2VTKGeometryMap[anObjID] = aCellId;
+        }
+      }
+
+      vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast<vtkUnstructuredGrid*>(aInputScalars);
+      if(aUnstructuredScalars)
+        anOutput->SetPoints(aUnstructuredScalars->GetPoints());
+      
+      anOutput->GetPointData()->ShallowCopy(aInputScalars->GetPointData());
+      
+      // Calculate output cells
+      int nbCells=0;
+      TSortedArray aCellIdsForCopy;
+      GetIdsForCopy(anInput,aPointsIds,aCellIdsForCopy);
+      aPointsIds->Delete();
+      nbCells = aCellIdsForCopy.size();
+      
+      // copy cells to output
+      anOutput->Allocate(nbCells);
+        
+      if(nbCells>0)
+        CopyElementsToOutput(anInput,
+                             nbCells,
+                             aCellIdsForCopy,
+                             anObj2VTKGeometryMap,
+                             anOutput);
+      return true;
+    }
+    
+  }
+  
+  return false;
 }
 
 void
@@ -593,10 +939,10 @@ VISU_MergeFilter
 
 void VISU_MergeFilter::Execute()
 {
+  VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_MergeFilter::Execute");
   vtkUnstructuredGrid *anInput = this->GetInput();
   vtkUnstructuredGrid *anOutput = this->GetOutput();
-
-  vtkPointData *aPointData   = anInput->GetPointData();
+  
   vtkDataSet*  aInputScalars = this->GetScalars();
   int nbPointsInScalars = aInputScalars->GetNumberOfPoints();
   int nbPointsInGeometr = anInput->GetNumberOfPoints();
@@ -605,267 +951,23 @@ void VISU_MergeFilter::Execute()
   vtkDataArray* aScalarsOnCellsArray = NULL;
   if(aInputScalars->GetCellData())
     aScalarsOnCellsArray = aInputScalars->GetCellData()->GetArray("VISU_FIELD");
+
   vtkDataArray* aScalarsOnPointsArray = NULL;
   if(aInputScalars->GetPointData())
     aScalarsOnPointsArray = aInputScalars->GetPointData()->GetArray("VISU_FIELD");
   
-  vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER");
-  vtkIntArray *aGeometryPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
   vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER");
   vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper);
 
-  if(aGeometryCellMapper && aScalarsOnCellsArray && (nbPointsInScalars == nbPointsInGeometr)){
-    vtkIntArray* aDataCellMapper = NULL;
-    VISU::TFieldListIterator anIter(this->FieldList);
-    for(anIter.Begin(); !anIter.End() ; anIter.Next()){
-      vtkCellData *aCellData = anIter.Get()->Ptr->GetCellData();
-      const char* aFieldName = anIter.Get()->GetName();
-      if(strcmp(aFieldName, "VISU_CELLS_MAPPER") == 0){
-       vtkDataArray *aCellMapper_tmp = aCellData->GetArray(aFieldName);
-       aDataCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper_tmp);
-       break;
-      }
-    }
-    
-    bool anIsDifferent = aDataCellMapper &&
-      aDataCellMapper->GetNumberOfTuples() != aGeometryCellMapper->GetNumberOfTuples();
-
-    if(anIsDifferent || IsMergingInputs() ){
-      // The situation for merging CELLS from anInput as Geometry
-      // and scalars on cell data
-      TSortedArray aGeometryCellArray;
-      GetSortedArray(aGeometryCellMapper, aGeometryCellArray);
-    
-      TSortedArray aDataCellArray;
-      GetSortedArray(aDataCellMapper, aDataCellArray);
-      
-      int aMaxLength = std::max(aGeometryCellArray.size(), aDataCellArray.size());
-      TSortedArray anIntersectionArray(aMaxLength);
-      TSortedArray::iterator anArrayIter = anIntersectionArray.begin();
-      anArrayIter = std::set_intersection(aGeometryCellArray.begin(),
-                                         aGeometryCellArray.end(),
-                                         aDataCellArray.begin(),
-                                         aDataCellArray.end(),
-                                         anArrayIter);
-      
-      anIntersectionArray.erase(anArrayIter, anIntersectionArray.end());
-      
-      bool anIsCompletelyCoincide = 
-       anIntersectionArray.size() == aGeometryCellArray.size() && 
-       anIntersectionArray.size() == aDataCellArray.size();
-
-      if(!anIsCompletelyCoincide || IsMergingInputs()){
-       {
-         TId2IdMap anObj2VTKGeometryMap;
-         vtkIdType aNbCells = aGeometryCellMapper->GetNumberOfTuples();
-         for(int aCellId = 0; aCellId < aNbCells; aCellId++){
-           vtkIdType anObjID = aGeometryCellMapper->GetValue(aCellId);
-           anObj2VTKGeometryMap[anObjID] = aCellId;
-         }
-         
-         vtkIdType aNbTuples = anIntersectionArray.size();
-         anOutput->Allocate(aNbTuples);
-         vtkIdList *aCellIds = vtkIdList::New();
-         for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
-           vtkIdType anObjID = anIntersectionArray[aTupleId];
-           vtkIdType aCellId = anObj2VTKGeometryMap[anObjID];
-           vtkCell *aCell = anInput->GetCell(aCellId);
-           aCellIds->Reset();
-           vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
-           for(vtkIdType aPointId = 0; aPointId < aNbPointIds; aPointId++)
-             aCellIds->InsertNextId(aCell->GetPointIds()->GetId(aPointId));
-           anOutput->InsertNextCell(anInput->GetCellType(aCellId), aCellIds);
-         }
-         aCellIds->Delete();
-         anOutput->SetPoints(anInput->GetPoints());
-       }
-       {
-         TId2IdMap anObj2VTKDataMap;
-         vtkIdType aNbCells = aDataCellMapper->GetNumberOfTuples();
-         for(int aCellId = 0; aCellId < aNbCells; aCellId++){
-           vtkIdType anObjID = aDataCellMapper->GetValue(aCellId);
-           anObj2VTKDataMap[anObjID] = aCellId;
-         }
-       
-         DeepCopyDataSetAttributes(this, 
-                                   anOutput, 
-                                   this->FieldList,
-                                   anIntersectionArray, 
-                                   anObj2VTKDataMap);
-       }
-       return;
-      }
-    }
-  } else if (aGeometryCellMapper && aScalarsOnPointsArray && (nbPointsInScalars == nbPointsInGeometr)) {
-    // The situation for merging CELLS from anInput as Geometry
-    // and scalars on point data
-    vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData();
-    
-    vtkIntArray* aDataPointMapper = NULL;
-    VISU::TFieldListIterator anIter(this->FieldList);
-    for(anIter.Begin(); !anIter.End() ; anIter.Next()){
-      const char* aFieldName = anIter.Get()->GetName();
-      if(strcmp(aFieldName, "VISU_POINTS_MAPPER") == 0){
-       vtkDataArray *aPointMapper = aInputScalarsPointData->GetArray(aFieldName);
-       aDataPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
-       break;
-      }
-    }
-
-    if(aDataPointMapper){
-      TSortedArray aGeometryPointArray;
-      GetSortedArray(aGeometryPointMapper, aGeometryPointArray);
-      
-      TSortedArray aDataPointArray;
-      GetSortedArray(aDataPointMapper, aDataPointArray);
-      
-      {
-        TId2IdMap anObj2VTKGeometryPointsMap;
-        vtkIdType aNbCells = aDataPointMapper->GetNumberOfTuples();
-        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
-          vtkIdType anObjID = aDataPointMapper->GetValue(aCellId);
-          anObj2VTKGeometryPointsMap[anObjID] = aCellId;
-        }
-        
-        TId2IdMap anObj2VTKGeometryCellsMap;
-        aNbCells = aGeometryCellMapper->GetNumberOfTuples();
-        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
-          vtkIdType anObjID = aGeometryCellMapper->GetValue(aCellId);
-          anObj2VTKGeometryCellsMap[anObjID] = aCellId;
-        }
-
-        // copy points to output
-        vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast<vtkUnstructuredGrid*>(aInputScalars);
-        if(aUnstructuredScalars)
-          anOutput->SetPoints(aUnstructuredScalars->GetPoints());
-        anOutput->GetPointData()->ShallowCopy(aInputScalars->GetPointData());
-        
-        // Calculate output cells
-        int nbCells=0;
-        TSortedArray aCellIdsForCopy_fromCellMapper;
-        GetSortedArray(aGeometryCellMapper, aCellIdsForCopy_fromCellMapper);
-        nbCells = aCellIdsForCopy_fromCellMapper.size();
-
-        TSortedArray aCellIdsForCopy;
-        for(int i=0;i<nbCells;i++)
-          aCellIdsForCopy.push_back(anObj2VTKGeometryCellsMap[aCellIdsForCopy_fromCellMapper[i]]);
-        
-        // copy cells to output
-        anOutput->Allocate(nbCells);
-        vtkIntArray* theOuputIDSArray = vtkIntArray::New();
-        theOuputIDSArray->SetName("VISU_CELLS_MAPPER");
-        theOuputIDSArray->SetNumberOfComponents(1);
-        theOuputIDSArray->SetNumberOfTuples(nbCells);
-        
-        if(nbCells>0)
-          CopyElementsToOutput(anInput,
-                               nbCells,
-                               aCellIdsForCopy,
-                               anObj2VTKGeometryPointsMap,
-                               theOuputIDSArray,
-                               anOutput);
-        theOuputIDSArray->Delete();
-        
-        return;
-      }
-    }
+  if (aGeometryCellMapper && aScalarsOnCellsArray && (nbPointsInScalars == nbPointsInGeometr)){
+    if(MergeGeometryCellsAndDataOnCells())
+      return;
+  } else if (aGeometryCellMapper && aScalarsOnPointsArray && (nbPointsInScalars == nbPointsInGeometr)){
+    if(MergeGeometryCellsAndDataOnAllPoints())
+      return;
   } else if (aGeometryCellMapper && (nbPointsInScalars < nbPointsInGeometr)) {
-    // The situation for merging CELLS from anInput as Geometry
-    // and scalars on point data (there the number of points of point data less than
-    // number of points of Geometry)
-
-    vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData();
-    
-    vtkIntArray* aDataPointMapper = NULL;
-    VISU::TFieldListIterator anIter(this->FieldList);
-    for(anIter.Begin(); !anIter.End() ; anIter.Next()){
-      const char* aFieldName = anIter.Get()->GetName();
-      if(strcmp(aFieldName, "VISU_POINTS_MAPPER") == 0){
-       vtkDataArray *aPointMapper = aInputScalarsPointData->GetArray(aFieldName);
-       aDataPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
-       break;
-      }
-    }
-    vtkIntArray* aDataCellMapper = NULL;
-    VISU::TFieldListIterator anIter2(this->FieldList);
-    for(anIter2.Begin(); !anIter2.End() ; anIter2.Next()){
-      vtkCellData *aCellData = anIter2.Get()->Ptr->GetCellData();
-      const char* aFieldName = anIter2.Get()->GetName();
-      if(strcmp(aFieldName, "VISU_CELLS_MAPPER") == 0){
-       vtkDataArray *aCellMapper_tmp = aInputScalarsPointData->GetArray(aFieldName);
-       aDataCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper_tmp);
-       break;
-      }
-    }
-
-    bool anIsDifferent = aDataPointMapper &&
-      aDataPointMapper->GetNumberOfTuples() != aGeometryPointMapper->GetNumberOfTuples();
-    if(anIsDifferent){
-      TSortedArray aGeometryPointArray;
-      GetSortedArray(aGeometryPointMapper, aGeometryPointArray);
-      
-      TSortedArray aDataPointArray;
-      GetSortedArray(aDataPointMapper, aDataPointArray);
-
-      int aMaxLength = std::max(aGeometryPointArray.size(), aDataPointArray.size());
-      TSortedArray anIntersectionArray(aMaxLength);
-      TSortedArray::iterator anArrayIter = anIntersectionArray.begin();
-      anArrayIter = std::set_intersection(aGeometryPointArray.begin(),
-                                         aGeometryPointArray.end(),
-                                         aDataPointArray.begin(),
-                                         aDataPointArray.end(),
-                                         anArrayIter);
-      
-      anIntersectionArray.erase(anArrayIter, anIntersectionArray.end());
-      
-      {
-        TId2IdMap anObj2VTKGeometryMap;
-        vtkIdType aNbCells = aDataPointMapper->GetNumberOfTuples();
-        for(int aCellId = 0; aCellId < aNbCells; aCellId++){
-          vtkIdType anObjID = aDataPointMapper->GetValue(aCellId);
-          anObj2VTKGeometryMap[anObjID] = aCellId;
-        }
-        
-        vtkIdType aNbTuples = anIntersectionArray.size();
-        
-        if ( aNbTuples == nbPointsInScalars ){
-          vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast<vtkUnstructuredGrid*>(aInputScalars);
-          if(aUnstructuredScalars)
-            anOutput->SetPoints(aUnstructuredScalars->GetPoints());
-          anOutput->GetPointData()->ShallowCopy(aInputScalars->GetPointData());
-          
-          // Calculate output cells
-          int nbCells=0;
-          TSortedArray aCellIdsForCopy;
-          GetIdsForCopy(anInput,aDataPointMapper,aCellIdsForCopy);
-          nbCells = aCellIdsForCopy.size();
-
-          // copy cells to output
-          anOutput->Allocate(nbCells);
-          vtkIntArray* theOuputIDSArray = vtkIntArray::New();
-          theOuputIDSArray->SetName("VISU_CELLS_MAPPER");
-          theOuputIDSArray->SetNumberOfComponents(1);
-          theOuputIDSArray->SetNumberOfTuples(nbCells);
-          
-          if(nbCells>0)
-            CopyElementsToOutput(anInput,
-                                 nbCells,
-                                 aCellIdsForCopy,
-                                 anObj2VTKGeometryMap,
-                                 theOuputIDSArray,
-                                 anOutput);
-          theOuputIDSArray->Delete();
-          return;
-          
-        } else {
-          // not implemented yet
-        }
-        
-        
-        
-      }
-      
-    }
+    if(MergeGeometryCellsAndDataOnNotAllPoints())
+      return;
   }
 
   anOutput->CopyStructure(anInput);
index 3379f5d6388a1460e125d9afbfcb9c240966ddaf..fb18bb5134369207edc504bdc240f3789f3aef72 100644 (file)
@@ -108,6 +108,10 @@ protected:
   bool myIsMergingInputs;
 
 private:
+  bool MergeGeometryCellsAndDataOnCells();
+  bool MergeGeometryCellsAndDataOnAllPoints();
+  bool MergeGeometryCellsAndDataOnNotAllPoints();
+  
   VISU_MergeFilter(const VISU_MergeFilter&);  // Not implemented.
   void operator=(const VISU_MergeFilter&);  // Not implemented.
 };
index e2e9be3293767f9e8d1fee0fb75ed26787a4b91e..36b2e2d358aae301179b4179406f434ee52cfa6b 100644 (file)
 #include "VTKViewer_ShrinkFilter.h"
 #include "VTKViewer_GeometryFilter.h"
 #include "VTKViewer_PassThroughFilter.h"
+
+#include "VISU_ConvertorUtils.hxx"
+#include "VISU_ConvertorDef.hxx"
+
 #include <stdexcept>
 #include <sstream>
 
@@ -408,25 +411,29 @@ vtkIdType
 VISU_Actor
 ::GetNodeObjId(vtkIdType theID)
 {
-  if(myIsVTKMapping)
-    return Superclass::GetNodeObjId(theID);
+  cout << "GetNodeObjId("<<theID<<")"<<endl;
+  return VISU::GetNodeObjID(this->GetInput(),theID);
+//   if(myIsVTKMapping)
+//     return Superclass::GetNodeObjId(theID);
 
-  vtkIdType anID = myGeomFilter->GetNodeObjId(theID);
+//   vtkIdType anID = myGeomFilter->GetNodeObjId(theID);
 
-  if(myIsShrunk)
-   anID = myShrinkFilter->GetNodeObjId(anID);
+//   if(myIsShrunk)
+//    anID = myShrinkFilter->GetNodeObjId(anID);
 
-  return GetCurrentPL()->GetNodeObjID(anID);
+//   return GetCurrentPL()->GetNodeObjID(anID);
 }
 
 vtkIdType
 VISU_Actor
 ::GetNodeVTKID(vtkIdType theID)
 {
-  if(myIsVTKMapping)
-    return theID;
+  cout << "GetNodeVTKID("<<theID<<")"<<endl;
+  return VISU::GetNodeVTKID(this->GetInput(),theID);
+//   if(myIsVTKMapping)
+//     return theID;
 
-  return GetCurrentPL()->GetNodeVTKID(theID);
+//   return GetCurrentPL()->GetNodeVTKID(theID);
 }
 
 vtkFloatingPointType*
@@ -445,25 +452,36 @@ vtkIdType
 VISU_Actor
 ::GetElemObjId(vtkIdType theID)
 {
-  if(myIsVTKMapping)
-    return Superclass::GetElemObjId(theID);
+  cout << "GetElemObjId("<<theID<<")"<<endl;
+  return VISU::GetElemObjID(this->GetInput(),theID);
+//   if(myIsVTKMapping)
+//     return Superclass::GetElemObjId(theID);
 
-  vtkIdType anID = myGeomFilter->GetElemObjId(theID);
+//   vtkIdType anID = myGeomFilter->GetElemObjId(theID);
 
-  if(myIsShrunk)
-   anID = myShrinkFilter->GetElemObjId(anID);
+//   if(myIsShrunk)
+//    anID = myShrinkFilter->GetElemObjId(anID);
 
-  return GetCurrentPL()->GetElemObjID(anID);
+//   return GetCurrentPL()->GetElemObjID(anID);
 }
 
 vtkIdType
 VISU_Actor
 ::GetElemVTKID(vtkIdType theID)
 {
-  if(myIsVTKMapping)
-    return theID;
-
-  return GetCurrentPL()->GetElemVTKID(theID);
+  cout << "GetElemVTKID("<<theID<<")"<<endl;
+  vtkIdType theId = VISU::GetElemVTKID(this->GetInput(),theID,VISU::CELL_ENTITY);
+  if(theId > -1)
+    return theId;
+  theId = VISU::GetElemVTKID(this->GetInput(),theID,VISU::FACE_ENTITY);
+  if(theId > -1)
+    return theId;
+  theId = VISU::GetElemVTKID(this->GetInput(),theID,VISU::EDGE_ENTITY);
+  return theId;
+//   if(myIsVTKMapping)
+//     return theID;
+
+//   return GetCurrentPL()->GetElemVTKID(theID);
 }
 
 vtkCell*