[vtkusers] Is there a way to check data before using vtkBooleanOperationPolyDataFilter?

Ronald Römer rroemer at gmail.com
Thu Jan 23 15:17:16 EST 2014


Hi,

the filter does not work very well. Here is an alternative:
https://github.com/zippy84/vtkbool

Currently you have to use C++, if this is not a problem for you.

Sorry for the commercial.

Best regards.
 Am 23.01.2014 14:57 schrieb "ftouvet" <francois.touvet at inria.fr>:

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.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140123/21cf24e6/attachment.html>


More information about the vtkusers mailing list