<div dir="ltr"><div>Hi Petr,</div><div><br></div><div>Unfortunately, vtkClipPolyData doesn't close off the surface after clipping.  It wasn't designed to do that.  In fact, closing things off after clipping is a rather difficult problem.</div><div><br></div><div>I recommend that you take another approach.  Your cap is rotationally symmetric, right?  Try the rotational extrusion filter: <a href="https://vtk.org/doc/nightly/html/classvtkRotationalExtrusionFilter.html" target="_blank">https://vtk.org/doc/nightly/html/classvtkRotationalExtrusionFilter.html</a></div><div><br></div><div>All you need to do is generate a cross-section of your cap, i.e. an arc.  Just do this by writing a couple "for" loops in python to build the arc using sin() and cos(), make a polyline and stuff it in a vtkPolyData.  For example, <a href="https://lorensen.github.io/VTKExamples/site/Python/GeometricObjects/PolyLine1/" target="_blank">https://lorensen.github.io/VTKExamples/site/Python/GeometricObjects/PolyLine1/</a></div><div><br></div><div>Once you have your cross-section, pass it through vtkRotationalExtrusionFilter to generate the shape.</div><span class="gmail-HOEnZb gmail-adL"><font color="#888888"><div><br></div><div>   David</div></font></span></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 14, 2019 at 9:30 AM Petr Vokac <<a href="mailto:petr.2006@centrum.cz">petr.2006@centrum.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I am trying to create hemispherical cap using two spheres, clipping them by<br>
plane - it works, and clipping them by cylinder - it does not work as it<br>
leaves two surfaces unconnected, why?<br>
<br>
python script:<br>
<br>
#!/usr/bin/env python<br>
<br>
import vtk<br>
sphere = vtk.vtkSphereSource()<br>
sphere.SetRadius(10.0)<br>
<br>
spherei = vtk.vtkSphereSource()<br>
spherei.SetRadius(8.0)<br>
<br>
sphereir=vtk.vtkReverseSense()<br>
sphereir.SetInputConnection(spherei.GetOutputPort())<br>
<br>
ext=vtk.vtkAppendPolyData()<br>
ext.AddInputConnection(sphere.GetOutputPort())<br>
ext.AddInputConnection(sphereir.GetOutputPort())<br>
<br>
plane = vtk.vtkPlane()<br>
plane.SetOrigin([0.0,0.0,0.0])<br>
plane.SetNormal([0.0,-1.0,0.0])<br>
<br>
clipclose=vtk.vtkClipClosedSurface()<br>
pc = vtk.vtkPlaneCollection()<br>
pc.AddItem(plane)<br>
clipclose.SetClippingPlanes(pc)<br>
clipclose.SetInputConnection(ext.GetOutputPort())<br>
<br>
cyl = vtk.vtkCylinder()<br>
cyl.SetCenter(0,0,0)<br>
cyl.SetRadius(5.0)<br>
ib = vtk.vtkImplicitBoolean()<br>
ib.AddFunction(cyl)<br>
<br>
clipper = vtk.vtkClipPolyData()<br>
clipper.SetInputConnection(clipclose.GetOutputPort())<br>
clipper.SetClipFunction(ib)<br>
clipper.GenerateClippedOutputOn()<br>
<br>
mapper = vtk.vtkPolyDataMapper()<br>
mapper.SetInputConnection(clipper.GetOutputPort())<br>
<br>
actor = vtk.vtkActor()<br>
actor.SetMapper(mapper)<br>
<br>
ren = vtk.vtkRenderer()<br>
ren.AddActor(actor)<br>
ren.ResetCamera()<br>
<br>
renWin = vtk.vtkRenderWindow()<br>
renWin.AddRenderer(ren)<br>
iren = vtk.vtkRenderWindowInteractor()<br>
iren.SetRenderWindow(renWin)<br>
<br>
iren.Initialize()<br>
renWin.Render()<br>
iren.Start()<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
Sent from: <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html</a><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://vtk.org/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div>