Re: Re: hemispherical cap with hole at the bottom (David Gobbi)
Andrew Maclean <[email protected]> Tue, 16 Apr 2019 15:38:55 +1000
| Newsgroups | gmane.comp.lib.vtk.user |
|---|---|
| Message-ID | <CAHDsG9PUAe9_PfCp05RH_oGr13h=5sa_1aouBH28648DXjA6og@mail.gmail.com> |
--===============1525884731==
Content-Type: multipart/alternative; boundary="0000000000007563c505869f31fd"
--0000000000007563c505869f31fd
Content-Type: text/plain; charset="UTF-8"
Here is a quick example to illustrate what David said, I'll add this and a
C++ version to VTKExamples.
Petr, you should consider using [VTK Discourse](https://discourse.vtk.org/)
instead of this site.
##############################################
#!/usr/bin/env python
import math
import vtk
def get_program_parameters():
import argparse
description = ''
epilogue = '''
'''
parser = argparse.ArgumentParser(description=description, epilog=epilogue,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('angle', default=90, type=float, nargs='?',
help='The arc of the sphere, an angle in
degrees from +y in the +x direction.')
parser.add_argument('step', default=1, type=float, nargs='?',
help='The step angle in degrees.')
parser.add_argument('radius', default=1, type=float, nargs='?',
help='The radius of the sphere.')
parser.add_argument('-c', '--closed', action='store_true',
help='Add a closed cap.')
args = parser.parse_args()
return args.angle, args.step, args.radius, args.closed
def main():
angle, step, radius, closed = get_program_parameters()
angle = math.radians(angle)
step = math.radians(step)
precision = 1.0e-6
start = math.radians(90)
pts = list()
# Do the curved line
theta = 0.0
while theta <= angle:
x = radius * math.cos(start - theta)
z = radius * math.sin(-start + theta)
if abs(x) < precision:
x = 0
if abs(z) < precision:
z = 0
pts.append((x, 0, z))
theta += step
if closed:
# Drop a perpendicular from the last point to the x-axis
last_point = pts[-1]
num_pts = 10
interval = float(num_pts) / radius
if last_point[0] > precision:
for i in range(1, num_pts):
x = last_point[0] - i / interval
z = last_point[2]
if abs(x) < precision:
x = 0
if abs(z) < precision:
z = 0
pts.append((x, 0, z))
if pts[-1][0] > precision:
pts.append((0, 0, z))
# Setup points and lines
points = vtk.vtkPoints()
lines = vtk.vtkCellArray()
for pt in pts:
pt_id = points.InsertNextPoint(pt)
for i in range(0, len(pts) - 1):
line = vtk.vtkLine()
line.GetPointIds().SetId(0, i)
line.GetPointIds().SetId(1, i + 1)
lines.InsertNextCell(line)
polydata = vtk.vtkPolyData()
polydata.SetPoints(points)
polydata.SetLines(lines)
# Extrude the profile to make the capped sphere.
#
extrude = vtk.vtkRotationalExtrusionFilter()
extrude.SetInputData(polydata)
extrude.SetResolution(60)
# Visualize
colors = vtk.vtkNamedColors()
mapper = vtk.vtkPolyDataMapper()
# To see the line
# mapper.SetInputData(polydata)
# To see the surface
mapper.SetInputConnection(extrude.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetLineWidth(4)
actor.GetProperty().SetColor(colors.GetColor3d('Cornsilk'))
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
ren.AddActor(actor)
ren.SetBackground(colors.GetColor3d('DarkGreen'))
ren.ResetCamera()
ren.GetActiveCamera().Azimuth(0)
ren.GetActiveCamera().Elevation(60)
ren.ResetCameraClippingRange()
renWin.SetSize(600, 600)
renWin.Render()
renWin.SetWindowName('CappedSphere')
iren.Start()
if __name__ == '__main__':
main()
##############################################
>
> ---------- Forwarded message ----------
> From: David Gobbi <[email protected]>
> To: VTK Users <[email protected]>
> Cc:
> Bcc:
> Date: Sun, 14 Apr 2019 15:06:17 -0600
> Subject: Re: [vtkusers] hemispherical cap with hole at the bottom
> Hi Petr,
>
> 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.
>
> I recommend that you take another approach. Your cap is rotationally
> symmetric, right? Try the rotational extrusion filter:
> https://vtk.org/doc/nightly/html/classvtkRotationalExtrusionFilter.html
>
> 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,
> https://lorensen.github.io/VTKExamples/site/Python/GeometricObjects/PolyLine1/
>
> Once you have your cross-section, pass it through
> vtkRotationalExtrusionFilter to generate the shape.
>
> David
>
> On Sun, Apr 14, 2019 at 9:30 AM Petr Vokac <[email protected]> wrote:
>
>> 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
>> _______________________________________________
>> 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
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> https://vtk.org/mailman/listinfo/vtkusers
>>
>
>
>
> --
___________________________________________
Andrew J. P. Maclean
___________________________________________
--0000000000007563c505869f31fd
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div class=3D"gmail_defa=
ult" style=3D"font-size:small">Here is a quick example to illustrate what D=
avid said, I'll add this and a C++ version to VTKExamples.</div><div cl=
ass=3D"gmail_default" style=3D"font-size:small">Petr, you should consider u=
sing [VTK Discourse](<a href=3D"https://discourse.vtk.org/">https://discour=
se.vtk.org/</a>) instead of this site.</div><div class=3D"gmail_default" st=
yle=3D"font-size:small"><br></div><div class=3D"gmail_default" style=3D"fon=
t-size:small">##############################################</div><div clas=
s=3D"gmail_default" style=3D"font-size:small"><pre style=3D"color:rgb(0,0,0=
);font-family:"DejaVu Sans Mono";font-size:18pt"><span style=3D"c=
olor:rgb(128,128,128);font-style:italic">#!/usr/bin/env python<br></span><s=
pan style=3D"color:rgb(128,128,128);font-style:italic"><br></span><span sty=
le=3D"color:rgb(0,0,128);font-weight:bold">import </span>math<br><br><span =
style=3D"color:rgb(0,0,128);font-weight:bold">import </span>vtk<br><br><br>=
<span style=3D"color:rgb(0,0,128);font-weight:bold">def </span>get_program_=
parameters():<br> <span style=3D"color:rgb(0,0,128);font-weight:bold">im=
port </span>argparse<br> description =3D <span style=3D"color:rgb(0,128,=
128);font-weight:bold">''<br></span><span style=3D"color:rgb(0,128,=
128);font-weight:bold"> </span>epilogue =3D <span style=3D"color:rgb(0,1=
28,128);font-weight:bold">'''<br></span><span style=3D"color:rg=
b(0,128,128);font-weight:bold"><br></span><span style=3D"color:rgb(0,128,12=
8);font-weight:bold"> '''<br></span><span style=3D"color:rgb(=
0,128,128);font-weight:bold"> </span>parser =3D argparse.ArgumentParser(=
<span style=3D"color:rgb(102,0,153)">description</span>=3Ddescription, <spa=
n style=3D"color:rgb(102,0,153)">epilog</span>=3Depilogue,<br> =
<span style=3D"color:rgb(102,0,153)">formatter_clas=
s</span>=3Dargparse.RawDescriptionHelpFormatter)<br> parser.add_argument=
(<span style=3D"color:rgb(0,128,128);font-weight:bold">'angle'</spa=
n>, <span style=3D"color:rgb(102,0,153)">default</span>=3D<span style=3D"co=
lor:rgb(0,0,255)">90</span>, <span style=3D"color:rgb(102,0,153)">type</spa=
n>=3D<span style=3D"color:rgb(0,0,128)">float</span>, <span style=3D"color:=
rgb(102,0,153)">nargs</span>=3D<span style=3D"color:rgb(0,128,128);font-wei=
ght:bold">'?'</span>,<br> <span style=3D"col=
or:rgb(102,0,153)">help</span>=3D<span style=3D"color:rgb(0,128,128);font-w=
eight:bold">'The arc of the sphere, an angle in degrees from +y in the =
+x direction.'</span>)<br> parser.add_argument(<span style=3D"color:=
rgb(0,128,128);font-weight:bold">'step'</span>, <span style=3D"colo=
r:rgb(102,0,153)">default</span>=3D<span style=3D"color:rgb(0,0,255)">1</sp=
an>, <span style=3D"color:rgb(102,0,153)">type</span>=3D<span style=3D"colo=
r:rgb(0,0,128)">float</span>, <span style=3D"color:rgb(102,0,153)">nargs</s=
pan>=3D<span style=3D"color:rgb(0,128,128);font-weight:bold">'?'</s=
pan>, <span style=3D"color:rgb(102,0,153)">help</span>=3D<span style=3D"col=
or:rgb(0,128,128);font-weight:bold">'The step angle in degrees.'</s=
pan>)<br> parser.add_argument(<span style=3D"color:rgb(0,128,128);font-w=
eight:bold">'radius'</span>, <span style=3D"color:rgb(102,0,153)">d=
efault</span>=3D<span style=3D"color:rgb(0,0,255)">1</span>, <span style=3D=
"color:rgb(102,0,153)">type</span>=3D<span style=3D"color:rgb(0,0,128)">flo=
at</span>, <span style=3D"color:rgb(102,0,153)">nargs</span>=3D<span style=
=3D"color:rgb(0,128,128);font-weight:bold">'?'</span>, <span style=
=3D"color:rgb(102,0,153)">help</span>=3D<span style=3D"color:rgb(0,128,128)=
;font-weight:bold">'The radius of the sphere.'</span>)<br> parse=
r.add_argument(<span style=3D"color:rgb(0,128,128);font-weight:bold">'-=
c'</span>, <span style=3D"color:rgb(0,128,128);font-weight:bold">'-=
-closed'</span>, <span style=3D"color:rgb(102,0,153)">action</span>=3D<=
span style=3D"color:rgb(0,128,128);font-weight:bold">'store_true'</=
span>, <span style=3D"color:rgb(102,0,153)">help</span>=3D<span style=3D"co=
lor:rgb(0,128,128);font-weight:bold">'Add a closed cap.'</span>)<br=
> args =3D parser.parse_args()<br> <span style=3D"color:rgb(0,0,128);=
font-weight:bold">return </span>args.angle, args.step, args.radius, args.cl=
osed<br><br><br><span style=3D"color:rgb(0,0,128);font-weight:bold">def </s=
pan>main():<br> angle, step, radius, closed =3D get_program_parameters()=
<br> angle =3D math.radians(angle)<br> step =3D math.radians(step)<br=
> precision =3D <span style=3D"color:rgb(0,0,255)">1.0e-6<br></span><spa=
n style=3D"color:rgb(0,0,255)"> </span>start =3D math.radians(<span styl=
e=3D"color:rgb(0,0,255)">90</span>)<br> pts =3D <span style=3D"color:rgb=
(0,0,128)">list</span>()<br> <span style=3D"color:rgb(128,128,128);font-=
style:italic"># Do the curved line<br></span><span style=3D"color:rgb(128,1=
28,128);font-style:italic"> </span>theta =3D <span style=3D"color:rgb(0,=
0,255)">0.0<br></span><span style=3D"color:rgb(0,0,255)"> </span><span s=
tyle=3D"color:rgb(0,0,128);font-weight:bold">while </span>theta <=3D ang=
le:<br> x =3D radius * math.cos(start - theta)<br> z =3D radi=
us * math.sin(-start + theta)<br> <span style=3D"color:rgb(0,0,128);=
font-weight:bold">if </span><span style=3D"color:rgb(0,0,128)">abs</span>(x=
) < precision:<br> x =3D <span style=3D"color:rgb(0,0,255)">0=
<br></span><span style=3D"color:rgb(0,0,255)"> </span><span style=3D=
"color:rgb(0,0,128);font-weight:bold">if </span><span style=3D"color:rgb(0,=
0,128)">abs</span>(z) < precision:<br> z =3D <span style=3D"c=
olor:rgb(0,0,255)">0<br></span><span style=3D"color:rgb(0,0,255)"> <=
/span>pts.append((x, <span style=3D"color:rgb(0,0,255)">0</span>, z))<br> =
theta +=3D step<br><br> <span style=3D"color:rgb(0,0,128);font-wei=
ght:bold">if </span>closed:<br> <span style=3D"color:rgb(128,128,128=
);font-style:italic"># Drop a perpendicular from the last point to the x-ax=
is<br></span><span style=3D"color:rgb(128,128,128);font-style:italic"> =
</span>last_point =3D pts[-<span style=3D"color:rgb(0,0,255)">1</span>]<=
br> num_pts =3D <span style=3D"color:rgb(0,0,255)">10<br></span><spa=
n style=3D"color:rgb(0,0,255)"> </span>interval =3D <span style=3D"c=
olor:rgb(0,0,128)">float</span>(num_pts) / radius<br> <span style=3D=
"color:rgb(0,0,128);font-weight:bold">if </span>last_point[<span style=3D"c=
olor:rgb(0,0,255)">0</span>] > precision:<br> <span style=3D"=
color:rgb(0,0,128);font-weight:bold">for </span>i <span style=3D"color:rgb(=
0,0,128);font-weight:bold">in </span><span style=3D"color:rgb(0,0,128)">ran=
ge</span>(<span style=3D"color:rgb(0,0,255)">1</span>, num_pts):<br> =
x =3D last_point[<span style=3D"color:rgb(0,0,255)">0</span>] - i =
/ interval<br> z =3D last_point[<span style=3D"color:rgb(0,0=
,255)">2</span>]<br> <span style=3D"color:rgb(0,0,128);font-=
weight:bold">if </span><span style=3D"color:rgb(0,0,128)">abs</span>(x) <=
; precision:<br> x =3D <span style=3D"color:rgb(0,0,255)=
">0<br></span><span style=3D"color:rgb(0,0,255)"> </span><sp=
an style=3D"color:rgb(0,0,128);font-weight:bold">if </span><span style=3D"c=
olor:rgb(0,0,128)">abs</span>(z) < precision:<br> z =
=3D <span style=3D"color:rgb(0,0,255)">0<br></span><span style=3D"color:rgb=
(0,0,255)"> </span>pts.append((x, <span style=3D"color:rgb(0=
,0,255)">0</span>, z))<br> <span style=3D"color:rgb(0,0,128);font-we=
ight:bold">if </span>pts[-<span style=3D"color:rgb(0,0,255)">1</span>][<spa=
n style=3D"color:rgb(0,0,255)">0</span>] > precision:<br> pts=
.append((<span style=3D"color:rgb(0,0,255)">0</span>, <span style=3D"color:=
rgb(0,0,255)">0</span>, z))<br><br> <span style=3D"color:rgb(128,128,128=
);font-style:italic"># Setup points and lines<br></span><span style=3D"colo=
r:rgb(128,128,128);font-style:italic"> </span>points =3D vtk.vtkPoints()=
<br> lines =3D vtk.vtkCellArray()<br> <span style=3D"color:rgb(0,0,12=
8);font-weight:bold">for </span>pt <span style=3D"color:rgb(0,0,128);font-w=
eight:bold">in </span>pts:<br> <span style=3D"color:rgb(128,128,128)=
">pt_id </span>=3D points.InsertNextPoint(pt)<br> <span style=3D"color:r=
gb(0,0,128);font-weight:bold">for </span>i <span style=3D"color:rgb(0,0,128=
);font-weight:bold">in </span><span style=3D"color:rgb(0,0,128)">range</spa=
n>(<span style=3D"color:rgb(0,0,255)">0</span>, <span style=3D"color:rgb(0,=
0,128)">len</span>(pts) - <span style=3D"color:rgb(0,0,255)">1</span>):<br>=
line =3D vtk.vtkLine()<br> line.GetPointIds().SetId(<span st=
yle=3D"color:rgb(0,0,255)">0</span>, i)<br> line.GetPointIds().SetId=
(<span style=3D"color:rgb(0,0,255)">1</span>, i + <span style=3D"color:rgb(=
0,0,255)">1</span>)<br> lines.InsertNextCell(line)<br><br> polyda=
ta =3D vtk.vtkPolyData()<br> polydata.SetPoints(points)<br> polydata.=
SetLines(lines)<br><br> <span style=3D"color:rgb(128,128,128);font-style=
:italic"># Extrude the profile to make the capped sphere.<br></span><span s=
tyle=3D"color:rgb(128,128,128);font-style:italic"> #<br></span><span sty=
le=3D"color:rgb(128,128,128);font-style:italic"> </span>extrude =3D vtk.=
vtkRotationalExtrusionFilter()<br> extrude.SetInputData(polydata)<br> =
extrude.SetResolution(<span style=3D"color:rgb(0,0,255)">60</span>)<br><br=
> <span style=3D"color:rgb(128,128,128);font-style:italic"># Visualize<=
br></span><span style=3D"color:rgb(128,128,128);font-style:italic"> </sp=
an>colors =3D vtk.vtkNamedColors()<br><br> mapper =3D vtk.vtkPolyDataMap=
per()<br> <span style=3D"color:rgb(128,128,128);font-style:italic"># To =
see the line<br></span><span style=3D"color:rgb(128,128,128);font-style:ita=
lic"> # mapper.SetInputData(polydata)<br></span><span style=3D"color:rgb=
(128,128,128);font-style:italic"> # To see the surface<br></span><span s=
tyle=3D"color:rgb(128,128,128);font-style:italic"> </span>mapper.SetInpu=
tConnection(extrude.GetOutputPort())<br><br> actor =3D vtk.vtkActor()<br=
> actor.SetMapper(mapper)<br> actor.GetProperty().SetLineWidth(<span =
style=3D"color:rgb(0,0,255)">4</span>)<br> actor.GetProperty().SetColor(=
colors.GetColor3d(<span style=3D"color:rgb(0,128,128);font-weight:bold">=
9;Cornsilk'</span>))<br><br> ren =3D vtk.vtkRenderer()<br> renWin=
=3D vtk.vtkRenderWindow()<br> renWin.AddRenderer(ren)<br> iren =3D v=
tk.vtkRenderWindowInteractor()<br> iren.SetRenderWindow(renWin)<br><br> =
ren.AddActor(actor)<br> ren.SetBackground(colors.GetColor3d(<span sty=
le=3D"color:rgb(0,128,128);font-weight:bold">'DarkGreen'</span>))<b=
r><br> ren.ResetCamera()<br> ren.GetActiveCamera().Azimuth(<span styl=
e=3D"color:rgb(0,0,255)">0</span>)<br> ren.GetActiveCamera().Elevation(<=
span style=3D"color:rgb(0,0,255)">60</span>)<br> ren.ResetCameraClipping=
Range()<br><br> renWin.SetSize(<span style=3D"color:rgb(0,0,255)">600</s=
pan>, <span style=3D"color:rgb(0,0,255)">600</span>)<br> renWin.Render()=
<br> renWin.SetWindowName(<span style=3D"color:rgb(0,128,128);font-weigh=
t:bold">'CappedSphere'</span>)<br> iren.Start()<br><br><br><span=
style=3D"color:rgb(0,0,128);font-weight:bold">if </span>__name__ =3D=3D <s=
pan style=3D"color:rgb(0,128,128);font-weight:bold">'__main__'</spa=
n>:<br> main()<br></pre></div><div class=3D"gmail_default" style=3D"font=
-size:small">##############################################<br></div><div c=
lass=3D"gmail_default" style=3D"font-size:small"><br></div><div class=3D"gm=
ail_default" style=3D"font-size:small"><br></div></div><br><div class=3D"gm=
ail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br><br>------=
---- Forwarded message ----------<br>From:=C2=A0David Gobbi <<a href=3D"=
mailto:[email protected]" target=3D"_blank">[email protected]</a>&g=
t;<br>To:=C2=A0VTK Users <<a href=3D"mailto:[email protected]" target=3D"=
_blank">[email protected]</a>><br>Cc:=C2=A0<br>Bcc:=C2=A0<br>Date:=C2=A0S=
un, 14 Apr 2019 15:06:17 -0600<br>Subject:=C2=A0Re: [vtkusers] hemispherica=
l cap with hole at the bottom<br><div dir=3D"ltr"><div>Hi Petr,</div><div><=
br></div><div>Unfortunately, vtkClipPolyData doesn't close off the surf=
ace after clipping.=C2=A0 It wasn't designed to do that.=C2=A0 In fact,=
closing things off after clipping is a rather difficult problem.</div><div=
><br></div><div>I recommend that you take another approach.=C2=A0 Your cap =
is rotationally symmetric, right?=C2=A0 Try the rotational extrusion filter=
:=C2=A0<a href=3D"https://vtk.org/doc/nightly/html/classvtkRotationalExtrus=
ionFilter.html" target=3D"_blank">https://vtk.org/doc/nightly/html/classvtk=
RotationalExtrusionFilter.html</a></div><div><br></div><div>All you need to=
do is generate a cross-section of your cap, i.e. an arc.=C2=A0 Just do thi=
s by writing a couple "for" loops in python to build the arc usin=
g sin() and cos(), make a polyline and stuff it in a vtkPolyData.=C2=A0 For=
example,=C2=A0<a href=3D"https://lorensen.github.io/VTKExamples/site/Pytho=
n/GeometricObjects/PolyLine1/" target=3D"_blank">https://lorensen.github.io=
/VTKExamples/site/Python/GeometricObjects/PolyLine1/</a></div><div><br></di=
v><div>Once you have your cross-section, pass it through vtkRotationalExtru=
sionFilter to generate the shape.</div><span class=3D"gmail-m_6875413692765=
619131gmail-HOEnZb gmail-m_6875413692765619131gmail-adL"><font color=3D"#88=
8888"><div><br></div><div>=C2=A0 =C2=A0David</div></font></span></div><br><=
div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sun, Apr=
14, 2019 at 9:30 AM Petr Vokac <<a href=3D"mailto:[email protected]"=
target=3D"_blank">[email protected]</a>> wrote:<br></div><blockquote=
class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px so=
lid 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 =3D vtk.vtkSphereSource()<br>
sphere.SetRadius(10.0)<br>
<br>
spherei =3D vtk.vtkSphereSource()<br>
spherei.SetRadius(8.0)<br>
<br>
sphereir=3Dvtk.vtkReverseSense()<br>
sphereir.SetInputConnection(spherei.GetOutputPort())<br>
<br>
ext=3Dvtk.vtkAppendPolyData()<br>
ext.AddInputConnection(sphere.GetOutputPort())<br>
ext.AddInputConnection(sphereir.GetOutputPort())<br>
<br>
plane =3D vtk.vtkPlane()<br>
plane.SetOrigin([0.0,0.0,0.0])<br>
plane.SetNormal([0.0,-1.0,0.0])<br>
<br>
clipclose=3Dvtk.vtkClipClosedSurface()<br>
pc =3D vtk.vtkPlaneCollection()<br>
pc.AddItem(plane)<br>
clipclose.SetClippingPlanes(pc)<br>
clipclose.SetInputConnection(ext.GetOutputPort())<br>
<br>
cyl =3D vtk.vtkCylinder()<br>
cyl.SetCenter(0,0,0)<br>
cyl.SetRadius(5.0)<br>
ib =3D vtk.vtkImplicitBoolean()<br>
ib.AddFunction(cyl)<br>
<br>
clipper =3D vtk.vtkClipPolyData()<br>
clipper.SetInputConnection(clipclose.GetOutputPort())<br>
clipper.SetClipFunction(ib)<br>
clipper.GenerateClippedOutputOn()<br>
<br>
mapper =3D vtk.vtkPolyDataMapper()<br>
mapper.SetInputConnection(clipper.GetOutputPort())<br>
<br>
actor =3D vtk.vtkActor()<br>
actor.SetMapper(mapper)<br>
<br>
ren =3D vtk.vtkRenderer()<br>
ren.AddActor(actor)<br>
ren.ResetCamera()<br>
<br>
renWin =3D vtk.vtkRenderWindow()<br>
renWin.AddRenderer(ren)<br>
iren =3D 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=3D"http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.h=
tml" rel=3D"noreferrer" target=3D"_blank">http://vtk.1045678.n5.nabble.com/=
VTK-Users-f1224199.html</a><br>
_______________________________________________<br>
Powered by <a href=3D"http://www.kitware.com" rel=3D"noreferrer" target=3D"=
_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href=3D"http://www.kitware.c=
om/opensource/opensource.html" rel=3D"noreferrer" target=3D"_blank">http://=
www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href=3D"http://w=
ww.vtk.org/Wiki/VTK_FAQ" rel=3D"noreferrer" target=3D"_blank">http://www.vt=
k.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href=3D"http://markmail.org/search/?q=3Dvtk=
users" rel=3D"noreferrer" target=3D"_blank">http://markmail.org/search/?q=
=3Dvtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href=3D"https://vtk.org/mailman/listinfo/vtkusers" rel=3D"noreferrer" ta=
rget=3D"_blank">https://vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div>
<br><br><br></blockquote></div>-- <br><div dir=3D"ltr" class=3D"gmail_signa=
ture">___________________________________________<br>Andrew J. P. Maclean<b=
r><br>___________________________________________</div></div></div>
--0000000000007563c505869f31fd--
--===============1525884731==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
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
Search the list archives at: http://markmail.org/search/?q=vtkusers
Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers
--===============1525884731==--