@woosh/meep-engine 2.78.0 → 2.78.1
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/build/meep.cjs +30 -28
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +30 -28
- package/package.json +1 -1
- package/src/core/{graph → geom/3d/topology}/build_face_graph_from_mesh.js +5 -5
- package/src/core/graph/Edge.js +10 -22
- package/src/core/graph/Edge.spec.js +35 -0
- package/src/core/graph/MultiNode.js +6 -7
- package/src/core/graph/v2/Graph.js +20 -8
- package/src/core/graph/v2/NodeContainer.js +1 -0
- package/src/core/graph/EdgeDirection.js +0 -11
package/build/meep.module.js
CHANGED
|
@@ -70583,10 +70583,19 @@ class Edge {
|
|
|
70583
70583
|
return this.first === node || this.second === node;
|
|
70584
70584
|
}
|
|
70585
70585
|
|
|
70586
|
+
/**
|
|
70587
|
+
*
|
|
70588
|
+
* @param {N} source
|
|
70589
|
+
* @param {N} target
|
|
70590
|
+
* @returns {boolean} True iff the edge contains both source and target and allows transition from source to target
|
|
70591
|
+
*/
|
|
70586
70592
|
validateTransition(source, target) {
|
|
70587
70593
|
const a = this.first;
|
|
70588
70594
|
const b = this.second;
|
|
70589
|
-
|
|
70595
|
+
|
|
70596
|
+
return (a === source && b === target && this.traversableForward())
|
|
70597
|
+
|| (b === source && a === target && this.traversableBackward())
|
|
70598
|
+
;
|
|
70590
70599
|
}
|
|
70591
70600
|
|
|
70592
70601
|
/**
|
|
@@ -70634,16 +70643,6 @@ class Edge {
|
|
|
70634
70643
|
|| (this.second === node && this.direction === EdgeDirectionType.Backward)
|
|
70635
70644
|
}
|
|
70636
70645
|
|
|
70637
|
-
/**
|
|
70638
|
-
* @deprecated
|
|
70639
|
-
* @returns {number}
|
|
70640
|
-
*/
|
|
70641
|
-
angle() {
|
|
70642
|
-
|
|
70643
|
-
const delta = this.second.clone().sub(this.first);
|
|
70644
|
-
return Math.atan2(delta.y, delta.x);
|
|
70645
|
-
}
|
|
70646
|
-
|
|
70647
70646
|
/**
|
|
70648
70647
|
*
|
|
70649
70648
|
* @returns {N[]}
|
|
@@ -70652,15 +70651,6 @@ class Edge {
|
|
|
70652
70651
|
return [this.first, this.second];
|
|
70653
70652
|
}
|
|
70654
70653
|
|
|
70655
|
-
|
|
70656
|
-
/**
|
|
70657
|
-
* @deprecated
|
|
70658
|
-
* @returns {number}
|
|
70659
|
-
*/
|
|
70660
|
-
get length() {
|
|
70661
|
-
|
|
70662
|
-
return this.first.distanceTo(this.second);
|
|
70663
|
-
}
|
|
70664
70654
|
}
|
|
70665
70655
|
|
|
70666
70656
|
/**
|
|
@@ -70691,6 +70681,7 @@ class NodeContainer {
|
|
|
70691
70681
|
/**
|
|
70692
70682
|
*
|
|
70693
70683
|
* @type {Map<N,number>}
|
|
70684
|
+
* Maps neighbour node to number of edges to that node from this one
|
|
70694
70685
|
* @private
|
|
70695
70686
|
*/
|
|
70696
70687
|
__neighbors = new Map();
|
|
@@ -71084,6 +71075,7 @@ class Graph {
|
|
|
71084
71075
|
/**
|
|
71085
71076
|
*
|
|
71086
71077
|
* @param {N} node
|
|
71078
|
+
* @returns {boolean}
|
|
71087
71079
|
*/
|
|
71088
71080
|
removeNode(node) {
|
|
71089
71081
|
|
|
@@ -71157,7 +71149,7 @@ class Graph {
|
|
|
71157
71149
|
}
|
|
71158
71150
|
|
|
71159
71151
|
/**
|
|
71160
|
-
*
|
|
71152
|
+
* Node degree is the number of attached edges
|
|
71161
71153
|
* @param {N} node
|
|
71162
71154
|
* @return {number}
|
|
71163
71155
|
*/
|
|
@@ -71199,13 +71191,18 @@ class Graph {
|
|
|
71199
71191
|
*
|
|
71200
71192
|
* @param {N} source
|
|
71201
71193
|
* @param {N} target
|
|
71202
|
-
* @param {EdgeDirectionType} [
|
|
71194
|
+
* @param {EdgeDirectionType} [direction] Undirected by default
|
|
71203
71195
|
* @returns {Edge<N>}
|
|
71204
71196
|
*/
|
|
71205
|
-
createEdge(
|
|
71197
|
+
createEdge(
|
|
71198
|
+
source,
|
|
71199
|
+
target,
|
|
71200
|
+
direction = EdgeDirectionType.Undirected
|
|
71201
|
+
) {
|
|
71202
|
+
|
|
71206
71203
|
const edge = new Edge(source, target);
|
|
71207
71204
|
|
|
71208
|
-
edge.direction =
|
|
71205
|
+
edge.direction = direction;
|
|
71209
71206
|
|
|
71210
71207
|
this.addEdge(edge);
|
|
71211
71208
|
|
|
@@ -71213,9 +71210,10 @@ class Graph {
|
|
|
71213
71210
|
}
|
|
71214
71211
|
|
|
71215
71212
|
/**
|
|
71216
|
-
*
|
|
71213
|
+
* Both nodes that the edge is attached to must be present
|
|
71217
71214
|
* @param {Edge<N>} edge
|
|
71218
|
-
* @returns {boolean}
|
|
71215
|
+
* @returns {boolean} true if edge was added, false if edge was already present
|
|
71216
|
+
* @throws if one or both nodes are not contained in the graph
|
|
71219
71217
|
*/
|
|
71220
71218
|
addEdge(edge) {
|
|
71221
71219
|
if (this.hasEdge(edge)) {
|
|
@@ -71417,10 +71415,10 @@ class Graph {
|
|
|
71417
71415
|
}
|
|
71418
71416
|
|
|
71419
71417
|
/**
|
|
71420
|
-
*
|
|
71418
|
+
* Find a path through the graph
|
|
71421
71419
|
* @param {N} start
|
|
71422
71420
|
* @param {N} goal
|
|
71423
|
-
* @returns {null|N[]}
|
|
71421
|
+
* @returns {null|N[]} null if no path exists
|
|
71424
71422
|
*/
|
|
71425
71423
|
findPath(start, goal) {
|
|
71426
71424
|
const start_node_container = this.__nodes.get(start);
|
|
@@ -71460,6 +71458,7 @@ class Graph {
|
|
|
71460
71458
|
const b = edge.second;
|
|
71461
71459
|
|
|
71462
71460
|
let other = null;
|
|
71461
|
+
|
|
71463
71462
|
if (a === current_node && (edge.direction === EdgeDirectionType.Forward || edge.direction === EdgeDirectionType.Undirected)) {
|
|
71464
71463
|
other = b;
|
|
71465
71464
|
} else if (b === current_node && (edge.direction === EdgeDirectionType.Backward || edge.direction === EdgeDirectionType.Undirected)) {
|
|
@@ -71488,6 +71487,9 @@ class Graph {
|
|
|
71488
71487
|
return null;
|
|
71489
71488
|
}
|
|
71490
71489
|
|
|
71490
|
+
/**
|
|
71491
|
+
* Remove all data from the graph, resetting it to empty state
|
|
71492
|
+
*/
|
|
71491
71493
|
clear() {
|
|
71492
71494
|
this.__nodes.clear();
|
|
71493
71495
|
this.__edges.clear();
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MultiNode } from "
|
|
3
|
-
import {
|
|
4
|
-
import { WeightedEdge } from "
|
|
5
|
-
import {
|
|
1
|
+
import { graph_compute_disconnected_clusters } from "../../../graph/graph_compute_disconnected_clusters.js";
|
|
2
|
+
import { MultiNode } from "../../../graph/MultiNode.js";
|
|
3
|
+
import { Graph } from "../../../graph/v2/Graph.js";
|
|
4
|
+
import { WeightedEdge } from "../../../graph/WeightedEdge.js";
|
|
5
|
+
import { compute_face_connection_weight } from "./util/compute_face_connection_weight.js";
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
/**
|
package/src/core/graph/Edge.js
CHANGED
|
@@ -55,10 +55,19 @@ export class Edge {
|
|
|
55
55
|
return this.first === node || this.second === node;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param {N} source
|
|
61
|
+
* @param {N} target
|
|
62
|
+
* @returns {boolean} True iff the edge contains both source and target and allows transition from source to target
|
|
63
|
+
*/
|
|
58
64
|
validateTransition(source, target) {
|
|
59
65
|
const a = this.first;
|
|
60
66
|
const b = this.second;
|
|
61
|
-
|
|
67
|
+
|
|
68
|
+
return (a === source && b === target && this.traversableForward())
|
|
69
|
+
|| (b === source && a === target && this.traversableBackward())
|
|
70
|
+
;
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
/**
|
|
@@ -106,17 +115,6 @@ export class Edge {
|
|
|
106
115
|
|| (this.second === node && this.direction === EdgeDirectionType.Backward)
|
|
107
116
|
}
|
|
108
117
|
|
|
109
|
-
/**
|
|
110
|
-
* @deprecated
|
|
111
|
-
* @returns {number}
|
|
112
|
-
*/
|
|
113
|
-
angle() {
|
|
114
|
-
console.error('method is deprecated, do not use');
|
|
115
|
-
|
|
116
|
-
const delta = this.second.clone().sub(this.first);
|
|
117
|
-
return Math.atan2(delta.y, delta.x);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
118
|
/**
|
|
121
119
|
*
|
|
122
120
|
* @returns {N[]}
|
|
@@ -125,16 +123,6 @@ export class Edge {
|
|
|
125
123
|
return [this.first, this.second];
|
|
126
124
|
}
|
|
127
125
|
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @deprecated
|
|
131
|
-
* @returns {number}
|
|
132
|
-
*/
|
|
133
|
-
get length() {
|
|
134
|
-
console.error('method is deprecated, do not use');
|
|
135
|
-
|
|
136
|
-
return this.first.distanceTo(this.second);
|
|
137
|
-
}
|
|
138
126
|
}
|
|
139
127
|
|
|
140
128
|
/**
|
|
@@ -48,3 +48,38 @@ test('other', () => {
|
|
|
48
48
|
expect(edge.other(3)).toBe(7);
|
|
49
49
|
expect(edge.other(7)).toBe(3);
|
|
50
50
|
});
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
test("isDirectedTowards", () => {
|
|
54
|
+
const e = new Edge(1, 3);
|
|
55
|
+
|
|
56
|
+
e.direction = EdgeDirectionType.Forward;
|
|
57
|
+
|
|
58
|
+
expect(e.isDirectedTowards(3)).toBe(true);
|
|
59
|
+
expect(e.isDirectedTowards(1)).toBe(false);
|
|
60
|
+
|
|
61
|
+
e.direction = EdgeDirectionType.Backward;
|
|
62
|
+
|
|
63
|
+
expect(e.isDirectedTowards(3)).toBe(false);
|
|
64
|
+
expect(e.isDirectedTowards(1)).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("isDirectedAwayFrom", () => {
|
|
68
|
+
const e = new Edge(1, 3);
|
|
69
|
+
|
|
70
|
+
e.direction = EdgeDirectionType.Forward;
|
|
71
|
+
|
|
72
|
+
expect(e.isDirectedAwayFrom(3)).toBe(false);
|
|
73
|
+
expect(e.isDirectedAwayFrom(1)).toBe(true);
|
|
74
|
+
|
|
75
|
+
e.direction = EdgeDirectionType.Backward;
|
|
76
|
+
|
|
77
|
+
expect(e.isDirectedAwayFrom(3)).toBe(true);
|
|
78
|
+
expect(e.isDirectedAwayFrom(1)).toBe(false);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("nodes accessor", () => {
|
|
82
|
+
const e = new Edge(1, 3);
|
|
83
|
+
|
|
84
|
+
expect(e.nodes).toEqual([1, 3]);
|
|
85
|
+
});
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* A grouping node, intended mainly for meta-graphs, or hierarchical graphs
|
|
2
3
|
* @template T
|
|
3
4
|
*/
|
|
4
5
|
export class MultiNode {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.source_nodes = [];
|
|
11
|
-
}
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @type {T[]}
|
|
9
|
+
*/
|
|
10
|
+
source_nodes = [];
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
*
|
|
@@ -92,6 +92,7 @@ export class Graph {
|
|
|
92
92
|
/**
|
|
93
93
|
*
|
|
94
94
|
* @param {N} node
|
|
95
|
+
* @returns {boolean}
|
|
95
96
|
*/
|
|
96
97
|
removeNode(node) {
|
|
97
98
|
|
|
@@ -165,7 +166,7 @@ export class Graph {
|
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
/**
|
|
168
|
-
*
|
|
169
|
+
* Node degree is the number of attached edges
|
|
169
170
|
* @param {N} node
|
|
170
171
|
* @return {number}
|
|
171
172
|
*/
|
|
@@ -207,13 +208,19 @@ export class Graph {
|
|
|
207
208
|
*
|
|
208
209
|
* @param {N} source
|
|
209
210
|
* @param {N} target
|
|
210
|
-
* @param {EdgeDirectionType} [
|
|
211
|
+
* @param {EdgeDirectionType} [direction] Undirected by default
|
|
211
212
|
* @returns {Edge<N>}
|
|
212
213
|
*/
|
|
213
|
-
createEdge(
|
|
214
|
+
createEdge(
|
|
215
|
+
source,
|
|
216
|
+
target,
|
|
217
|
+
direction = EdgeDirectionType.Undirected
|
|
218
|
+
) {
|
|
219
|
+
assert.enum(direction, EdgeDirectionType, 'direction');
|
|
220
|
+
|
|
214
221
|
const edge = new Edge(source, target);
|
|
215
222
|
|
|
216
|
-
edge.direction =
|
|
223
|
+
edge.direction = direction;
|
|
217
224
|
|
|
218
225
|
this.addEdge(edge);
|
|
219
226
|
|
|
@@ -221,9 +228,10 @@ export class Graph {
|
|
|
221
228
|
}
|
|
222
229
|
|
|
223
230
|
/**
|
|
224
|
-
*
|
|
231
|
+
* Both nodes that the edge is attached to must be present
|
|
225
232
|
* @param {Edge<N>} edge
|
|
226
|
-
* @returns {boolean}
|
|
233
|
+
* @returns {boolean} true if edge was added, false if edge was already present
|
|
234
|
+
* @throws if one or both nodes are not contained in the graph
|
|
227
235
|
*/
|
|
228
236
|
addEdge(edge) {
|
|
229
237
|
if (this.hasEdge(edge)) {
|
|
@@ -431,10 +439,10 @@ export class Graph {
|
|
|
431
439
|
}
|
|
432
440
|
|
|
433
441
|
/**
|
|
434
|
-
*
|
|
442
|
+
* Find a path through the graph
|
|
435
443
|
* @param {N} start
|
|
436
444
|
* @param {N} goal
|
|
437
|
-
* @returns {null|N[]}
|
|
445
|
+
* @returns {null|N[]} null if no path exists
|
|
438
446
|
*/
|
|
439
447
|
findPath(start, goal) {
|
|
440
448
|
const start_node_container = this.__nodes.get(start);
|
|
@@ -474,6 +482,7 @@ export class Graph {
|
|
|
474
482
|
const b = edge.second;
|
|
475
483
|
|
|
476
484
|
let other = null;
|
|
485
|
+
|
|
477
486
|
if (a === current_node && (edge.direction === EdgeDirectionType.Forward || edge.direction === EdgeDirectionType.Undirected)) {
|
|
478
487
|
other = b;
|
|
479
488
|
} else if (b === current_node && (edge.direction === EdgeDirectionType.Backward || edge.direction === EdgeDirectionType.Undirected)) {
|
|
@@ -502,6 +511,9 @@ export class Graph {
|
|
|
502
511
|
return null;
|
|
503
512
|
}
|
|
504
513
|
|
|
514
|
+
/**
|
|
515
|
+
* Remove all data from the graph, resetting it to empty state
|
|
516
|
+
*/
|
|
505
517
|
clear() {
|
|
506
518
|
this.__nodes.clear();
|
|
507
519
|
this.__edges.clear();
|