<div dir="ltr">Hi Jeffery,<div><br></div><div>Your replies include the digest of the whole day's vtk-users posts.  Can you trim them from your messages?</div><div><br></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">To be fair, when you move the slider to the left, triangles in the toroid become degenerate.  This can be seen by viewing the toroid as a wireframe. I'm guessing that you don't actually need a square toroid for your application.</span><br></div><div><br></div><div>The vtkContourTriangulator doesn't care if the points have different z, as long as the points all lie in a plane, and as long as all the line segments form a closed curve (or multiple closed curves) that do not self-intersect when viewed along the plane normal.  Of course there are tolerance issues since the "plane normal" is computed within the limits of double-precision.</div><div><br></div><div>One thing that might help is a filter that I wrote a few years ago for clipping surfaces generated from vtkMarchingCubes.  This class does both the clipping and the triangulation and is more robust than vtkCutter because it never accidentally merges points in ways that change the topology.  Unfortunately it is a "clipping" filter rather than a "cutting" filter, so it's output has to be filtered in order for it to do what you need:</div><div><br></div><div><div><span style="white-space:pre">     </span>// Set up the clipper which will produce the cut polygons (unfortunately, its output includes half the original surface)</div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="white-space:pre">  </span>vtkSmartPointer<vtkPlaneCollection> planes = vtkSmartPointer<vtkPlaneCollection>::New();</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">        planes->AddItem(planeCut);</div></div><div><span style="white-space:pre">     </span>vtkSmartPointer<vtkClipClosedSurface> polygonsClip = vtkSmartPointer<vtkClipClosedSurface>::New();</div><div><span style="white-space:pre">        </span>polygonsClip->SetInputConnection(clean->GetOutputPort());</div><div>        polygonsClip->SetClippingPlanes(planes);</div><div>        polygonsClip->SetScalarModeToLabels();</div><div><br></div><div>        // extract just the cut-surface polygons (I wish this was simpler!)</div><div>        vtkSmartPointer<vtkIdTypeArray> labels = vtkSmartPointer<vtkIdTypeArray>::New();</div><div>        labels->SetName("Labels");</div><div>        labels->InsertNextValue(1); // extract cut faces, which are labeled with "1"</div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="white-space:pre">     </span>vtkSmartPointer<vtkSelectionNode> node = vtkSmartPointer<vtkSelectionNode>::New();</div></div><div>        node->SetFieldType(vtkSelectionNode::CELL);</div><div>        node->SetContentType(vtkSelectionNode::VALUES);</div><div>        node->SetSelectionList(labels);</div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255)"><span style="white-space:pre">     </span>vtkSmartPointer<vtkSelection> select = vtkSmartPointer<vtkSelection>::New();</div></div><div>        select->AddNode(node);</div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;white-space:pre">    </span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">vtkSmartPointer<vtkExtractSelection> extract = vtkSmartPointer<vtkExtractSelection>::New();</span><br></div><div>        extract->SetInputConnection(0, polygonsClip->GetOutputPort());</div><div>        extract->SetInputData(1, select);</div></div><div>        // the "extract' filter produces the cut-face polygons that we want</div><div><br></div><div>This filter is described further here: <a href="https://www.vtk.org/Wiki/VTK/Closed_Surface_Clipping">https://www.vtk.org/Wiki/VTK/Closed_Surface_Clipping</a></div><div><br></div><div>Regarding the vtkPlaneCutter class, it doesn't work for me, either.  Hopefully somebody reading this message is familiar with this class and will chime it.  Perhaps it hasn't been fully tested with vtkPolyData as an input?  It looks like it was primarily designed for use on 3D mesh data.</div><div><br></div><div> - David</div><div><br></div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 8, 2018 at 9:42 AM, Jeffery Lewis <span dir="ltr"><<a href="mailto:jlewis@accuray.com" target="_blank">jlewis@accuray.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thank you David for investigating this.<br>
<br>
Adding the call to SetTolerance() on the vtkCleanPolyData does help. If you play around with the XY squareness slider (particularly to the left), you will still see the problem (even with tolerance set lower to 1e-4).<br>
<br>
Does vtkContourTriangulator require no z components in the polygons? I am cutting the surface model in 3D space. The contour generated by vtkCutter is essentially confined to a plane, but the contour polygons have z components in the coordinates (e.g. they are 3D points).<br>
<br>
Also, if I replace vtkCutter with vtkPlaneCutter, the program still crashes at start up.<br></blockquote></div></div></div></div>