From 46782fb9fbb7ad3104ba00e7bdb505aa8573b1e7 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 11 May 2007 06:09:19 +0000 Subject: [PATCH] To improve handling data on points. If geometry have a point with the same object id it is prefered in compare with a point which is used in data. --- src/CONVERTOR/VISU_MergeFilter.cxx | 37 ++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/CONVERTOR/VISU_MergeFilter.cxx b/src/CONVERTOR/VISU_MergeFilter.cxx index 29ad6ec6..8b591093 100644 --- a/src/CONVERTOR/VISU_MergeFilter.cxx +++ b/src/CONVERTOR/VISU_MergeFilter.cxx @@ -554,9 +554,42 @@ namespace continue; } aCellIds->Delete(); - + + // Copy geometry points + // 1. Create vtkPoints instance of the same data type vtkPointSet* aScalarsDataSet = dynamic_cast(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()); -- 2.39.2