From: rnv Date: Tue, 10 Jan 2012 14:50:34 +0000 (+0000) Subject: Fix for the 0021424: EDF 2010 VISU: Dislay of a fiel of type "ELNO" issue. X-Git-Tag: V6_main_20120112 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3cc74325481b8c480246d45a17413aeecef79e4f;p=modules%2Fvisu.git Fix for the 0021424: EDF 2010 VISU: Dislay of a fiel of type "ELNO" issue. --- diff --git a/src/CONVERTOR/VISU_ConvertorUtils.hxx b/src/CONVERTOR/VISU_ConvertorUtils.hxx index d0050a09..842412f4 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.hxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.hxx @@ -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; diff --git a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx index 2d680b09..5cffae7c 100644 --- a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx +++ b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx @@ -24,6 +24,7 @@ // $Header$ // #include "VISU_MergeFilterUtilities.hxx" +#include "VISU_ConvertorUtils.hxx" #include #include @@ -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(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