<div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12px"><div id="yui_3_16_0_1_1432599151219_4389"><span>Hi David,</span></div><div id="yui_3_16_0_1_1432599151219_4010"><span></span><br></div><div id="yui_3_16_0_1_1432599151219_4391" dir="ltr"><span id="yui_3_16_0_1_1432599151219_4390">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 id="yui_3_16_0_1_1432599151219_7370" dir="ltr"><span></span><br></div><div id="yui_3_16_0_1_1432599151219_7372" dir="ltr"><span id="yui_3_16_0_1_1432599151219_7371">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 id="yui_3_16_0_1_1432599151219_5472" dir="ltr"><span></span><br></div><div id="yui_3_16_0_1_1432599151219_6613" dir="ltr"><span>Thanks for taking a look.</span></div><div id="yui_3_16_0_1_1432599151219_5890" dir="ltr"><span></span><br></div><div id="yui_3_16_0_1_1432599151219_5473" dir="ltr"><span>Kent</span></div><div id="yui_3_16_0_1_1432599151219_5475" dir="ltr"><span></span><br></div><div id="yui_3_16_0_1_1432599151219_5479" dir="ltr"><span></span><br></div>  <br><div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" 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 dir="ltr"> <font face="Arial" size="2"> On Monday, May 25, 2015 5:09 PM, David Gobbi [via VTK] <<a href="/user/SendEmail.jtp?type=node&node=5731997&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>> wrote:<br> </font> </div>  <br><br> <div class="y_msg_container"><div id="yiv6458655876"><div><div dir="ltr"><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 class="yiv6458655876gmail_extra"><br clear="none"><div class="yiv6458655876yqt2281037939" id="yiv6458655876yqtfd67022"><div class="yiv6458655876gmail_quote">On Mon, May 25, 2015 at 5:18 PM, kent myers via vtkusers <span dir="ltr"><<a href="" rel="nofollow" shape="rect" target="_top" link="external">[hidden email]</a>></span> wrote:<br clear="none"><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="yiv6458655876gmail_quote" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;">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" target="_blank" rel="nofollow" shape="rect" link="external">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 class="yiv6458655876yqt2281037939" id="yiv6458655876yqtfd70709">
<br clear="none">_______________________________________________
<br clear="none">Powered by www.kitware.com
<br clear="none"><br clear="none">Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank" rel="nofollow" shape="rect" link="external">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" target="_blank" rel="nofollow" shape="rect" link="external">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" target="_blank" rel="nofollow" shape="rect" link="external">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" target="_blank" rel="nofollow" shape="rect" link="external">http://public.kitware.com/mailman/listinfo/vtkusers</a></div><br clear="none">

        
        
        
        <br clear="none">
        <br clear="none">
        <hr size="1" color="#cccccc" noshade="">
        <div style="font: 12px/normal tahoma, geneva, helvetica, arial, sans-serif; color: rgb(68, 68, 68); font-size-adjust: none; 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" target="_blank" rel="nofollow" shape="rect" link="external">http://vtk.1045678.n5.nabble.com/using-vtkClipClosedSurface-on-a-box-crashes-tp5731995p5731996.html</a>
        </div>
        <div style="font: 11px/1.5em tahoma, geneva, helvetica, arial, sans-serif; color: rgb(102, 102, 102); margin-top: 0.4em; font-size-adjust: none; font-stretch: normal;">
                
                To unsubscribe from using vtkClipClosedSurface() on a box crashes, <a href="" target="_blank" rel="nofollow" shape="rect" link="external">click here</a>.<br clear="none">
                <a style="font: 9px/normal serif; font-size-adjust: none; 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" target="_blank" rel="nofollow" shape="rect" link="external">NAML</a><div class="yiv6458655876yqt2281037939" id="yiv6458655876yqtfd93998">
        </div></div></div></div><br><br></div>  </div> </div>  </div></div><!--start-attachments--><div class="small"><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" target="_top" rel="nofollow" link="external">Download Attachment</a></div><!--end-attachments-->

        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/using-vtkClipClosedSurface-on-a-box-crashes-tp5731995p5731997.html">Re: using vtkClipClosedSurface() on a box crashes</a><br/>
Sent from the <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html">VTK - Users mailing list archive</a> at Nabble.com.<br/>