]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug NPAL15278:
authorenk <enk@opencascade.com>
Wed, 2 May 2007 06:08:02 +0000 (06:08 +0000)
committerenk <enk@opencascade.com>
Wed, 2 May 2007 06:08:02 +0000 (06:08 +0000)
EDF 347 : ScalarMaponDeformedShape
On comments from 2007-04-30 10:13

src/CONVERTOR/VISU_MergeFilter.cxx

index 7489367773b7a142a02471adf7a3e6a7c615bb36..220888f16e9b470c2abaaa684e9e5eab518f1c2f 100644 (file)
@@ -599,8 +599,30 @@ namespace
     theOutputUG->GetCellData()->AddArray(theOuputIDSArray);
     theOuputIDSArray->Delete();
   }
-  
-  
+
+  void
+  copyOneToOneComponent(vtkIntArray* input,
+                        vtkIntArray* output)
+  {
+    int nbTuples = input->GetNumberOfTuples();
+    int nbComp   = input->GetNumberOfComponents();
+    int* aInputPtr = input->GetPointer(0);
+    int* aOutputPtr = output->GetPointer(0);
+    if(nbComp == 2){
+      for(int i=0;i<nbTuples;i++){
+        *aOutputPtr = *aInputPtr;
+        aOutputPtr++;
+        aInputPtr++;
+        aInputPtr++;
+      }
+    } else if (nbComp == 1){
+      for(int i=0;i<nbTuples;i++){
+        *aOutputPtr = *aInputPtr;
+        aOutputPtr++;
+        aInputPtr++;
+      }
+    }
+  }
 }
 
 bool 
@@ -612,7 +634,7 @@ VISU_MergeFilter
   vtkUnstructuredGrid *anOutput = this->GetOutput();
   vtkCellData *aCellData = anInput->GetCellData();
   vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); // 1
-  vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper); // 1->2
+  vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper);
   
   // The situation for merging CELLS from anInput as Geometry
   // and scalars on cell data
@@ -633,10 +655,21 @@ VISU_MergeFilter
   
   if(anIsDifferent || IsMergingInputs() ){
     TSortedArray aGeometryCellArray;
-    GetSortedArray(aGeometryCellMapper, aGeometryCellArray);
+    vtkIntArray* aGeometryCellMapperOnly = vtkIntArray::New();
+    vtkIntArray* aDataCellMapperOnly     = vtkIntArray::New();
+    aGeometryCellMapperOnly->SetNumberOfComponents(1);
+    aGeometryCellMapperOnly->SetNumberOfTuples(aGeometryCellMapper->GetNumberOfTuples());
+    aGeometryCellMapperOnly->SetName(aGeometryCellMapper->GetName());
+    aDataCellMapperOnly->SetNumberOfComponents(1);
+    aDataCellMapperOnly->SetNumberOfTuples(aDataCellMapper->GetNumberOfTuples());
+    aDataCellMapperOnly->SetName(aDataCellMapper->GetName());
+    
+    copyOneToOneComponent(aGeometryCellMapper,aGeometryCellMapperOnly);
+    copyOneToOneComponent(aDataCellMapper,aDataCellMapperOnly);
     
+    GetSortedArray(aGeometryCellMapperOnly, aGeometryCellArray);
     TSortedArray aDataCellArray;
-    GetSortedArray(aDataCellMapper, aDataCellArray);
+    GetSortedArray(aDataCellMapperOnly, aDataCellArray);
     
     int aMaxLength = std::max(aGeometryCellArray.size(), aDataCellArray.size());
     TSortedArray anIntersectionArray(aMaxLength);
@@ -652,13 +685,15 @@ VISU_MergeFilter
     bool anIsCompletelyCoincide = 
       anIntersectionArray.size() == aGeometryCellArray.size() && 
       anIntersectionArray.size() == aDataCellArray.size();
-
+    
     if(!anIsCompletelyCoincide || IsMergingInputs()){
       {
         TId2IdMap anObj2VTKGeometryMap;
-        vtkIdType aNbCells = aGeometryCellMapper->GetNumberOfTuples();
+        vtkIdType aNbCells = aGeometryCellMapperOnly->GetNumberOfTuples();
+        int* aGPtr = aGeometryCellMapperOnly->GetPointer(0);
         for(int aCellId = 0; aCellId < aNbCells; aCellId++){
-          vtkIdType anObjID = aGeometryCellMapper->GetValue(aCellId);
+          vtkIdType anObjID = *aGPtr;
+          aGPtr++;
           anObj2VTKGeometryMap[anObjID] = aCellId;
         }
         
@@ -680,9 +715,11 @@ VISU_MergeFilter
        }
       {
         TId2IdMap anObj2VTKDataMap;
-        vtkIdType aNbCells = aDataCellMapper->GetNumberOfTuples();
+        vtkIdType aNbCells = aDataCellMapperOnly->GetNumberOfTuples();
+        int* aDPtr = aDataCellMapperOnly->GetPointer(0);
         for(int aCellId = 0; aCellId < aNbCells; aCellId++){
-          vtkIdType anObjID = aDataCellMapper->GetValue(aCellId);
+          vtkIdType anObjID = *aDPtr;
+          aDPtr++;
           anObj2VTKDataMap[anObjID] = aCellId;
         }
        
@@ -692,8 +729,12 @@ VISU_MergeFilter
                                   anIntersectionArray, 
                                   anObj2VTKDataMap);
       }
+      aGeometryCellMapperOnly->Delete();
+      aDataCellMapperOnly->Delete();
       return true;
     }
+    aGeometryCellMapperOnly->Delete();
+    aDataCellMapperOnly->Delete();
   }
   return false;
 }
@@ -757,17 +798,17 @@ VISU_MergeFilter
       TId2IdMap anObj2VTKGeometryCellsMap;
       aNbCells = aGeometryCellMapper->GetNumberOfTuples();
       aNbComp  = aGeometryCellMapper->GetNumberOfComponents();
-      aPtr = aGeometryCellMapper->GetPointer(0);
+      int *aPtr2 = aGeometryCellMapper->GetPointer(0);
       if(aNbComp == 1)
         for(int aCellId = 0; aCellId < aNbCells; aCellId++){
-          vtkIdType anObjID = *aPtr;
-          aPtr++;
+          vtkIdType anObjID = *aPtr2;
+          aPtr2++;
           anObj2VTKGeometryCellsMap[anObjID] = aCellId;
         }
       else if (aNbComp == 2){
         for(int aCellId = 0; aCellId < aNbCells; aCellId++){
-          vtkIdType anObjID = *aPtr;
-          aPtr++;aPtr++;
+          vtkIdType anObjID = *aPtr2;
+          aPtr2++;aPtr2++;
           anObj2VTKGeometryCellsMap[anObjID] = aCellId;
         }
       }