Implement InsideOut For VtkCookieCutter
Tip: The various gitlab links in this post might show this message.
Click "Expand all files" under the message else you won't really be taken to the diff I linked..
Additions:
h,cxx]:
Common/DataModel/vtkCellClassification.[-
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.-
Initialize classification infrastructure with a
vtkCell
. - Time of initialization is recorded.
- Each
Insert()
invocation modifies the object. This is tracked by MTime (it derives fromvtkObject
) - Unnecessary initializations from the same cell are avoided if internal points have not been changed.
- To initialize from a different cell, first, make a call to
Clear()
. This resets the time of initialization.
-
Initialize classification infrastructure with a
4, 5, 6].py
Filters/Modeling/Testing/Python/TestCookieCutter[- 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
- Forward declare
vtkCellClassification
. - Declare pure virtual
vtkCell::CookieCut(vtkCell* clipPoly, vtkCellClassification* clipClassification, vtkCellClassification* subjectClassification, vtkIncrementalPointLocator* locator, vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd, vtkIdType inCellId, vtkCellData* outVertsCd, vtkCellData* outLinesCd, vtkCellData* outPolysCd, vtkCellArray* outVerts, vtkCellArray* outLines, vtkCellArray* outPolys, const bool& insideOut, const double& tolerance)
. It uses an externally providedvtkCellClassification
object to aid cookie-cutting.
Common/DataModel/vtkCell3D.h
- Declare
vtkCell3D::CookieCut(...)
.
Common/DataModel/vtkCell3D.cxx
- Define
vtkCell3D::CookieCut(...)
. It logs an error since cookie-cutting algorithm does not yet support 3D cells.
Common/DataModel/vtkEmptyCell.h
- Declare
vtkEmptyCell::CookieCut(...)
Common/DataModel/vtkEmptyCell.cxx
- Define
vtkEmptyCell::CookieCut(...)
to do absolutely nothing.
Common/DataModel/vtkGenericCell.h
- Declare
vtkGenericCell::CookieCut(...)
Common/DataModel/vtkGenericCell.cxx
Common/DataModel/vtkLine.h
- Declare
vtkLine::CookieCut(...)
Common/DataModel/vtkLine.cxx
- Define
vtkLine::CookieCut(...)
- Return early when either subject or clip cell cannot be classified
- Under special conditions, return early if there is no overlap.
- Line, polygon edge intersections
- Sort the points
- Clean and merge the sorted points
- Classify the unique sorted points.
- Loop over two kinds of strands, rejecting either of one depending upon a set of conditions.
- Interior strands are accumulated if necessary. Similarly,exterior strands.
- The strands 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/vtkNonLinearCell.h
- Declare
vtkNonLinearCell::CookieCut(...)
Common/DataModel/vtkNonLinearCell.cxx
- Define
vtkNonLinearCell::CookieCut(...)
.It logs an error since cookie-cutting algorithm does not yet support non-linear cells.
Common/DataModel/vtkPixel.h
- Define
vtkPixel::CookieCut(...)
Common/DataModel/vtkPixel.cxx
- Declare
vtkPixel::CookieCut(...)
to shallow copy itself into a quad, now cookie cut the quad withclipPoly
Common/DataModel/vtkPolyLine.h
- Declare
vtkPolyLine::CookieCut(...)
Common/DataModel/vtkPolyLine.cxx
- Define
vtkPolyLine::CookieCut(...)
. It processes each constituent line sequentially. Just likeContour
,Clip
Common/DataModel/vtkPolyVertex.h
- Declare
vtkPolyVertex::CookieCut(...)
Common/DataModel/vtkPolyVertex.cxx
- Define
vtkPolyVertex::CookieCut(...)
. It processes each constituent vertex sequentially. Just likeContour
,Clip
Common/DataModel/vtkPolygon.h
- Define
vtkPolygon::CookieCut(...)
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
- Declare
vtkQuad::CookieCut(...)
Common/DataModel/vtkQuad.cxx
- Define
vtkQuad::CookieCut(...)
to shallow copy itself into a polygon, now cookie cut the polygon withclipPoly
Common/DataModel/vtkTriangle.h
- Declare
vtkTriangle::CookieCut(...)
Common/DataModel/vtkTriangle.cxx
- Define
vtkTriangle::CookieCut(...)
to shallow copy itself into a polygon, now cookie cut the polygon withclipPoly
Common/DataModel/vtkTriangleStrip.h
- Declare
vtkTriangleStrip::CookieCut(...)
Common/DataModel/vtkTriangleStrip.cxx
- Define
vtkTriangleStrip::CookieCut(...)
. It processes each constituent triangle sequentially. Just likeContour
,Clip
Common/DataModel/vtkVertex.h
- Declare
vtkVertex::CookieCut(...)
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
h, cxx]
Filters/Modeling/vtkCookieCutter.[- 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