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

Cory Quammen cory.quammen at kitware.com
Thu Jan 23 16:54:49 EST 2014


Francois,

I'm a little confused about the picture you attached. The two meshes
are the two gray objects, one large and one a small cylinder? If so, I
would expect the union operation to make the cylinder that is green
red in the image you attached. Or was the red cylinder covered up by
the green intersection result? And where is the blue object?

It would help to see what is going on if you could provide the
complete code and geometry files.

Thanks,
Cory

On Thu, Jan 23, 2014 at 8:57 AM, ftouvet <francois.touvet at inria.fr> wrote:
> 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


More information about the vtkusers mailing list