[vtkusers] hemispherical cap with hole at the bottom

Petr Vokac petr.2006 at centrum.cz
Sun Apr 14 11:30:45 EDT 2019


I am trying to create hemispherical cap using two spheres, clipping them by
plane - it works, and clipping them by cylinder - it does not work as it
leaves two surfaces unconnected, why?

python script:

#!/usr/bin/env python

import vtk
sphere = vtk.vtkSphereSource()
sphere.SetRadius(10.0)

spherei = vtk.vtkSphereSource()
spherei.SetRadius(8.0)

sphereir=vtk.vtkReverseSense()
sphereir.SetInputConnection(spherei.GetOutputPort())

ext=vtk.vtkAppendPolyData()
ext.AddInputConnection(sphere.GetOutputPort())
ext.AddInputConnection(sphereir.GetOutputPort())

plane = vtk.vtkPlane()
plane.SetOrigin([0.0,0.0,0.0])
plane.SetNormal([0.0,-1.0,0.0])

clipclose=vtk.vtkClipClosedSurface()
pc = vtk.vtkPlaneCollection()
pc.AddItem(plane)
clipclose.SetClippingPlanes(pc)
clipclose.SetInputConnection(ext.GetOutputPort())

cyl = vtk.vtkCylinder()
cyl.SetCenter(0,0,0)
cyl.SetRadius(5.0)
ib = vtk.vtkImplicitBoolean()
ib.AddFunction(cyl)

clipper = vtk.vtkClipPolyData()
clipper.SetInputConnection(clipclose.GetOutputPort())
clipper.SetClipFunction(ib)
clipper.GenerateClippedOutputOn()

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(clipper.GetOutputPort())

actor = vtk.vtkActor()
actor.SetMapper(mapper)

ren = vtk.vtkRenderer()
ren.AddActor(actor)
ren.ResetCamera()

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

iren.Initialize()
renWin.Render()
iren.Start()






--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list