<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_1432603698832_11276"><span>Hi David,</span></div><div id="yui_3_16_0_1_1432603698832_10539"><span></span><br></div><div id="yui_3_16_0_1_1432603698832_8697"><span id="yui_3_16_0_1_1432603698832_8696">Changing to your technique of filling the point and cells did solve the problem.  One reason I did not do it that way is because in my actual application, I have 10's of thousands of points and I do not want to make a Java API call to store every point and every cell connection.  I am afraid the efficiency hit would be very high.  I found the technique of copying the entire point and cell data arrays in one call in an article that you wrote:</span></div><div id="yui_3_16_0_1_1432603698832_11277"><span></span><br></div><div id="yui_3_16_0_1_1432603698832_11278" dir="ltr"><span id="yui_3_16_0_1_1432603698832_12002"><a id="yui_3_16_0_1_1432603698832_12001" href="http://public.kitware.com/pipermail/vtkusers/2010-January/056525.html" target="_top" rel="nofollow" link="external">http://public.kitware.com/pipermail/vtkusers/2010-January/056525.html</a></span></div><div id="yui_3_16_0_1_1432603698832_11279" dir="ltr"><span></span><br></div><div id="yui_3_16_0_1_1432603698832_11280" dir="ltr"><span id="yui_3_16_0_1_1432603698832_11281">Of course it was C++, but since the methods are in the Java API, I assumed it was a safe method to use.  Do you know of a better way to pass the java points and cell definitions more efficiently than one by one?</span></div><div id="yui_3_16_0_1_1432603698832_13446" dir="ltr"><span></span><br></div><div id="yui_3_16_0_1_1432603698832_13448" dir="ltr"><span>Thanks,</span></div><div id="yui_3_16_0_1_1432603698832_12006" dir="ltr"><span></span><br></div><div id="yui_3_16_0_1_1432603698832_13447" dir="ltr"><span>Kent</span></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:33 PM, David Gobbi [via VTK] <<a href="/user/SendEmail.jtp?type=node&node=5732000&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>> wrote:<br> </font> </div>  <br><br> <div class="y_msg_container"><div id="yiv4823313494"><div><div dir="ltr">Hi Kent,<div><br clear="none"></div><div>Yes, it displayed half a box (see attached screenshot).</div><div><br clear="none"></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 clear="none"></span></div><div><span style="color: rgb(0, 0, 0); white-space: pre-wrap;"> - David</span></div><div><br clear="none"><div class="yiv4823313494gmail_extra"><br clear="none"><div class="yiv4823313494gmail_quote">On Mon, May 25, 2015 at 6:23 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="yiv4823313494gmail_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;"><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 clear="none"></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 clear="none"></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 clear="none"></div><div dir="ltr"><span>Thanks for taking a look.</span></div><div dir="ltr"><span></span><br clear="none"></div><div dir="ltr"><span>Kent</span></div><div dir="ltr"><span></span><br clear="none"></div><div dir="ltr"><span></span><br clear="none"></div>  <br clear="none"><div><br clear="none"><br clear="none"></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="yiv4823313494h5"> <div dir="ltr"> <font face="Arial" size="2"> On Monday, May 25, 2015 5:09 PM, David Gobbi [via VTK] <<a href="" rel="nofollow" shape="rect" target="_top" link="external">[hidden email]</a>> wrote:<br clear="none"> </font> </div>  <br clear="none"><br clear="none"> </div></div><div><div><div><div dir="ltr"><div><div class="yiv4823313494h5"><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="yiv4823313494h5"><div><br clear="none"><div><div>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' style="padding: 0px 1em; border-left-color: rgb(204, 204, 204); border-left-width: 2px; 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></div><span class="yiv4823313494"></span><div>
<br clear="none">_______________________________________________
<br clear="none">Powered by <a href="http://www.kitware.com/" target="_blank" rel="nofollow" shape="rect" link="external">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" 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="" rel="nofollow" shape="rect" target="_top" 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>
        </div></div></div></div><br clear="none"><br clear="none"></div>  </div> </div>  </div></div><div><br clear="none"><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="_blank" rel="nofollow" shape="rect" link="external">Download Attachment</a></div>

        
        
        
<br clear="none"></blockquote></div><br clear="none"></div></div></div>
<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><br clear="none"><div class="yiv4823313494small"><br clear="none"><img src="http://vtk.1045678.n5.nabble.com/images/icon_attachment.gif"> <strong>ScreenShot.png</strong> (30K) <a href="http://vtk.1045678.n5.nabble.com/attachment/5731998/0/ScreenShot.png" target="_blank" rel="nofollow" shape="rect" link="external">Download Attachment</a></div>

        
        
        
        <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-tp5731995p5731998.html" target="_blank" rel="nofollow" shape="rect" link="external">http://vtk.1045678.n5.nabble.com/using-vtkClipClosedSurface-on-a-box-crashes-tp5731995p5731998.html</a>
        </div><div class="yiv4823313494yqt9807036020" id="yiv4823313494yqtfd63979">
        <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></div></div></div><br><br></div>  </div> </div>  </div></div>

        
        
        
<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-tp5731995p5732000.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/>