From: enk Date: Wed, 2 May 2007 09:13:38 +0000 (+0000) Subject: Fix for Bug NPAL15278: X-Git-Tag: T_PAL_15278~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=578b1e96d3da2ce8753de1af7e8d7dfb4d32091a;p=modules%2Fvisu.git Fix for Bug NPAL15278: EDF 347 : ScalarMaponDeformedShape On comments from 2007-04-30 10:32 --- diff --git a/src/CONVERTOR/VISU_MergeFilter.cxx b/src/CONVERTOR/VISU_MergeFilter.cxx index 220888f1..f7b384ff 100644 --- a/src/CONVERTOR/VISU_MergeFilter.cxx +++ b/src/CONVERTOR/VISU_MergeFilter.cxx @@ -562,13 +562,13 @@ namespace TId2IdMap& theOldId2NewIdPointsMap, vtkUnstructuredGrid* theOutputUG) { - vtkIntArray* theOuputIDSArray = vtkIntArray::New(); - theOuputIDSArray->SetName("VISU_CELLS_MAPPER"); + vtkIntArray* theOutputIDSArray = vtkIntArray::New(); + theOutputIDSArray->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); + theOutputIDSArray->SetNumberOfComponents(2); + theOutputIDSArray->SetNumberOfTuples(theNbElements); + int* aOutputIDSPtr = theOutputIDSArray->GetPointer(0); vtkIntArray* aInputCellsMapper = dynamic_cast(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER")); @@ -589,17 +589,18 @@ namespace theOutputUG->InsertNextCell(theInputUG->GetCellType(aCellId), aNewPointIds); - *aOuputIDSPtr = aInputCellsMapperPointer[2*aCellId]; - aOuputIDSPtr++; - *aOuputIDSPtr = aInputCellsMapperPointer[2*aCellId+1]; - aOuputIDSPtr++; + *aOutputIDSPtr = aInputCellsMapperPointer[2*aCellId]; + aOutputIDSPtr++; + *aOutputIDSPtr = aInputCellsMapperPointer[2*aCellId+1]; + aOutputIDSPtr++; aNewPointIds->Delete(); } - theOutputUG->GetCellData()->AddArray(theOuputIDSArray); - theOuputIDSArray->Delete(); + theOutputUG->GetCellData()->AddArray(theOutputIDSArray); + theOutputIDSArray->Delete(); } + inline void copyOneToOneComponent(vtkIntArray* input, vtkIntArray* output) @@ -623,6 +624,25 @@ namespace } } } + + inline + bool + isTwoArraysSame(vtkIntArray* theFirst, + vtkIntArray* theSecond) + { + int* theFirstPtr = theFirst->GetPointer(0); + int* theSecondPtr = theSecond->GetPointer(0); + int nbTuples1 = theFirst->GetNumberOfTuples(); + int nbTuples2 = theSecond->GetNumberOfTuples(); + if(nbTuples1 != nbTuples2) + return false; + for(int i=0;iGetNumberOfTuples(); - 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; - } + vtkIdType aNbPoints = aDataPointMapper->GetNumberOfTuples(); + if(isArraysEqual){ + for(int aCellId = 0; aCellId < aNbPoints; aCellId++) + anObj2VTKGeometryPointsMap[aCellId] = aCellId; + } else { + // situation: the numbering of points are different in geometry and in scalars + cout << "------------------"<GetNumberOfTuples(); - aNbComp = aGeometryCellMapper->GetNumberOfComponents(); - int *aPtr2 = aGeometryCellMapper->GetPointer(0); - if(aNbComp == 1) - for(int aCellId = 0; aCellId < aNbCells; aCellId++){ - vtkIdType anObjID = *aPtr2; - aPtr2++; - anObj2VTKGeometryCellsMap[anObjID] = aCellId; - } - else if (aNbComp == 2){ - for(int aCellId = 0; aCellId < aNbCells; aCellId++){ - vtkIdType anObjID = *aPtr2; - aPtr2++;aPtr2++; - anObj2VTKGeometryCellsMap[anObjID] = aCellId; - } - } + int aNbCells = aGeometryCellMapper->GetNumberOfTuples(); // copy points to output vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast(aInputScalars);