Examples of RegionOps


This splits any curve into parts in, on, and outside an xy region.

25 points >
split the black path into parts inside and outside the grey area const splitParts = RegionOps.splitPathsByRegionInOnOutXY(path, loop);
(red) Path parts "inside" the region
(green) Path parts "outside" the region


Using a closed region as the cutter is a specialized high level operation, just one of the many ways that splitting may be needed. It is a combination of

a split step uses the region boundary curves but not the interior/exterior properties. const splitPaths = RegionOps.splitToPathsBetweenFlagBreaks ((pathWithIntersectionMarkup, true);
a classification step tests one point from each fragment of the splitPaths:
(a) obtain one point on a fragment being tested const pointOnChild = CurveCollection.createCurveLocationDetailOnAnyCurvePrimitive(splitPaths);
(b) determine if that single point is inside or outside.
since the fragments have no interior crossings, that point classifies the whole fragment
const inOnOut = RegionOps.testPointInOnOutRegionXY(region, pointOnChild.point.x, pointOnChild.point.y);

Unit Test

  • source: imodeljs\core\geometry\src\test\topology\RegionOps.test.ts
  • test name: "InOutSplits"
  • output: imodeljs\core\geometry\src\test\output\RegionOps\InOutSplits.imjs


This tests whether single points are in, out, or on an xy region.

Parity region with various test points
circle is "on"
diamond is "in"
plus is "out"

Unit Test

  • source: imodeljs\core\geometry\src\test\topology\RegionOps.test.ts
  • test name: "MixedInOut"
  • output: imodeljs\core\geometry\src\test\output\RegionOps\MixedInOut.imjs

Last Updated: 08 January, 2020