Examples of PolyfaceClip
methods
Cut Fill
red and green meshes | |
Compute "over and under" mesh parts (red is meshA, green is meshB) |
const cutFill = PolyfaceClip.computeCutFill(meshA, meshB); |
cutFill.meshAOverB |
` |
cutFill.meshBOverA |
` |
Unit Test
- source: core\geometry\src\test\clipping\PolyfaceClip.test.ts
- test name: "CutFill"
- output: core\geometry\src\test\output\PolyfaceClip\CutFill.imjs
Section Cut
grey: closed volume mesh green: section plane |
|
extract linework of section cut | const section = PolyfaceClip.sectionPolyfaceClipPlane(facets, clipPlane); |
This produces an array of LineString3d |
|
Clip the facet set and produce facets on the cut plane |
|
insideClip is a boolean controlling which side of the cut is kept. |
` const clippedPolyface = PolyfaceClip.clipPolyfaceClipPlaneWithClosureFace(facets, clipPlane, insideClip, true);' |
Lower and upper parts |
Unit Test:
- source: core\geometry\src\test\clipping\PolyfaceClip.test.ts
- test name: "ClosedSection"
- output: core\geometry\src\test\output\PolyfaceClip\ClosedSection.imjs
Clipping with ConvexClipPlaneSet or UnionOfConvexClipPlaneSet
gray box is a closed volume mesh Red shape is to be swept vertically |
|
Create SweepContour as intermediate step to UnionOfConvexClipPlaneSets for the clipping. |
const contour = SweepContour.createForPolygon([Point3d.create(xA, yA), Point3d.create(xB, yA), Point3d.create(xA, yB), Point3d.create(xA, yA)])!; |
Get the clipper out of the SweepContour |
const clipper = contourP0.sweepToUnionOfConvexClipPlaneSets()!; |
Create a ClipBuilders object for use in the clip |
const clipBuilders = ClippedPolyfaceBuilders.create(true, true, true); |
Do the clip | PolyfaceClip.clipPolyfaceInsideOutside(facets, clipper, clipBuilders); |
Extract the inside part | insidePart = clipBuilders.claimPolyface(0, true); |
Extract the outside part | insidePart = clipBuilders.claimPolyface(1, true); |
Unit Test:
- source: core\geometry\src\test\clipping\PolyfaceClip.test.ts
- test name: "BoxClosureNonConvex"
- output: core\geometry\src\test\output\PolyfaceClip\BoxClosureNonConvex.imjs
Last Updated: 02 December, 2021