flo-mat 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/index.js +8230 -8229
- package/browser/index.min.js +1 -1
- package/node/circle.d.ts +20 -20
- package/node/circle.js +31 -31
- package/node/compare-curvatures-at-interface.d.ts +19 -19
- package/node/compare-curvatures-at-interface.js +124 -124
- package/node/contact-point.d.ts +26 -26
- package/node/contact-point.js +25 -25
- package/node/cp-node/clone.d.ts +8 -8
- package/node/cp-node/clone.js +31 -31
- package/node/cp-node/remove.d.ts +9 -9
- package/node/cp-node/remove.js +19 -19
- package/node/cp-node.d.ts +202 -202
- package/node/cp-node.js +320 -320
- package/node/curve.d.ts +46 -46
- package/node/curve.js +88 -88
- package/node/debug/cp-node-for-debugging.d.ts +11 -11
- package/node/debug/cp-node-for-debugging.js +1 -1
- package/node/debug/debug-elem-types.d.ts +32 -32
- package/node/debug/debug-elem-types.js +1 -1
- package/node/debug/debug.d.ts +50 -50
- package/node/debug/debug.js +75 -75
- package/node/debug/functions/draw-elem/bounding-hull.d.ts +3 -3
- package/node/debug/functions/draw-elem/bounding-hull.js +7 -7
- package/node/debug/functions/draw-elem/branch.d.ts +4 -4
- package/node/debug/functions/draw-elem/branch.js +22 -22
- package/node/debug/functions/draw-elem/culls.d.ts +4 -4
- package/node/debug/functions/draw-elem/culls.js +21 -21
- package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +3 -3
- package/node/debug/functions/draw-elem/draw-circle-percent.js +12 -12
- package/node/debug/functions/draw-elem/draw-elem.d.ts +8 -8
- package/node/debug/functions/draw-elem/draw-elem.js +45 -45
- package/node/debug/functions/draw-elem/dull-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/dull-corner.js +10 -10
- package/node/debug/functions/draw-elem/leaves.d.ts +4 -4
- package/node/debug/functions/draw-elem/leaves.js +12 -12
- package/node/debug/functions/draw-elem/loop.d.ts +4 -4
- package/node/debug/functions/draw-elem/loop.js +11 -11
- package/node/debug/functions/draw-elem/loops.d.ts +4 -4
- package/node/debug/functions/draw-elem/loops.js +6 -6
- package/node/debug/functions/draw-elem/loose-bounding-box.d.ts +3 -3
- package/node/debug/functions/draw-elem/loose-bounding-box.js +9 -9
- package/node/debug/functions/draw-elem/mat.d.ts +4 -4
- package/node/debug/functions/draw-elem/mat.js +30 -30
- package/node/debug/functions/draw-elem/max-vertex.d.ts +4 -4
- package/node/debug/functions/draw-elem/max-vertex.js +8 -8
- package/node/debug/functions/draw-elem/min-y.d.ts +4 -4
- package/node/debug/functions/draw-elem/min-y.js +13 -13
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js +12 -12
- package/node/debug/functions/draw-elem/one-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/one-prong.js +16 -16
- package/node/debug/functions/draw-elem/sharp-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/sharp-corner.js +9 -9
- package/node/debug/functions/draw-elem/three-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/three-prong.js +16 -16
- package/node/debug/functions/draw-elem/tight-bounding-box.d.ts +3 -3
- package/node/debug/functions/draw-elem/tight-bounding-box.js +7 -7
- package/node/debug/functions/draw-elem/two-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/two-prong.js +36 -36
- package/node/debug/functions/draw-elem/vertex.d.ts +4 -4
- package/node/debug/functions/draw-elem/vertex.js +27 -27
- package/node/debug/functions/general.d.ts +48 -48
- package/node/debug/functions/general.js +52 -52
- package/node/debug/functions/three-prong.d.ts +11 -11
- package/node/debug/functions/three-prong.js +184 -184
- package/node/debug/functions/two-prong.d.ts +13 -13
- package/node/debug/functions/two-prong.js +117 -117
- package/node/debug/three-prong-for-debugging.d.ts +31 -31
- package/node/debug/three-prong-for-debugging.js +20 -20
- package/node/debug/two-prong-for-debugging.d.ts +26 -26
- package/node/debug/two-prong-for-debugging.js +1 -1
- package/node/find-mats.d.ts +26 -26
- package/node/find-mats.js +122 -122
- package/node/get-boundary-bezier-parts-to-next.d.ts +9 -9
- package/node/get-boundary-bezier-parts-to-next.js +42 -42
- package/node/get-boundary-beziers-to-next.d.ts +8 -8
- package/node/get-boundary-beziers-to-next.js +44 -44
- package/node/get-bounding-box-.d.ts +2 -2
- package/node/get-bounding-box-.js +4 -4
- package/node/get-branches.d.ts +12 -12
- package/node/get-branches.js +68 -68
- package/node/get-curve/get-curve-between.d.ts +9 -9
- package/node/get-curve/get-curve-between.js +56 -56
- package/node/get-curve/get-edge-direction.d.ts +9 -9
- package/node/get-curve/get-edge-direction.js +53 -53
- package/node/get-curve-to-next.d.ts +9 -9
- package/node/get-curve-to-next.js +11 -11
- package/node/get-interface-ccw.d.ts +24 -24
- package/node/get-interface-ccw.js +97 -97
- package/node/index.d.ts +36 -36
- package/node/index.js +32 -32
- package/node/loop/get-max-coordinate.d.ts +10 -10
- package/node/loop/get-max-coordinate.js +43 -43
- package/node/loop.d.ts +16 -16
- package/node/loop.js +34 -34
- package/node/mat/add-to-cp-graph.d.ts +16 -16
- package/node/mat/add-to-cp-graph.js +30 -30
- package/node/mat/bezier-piece.d.ts +12 -12
- package/node/mat/bezier-piece.js +1 -1
- package/node/mat/closest-boundary-point/closest-points-on-curve.d.ts +14 -14
- package/node/mat/closest-boundary-point/closest-points-on-curve.js +72 -72
- package/node/mat/closest-boundary-point/cull-bezier-pieces.d.ts +9 -9
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js +19 -19
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.d.ts +11 -11
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js +24 -24
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.d.ts +11 -11
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js +26 -26
- package/node/mat/closest-boundary-point/get-best-distance-squared.d.ts +8 -8
- package/node/mat/closest-boundary-point/get-best-distance-squared.js +24 -24
- package/node/mat/closest-boundary-point/get-close-boundary-points.d.ts +17 -17
- package/node/mat/closest-boundary-point/get-close-boundary-points.js +80 -80
- package/node/mat/closest-boundary-point/get-closest-boundary-point.d.ts +18 -18
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js +40 -40
- package/node/mat/corner.d.ts +37 -37
- package/node/mat/corner.js +1 -1
- package/node/mat/create-new-cp-tree.d.ts +9 -9
- package/node/mat/create-new-cp-tree.js +23 -23
- package/node/mat/elem-type-two-prong.d.ts +3 -3
- package/node/mat/elem-type-two-prong.js +1 -1
- package/node/mat/find-mat/add-1-prong.d.ts +12 -12
- package/node/mat/find-mat/add-1-prong.js +42 -42
- package/node/mat/find-mat/add-2-prong.d.ts +21 -21
- package/node/mat/find-mat/add-2-prong.js +192 -192
- package/node/mat/find-mat/add-3-prong.d.ts +19 -19
- package/node/mat/find-mat/add-3-prong.js +54 -54
- package/node/mat/find-mat/add-debug-info.d.ts +9 -9
- package/node/mat/find-mat/add-debug-info.js +67 -67
- package/node/mat/find-mat/create-get-interesting-points-on-loop.d.ts +11 -11
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js +51 -51
- package/node/mat/find-mat/create-initial-cp-graph.d.ts +12 -12
- package/node/mat/find-mat/create-initial-cp-graph.js +40 -40
- package/node/mat/find-mat/find-2-prong/add-debug-info.d.ts +8 -8
- package/node/mat/find-mat/find-2-prong/add-debug-info.js +21 -21
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.d.ts +11 -11
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js +29 -29
- package/node/mat/find-mat/find-2-prong/find-2-prong.d.ts +37 -37
- package/node/mat/find-mat/find-2-prong/find-2-prong.js +232 -232
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.d.ts +9 -9
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js +39 -39
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.d.ts +11 -11
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js +37 -37
- package/node/mat/find-mat/find-2-prong/x-for-debugging.d.ts +9 -9
- package/node/mat/find-mat/find-2-prong/x-for-debugging.js +1 -1
- package/node/mat/find-mat/find-3-prong/calc-better-x.d.ts +19 -19
- package/node/mat/find-mat/find-3-prong/calc-better-x.js +36 -36
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.d.ts +13 -13
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js +25 -25
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.d.ts +22 -22
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js +159 -159
- package/node/mat/find-mat/find-3-prong/find-3-prong.d.ts +16 -16
- package/node/mat/find-mat/find-3-prong/find-3-prong.js +76 -76
- package/node/mat/find-mat/find-3-prong/get-closest-points.d.ts +9 -9
- package/node/mat/find-mat/find-3-prong/get-closest-points.js +16 -16
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.d.ts +15 -15
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js +20 -20
- package/node/mat/find-mat/find-and-add-2-prongs.d.ts +16 -16
- package/node/mat/find-mat/find-and-add-2-prongs.js +73 -73
- package/node/mat/find-mat/find-and-add-3-prongs.d.ts +13 -13
- package/node/mat/find-mat/find-and-add-3-prongs.js +146 -146
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.d.ts +14 -14
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js +33 -33
- package/node/mat/find-mat/get-potential-2-prongs.d.ts +4 -4
- package/node/mat/find-mat/get-potential-2-prongs.js +16 -16
- package/node/mat/find-mat/get-sharp-corners.d.ts +4 -4
- package/node/mat/find-mat/get-sharp-corners.js +17 -17
- package/node/mat/geometry/get-closest-square-distance-to-rect.d.ts +5 -5
- package/node/mat/geometry/get-closest-square-distance-to-rect.js +49 -49
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +5 -5
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js +15 -15
- package/node/mat/get-boundary-piece-beziers.d.ts +11 -11
- package/node/mat/get-boundary-piece-beziers.js +58 -58
- package/node/mat/get-contact-circles-at-interface.d.ts +8 -8
- package/node/mat/get-contact-circles-at-interface.js +20 -20
- package/node/mat/get-largest-vertex.d.ts +4 -4
- package/node/mat/get-largest-vertex.js +9 -9
- package/node/mat/get-leaves.d.ts +4 -4
- package/node/mat/get-leaves.js +12 -12
- package/node/mat/get-neighboring-cps.d.ts +14 -14
- package/node/mat/get-neighboring-cps.js +30 -30
- package/node/mat/get-two-prong-type.d.ts +5 -5
- package/node/mat/get-two-prong-type.js +8 -8
- package/node/mat/is-another-cp-closeby.d.ts +20 -20
- package/node/mat/is-another-cp-closeby.js +55 -55
- package/node/mat/simplify-mat-map-only.d.ts +23 -23
- package/node/mat/simplify-mat-map-only.js +80 -80
- package/node/mat/to-scale-axis/add-debug-info.d.ts +7 -7
- package/node/mat/to-scale-axis/add-debug-info.js +13 -13
- package/node/mat/to-scale-axis/cull-non-cycles.d.ts +9 -9
- package/node/mat/to-scale-axis/cull-non-cycles.js +51 -51
- package/node/mat/to-scale-axis/cull.d.ts +12 -12
- package/node/mat/to-scale-axis/cull.js +132 -132
- package/node/mat/trim-mat.d.ts +8 -8
- package/node/mat/trim-mat.js +16 -16
- package/node/mat.d.ts +22 -22
- package/node/mat.js +1 -1
- package/node/point-on-shape.d.ts +73 -73
- package/node/point-on-shape.js +167 -167
- package/node/simplify-mat.d.ts +16 -16
- package/node/simplify-mat.js +71 -71
- package/node/svg/get-loop-bounds.d.ts +12 -12
- package/node/svg/get-loop-bounds.js +80 -80
- package/node/svg/get-min-y-pos.d.ts +8 -8
- package/node/svg/get-min-y-pos.js +9 -9
- package/node/svg/get-shape-bounds.d.ts +9 -9
- package/node/svg/get-shape-bounds.js +35 -35
- package/node/sweep-line/sweep-line.d.ts +18 -18
- package/node/sweep-line/sweep-line.js +72 -72
- package/node/to-scale-axis.d.ts +16 -16
- package/node/to-scale-axis.js +74 -74
- package/node/traverse-edges.d.ts +10 -10
- package/node/traverse-edges.js +21 -21
- package/node/traverse-vertices.d.ts +12 -12
- package/node/traverse-vertices.js +27 -27
- package/package.json +11 -11
- package/tsconfig.json +0 -1
package/node/cp-node.d.ts
CHANGED
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
-
import { ContactPoint } from './contact-point.js';
|
|
3
|
-
import { removeCpNode } from './cp-node/remove.js';
|
|
4
|
-
/**
|
|
5
|
-
* The primary class of the library.
|
|
6
|
-
*
|
|
7
|
-
* Since the MAT is a full representation of the shape boundary an instance of
|
|
8
|
-
* this class contains both the information of a boundary point and a medial
|
|
9
|
-
* axis point (and edge to the next point(s)). It also contains edges to other
|
|
10
|
-
* [[CpNode]]s which allows for traversal of the MAT and thus implictly
|
|
11
|
-
* represents the entire MAT.
|
|
12
|
-
*
|
|
13
|
-
* To get the maximal disk circle (of which the center is on the medial axis)
|
|
14
|
-
* use [[cp]].circle.
|
|
15
|
-
*
|
|
16
|
-
* To get the boundary point, use [[cp]].pointOnShape.
|
|
17
|
-
*
|
|
18
|
-
* The edge [[next]] (resp. [[prev]]) allows one to move anti-clockwise (resp.
|
|
19
|
-
* clockwise) on the shape boundary to the next [[CpNode]]. This also imposes a
|
|
20
|
-
* direction of traversal of the MAT edges and vertices.
|
|
21
|
-
*
|
|
22
|
-
* The edge [[nextOnCircle]] (resp. [[prevOnCircle]]) allows one to go
|
|
23
|
-
* anti-clockwise (resp. clockwise) around the maximal disks implied by
|
|
24
|
-
* the CpNode to the next maximal disk contact point. This is equivalent to
|
|
25
|
-
* following other branches on the MAT.
|
|
26
|
-
*
|
|
27
|
-
* Call [[getCurveBetween]](cpNodeFrom, cpNodeTo) or getCurveToNext(cpNode)
|
|
28
|
-
* (replacing the older CpNode.[[matCurveToNextVertex]]) to get a bezier curve
|
|
29
|
-
* from the maximal disk of this [[CpNode]] to the next [[CpNode]]'s
|
|
30
|
-
* maximal disk and thus directly representing a piece of the medial axis.
|
|
31
|
-
*
|
|
32
|
-
* The function, [[getChildren]], returns the children of this [[CpNode]] when
|
|
33
|
-
* seen as a MAT edge. Only children in a 'forward' direction are returned. These
|
|
34
|
-
* include all edges except the 'backward' edge given by [[prevOnCircle]]. For
|
|
35
|
-
* [[CpNode]]s having a maximal disk with 2 contact points (a 2-prong, the usual
|
|
36
|
-
* case) the children will be the single edge [[next]]. For a 3-prong this will
|
|
37
|
-
* be the edges [[next]] and [[nextOnCircle]], etc. [[getChildren]] allows one to
|
|
38
|
-
* easily traverse the MAT tree - see e.g. the implementation of [[traverseEdges]].
|
|
39
|
-
*
|
|
40
|
-
* The getter, [[vertexChildren]], is similar to [[getChildren]] but returns the
|
|
41
|
-
* child nodes of the tree when [[CpNode]] is seen as a MAT vertex point (as
|
|
42
|
-
* opposed to edge). In this way the dual graph of the tree can easily be
|
|
43
|
-
* traversed - see e.g. [[traverseVertices]]. Generally, however, traversing the
|
|
44
|
-
* edges is preferred as it returns the entire Medial Axis (by utilizing
|
|
45
|
-
* [[getCurveToNext]] on each returned edge).
|
|
46
|
-
*
|
|
47
|
-
* It may be worth mentioning that by traversing from the CpNode by following
|
|
48
|
-
* [[next]] repeatedly until one is back at the same CpNode allows one
|
|
49
|
-
* to 'go around' the shape boundary and at the same time traverse the MAT twice
|
|
50
|
-
* in opposite directions.
|
|
51
|
-
*/
|
|
52
|
-
declare class CpNode {
|
|
53
|
-
readonly cp: ContactPoint;
|
|
54
|
-
isHoleClosing: boolean;
|
|
55
|
-
isIntersection: boolean;
|
|
56
|
-
prev: CpNode;
|
|
57
|
-
next: CpNode;
|
|
58
|
-
prevOnCircle: CpNode;
|
|
59
|
-
nextOnCircle: CpNode;
|
|
60
|
-
/**
|
|
61
|
-
* Primarily for internal use.
|
|
62
|
-
* @param cp The shape boundary contact point, i.e. a [[CpNode]] without its
|
|
63
|
-
* edges.
|
|
64
|
-
* @param isHoleClosing If true, this [[CpNode]] belongs to a hole-closing
|
|
65
|
-
* maximal disk.
|
|
66
|
-
* @param isIntersection true if this cpNode is at a shape boundary
|
|
67
|
-
* intersection point, false otherwise
|
|
68
|
-
* @param prev The previous (going clockwise around the boundary) contact
|
|
69
|
-
* point ([[CpNode]]).
|
|
70
|
-
* @param next The next (going anti-clockwise around the boundary) contact
|
|
71
|
-
* point ([[CpNode]]).
|
|
72
|
-
* @param prevOnCircle The previous [[CpNode]] (going clockwise around
|
|
73
|
-
* the inscribed circle defined by the maximal disk).
|
|
74
|
-
* @param nextOnCircle The next [[CpNode]] (going anti-clockwise around
|
|
75
|
-
* the inscribed circle defined by the maximal disk).
|
|
76
|
-
*/
|
|
77
|
-
constructor(cp: ContactPoint, isHoleClosing: boolean, isIntersection: boolean, prev?: CpNode, next?: CpNode, prevOnCircle?: CpNode, nextOnCircle?: CpNode);
|
|
78
|
-
/**
|
|
79
|
-
* Returns the bezier curve from the maximal disk of this [[CpNode]] to the
|
|
80
|
-
* next [[CpNode]]'s maximal disk and thus directly represents a piece of the
|
|
81
|
-
* medial axis.
|
|
82
|
-
* @deprecated Use [[getCurveToNext]] instead
|
|
83
|
-
* @param cpNode
|
|
84
|
-
*/
|
|
85
|
-
get matCurveToNextVertex(): number[][];
|
|
86
|
-
/**
|
|
87
|
-
* Primarily for internal use.
|
|
88
|
-
*
|
|
89
|
-
* Compares the order of two [[CpNode]]s. The order is cyclic and depends
|
|
90
|
-
* on a [[CpNode]]'s relative position along the shape boundary.
|
|
91
|
-
*/
|
|
92
|
-
static comparator: (a: CpNode, b: CpNode) => number;
|
|
93
|
-
/**
|
|
94
|
-
* Returns the children of this [[CpNode]] when seen as a MAT edge. Only
|
|
95
|
-
* children in a 'forward' direction are returned. These include all edges
|
|
96
|
-
* except the 'backward' edge given by [[prevOnCircle]], even terminating
|
|
97
|
-
* edges.
|
|
98
|
-
*/
|
|
99
|
-
getChildren(): CpNode[];
|
|
100
|
-
static remove: typeof removeCpNode;
|
|
101
|
-
/**
|
|
102
|
-
* Similar to [[getChildren]] but returns the child nodes of the tree when
|
|
103
|
-
* [[CpNode]] is seen as a MAT vertex point (as opposed to edge). In this
|
|
104
|
-
* way the dual graph of the tree can easily be traversed - see e.g.
|
|
105
|
-
* [[traverseVertices]]. Generally, however, traversing the edges is
|
|
106
|
-
* preferred as it returns the entire Medial Axis (by utilizing
|
|
107
|
-
* [[getCurveToNext]] on each returned edge).
|
|
108
|
-
*/
|
|
109
|
-
get vertexChildren(): CpNode[];
|
|
110
|
-
/**
|
|
111
|
-
* Returns all [[CpNode]]s on the MAT that this [[CpNode]] is part of
|
|
112
|
-
* starting from the current one and going anti-clockwise around the shape.
|
|
113
|
-
*/
|
|
114
|
-
getAllOnLoop(): CpNode[];
|
|
115
|
-
/**
|
|
116
|
-
* Primarily for internal use.
|
|
117
|
-
*
|
|
118
|
-
* Insert a [[CpNode]] into the MAT tree graph after the specified point
|
|
119
|
-
* and returns the freshly inserted [[CpNode]].
|
|
120
|
-
* @param isHoleClosing True if this is a hole closing contact point.
|
|
121
|
-
* @param isIntersection True if this is a contact point at a shape boundary
|
|
122
|
-
* intersection point.
|
|
123
|
-
* @param cpTree The tree graph holding the [[CpNodes]] of the MAT.
|
|
124
|
-
* @param cp [[ContactPoint]] defining the [[CpNode]].
|
|
125
|
-
* @param prev_ Inserts the new [[CpNode]] right after this item if the
|
|
126
|
-
* loop is not empty, else insert the new [[CpNode]] as the only item in the
|
|
127
|
-
* loop.
|
|
128
|
-
*/
|
|
129
|
-
static insert(isHoleClosing: boolean, isIntersection: boolean, cpTree: LlRbTree<CpNode>, cp: ContactPoint, prev_: CpNode): CpNode;
|
|
130
|
-
/**
|
|
131
|
-
* Return this (except if exclThis is truthy) and the the other CpNodes
|
|
132
|
-
* around the maximal disk vertex circle in an anti-clockwise order.
|
|
133
|
-
* @param exclThis If true the returned array does not include this
|
|
134
|
-
* [[CpNode]].
|
|
135
|
-
*/
|
|
136
|
-
getCpNodesOnCircle(exclThis?: boolean): CpNode[];
|
|
137
|
-
/**
|
|
138
|
-
* Returns true if the 2 given [[CpNode]]s are on the same maximal disk
|
|
139
|
-
* circle.
|
|
140
|
-
* @param cpNode1 A [[CpNode]].
|
|
141
|
-
* @param cpNode2 Another [[CpNode]]
|
|
142
|
-
*/
|
|
143
|
-
static isOnSameCircle(cpNode1: CpNode, cpNode2: CpNode): boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Returns true if this [[CpNode]] is terminating, i.e. implies a leaf MAT
|
|
146
|
-
* vertex.
|
|
147
|
-
*
|
|
148
|
-
* This is always the case for sharp corners and maximal disks with
|
|
149
|
-
* a single contact point. Note, however, that even in these cases there are
|
|
150
|
-
* two contact points stored (sitting 'on top' of each other) for the
|
|
151
|
-
* maximal disk. It can be seen as a limiting case of a two-prong where the
|
|
152
|
-
* distance between two of the contact points tend to zero. One point
|
|
153
|
-
* (represented by a [[CpNode]] of course) will be terminating with the
|
|
154
|
-
* other point being its [[next]], whereas the other point will *not* be
|
|
155
|
-
* terminating and 'points' back into the shape.
|
|
156
|
-
*/
|
|
157
|
-
isTerminating(): boolean;
|
|
158
|
-
/**
|
|
159
|
-
* Like isTerminating() but only returns true if all cpNodes on the circle
|
|
160
|
-
* (except this.prevOnCircle) is terminating.
|
|
161
|
-
*/
|
|
162
|
-
isFullyTerminating(): boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Returns the first [[CpNode]] (from this one by successively applying
|
|
165
|
-
* .nextOnCircle) that exits the circle.
|
|
166
|
-
*/
|
|
167
|
-
getFirstExit(): CpNode;
|
|
168
|
-
/**
|
|
169
|
-
* Returns true if this [[CpNode]] represents a sharp corner, i.e. the
|
|
170
|
-
* limiting case of a two-prong having zero radius.
|
|
171
|
-
*
|
|
172
|
-
* Note that two [[CpNode]]s are stored for each sharp corner, one being
|
|
173
|
-
* terminating and one not. See [[isTerminating]] for more details.
|
|
174
|
-
*/
|
|
175
|
-
isSharp(): boolean;
|
|
176
|
-
/**
|
|
177
|
-
* Returns true if this [[CpNode]]'s maximal disk has only one contact point
|
|
178
|
-
* on the shape boundary (up to planar coordinates). These includes sharp
|
|
179
|
-
* corners.
|
|
180
|
-
*
|
|
181
|
-
* Note, however, that two [[CpNode]]s are stored for each such point to
|
|
182
|
-
* preserve symmetry - see [[isTerminating]] for more details.
|
|
183
|
-
*/
|
|
184
|
-
isOneProng(): boolean;
|
|
185
|
-
/**
|
|
186
|
-
* Returns the number of contact points on the maximal disk circle implied
|
|
187
|
-
* by this [[CpNode]].
|
|
188
|
-
*
|
|
189
|
-
* Note, however, that even one-prongs and sharp corners will return 2 (see
|
|
190
|
-
* [[isTerminating]] for more details); if this is not desired use
|
|
191
|
-
* [[getRealProngCount]] instead which will return 1 in these cases.
|
|
192
|
-
*/
|
|
193
|
-
getProngCount(): number;
|
|
194
|
-
/**
|
|
195
|
-
* Returns the number of contact points (up to planar coordinates) on the
|
|
196
|
-
* maximal disk circle implied by this [[CpNode]].
|
|
197
|
-
*
|
|
198
|
-
* See also [[getProngCount]].
|
|
199
|
-
*/
|
|
200
|
-
getRealProngCount(): number;
|
|
201
|
-
}
|
|
202
|
-
export { CpNode };
|
|
1
|
+
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
+
import { ContactPoint } from './contact-point.js';
|
|
3
|
+
import { removeCpNode } from './cp-node/remove.js';
|
|
4
|
+
/**
|
|
5
|
+
* The primary class of the library.
|
|
6
|
+
*
|
|
7
|
+
* Since the MAT is a full representation of the shape boundary an instance of
|
|
8
|
+
* this class contains both the information of a boundary point and a medial
|
|
9
|
+
* axis point (and edge to the next point(s)). It also contains edges to other
|
|
10
|
+
* [[CpNode]]s which allows for traversal of the MAT and thus implictly
|
|
11
|
+
* represents the entire MAT.
|
|
12
|
+
*
|
|
13
|
+
* To get the maximal disk circle (of which the center is on the medial axis)
|
|
14
|
+
* use [[cp]].circle.
|
|
15
|
+
*
|
|
16
|
+
* To get the boundary point, use [[cp]].pointOnShape.
|
|
17
|
+
*
|
|
18
|
+
* The edge [[next]] (resp. [[prev]]) allows one to move anti-clockwise (resp.
|
|
19
|
+
* clockwise) on the shape boundary to the next [[CpNode]]. This also imposes a
|
|
20
|
+
* direction of traversal of the MAT edges and vertices.
|
|
21
|
+
*
|
|
22
|
+
* The edge [[nextOnCircle]] (resp. [[prevOnCircle]]) allows one to go
|
|
23
|
+
* anti-clockwise (resp. clockwise) around the maximal disks implied by
|
|
24
|
+
* the CpNode to the next maximal disk contact point. This is equivalent to
|
|
25
|
+
* following other branches on the MAT.
|
|
26
|
+
*
|
|
27
|
+
* Call [[getCurveBetween]](cpNodeFrom, cpNodeTo) or getCurveToNext(cpNode)
|
|
28
|
+
* (replacing the older CpNode.[[matCurveToNextVertex]]) to get a bezier curve
|
|
29
|
+
* from the maximal disk of this [[CpNode]] to the next [[CpNode]]'s
|
|
30
|
+
* maximal disk and thus directly representing a piece of the medial axis.
|
|
31
|
+
*
|
|
32
|
+
* The function, [[getChildren]], returns the children of this [[CpNode]] when
|
|
33
|
+
* seen as a MAT edge. Only children in a 'forward' direction are returned. These
|
|
34
|
+
* include all edges except the 'backward' edge given by [[prevOnCircle]]. For
|
|
35
|
+
* [[CpNode]]s having a maximal disk with 2 contact points (a 2-prong, the usual
|
|
36
|
+
* case) the children will be the single edge [[next]]. For a 3-prong this will
|
|
37
|
+
* be the edges [[next]] and [[nextOnCircle]], etc. [[getChildren]] allows one to
|
|
38
|
+
* easily traverse the MAT tree - see e.g. the implementation of [[traverseEdges]].
|
|
39
|
+
*
|
|
40
|
+
* The getter, [[vertexChildren]], is similar to [[getChildren]] but returns the
|
|
41
|
+
* child nodes of the tree when [[CpNode]] is seen as a MAT vertex point (as
|
|
42
|
+
* opposed to edge). In this way the dual graph of the tree can easily be
|
|
43
|
+
* traversed - see e.g. [[traverseVertices]]. Generally, however, traversing the
|
|
44
|
+
* edges is preferred as it returns the entire Medial Axis (by utilizing
|
|
45
|
+
* [[getCurveToNext]] on each returned edge).
|
|
46
|
+
*
|
|
47
|
+
* It may be worth mentioning that by traversing from the CpNode by following
|
|
48
|
+
* [[next]] repeatedly until one is back at the same CpNode allows one
|
|
49
|
+
* to 'go around' the shape boundary and at the same time traverse the MAT twice
|
|
50
|
+
* in opposite directions.
|
|
51
|
+
*/
|
|
52
|
+
declare class CpNode {
|
|
53
|
+
readonly cp: ContactPoint;
|
|
54
|
+
isHoleClosing: boolean;
|
|
55
|
+
isIntersection: boolean;
|
|
56
|
+
prev: CpNode;
|
|
57
|
+
next: CpNode;
|
|
58
|
+
prevOnCircle: CpNode;
|
|
59
|
+
nextOnCircle: CpNode;
|
|
60
|
+
/**
|
|
61
|
+
* Primarily for internal use.
|
|
62
|
+
* @param cp The shape boundary contact point, i.e. a [[CpNode]] without its
|
|
63
|
+
* edges.
|
|
64
|
+
* @param isHoleClosing If true, this [[CpNode]] belongs to a hole-closing
|
|
65
|
+
* maximal disk.
|
|
66
|
+
* @param isIntersection true if this cpNode is at a shape boundary
|
|
67
|
+
* intersection point, false otherwise
|
|
68
|
+
* @param prev The previous (going clockwise around the boundary) contact
|
|
69
|
+
* point ([[CpNode]]).
|
|
70
|
+
* @param next The next (going anti-clockwise around the boundary) contact
|
|
71
|
+
* point ([[CpNode]]).
|
|
72
|
+
* @param prevOnCircle The previous [[CpNode]] (going clockwise around
|
|
73
|
+
* the inscribed circle defined by the maximal disk).
|
|
74
|
+
* @param nextOnCircle The next [[CpNode]] (going anti-clockwise around
|
|
75
|
+
* the inscribed circle defined by the maximal disk).
|
|
76
|
+
*/
|
|
77
|
+
constructor(cp: ContactPoint, isHoleClosing: boolean, isIntersection: boolean, prev?: CpNode, next?: CpNode, prevOnCircle?: CpNode, nextOnCircle?: CpNode);
|
|
78
|
+
/**
|
|
79
|
+
* Returns the bezier curve from the maximal disk of this [[CpNode]] to the
|
|
80
|
+
* next [[CpNode]]'s maximal disk and thus directly represents a piece of the
|
|
81
|
+
* medial axis.
|
|
82
|
+
* @deprecated Use [[getCurveToNext]] instead
|
|
83
|
+
* @param cpNode
|
|
84
|
+
*/
|
|
85
|
+
get matCurveToNextVertex(): number[][];
|
|
86
|
+
/**
|
|
87
|
+
* Primarily for internal use.
|
|
88
|
+
*
|
|
89
|
+
* Compares the order of two [[CpNode]]s. The order is cyclic and depends
|
|
90
|
+
* on a [[CpNode]]'s relative position along the shape boundary.
|
|
91
|
+
*/
|
|
92
|
+
static comparator: (a: CpNode, b: CpNode) => number;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the children of this [[CpNode]] when seen as a MAT edge. Only
|
|
95
|
+
* children in a 'forward' direction are returned. These include all edges
|
|
96
|
+
* except the 'backward' edge given by [[prevOnCircle]], even terminating
|
|
97
|
+
* edges.
|
|
98
|
+
*/
|
|
99
|
+
getChildren(): CpNode[];
|
|
100
|
+
static remove: typeof removeCpNode;
|
|
101
|
+
/**
|
|
102
|
+
* Similar to [[getChildren]] but returns the child nodes of the tree when
|
|
103
|
+
* [[CpNode]] is seen as a MAT vertex point (as opposed to edge). In this
|
|
104
|
+
* way the dual graph of the tree can easily be traversed - see e.g.
|
|
105
|
+
* [[traverseVertices]]. Generally, however, traversing the edges is
|
|
106
|
+
* preferred as it returns the entire Medial Axis (by utilizing
|
|
107
|
+
* [[getCurveToNext]] on each returned edge).
|
|
108
|
+
*/
|
|
109
|
+
get vertexChildren(): CpNode[];
|
|
110
|
+
/**
|
|
111
|
+
* Returns all [[CpNode]]s on the MAT that this [[CpNode]] is part of
|
|
112
|
+
* starting from the current one and going anti-clockwise around the shape.
|
|
113
|
+
*/
|
|
114
|
+
getAllOnLoop(): CpNode[];
|
|
115
|
+
/**
|
|
116
|
+
* Primarily for internal use.
|
|
117
|
+
*
|
|
118
|
+
* Insert a [[CpNode]] into the MAT tree graph after the specified point
|
|
119
|
+
* and returns the freshly inserted [[CpNode]].
|
|
120
|
+
* @param isHoleClosing True if this is a hole closing contact point.
|
|
121
|
+
* @param isIntersection True if this is a contact point at a shape boundary
|
|
122
|
+
* intersection point.
|
|
123
|
+
* @param cpTree The tree graph holding the [[CpNodes]] of the MAT.
|
|
124
|
+
* @param cp [[ContactPoint]] defining the [[CpNode]].
|
|
125
|
+
* @param prev_ Inserts the new [[CpNode]] right after this item if the
|
|
126
|
+
* loop is not empty, else insert the new [[CpNode]] as the only item in the
|
|
127
|
+
* loop.
|
|
128
|
+
*/
|
|
129
|
+
static insert(isHoleClosing: boolean, isIntersection: boolean, cpTree: LlRbTree<CpNode>, cp: ContactPoint, prev_: CpNode): CpNode;
|
|
130
|
+
/**
|
|
131
|
+
* Return this (except if exclThis is truthy) and the the other CpNodes
|
|
132
|
+
* around the maximal disk vertex circle in an anti-clockwise order.
|
|
133
|
+
* @param exclThis If true the returned array does not include this
|
|
134
|
+
* [[CpNode]].
|
|
135
|
+
*/
|
|
136
|
+
getCpNodesOnCircle(exclThis?: boolean): CpNode[];
|
|
137
|
+
/**
|
|
138
|
+
* Returns true if the 2 given [[CpNode]]s are on the same maximal disk
|
|
139
|
+
* circle.
|
|
140
|
+
* @param cpNode1 A [[CpNode]].
|
|
141
|
+
* @param cpNode2 Another [[CpNode]]
|
|
142
|
+
*/
|
|
143
|
+
static isOnSameCircle(cpNode1: CpNode, cpNode2: CpNode): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Returns true if this [[CpNode]] is terminating, i.e. implies a leaf MAT
|
|
146
|
+
* vertex.
|
|
147
|
+
*
|
|
148
|
+
* This is always the case for sharp corners and maximal disks with
|
|
149
|
+
* a single contact point. Note, however, that even in these cases there are
|
|
150
|
+
* two contact points stored (sitting 'on top' of each other) for the
|
|
151
|
+
* maximal disk. It can be seen as a limiting case of a two-prong where the
|
|
152
|
+
* distance between two of the contact points tend to zero. One point
|
|
153
|
+
* (represented by a [[CpNode]] of course) will be terminating with the
|
|
154
|
+
* other point being its [[next]], whereas the other point will *not* be
|
|
155
|
+
* terminating and 'points' back into the shape.
|
|
156
|
+
*/
|
|
157
|
+
isTerminating(): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Like isTerminating() but only returns true if all cpNodes on the circle
|
|
160
|
+
* (except this.prevOnCircle) is terminating.
|
|
161
|
+
*/
|
|
162
|
+
isFullyTerminating(): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Returns the first [[CpNode]] (from this one by successively applying
|
|
165
|
+
* .nextOnCircle) that exits the circle.
|
|
166
|
+
*/
|
|
167
|
+
getFirstExit(): CpNode;
|
|
168
|
+
/**
|
|
169
|
+
* Returns true if this [[CpNode]] represents a sharp corner, i.e. the
|
|
170
|
+
* limiting case of a two-prong having zero radius.
|
|
171
|
+
*
|
|
172
|
+
* Note that two [[CpNode]]s are stored for each sharp corner, one being
|
|
173
|
+
* terminating and one not. See [[isTerminating]] for more details.
|
|
174
|
+
*/
|
|
175
|
+
isSharp(): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Returns true if this [[CpNode]]'s maximal disk has only one contact point
|
|
178
|
+
* on the shape boundary (up to planar coordinates). These includes sharp
|
|
179
|
+
* corners.
|
|
180
|
+
*
|
|
181
|
+
* Note, however, that two [[CpNode]]s are stored for each such point to
|
|
182
|
+
* preserve symmetry - see [[isTerminating]] for more details.
|
|
183
|
+
*/
|
|
184
|
+
isOneProng(): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Returns the number of contact points on the maximal disk circle implied
|
|
187
|
+
* by this [[CpNode]].
|
|
188
|
+
*
|
|
189
|
+
* Note, however, that even one-prongs and sharp corners will return 2 (see
|
|
190
|
+
* [[isTerminating]] for more details); if this is not desired use
|
|
191
|
+
* [[getRealProngCount]] instead which will return 1 in these cases.
|
|
192
|
+
*/
|
|
193
|
+
getProngCount(): number;
|
|
194
|
+
/**
|
|
195
|
+
* Returns the number of contact points (up to planar coordinates) on the
|
|
196
|
+
* maximal disk circle implied by this [[CpNode]].
|
|
197
|
+
*
|
|
198
|
+
* See also [[getProngCount]].
|
|
199
|
+
*/
|
|
200
|
+
getRealProngCount(): number;
|
|
201
|
+
}
|
|
202
|
+
export { CpNode };
|