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<vtkIntArray*>(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER"));
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)
}
}
}
+
+ 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;i<nbTuples1;i++,theFirstPtr++,theSecondPtr++){
+ if(*theFirstPtr != *theSecondPtr)
+ return false;
+ }
+
+ return true;
+ }
}
bool
}
if(aDataPointMapper){
- TSortedArray aGeometryPointArray;
- GetSortedArray(aGeometryPointMapper, aGeometryPointArray);
-
- TSortedArray aDataPointArray;
- GetSortedArray(aDataPointMapper, aDataPointArray);
-
+ bool isArraysEqual = isTwoArraysSame(aDataPointMapper,aGeometryPointMapper);
{
TId2IdMap anObj2VTKGeometryPointsMap;
- vtkIdType aNbCells = aDataPointMapper->GetNumberOfTuples();
- 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 << "------------------"<<endl;
+ cout << "Warning! Incorrect data are used in "<<__FILE__<<"["<<__LINE__<<"]"<<endl;
+ cout << "------------------"<<endl;
}
- TId2IdMap anObj2VTKGeometryCellsMap;
- aNbCells = aGeometryCellMapper->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<vtkUnstructuredGrid*>(aInputScalars);