Skip to content

editorGlobalsConvertTouchingOutlineToHoles

Class: ConvertTouchingOutlineToHoles

CGAL doesn't work well with polygon which touch themselves. Hence, we convert the polygon first to a polygon with holes. Basically the opposite of what ConvertTouchingHolesToOutlines does. Also do this for holes (so if you have a self-touching hole, convert it to two holes). For what's valid, see https://doc.cgal.org/latest/Boolean_set_operations_2/index.html.

Hierarchy

  • ConvertTouchingOutlineToHoles

Index

Methods

Methods

Static Private _cycleHasCrossover

_cycleHasCrossover(cycle: ArrayPoint2[]): boolean

Defined in src/util/polygon/ConvertTouchingOutlineToHoles.ts:148

One point appears multiple times in the same cycle. If it has epsilon distance, everything is fine (CGAL doesnt care).

Parameters:

Name Type
cycle ArrayPoint2[]

Returns: boolean


Static Private _findDisjointPolygonNumberCycles

_findDisjointPolygonNumberCycles(polygon: Polygon): ArrayPoint2[][]

Defined in src/util/polygon/ConvertTouchingOutlineToHoles.ts:124

Parameters:

Name Type
polygon Polygon

Returns: ArrayPoint2[][]


Static Private _findPolygonInCycles

_findPolygonInCycles(cycles: ArrayPoint2[][]): Polygon[]

Defined in src/util/polygon/ConvertTouchingOutlineToHoles.ts:104

Parameters:

Name Type
cycles ArrayPoint2[][]

Returns: Polygon[]


Static execute

execute(polygon: Polygon): Polygon[]

Defined in src/util/polygon/ConvertTouchingOutlineToHoles.ts:34

Convert a polygon so that we have holes instead of the outline touching itself and forming "holes". If a cycle contains another cycle, it must be a part of the outline. If a polygon has a self-touching outline that doesn't go inside (so no hole to create but two or more polygons that touch themselves in on or more points), split the polygon up.

Parameters:

Name Type Description
polygon Polygon changes them in-place

Returns: Polygon[]


Static findDisjointOutlineCycles

findDisjointOutlineCycles(outlineEdges: MeshHalfEdge[]): MeshHalfEdge[][]

Defined in src/util/polygon/ConvertTouchingOutlineToHoles.ts:49

Separate the outline (possibly touching itself) into multiple cycles which are all smallest cycles which don't touch themselves, so the "inclusion-minimal" cycles.

Parameters:

Name Type
outlineEdges MeshHalfEdge[]

Returns: MeshHalfEdge[][]

disjoint cycles of halfedges. all in CCW (also holes)


Static polygonHasCrossover

polygonHasCrossover(polygon: Polygon): boolean

Defined in src/util/polygon/ConvertTouchingOutlineToHoles.ts:23

Return true if using this polygon results in CGAL error. Possible errors we handle here: - polygon has no holes and its outline has a crossover - polygon has holes but holes have a crossover - apparently the documentation is wrong on https://doc.cgal.org/latest/Boolean_set_operations_2/index.html and it also fails when there are holes and just the outline is touching itself. Hence, return true if any cycle is a crossover.

Parameters:

Name Type
polygon Polygon

Returns: boolean