Skip to content

Implement InsideOut For VtkCookieCutter

Tip: The various gitlab links in this post might show this message.

image

Click "Expand all files" under the message else you won't really be taken to the diff I linked..

Additions:

Common/DataModel/vtkCellClassification.[h,cxx]:

  • Class: vtkCellClassification

  • Base: vtkObject

  • What: Provides methods to store and retrieve a point's classification¹ w.r.t another polygon.

  • Why: Keeps track of changes to a cell's classification and convenient access in vtkCookieCutter.

  • ToWrap?: Not really required. This is obviously a pure implementation construct.

  • Usage and how it works: It is provided externally to the vtkCell::CookieCut() methods.

    1. Initialize classification infrastructure with a vtkCell.
    2. Time of initialization is recorded.
    3. Each Insert() invocation modifies the object. This is tracked by MTime (it derives from vtkObject)
    4. Unnecessary initializations from the same cell are avoided if internal points have not been changed.
    5. To initialize from a different cell, first, make a call to Clear(). This resets the time of initialization.

Filters/Modeling/Testing/Python/TestCookieCutter[4, 5, 6].py

  • Same as the three previous tests but this time with cookie.InsideOutOff(). The default is InsideOut = On.

Modifications:

Common/DataModel/CMakeLists.txt

  • Require the new class described above to be built as part of VTK::CommonDataModel module

Common/DataModel/vtkCell.h

Common/DataModel/vtkCell3D.h

Common/DataModel/vtkCell3D.cxx

Common/DataModel/vtkEmptyCell.h

Common/DataModel/vtkEmptyCell.cxx

Common/DataModel/vtkGenericCell.h

Common/DataModel/vtkGenericCell.cxx

Common/DataModel/vtkLine.h

Common/DataModel/vtkLine.cxx

Common/DataModel/vtkNonLinearCell.h

Common/DataModel/vtkNonLinearCell.cxx

Common/DataModel/vtkPixel.h

Common/DataModel/vtkPixel.cxx

Common/DataModel/vtkPolyLine.h

Common/DataModel/vtkPolyLine.cxx

Common/DataModel/vtkPolyVertex.h

Common/DataModel/vtkPolyVertex.cxx

Common/DataModel/vtkPolygon.h

Common/DataModel/vtkPolygon.cxx

  • Declare vtkPolygon::CookieCut(...).
  • Return early when either the subject or clip cell cannot be classified
  • Under special conditions, return early if there is no overlap.
  • subject edge, clipper edge intersections.
  • Sort both subject, clipper points.
  • Clean and merge both subject, clipper's sorted points.
  • Classify both subject, clipper's unique sorted points.
  • An undirected graph is used to distinctly identify edges that make up interior, exterior polys.
  • Retrieval of indices into sorted classification is achieved with an idLookUp map. This facilitates fast retrieval of actual point coordinates when building the polygons. The previous implementation instead used a heavyweight vtkPoints instance to incrementally insert and store all points.
  • Add an interior edge only if certain conditions are met.
  • Now, the interesting part. Builds exterior edges.
  • The result loops are then output into a cellarray along with a copy of input cell data through to output cell data.
  • Compute weights and interpolate point data.

Common/DataModel/vtkQuad.h

Common/DataModel/vtkQuad.cxx

Common/DataModel/vtkTriangle.h

Common/DataModel/vtkTriangle.cxx

Common/DataModel/vtkTriangleStrip.h

Common/DataModel/vtkTriangleStrip.cxx

Common/DataModel/vtkVertex.h

Common/DataModel/vtkVertex.cxx

  • Define vtkVertex::CookieCut(...)
  • Return early when either subject or clip cell cannot be classified
  • Return early if under special conditions, there is no overlap.
  • Attempt to find a similar point coincident with this vertex.
  • Classify
  • The vertex is then output into a cellarray along with a copy of input cell data through to output cell data.
  • Compute weights and interpolate point data.

=============================================================================================================

Filters/Modeling/Testing/Python/TestCookieCutter3.py

  • This test used to fail because the loop was not being displayed. It required setting specular to 1. This shows the wireframe poly and fixes the test. It should pass in the dashboard and anywhere else (hopefully)

Filters/Modeling/Testing/Python/CMakeLists.txt

  • Add cookie cutter tests for InsideOut = Off

Filters/Modeling/vtkCookieCutter.[h, cxx]

  • InsideOut option to invert cookie-cut output w.r.t loop polygons in second input.
  • Tolerance parameter for point locator, clean and merge procedures in vtkCell::CookieCut(...)
  • Iterate over input polygons on second input and invoke CookieCut on cells of the mesh on first input.
  • If InsideOut = off, re-use the output for the next iteration.

¹ refers to the ClassType of a cell's point w.r.t another polygon. Upon initialization, ClassType is Indeterminate. It's position w.r.t a polygon's interior area is described by ClassType::Inside, ClassType::Outside, ClassType::On. If a point is an intersection of the two distinct polygon's edges, it is one of ClassType::Intersection, ClassType::MultIntrscts, ClassType::On

Edited by Jaswant Panchumarti

Merge request reports