@thi.ng/quad-edge 3.1.41 → 3.1.43
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/CHANGELOG.md +1 -1
- package/index.js +157 -162
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -1,165 +1,160 @@
|
|
|
1
1
|
import { assert } from "@thi.ng/errors/assert";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
function defEdge(id, src, dest) {
|
|
3
|
+
assert((id & 3) === 0, `id must be multiple of 4`);
|
|
4
|
+
const quad = new Array(4);
|
|
5
|
+
const a = quad[0] = new Edge(quad, id);
|
|
6
|
+
const b = quad[1] = new Edge(quad, id + 1);
|
|
7
|
+
const c = quad[2] = new Edge(quad, id + 2);
|
|
8
|
+
const d = quad[3] = new Edge(quad, id + 3);
|
|
9
|
+
a.onext = a;
|
|
10
|
+
c.onext = c;
|
|
11
|
+
b.onext = d;
|
|
12
|
+
d.onext = b;
|
|
13
|
+
src && dest && a.setEnds(src, dest);
|
|
14
|
+
return a;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const t2 = this.onext;
|
|
157
|
-
const t3 = beta.onext;
|
|
158
|
-
const t4 = alpha.onext;
|
|
159
|
-
this.onext = t1;
|
|
160
|
-
e.onext = t2;
|
|
161
|
-
alpha.onext = t3;
|
|
162
|
-
beta.onext = t4;
|
|
163
|
-
return this;
|
|
164
|
-
}
|
|
16
|
+
class Edge {
|
|
17
|
+
id;
|
|
18
|
+
parent;
|
|
19
|
+
origin;
|
|
20
|
+
constructor(parent, id) {
|
|
21
|
+
this.parent = parent;
|
|
22
|
+
this.id = id;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Next CCW edge from this edge's origin.
|
|
26
|
+
*/
|
|
27
|
+
onext;
|
|
28
|
+
/**
|
|
29
|
+
* Next CW edge from this edge's origin.
|
|
30
|
+
*/
|
|
31
|
+
get oprev() {
|
|
32
|
+
return this.rot.onext.rot;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Dual of this edge, right -> left.
|
|
36
|
+
*/
|
|
37
|
+
get rot() {
|
|
38
|
+
return this.parent[this.id + 1 & 3];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Dual of this edge, left -> right.
|
|
42
|
+
* I.e same as `this.rot.sym`
|
|
43
|
+
*/
|
|
44
|
+
get invrot() {
|
|
45
|
+
return this.parent[this.id + 3 & 3];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Symmetric partner edge of this edge, from dest -> src.
|
|
49
|
+
* I.e. `this === this.sym.sym`
|
|
50
|
+
*/
|
|
51
|
+
get sym() {
|
|
52
|
+
return this.parent[this.id + 2 & 3];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Next CCW edge to this edge's dest.
|
|
56
|
+
*/
|
|
57
|
+
get dnext() {
|
|
58
|
+
return this.sym.onext.sym;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Next CW edge to this edge's dest.
|
|
62
|
+
*/
|
|
63
|
+
get dprev() {
|
|
64
|
+
return this.invrot.onext.invrot;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Next CCW edge around the left face (dual vertex) from this edge's
|
|
68
|
+
* dest.
|
|
69
|
+
*/
|
|
70
|
+
get lnext() {
|
|
71
|
+
return this.invrot.onext.rot;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Next CCW edge around the left face (dual vertex) to this edge's
|
|
75
|
+
* origin.
|
|
76
|
+
*/
|
|
77
|
+
get lprev() {
|
|
78
|
+
return this.onext.sym;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Next CCW edge around the right face (dual vertex) to this edge's
|
|
82
|
+
* dest.
|
|
83
|
+
*/
|
|
84
|
+
get rnext() {
|
|
85
|
+
return this.rot.onext.invrot;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Next CCW edge around the right face (dual vertex) to this edge's
|
|
89
|
+
* origin.
|
|
90
|
+
*/
|
|
91
|
+
get rprev() {
|
|
92
|
+
return this.sym.onext;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Returns this edge's dest vertex. I.e. `this.sym.origin`
|
|
96
|
+
*/
|
|
97
|
+
get dest() {
|
|
98
|
+
return this.sym.origin;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Sets the origin & dest vertices of this edge (in other words, the
|
|
102
|
+
* origins of this edge and `this.sym`).
|
|
103
|
+
*
|
|
104
|
+
* @param o -
|
|
105
|
+
* @param d -
|
|
106
|
+
*/
|
|
107
|
+
setEnds(o, d) {
|
|
108
|
+
this.origin = o;
|
|
109
|
+
this.sym.origin = d;
|
|
110
|
+
}
|
|
111
|
+
connect(e, id) {
|
|
112
|
+
const n = defEdge(id);
|
|
113
|
+
n.splice(this.lnext);
|
|
114
|
+
n.sym.splice(e);
|
|
115
|
+
n.setEnds(this.dest, e.origin);
|
|
116
|
+
return n;
|
|
117
|
+
}
|
|
118
|
+
swap() {
|
|
119
|
+
const a = this.oprev;
|
|
120
|
+
const b = this.sym.oprev;
|
|
121
|
+
this.splice(a);
|
|
122
|
+
this.sym.splice(b);
|
|
123
|
+
this.splice(a.lnext);
|
|
124
|
+
this.sym.splice(b.lnext);
|
|
125
|
+
this.setEnds(a.dest, b.dest);
|
|
126
|
+
}
|
|
127
|
+
remove() {
|
|
128
|
+
this.splice(this.oprev);
|
|
129
|
+
this.sym.splice(this.sym.oprev);
|
|
130
|
+
delete this.parent;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Modifies the edge rings around the origins of this edge and `e`,
|
|
134
|
+
* as well as, independently, the edge rings of both edges' left
|
|
135
|
+
* dual vertex. In each case, if the rings are separate, this
|
|
136
|
+
* operator will join them and if both rings are the same ring, they
|
|
137
|
+
* will be split / separated. Therefore, splice` is it's own reverse
|
|
138
|
+
* operator and the only operator needed to edit quad edge
|
|
139
|
+
* topologies.
|
|
140
|
+
*
|
|
141
|
+
* @param e -
|
|
142
|
+
*/
|
|
143
|
+
splice(e) {
|
|
144
|
+
const alpha = this.onext.rot;
|
|
145
|
+
const beta = e.onext.rot;
|
|
146
|
+
const t1 = e.onext;
|
|
147
|
+
const t2 = this.onext;
|
|
148
|
+
const t3 = beta.onext;
|
|
149
|
+
const t4 = alpha.onext;
|
|
150
|
+
this.onext = t1;
|
|
151
|
+
e.onext = t2;
|
|
152
|
+
alpha.onext = t3;
|
|
153
|
+
beta.onext = t4;
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
165
156
|
}
|
|
157
|
+
export {
|
|
158
|
+
Edge,
|
|
159
|
+
defEdge
|
|
160
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/quad-edge",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.43",
|
|
4
4
|
"description": "Quadedge data structure after Guibas & Stolfi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "yarn
|
|
27
|
+
"build": "yarn build:esbuild && yarn build:decl",
|
|
28
|
+
"build:decl": "tsc --declaration --emitDeclarationOnly",
|
|
29
|
+
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
|
|
28
30
|
"clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",
|
|
29
31
|
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
30
32
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
@@ -33,11 +35,11 @@
|
|
|
33
35
|
"test": "bun test"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"@thi.ng/errors": "^2.4.
|
|
38
|
+
"@thi.ng/errors": "^2.4.6"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@microsoft/api-extractor": "^7.38.3",
|
|
40
|
-
"
|
|
42
|
+
"esbuild": "^0.19.8",
|
|
41
43
|
"rimraf": "^5.0.5",
|
|
42
44
|
"tools": "^0.0.1",
|
|
43
45
|
"typedoc": "^0.25.4",
|
|
@@ -77,5 +79,5 @@
|
|
|
77
79
|
],
|
|
78
80
|
"year": 2015
|
|
79
81
|
},
|
|
80
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
|
|
81
83
|
}
|