[vtkusers] PolyData Operations VTK 5

Paulo Henrique Junqueira Amorim paulojamorim at gmail.com
Fri May 2 12:26:08 EDT 2008


Hi Mathieu,

Thank but the vtkImplicitPolyData only works in vtk 4.2, my project uses vtk
5.1 and wrapper to Python.

I tried to convert PolyData implicit function and then use the
vtkImplicitBoolean but the output of vtkImplicitBoolean is null,  I am
exported to stl and export null, I am creted Actor and Add renderer, but the
output of the renderer is black. See below code.

Best Regards,
Paulo Amorim


The code convert PolyData in Implicit Function:

from vtk import *

#To test PolyData Boolean
Cylinder = vtkCylinderSource()
Cylinder.SetHeight(35)
Cylinder.SetRadius(6)

Cube = vtkCubeSource()
Cube.SetXLength(100)
Cube.SetYLength(10)
Cube.SetZLength(10)



# transforming polyData of the Cylinder to an implicitFunction
poly_Cylinder = vtkPolyData()
poly_Cylinder.SetPoints(Cylinder.GetOutput().GetPoints())

tri_Cylinder = vtkTriangleFilter()
tri_Cylinder.SetInput(poly_Cylinder)

implicit_Cylinder = vtkImplicitModeller()
implicit_Cylinder.SetInputConnection(tri_Cylinder.GetOutputPort())

dataset_Cylinder = vtkImplicitDataSet()
dataset_Cylinder.SetDataSet(implicit_Cylinder.GetOutput())



# ----   transforming polyData of the Cube to an implicitFunction
-----------
poly_Cube = vtkPolyData()
poly_Cube.SetPoints(Cube.GetOutput().GetPoints())

tri_Cube = vtkTriangleFilter()
tri_Cube.SetInput(poly_Cube)

implicit_Cube = vtkImplicitModeller()
implicit_Cube.SetInputConnection(tri_Cube.GetOutputPort())

dataset_Cube = vtkImplicitDataSet()
dataset_Cube.SetDataSet(implicit_Cube.GetOutput())


#Boolean Difference two implicit funcion (cylinder and cube)

implict_Boolean = vtkImplicitBoolean()
implict_Boolean.SetOperationTypeToDifference()

implict_Boolean.AddFunction(dataset_Cube)
implict_Boolean.AddFunction(dataset_Cylinder)


Sample = vtkSampleFunction()
Sample.SetImplicitFunction(implict_Boolean)

Surface = vtkContourFilter()
Surface.SetInputConnection(Sample.GetOutputPort())


#Export to STL
writerBinary = vtkSTLWriter()
writerBinary.SetFileName("c:\\exported.stl")
writerBinary.SetInput(Surface.GetOutput())
writerBinary.SetFileType(2)
writerBinary.Write()



Mapper = vtkPolyDataMapper()
Mapper.SetInput(Surface.GetOutput())
Mapper.ScalarVisibilityOn()

Actor = vtkActor()
Actor.SetMapper(Mapper)
Actor.SetPosition(0,0,0)


ren = vtkRenderer()
ren.AddActor(Actor)

renWin = vtkRenderWindow()
renWin.AddRenderer(ren)

iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

renWin.Render()




2008/4/28 Mathieu Malaterre <mathieu.malaterre at gmail.com>:

> Hi Paulo,
>
>  I believe this question has been raised in the vtkusers mailing list
> before, how about:
>
> http://www.vtk.org/pipermail/vtkusers/2007-April/090730.html
>
> HTH
> -Mathieu
>
> On Sun, Apr 27, 2008 at 3:44 AM, Paulo Henrique Junqueira Amorim
> <paulojamorim at gmail.com> wrote:
> > Hi All,
> >
> > I am researching how to make operation of intersseção and subtraction of
> > PolyData with the vtk 5. But I do not think any refence.
> >
> > That class could use?
> >
> >
> > Best Regards,
> > Paulo
> >
> >
> > _______________________________________________
> >  This is the private VTK discussion list.
> >  Please keep messages on-topic. Check the FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> >  Follow this link to subscribe/unsubscribe:
> >  http://www.vtk.org/mailman/listinfo/vtkusers
> >
> >
>
>
>
> --
> Mathieu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080502/c6bbea7e/attachment.htm>


More information about the vtkusers mailing list