<div dir="ltr">Screenshot is here!<br><br><br><br><div class="gmail_quote">On Tue, May 18, 2010 at 11:12 AM, Jothy <span dir="ltr">&lt;<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr">Hi David,<br><br>I tried the vtkHexahedron example. But, when I try to cut this I get a line across the cut plane . see the screenshot and also the code.<br><br>Could you please figure it out?<br><br><font size="2"><span style="color: rgb(0, 0, 153);">from vtk import*</span><br style="color: rgb(0, 0, 153);">

<br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#Setup the coordinates of eight points</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#(the two faces must be in counter clockwise order as viewd from the outside)</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">P0 = [0.0, 0.0, 0.0];</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">P1 = [1.0, 0.0, 0.0];</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">P2 = [1.0, 1.0, 0.0];</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">P3 = [0.0, 1.0, 0.0];</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">P4 = [0.0, 0.0, 1.0];</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">P5 = [1.0, 0.0, 1.0];</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">P6 = [1.0, 1.0, 1.0];</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">P7 = [0.0, 1.0, 1.0];</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);">

<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#Create the points</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">points = vtkPoints();</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">points.InsertNextPoint(P0);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">points.InsertNextPoint(P1);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">points.InsertNextPoint(P2);</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">points.InsertNextPoint(P3);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">points.InsertNextPoint(P4);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">points.InsertNextPoint(P5);</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">points.InsertNextPoint(P6);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">points.InsertNextPoint(P7);</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">#Create a hexahedron from the points</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">hexa = vtkHexahedron();</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">hexa.GetPointIds().SetId(0,0);</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">hexa.GetPointIds().SetId(1,1);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">hexa.GetPointIds().SetId(2,2);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">hexa.GetPointIds().SetId(3,3);</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">hexa.GetPointIds().SetId(4,4);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">hexa.GetPointIds().SetId(5,5);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">hexa.GetPointIds().SetId(6,6);</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">hexa.GetPointIds().SetId(7,7);</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#Add the hexahedron to a cell array</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">hexs = vtkCellArray();</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">hexs.InsertNextCell(hexa);</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">#Add the points and hexahedron to an unstructured grid</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">uGrid =vtkUnstructuredGrid();</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">uGrid.SetPoints(points);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">uGrid.InsertNextCell(hexa.GetCellType(), hexa.GetPointIds());</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">aBeamMapper = vtkDataSetMapper()</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">aBeamMapper.SetInput(uGrid)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">aBeamActor = vtkActor()</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">aBeamActor.SetMapper(aBeamMapper)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">aBeamActor.AddPosition(0,0,0)</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">aBeamActor.GetProperty().SetColor(1,1,0)</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">aBeamActor.GetProperty().SetOpacity(0.60)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">aBeamActor.GetProperty().EdgeVisibilityOn()</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">aBeamActor.GetProperty().SetEdgeColor(1,1,1)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">aBeamActor.GetProperty().SetLineWidth(1.5)</span><br style="color: rgb(0, 0, 153);">

<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#create a plane to cut,here it cuts in the XZ direction (xz normal=(1,0,0);XY =(0,0,1),YZ =(0,1,0)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">plane=vtkPlane()</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">plane.SetOrigin(0.5,0,0)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">plane.SetNormal(1,0,0)</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">#create cutter</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">cutter=vtkCutter()</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">cutter.SetCutFunction(plane)</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">cutter.SetInput(aBeamActor.GetMapper().GetInput())</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">cutter.Update()</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">cutterMapper=vtkPolyDataMapper()</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">cutterMapper.SetInputConnection( cutter.GetOutputPort())</span><br style="color: rgb(0, 0, 153);">

<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#create plane actor</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">planeActor=vtkActor()</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">planeActor.GetProperty().SetColor(1,0.5,0.5)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">planeActor.GetProperty().SetLineWidth(2)</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">planeActor.SetMapper(cutterMapper)</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);"># Setup a renderer, render window, and interactor</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">renderer = vtkRenderer()</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderWindow = vtkRenderWindow()</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#renderWindow.SetWindowName(&quot;Test&quot;)</span><br style="color: rgb(0, 0, 153);">

<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderWindow.AddRenderer(renderer);</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderWindowInteractor = vtkRenderWindowInteractor()</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">renderWindowInteractor.SetRenderWindow(renderWindow)</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#Add the actor to the scene</span><br style="color: rgb(0, 0, 153);">

<span style="color: rgb(0, 0, 153);">renderer.AddActor(aBeamActor)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderer.AddActor(planeActor)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderer.SetBackground(0,0,0) # Background color white</span><br style="color: rgb(0, 0, 153);">

<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#Render and interact</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderWindow.Render()</span><br style="color: rgb(0, 0, 153);">

</font><i><b><br style="color: rgb(0, 0, 153);"></b></i><br>I think it has be passed through a filter. But what it&#39;s that??<br><br>Thanks,<br><font color="#888888"><br>Jothy</font><div><div></div><div class="h5"><br>
<br><br>On Mon, May 17, 2010 at 10:08 PM, David Doria &lt;<a href="mailto:daviddoria%2Bvtk@gmail.com" target="_blank">daviddoria+vtk@gmail.com</a>&gt; wrote:<br>
&gt; On Mon, May 17, 2010 at 5:03 PM, Jothy &lt;<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>&gt; wrote:<br>&gt;&gt; Hi all,<br>&gt;&gt;<br>&gt;&gt; I want to create a hexahedron using vtkPolyData. I think there is no<br>

&gt;&gt; example in wiki. I created it with a vtkHexaHedron but when I cut it<br>&gt;&gt; it produces a line across the cut section.I don&#39;t want this. I am not<br>&gt;&gt; able to solve this problem for many months.I used it passing through<br>

&gt;&gt; vtkstripper, vtkTriangle. Finally found that only if the input is of<br>&gt;&gt; vtkPolyData, cutter will not produce that line across the cut section.<br>&gt;&gt; Can some with kind enough :), add an example of how to create cube or<br>

&gt;&gt; cone with vtkPoldata.<br>&gt;&gt;<br>&gt;&gt; Many thanks,<br>&gt;&gt;<br>&gt;&gt; Jothy<br>&gt;<br>&gt; I don&#39;t really understand your question. The title and your last<br>&gt; sentence talk about cubes and cones<br>

&gt;<br>&gt; <a href="http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Cube" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Cube</a><br>&gt; <a href="http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Display/Cone" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Display/Cone</a><br>

&gt;<br>&gt; but the beginning talks about hexahedrons<br>&gt;<br>&gt; <a href="http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Hexahedron" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Hexahedron</a><br>
&gt;<br>
&gt; Let us know if these links do not help.<br>&gt;<br>&gt; David<br>&gt;<br><br></div></div></div>
</blockquote></div><br></div>