editor › Globals › ConvertTouchingHolesToOutlines
Class: ConvertTouchingHolesToOutlines
Convert the polygon iff it contains a hole which has at least one shared point with the outline. Returns multiple Polygons where we removed all holes which touch the outline at one or more points. CGAL outputs these polygons with such holes. The DelaunayPolygonTriangulator doesn't like such polygons and fails, hence we convert them. See _findPolygons todo: possibly add collinear points? todo: inflate polygons so we don't have flaky point in polygon/cycle inside cycle false positives?
Hierarchy
- ConvertTouchingHolesToOutlines
Index
Methods
- _constructSelfTouchingOutlineFromOutlineAndHoles
- _findPolygons
- _splitUpNonOverlappingOutlineCycles
- _splitUpOutlineWithoutHoles
- execute
Methods
Static Private _constructSelfTouchingOutlineFromOutlineAndHoles
▸ _constructSelfTouchingOutlineFromOutlineAndHoles(outlineOfNumbers: ArrayPoint2[], holesOfNumbers: ArrayPoint2[][]): ArrayPoint2[]
Defined in src/util/polygon/ConvertTouchingHolesToOutlines.ts:176
Given cycles of outline and holes, construct a single outline (touching itself). We know that the holes are contained inside the outline polygon and that they touch the outline at some point. We assume that at one point, only one hole can touch (for now, if multiple holes touch at the same point, we would need to avoid creating self-intersecting outline instead of just a self-touching one). It works for holes which are contained recursively (so a hole touching another hole which touches the outline at some point).
Parameters:
| Name | Type |
|---|---|
outlineOfNumbers |
ArrayPoint2[] |
holesOfNumbers |
ArrayPoint2[][] |
Returns: ArrayPoint2[]
Static Private _findPolygons
▸ _findPolygons(outline: MeshHalfEdge[], holes: MeshHalfEdge[][]): ArrayPoint2[][][]
Defined in src/util/polygon/ConvertTouchingHolesToOutlines.ts:39
Take a polygon and remove all holes which share points with the outline. We define a polygon with an outline touching itself where both disjoint cycles are not contained in one another as two polygons so we take care of that when removing holes. assumes that holes have at least one point which is really inside the polygon and not on the edge
Parameters:
| Name | Type |
|---|---|
outline |
MeshHalfEdge[] |
holes |
MeshHalfEdge[][] |
Returns: ArrayPoint2[][][]
Static Private _splitUpNonOverlappingOutlineCycles
▸ _splitUpNonOverlappingOutlineCycles(cyclesOfNumbers: ArrayPoint2[][]): ArrayPoint2[][]
Defined in src/util/polygon/ConvertTouchingHolesToOutlines.ts:138
Recursively find outlines and holes they contain.
Parameters:
| Name | Type | Description |
|---|---|---|
cyclesOfNumbers |
ArrayPoint2[][] | disjoint cycles which consist of cycles which are actually outlines and others which are holes |
Returns: ArrayPoint2[][]
Static Private _splitUpOutlineWithoutHoles
▸ _splitUpOutlineWithoutHoles(outline: MeshHalfEdge[]): ArrayPoint2[][][]
Defined in src/util/polygon/ConvertTouchingHolesToOutlines.ts:124
Split up the outline which may touch itself (which creates either implicit holes or implicit other outlines) into possibly multiple outlines, each with their respective holes implicitly included in the outline (so again the outline must touch itself if there is such hole). If these outlines have holes, these holes must be touching the outline at exactly one point.
Parameters:
| Name | Type |
|---|---|
outline |
MeshHalfEdge[] |
Returns: ArrayPoint2[][][]
a collection of polygons, each with no explicit holes (explicit = another array for the hole, implicit = by the outline touching itself)
Static execute
▸ execute(polygon: Polygon): Polygon[]
Defined in src/util/polygon/ConvertTouchingHolesToOutlines.ts:20
Parameters:
| Name | Type |
|---|---|
polygon |
Polygon |
Returns: Polygon[]