continue;
}
aCellIds->Delete();
-
+
+ // Copy geometry points
+ // 1. Create vtkPoints instance of the same data type
vtkPointSet* aScalarsDataSet = dynamic_cast<vtkPointSet*>(theScalarsDataSet);
- theOutput->SetPoints(aScalarsDataSet->GetPoints());
+ vtkPoints* anGeometryPoints = theInput->GetPoints();
+ vtkPoints* aDataPoints = aScalarsDataSet->GetPoints();
+ vtkPoints* anOutputPoints = vtkPoints::New(aDataPoints->GetDataType());
+ theOutput->SetPoints(anOutputPoints);
+ anOutputPoints->Delete();
+
+ // 2. Perform mapping of geometry points
+ TObjectId2TupleIdMap aGeomObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(theGeometryPointMapper, aGeomObjectId2TupleIdMap);
+
+ // 3. Loop over all data points
+ int aNbDataPoints = theDataPointMapper->GetNumberOfTuples();
+ anOutputPoints->SetNumberOfPoints(aNbDataPoints);
+ for(int aPointId = 0; aPointId < aNbDataPoints; aPointId++){
+ int* aPointer = theDataPointMapper->GetPointer(aPointId * 2);
+ TCellId aCellId = *aPointer;
+ TEntityId anEntityId = *(aPointer + 1);
+ TObjectId anObjectId(aCellId, anEntityId);
+ TObjectId2TupleIdMap::iterator anIter = aGeomObjectId2TupleIdMap.find(anObjectId);
+ if(anIter != aDataObjectId2PointIdMap.end()){
+ // If the point exists in the geometry put it to output
+ int aGeometryPointId = anIter->second;
+ vtkFloatingPointType aCoords[3];
+ anGeometryPoints->GetPoint(aGeometryPointId, aCoords);
+ anOutputPoints->SetPoint(aPointId, aCoords);
+ }else{
+ // If no, the point from data should be used
+ vtkFloatingPointType aCoords[3];
+ aDataPoints->GetPoint(aPointId, aCoords);
+ anOutputPoints->SetPoint(aPointId, aCoords);
+ }
+ }
}else{
theOutput->CopyStructure(theInput);
theOutput->GetCellData()->ShallowCopy(theInput->GetCellData());