]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve handling data on points.
authorapo <apo@opencascade.com>
Fri, 11 May 2007 06:09:19 +0000 (06:09 +0000)
committerapo <apo@opencascade.com>
Fri, 11 May 2007 06:09:19 +0000 (06:09 +0000)
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

index 29ad6ec696b43eb839ac802131b6b0399f5ba1c4..8b59109334b4ece03535397dc42423812c40c16e 100644 (file)
@@ -554,9 +554,42 @@ namespace
        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());