From 2d07e119eb3039635e0ba6a0666dc14c763678e4 Mon Sep 17 00:00:00 2001 From: enk Date: Wed, 2 May 2007 06:08:02 +0000 Subject: [PATCH] Fix for Bug NPAL15278: EDF 347 : ScalarMaponDeformedShape On comments from 2007-04-30 10:13 --- src/CONVERTOR/VISU_MergeFilter.cxx | 71 +++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/src/CONVERTOR/VISU_MergeFilter.cxx b/src/CONVERTOR/VISU_MergeFilter.cxx index 74893677..220888f1 100644 --- a/src/CONVERTOR/VISU_MergeFilter.cxx +++ b/src/CONVERTOR/VISU_MergeFilter.cxx @@ -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;iGetOutput(); vtkCellData *aCellData = anInput->GetCellData(); vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); // 1 - vtkIntArray *aGeometryCellMapper = dynamic_cast(aCellMapper); // 1->2 + vtkIntArray *aGeometryCellMapper = dynamic_cast(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; } } -- 2.39.2