<div dir="ltr">Hi Kent,<div><br></div><div>Yes, it displayed half a box (see attached screenshot).</div><div><br></div><div>Let's just say that code like "<span style="color:rgb(0,0,0);white-space:pre-wrap">vtkPoints vtkPoints = new vtkPoints();"</span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">doesn't fill me with confidence.  Can you try building the polydata</span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">as per my python example and see if that works?</span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap"> - David</span></div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 25, 2015 at 6:23 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="color:rgb(0,0,0);font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:12px;background-color:rgb(255,255,255)"><div><span>Hi David,</span></div><div><span></span><br></div><div dir="ltr"><span>I did display the box successfully.  This method was extracted from a complete demo  application that I submitted to the bug tracker as issue 0015487.  I have attached it here if you want to look at it.  This would not be the first time that the Java API crashes using methods that work in other languages.</span></div><div dir="ltr"><span></span><br></div><div dir="ltr"><span>You said it ran without errors.  Did you get a properly clipped box as a result?  It started out as a cube and I put the clipping plane half the height of the cube.</span></div><div dir="ltr"><span></span><br></div><div dir="ltr"><span>Thanks for taking a look.</span></div><div dir="ltr"><span></span><br></div><div dir="ltr"><span>Kent</span></div><div dir="ltr"><span></span><br></div><div dir="ltr"><span></span><br></div>  <br><div><br><br></div><div style="display:block"> <div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:12px"> <div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;font-size:16px"><div><div class="h5"> <div dir="ltr"> <font face="Arial" size="2"> On Monday, May 25, 2015 5:09 PM, David Gobbi [via VTK] <<a href="http:///user/SendEmail.jtp?type=node&node=5731997&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>> wrote:<br> </font> </div>  <br><br> </div></div><div><div><div><div dir="ltr"><div><div class="h5"><div>Hi Kent,</div><div><br clear="none"></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 clear="none"></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 clear="none"></div><div><br clear="none"></div><div>from vtk import *</div><div><br clear="none"></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 clear="none"></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 clear="none"></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 clear="none"></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 clear="none"></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 clear="none"></div><div>clipMapper = vtkDataSetMapper();</div><div>clipMapper.SetInputConnection(clipClosedSurface.GetOutputPort());</div><div><br clear="none"></div><div>boxActor = vtkActor();</div><div>boxActor.SetMapper(clipMapper);</div><div>boxActor.GetProperty().SetColor(0.8900, 0.8100, 0.3400);</div><div><br clear="none"></div><div>ren = vtkRenderer()</div><div>ren.AddActor(boxActor)</div><div><br clear="none"></div><div>win = vtkRenderWindow()</div><div>win.AddRenderer(ren)</div><div><br clear="none"></div><div>iren = vtkRenderWindowInteractor()</div><div>win.SetInteractor(iren)</div><div><br clear="none"></div><div>iren.Initialize()</div><div>iren.Start()</div></div></div><div><div class="h5"><div><br clear="none"><div><div>On Mon, May 25, 2015 at 5:18 PM, kent myers via vtkusers <span dir="ltr"><<a rel="nofollow" shape="rect" link="external">[hidden email]</a>></span> wrote:<br clear="none"><blockquote style="border-left-width:2px;border-left-style:solid;border-left-color:rgb(204,204,204);padding:0px 1em">I am trying to clip a box constructed as a polydata mesh.  I have tried the<br clear="none">
vtkClipPolyData class based on the quadric surface example in the following<br clear="none">
link, but have not succeeded.<br clear="none">
<br clear="none">
<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/SolidClip" rel="nofollow" shape="rect" link="external" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/SolidClip</a><br clear="none">
<br clear="none">
I found the vtkClipClosedSurface class and it seems like exactly what I am<br clear="none">
looking for, but I could not find any examples of how to use it.  The code<br clear="none">
below shows my attempt.  It crashes when calling the Update() method.<br clear="none">
Without that call, I get no visible result.<br clear="none">
<br clear="none">
Any help would be appreciated!<br clear="none">
<br clear="none">
Kent<br clear="none">
<br clear="none">
        private static void createBox() {<br clear="none">
                float[] points = {<br clear="none">
                                0.0f, 0.0f, 0.0f,<br clear="none">
                                1.0f, 0.0f, 0.0f,<br clear="none">
                                1.0f, 1.0f, 0.0f,<br clear="none">
                                0.0f, 1.0f, 0.0f,<br clear="none">
                                0.0f, 0.0f, 1.0f,<br clear="none">
                                1.0f, 0.0f, 1.0f,<br clear="none">
                                1.0f, 1.0f, 1.0f,<br clear="none">
                                0.0f, 1.0f, 1.0f,<br clear="none">
                                };<br clear="none">
                int[] seq = {<br clear="none">
                                4, 0, 1, 2, 3,<br clear="none">
                                4, 1,5,6,2,<br clear="none">
                                4, 5,4,7,6,<br clear="none">
                                4, 4,0,3,7,<br clear="none">
                                4, 0,1,5,4,<br clear="none">
                                4, 3,2,6,7};<br clear="none">
<br clear="none">
<br clear="none">
                // create a plane for clipping<br clear="none">
                vtkPlane plane = new vtkPlane();<br clear="none">
                plane.SetOrigin(0.0, 0.0, 0.5);<br clear="none">
                plane.SetNormal(0, 0, 1);<br clear="none">
<br clear="none">
                // create the box from points and sequence<br clear="none">
                vtkPolyData polyData = new vtkPolyData();<br clear="none">
                vtkPoints vtkPoints = new vtkPoints();<br clear="none">
                vtkFloatArray d = new vtkFloatArray();<br clear="none">
                d.SetJavaArray(points);<br clear="none">
                d.SetNumberOfComponents(3);<br clear="none">
                vtkPoints.SetData(d);<br clear="none">
                polyData.SetPoints(vtkPoints);<br clear="none">
                vtkCellArray vtkCells = new vtkCellArray();<br clear="none">
                vtkIdTypeArray array = new vtkIdTypeArray();<br clear="none">
                vtkIntArray intArray = new vtkIntArray();<br clear="none">
                intArray.SetJavaArray(seq);<br clear="none">
                array.DeepCopy(intArray);<br clear="none">
                vtkCells.SetCells(seq.length, array);<br clear="none">
                polyData.SetPolys(vtkCells);<br clear="none">
<br clear="none">
                vtkClipClosedSurface clipClosedSurface = new vtkClipClosedSurface();<br clear="none">
                vtkPlaneCollection planes = new vtkPlaneCollection();<br clear="none">
                planes.AddItem(plane);<br clear="none">
                clipClosedSurface.SetClippingPlanes(planes);<br clear="none">
                clipClosedSurface.AddInputData(polyData);<br clear="none">
                clipClosedSurface.Update();   // THIS CRASHES<br clear="none">
<br clear="none">
                vtkDataSetMapper clipMapper = new vtkDataSetMapper();<br clear="none">
                clipMapper.SetInputConnection(clipClosedSurface.GetOutputPort());<br clear="none">
<br clear="none">
                boxActor = new vtkActor();<br clear="none">
                boxActor.SetMapper(clipMapper);<br clear="none">
                boxActor.GetProperty().SetColor(0.8900, 0.8100, 0.3400);<br clear="none">
<br clear="none">
        }<br clear="none"><br clear="none"></blockquote></div></div></div></div></div></div><span class=""><div>
<br clear="none">_______________________________________________
<br clear="none">Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a>
<br clear="none"><br clear="none">Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="nofollow" shape="rect" link="external" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br clear="none"><br clear="none">Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="nofollow" shape="rect" link="external" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br clear="none"><br clear="none">Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="nofollow" shape="rect" link="external" target="_blank">http://markmail.org/search/?q=vtkusers</a><br clear="none"><br clear="none">Follow this link to subscribe/unsubscribe:
<br clear="none"><a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="nofollow" shape="rect" link="external" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a></div><br clear="none">

        
        
        
        <br clear="none">
        <br clear="none">
        </span><hr size="1" color="#cccccc" noshade>
        <div style="font-style:normal;font-variant:normal;font-weight:normal;font-size:12px;line-height:normal;font-family:tahoma,geneva,helvetica,arial,sans-serif;color:rgb(68,68,68);font-stretch:normal">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                <a href="http://vtk.1045678.n5.nabble.com/using-vtkClipClosedSurface-on-a-box-crashes-tp5731995p5731996.html" rel="nofollow" shape="rect" link="external" target="_blank">http://vtk.1045678.n5.nabble.com/using-vtkClipClosedSurface-on-a-box-crashes-tp5731995p5731996.html</a>
        </div>
        <div style="font-style:normal;font-variant:normal;font-weight:normal;font-size:11px;line-height:1.5em;font-family:tahoma,geneva,helvetica,arial,sans-serif;color:rgb(102,102,102);margin-top:0.4em;font-stretch:normal">
                
                To unsubscribe from using vtkClipClosedSurface() on a box crashes, <a rel="nofollow" shape="rect" link="external">click here</a>.<br clear="none">
                <a style="font-style:normal;font-variant:normal;font-weight:normal;font-size:9px;line-height:normal;font-family:serif;font-stretch:normal" href="http://vtk.1045678.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" shape="rect" link="external" target="_blank">NAML</a><div>
        </div></div></div></div><br><br></div>  </div> </div>  </div></div><div><br><img src="http://vtk.1045678.n5.nabble.com/images/icon_attachment.gif"> <strong>vtkCuttingPlane.java</strong> (8K) <a href="http://vtk.1045678.n5.nabble.com/attachment/5731997/0/vtkCuttingPlane.java" rel="nofollow" link="external" target="_blank">Download Attachment</a></div>

        
        
        
<br></blockquote></div><br></div></div></div>