[vtkusers] Is there a way to check data before using vtkBooleanOperationPolyDataFilter?
ftouvet
francois.touvet at inria.fr
Thu Jan 23 08:57:20 EST 2014
Hello all,
I would like to use the Intersection operation from
vtkBooleanOperationPolyDataFilter in order to know how much my meshes are
overlapping each other ; so I designed a pipeline to prepare the data and
make it fit to the Filter initial conditions, but it seems that I do miss
something. Do somebody use this filter and know a way to be sure that the
input data are ok?
Here is my code in Python:
source1 = vtk.vtkPolyDataReader()
source1.SetFileName("mesh1.vtk")
source1.Update()
source2 = vtk.vtkPolyDataReader()
source2.SetFileName("mesh2.vtk")
source2.Update()
poly = [source1.GetOutput(), source2.GetOutput()]
triFilt = [vtk.vtkPolyData(), vtk.vtkPolyData()]
# Converts the polydatas in Triangles and check Normals are ok
for ind in range(2):
polyCopy = vtk.vtkPolyData()
polyCopy.ShallowCopy(poly[ind])
trif = vtk.vtkTriangleFilter()
trif.SetInput(polyCopy)
trif.PassVertsOff()
trif.PassLinesOff()
trif.Update()
normalf = vtk.vtkPolyDataNormals()
normalf.SetInput(trif.GetOutput())
normalf.SetFeatureAngle(60.0)
normalf.ComputePointNormalsOn()
normalf.ComputeCellNormalsOn()
normalf.SplittingOff()
normalf.ConsistencyOff()
# Had to use this in order for the data to be correct. Doc says:
NOTE: This assumes a completely closed surface (i.e. no boundary edges) and
no non-manifold edges. If these constraints do not hold, all bets are off.
normalf.AutoOrientNormalsOn()
normalf.Update()
triFilt[ind].ShallowCopy(normalf.GetOutput())
# Design Boolean operation
boolFilter = vtk.vtkBooleanOperationPolyDataFilter()
boolFilter.SetOperation(Operation) #default value is 1: Intersection
boolFilter.SetInput(0,triFilt[0]);
boolFilter.SetInput(1,triFilt[1]);
boolFilter.Update()
# Result
InterPoly = boolFilter.GetOutput()
Using this three times (one for each boolean operation type) resulted in the
attached picture (Grey, the two meshes; Red, Union result : Green,
Intersection result ; Blue, Difference result ). The two meshes do not
touch, but still there is a PolyData generated by the Intersection
operation, and I cannot understand why.
<http://vtk.1045678.n5.nabble.com/file/n5725561/Real_test.png>
--
View this message in context: http://vtk.1045678.n5.nabble.com/Is-there-a-way-to-check-data-before-using-vtkBooleanOperationPolyDataFilter-tp5725561.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list