Salome HOME
Fix for the 0021424: EDF 2010 VISU: Dislay of a fiel of type "ELNO" issue. V6_main_20120112
authorrnv <rnv@opencascade.com>
Tue, 10 Jan 2012 14:50:34 +0000 (14:50 +0000)
committerrnv <rnv@opencascade.com>
Tue, 10 Jan 2012 14:50:34 +0000 (14:50 +0000)
src/CONVERTOR/VISU_ConvertorUtils.hxx
src/CONVERTOR/VISU_MergeFilterUtilities.cxx

index d0050a0922b0d7370ed507d6d2c3c5c9f66ddfe4..842412f4374c3dad129093a5380c70874eebb20d 100644 (file)
@@ -45,6 +45,7 @@ class vtkPolyData;
 class vtkTimerLog;
 class vtkDataSet;
 class vtkCell;
+class vtkDataArray;
 
 #ifndef VISU_ENABLE_QUADRATIC
   #define VISU_ENABLE_QUADRATIC
@@ -163,6 +164,15 @@ namespace VISU
   vtkDataSet*
   GetOutput(vtkInformationVector *theOutputVector);
 
+  VISU_CONVERTOR_EXPORT
+  vtkIdType
+  GetObjectID(vtkDataArray *theIDDataArray, vtkIdType theID);
+
+  VISU_CONVERTOR_EXPORT
+  vtkIdType
+  GetVTKID(vtkDataArray *theIDDataArray, vtkIdType theID, int theEntity);
+
+
   //! Utility for ELNO Data Selection
   //---------------------------------------------------------------
   typedef vtkIdType TVTKPointID;
index 2d680b0986467a67d25fdbd9776c567ef7c3f5d4..5cffae7c091d0b1a300cbcd47d386bf77a6ccda5 100644 (file)
@@ -24,6 +24,7 @@
 //  $Header$
 //
 #include "VISU_MergeFilterUtilities.hxx"
+#include "VISU_ConvertorUtils.hxx"
 
 #include <vtkCellData.h>
 #include <vtkObjectFactory.h>
@@ -192,32 +193,68 @@ namespace
       vtkIdList *aCellIds = vtkIdList::New();
       int aNbCells = theInput->GetNumberOfCells();
       theOutput->Allocate(aNbCells);
-      for(int aCellId = 0; aCellId < aNbCells; aCellId++){
-        aCellIds->Reset();
-        vtkCell *aCell = theInput->GetCell(aCellId);
-        vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
-        for(vtkIdType anId = 0; anId < aNbPointIds; anId++){
-          vtkIdType aPointId = aCell->GetPointIds()->GetId(anId);
-          int* aPointer = theGeometryPointMapper->GetPointer(aPointId * 2);
-          TCellId aCellId = *aPointer;
-          TEntityId anEntityId = *(aPointer + 1);
-          TObjectId anObjectId(aCellId, anEntityId);
-          TObjectId2TupleIdMap::iterator anIter = aDataObjectId2PointIdMap.find(anObjectId);
-          if(anIter != aDataObjectId2PointIdMap.end()){
-            aPointId = anIter->second;
-            aCellIds->InsertNextId(aPointId);
-          }else
-            goto PASS_INSERT_NEXT_CELL;
-        }
-        {
-          vtkIdType aCellType = theInput->GetCellType(aCellId);
-          vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
-          anOutputCellData->CopyData(aCellData, aCellId, aNewCellId);
-        }
-      PASS_INSERT_NEXT_CELL:
-        continue;
-      }
-      aCellIds->Delete();
+         if(!VISU::IsElnoData(theScalarsDataSet)) {
+                 for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+                       aCellIds->Reset();
+                       vtkCell *aCell = theInput->GetCell(aCellId);
+                       vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
+                       for(vtkIdType anId = 0; anId < aNbPointIds; anId++){
+                         vtkIdType aPointId = aCell->GetPointIds()->GetId(anId);
+                         int* aPointer = theGeometryPointMapper->GetPointer(aPointId * 2);
+                         TCellId aCellId = *aPointer;
+                         TEntityId anEntityId = *(aPointer + 1);
+                         TObjectId anObjectId(aCellId, anEntityId);
+                         TObjectId2TupleIdMap::iterator anIter = aDataObjectId2PointIdMap.find(anObjectId);
+                         if(anIter != aDataObjectId2PointIdMap.end()){
+                               aPointId = anIter->second;
+                               aCellIds->InsertNextId(aPointId);
+                         }else
+                               goto PASS_INSERT_NEXT_CELL;
+                       }
+                       {
+                         vtkIdType aCellType = theInput->GetCellType(aCellId);
+                         vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+                         anOutputCellData->CopyData(aCellData, aCellId, aNewCellId);
+                       }
+                 PASS_INSERT_NEXT_CELL:
+                       continue;
+                 }
+                 aCellIds->Delete();
+         } else {
+               vtkIntArray* anInputCellIDMapper = GetIDMapper(theInput,
+                                                                                                          TGetCellData(),
+                                                                      "VISU_CELLS_MAPPER");
+
+               vtkIntArray* anScalarsCellIDMapper = GetIDMapper(theScalarsDataSet,
+                                                                                                            TGetCellData(),
+                                                                        "VISU_CELLS_MAPPER");
+
+               vtkIntArray *anInputArray = dynamic_cast<vtkIntArray*>(anInputCellIDMapper);
+               int aNbComp = anInputArray->GetNumberOfComponents();
+               TCellId inCellObjId = -1;
+               TEntityId inEntityId = -1;
+               TCellId scalarCellVtkId = -1;
+               vtkCell* inputCell = NULL;
+               vtkCell* scalarCell = NULL;
+                               
+               for(int aCellId = 0; aCellId < aNbCells; aCellId++) {
+                       aCellIds->Reset();
+                       int* anInPointer = anInputArray->GetPointer(aCellId*aNbComp);
+                       inCellObjId = *anInPointer;
+                       inEntityId = *(anInPointer+1);
+                       if(inCellObjId == -1) continue;
+                       scalarCellVtkId = VISU::GetVTKID(anScalarsCellIDMapper,inCellObjId,inEntityId);
+                       if(scalarCellVtkId == -1) continue;
+                       scalarCell = theScalarsDataSet->GetCell(scalarCellVtkId);
+                       inputCell = theInput->GetCell(aCellId);
+                       vtkIdType aCellType = inputCell->GetCellType();
+                       if(scalarCell->GetCellType() == aCellType) {
+                               aCellIds->DeepCopy(scalarCell->PointIds);                                                         
+                               vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+                               anOutputCellData->CopyData(aCellData, aCellId, aNewCellId);
+                       }                               
+               }
+         }
       
       // Copy geometry points
       // 1. Create vtkPoints instance of the same data type