<div dir="ltr"><div>Hi Kent,</div><div><br></div><div>Your code for building the polydata looks suspicious.  If you put your box polydata directly into the mapper (i.e. without vtkClipClosedSurface) does it display properly? </div><div><br></div><div>I translated your code into python (I'm not much of a Java programmer), and it ran without any errors:</div><div><br></div><div><br></div><div>from vtk import *</div><div><br></div><div>points = [</div><div>  0.0, 0.0, 0.0,</div><div>  1.0, 0.0, 0.0,</div><div>  1.0, 1.0, 0.0,</div><div>  0.0, 1.0, 0.0,</div><div>  0.0, 0.0, 1.0,</div><div>  1.0, 0.0, 1.0,</div><div>  1.0, 1.0, 1.0,</div><div>  0.0, 1.0, 1.0,</div><div>]</div><div><br></div><div>seq = [</div><div>  4, 0,1,2,3,</div><div>  4, 1,5,6,2,</div><div>  4, 5,4,7,6,</div><div>  4, 4,0,3,7,</div><div>  4, 0,1,5,4,</div><div>  4, 3,2,6,7</div><div>]</div><div><br></div><div># create a plane for clipping</div><div>plane = vtkPlane();</div><div>plane.SetOrigin(0.0, 0.0, 0.5);</div><div>plane.SetNormal(0, 0, 1);</div><div><br></div><div># create the box from points and sequence</div><div>polyData = vtkPolyData();</div><div>pts = vtkPoints();</div><div>for i in range(8):</div><div>    pts.InsertNextPoint(points[i*3:(i+1)*3])</div><div>polyData.SetPoints(pts);</div><div>cells = vtkCellArray();</div><div>for i in range(6):</div><div>    cells.InsertNextCell(4)</div><div>    for j in range(1,5):</div><div>        cells.InsertCellPoint(seq[5*i + j])</div><div>polyData.SetPolys(cells);</div><div><br></div><div>clipClosedSurface = vtkClipClosedSurface();</div><div>planes = vtkPlaneCollection();</div><div>planes.AddItem(plane);</div><div>clipClosedSurface.SetClippingPlanes(planes);</div><div>clipClosedSurface.AddInputData(polyData);</div><div>clipClosedSurface.Update();   # THIS CRASHES</div><div><br></div><div>clipMapper = vtkDataSetMapper();</div><div>clipMapper.SetInputConnection(clipClosedSurface.GetOutputPort());</div><div><br></div><div>boxActor = vtkActor();</div><div>boxActor.SetMapper(clipMapper);</div><div>boxActor.GetProperty().SetColor(0.8900, 0.8100, 0.3400);</div><div><br></div><div>ren = vtkRenderer()</div><div>ren.AddActor(boxActor)</div><div><br></div><div>win = vtkRenderWindow()</div><div>win.AddRenderer(ren)</div><div><br></div><div>iren = vtkRenderWindowInteractor()</div><div>win.SetInteractor(iren)</div><div><br></div><div>iren.Initialize()</div><div>iren.Start()</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 25, 2015 at 5:18 PM, kent myers via vtkusers <span dir="ltr"><<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am trying to clip a box constructed as a polydata mesh.  I have tried the<br>
vtkClipPolyData class based on the quadric surface example in the following<br>
link, but have not succeeded.<br>
<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/SolidClip" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/SolidClip</a><br>
<br>
I found the vtkClipClosedSurface class and it seems like exactly what I am<br>
looking for, but I could not find any examples of how to use it.  The code<br>
below shows my attempt.  It crashes when calling the Update() method.<br>
Without that call, I get no visible result.<br>
<br>
Any help would be appreciated!<br>
<br>
Kent<br>
<br>
        private static void createBox() {<br>
                float[] points = {<br>
                                0.0f, 0.0f, 0.0f,<br>
                                1.0f, 0.0f, 0.0f,<br>
                                1.0f, 1.0f, 0.0f,<br>
                                0.0f, 1.0f, 0.0f,<br>
                                0.0f, 0.0f, 1.0f,<br>
                                1.0f, 0.0f, 1.0f,<br>
                                1.0f, 1.0f, 1.0f,<br>
                                0.0f, 1.0f, 1.0f,<br>
                                };<br>
                int[] seq = {<br>
                                4, 0, 1, 2, 3,<br>
                                4, 1,5,6,2,<br>
                                4, 5,4,7,6,<br>
                                4, 4,0,3,7,<br>
                                4, 0,1,5,4,<br>
                                4, 3,2,6,7};<br>
<br>
<br>
                // create a plane for clipping<br>
                vtkPlane plane = new vtkPlane();<br>
                plane.SetOrigin(0.0, 0.0, 0.5);<br>
                plane.SetNormal(0, 0, 1);<br>
<br>
                // create the box from points and sequence<br>
                vtkPolyData polyData = new vtkPolyData();<br>
                vtkPoints vtkPoints = new vtkPoints();<br>
                vtkFloatArray d = new vtkFloatArray();<br>
                d.SetJavaArray(points);<br>
                d.SetNumberOfComponents(3);<br>
                vtkPoints.SetData(d);<br>
                polyData.SetPoints(vtkPoints);<br>
                vtkCellArray vtkCells = new vtkCellArray();<br>
                vtkIdTypeArray array = new vtkIdTypeArray();<br>
                vtkIntArray intArray = new vtkIntArray();<br>
                intArray.SetJavaArray(seq);<br>
                array.DeepCopy(intArray);<br>
                vtkCells.SetCells(seq.length, array);<br>
                polyData.SetPolys(vtkCells);<br>
<br>
                vtkClipClosedSurface clipClosedSurface = new vtkClipClosedSurface();<br>
                vtkPlaneCollection planes = new vtkPlaneCollection();<br>
                planes.AddItem(plane);<br>
                clipClosedSurface.SetClippingPlanes(planes);<br>
                clipClosedSurface.AddInputData(polyData);<br>
                clipClosedSurface.Update();   // THIS CRASHES<br>
<br>
                vtkDataSetMapper clipMapper = new vtkDataSetMapper();<br>
                clipMapper.SetInputConnection(clipClosedSurface.GetOutputPort());<br>
<br>
                boxActor = new vtkActor();<br>
                boxActor.SetMapper(clipMapper);<br>
                boxActor.GetProperty().SetColor(0.8900, 0.8100, 0.3400);<br>
<br>
        }<br><br></blockquote></div></div></div>