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;i<nbTuples;i++){
+ *aOutputPtr = *aInputPtr;
+ aOutputPtr++;
+ aInputPtr++;
+ aInputPtr++;
+ }
+ } else if (nbComp == 1){
+ for(int i=0;i<nbTuples;i++){
+ *aOutputPtr = *aInputPtr;
+ aOutputPtr++;
+ aInputPtr++;
+ }
+ }
+ }
}
bool
vtkUnstructuredGrid *anOutput = this->GetOutput();
vtkCellData *aCellData = anInput->GetCellData();
vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); // 1
- vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper); // 1->2
+ vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper);
// The situation for merging CELLS from anInput as Geometry
// and scalars on cell data
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);
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;
}
}
{
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;
}
anIntersectionArray,
anObj2VTKDataMap);
}
+ aGeometryCellMapperOnly->Delete();
+ aDataCellMapperOnly->Delete();
return true;
}
+ aGeometryCellMapperOnly->Delete();
+ aDataCellMapperOnly->Delete();
}
return false;
}
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;
}
}