[vtkusers] Problem with vtkContourTriangulator and vtkPlaneCutter
Bill Lorensen
bill.lorensen at gmail.com
Thu Mar 8 14:18:06 EST 2018
Here is an example for ClipClosedSurface
https://lorensen.github.io/VTKExamples/site/Cxx/Meshes/ClipClosedSurface/
On Thu, Mar 8, 2018 at 9:59 AM, David Gobbi <david.gobbi at gmail.com> wrote:
> Hi Jeffery,
>
> Your replies include the digest of the whole day's vtk-users posts. Can you
> trim them from your messages?
>
> 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.
>
> 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.
>
> 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:
>
> // Set up the clipper which will produce the cut polygons (unfortunately,
> its output includes half the original surface)
> vtkSmartPointer<vtkPlaneCollection> planes =
> vtkSmartPointer<vtkPlaneCollection>::New();
> planes->AddItem(planeCut);
> vtkSmartPointer<vtkClipClosedSurface> polygonsClip =
> vtkSmartPointer<vtkClipClosedSurface>::New();
> polygonsClip->SetInputConnection(clean->GetOutputPort());
> polygonsClip->SetClippingPlanes(planes);
> polygonsClip->SetScalarModeToLabels();
>
> // extract just the cut-surface polygons (I wish this was simpler!)
> vtkSmartPointer<vtkIdTypeArray> labels =
> vtkSmartPointer<vtkIdTypeArray>::New();
> labels->SetName("Labels");
> labels->InsertNextValue(1); // extract cut faces, which are labeled
> with "1"
> vtkSmartPointer<vtkSelectionNode> node =
> vtkSmartPointer<vtkSelectionNode>::New();
> node->SetFieldType(vtkSelectionNode::CELL);
> node->SetContentType(vtkSelectionNode::VALUES);
> node->SetSelectionList(labels);
> vtkSmartPointer<vtkSelection> select = vtkSmartPointer<vtkSelection>::New();
> select->AddNode(node);
> vtkSmartPointer<vtkExtractSelection> extract =
> vtkSmartPointer<vtkExtractSelection>::New();
> extract->SetInputConnection(0, polygonsClip->GetOutputPort());
> extract->SetInputData(1, select);
> // the "extract' filter produces the cut-face polygons that we want
>
> This filter is described further here:
> https://www.vtk.org/Wiki/VTK/Closed_Surface_Clipping
>
> 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.
>
> - David
>
>
> On Thu, Mar 8, 2018 at 9:42 AM, Jeffery Lewis <jlewis at accuray.com> wrote:
>>
>> Thank you David for investigating this.
>>
>> 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).
>>
>> 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).
>>
>> Also, if I replace vtkCutter with vtkPlaneCutter, the program still
>> crashes at start up.
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers
>
--
Unpaid intern in BillsParadise at noware dot com
More information about the vtkusers
mailing list