@eclipse-glsp/client 1.1.0-next.855c7d2.252 → 1.1.0-next.86cf8e6.253
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.
|
@@ -130,6 +130,8 @@ export declare function toElementAndBounds(element: BoundsAwareModelElement): El
|
|
|
130
130
|
* @returns The corresponding {@link ElementAndRoutingPoints} for the given element.
|
|
131
131
|
*/
|
|
132
132
|
export declare function toElementAndRoutingPoints(element: SRoutableElement): ElementAndRoutingPoints;
|
|
133
|
+
/** All routing points. */
|
|
134
|
+
export declare const ALL_ROUTING_POINTS: undefined;
|
|
133
135
|
/** Pure routing point data kinds. */
|
|
134
136
|
export declare const ROUTING_POINT_KINDS: string[];
|
|
135
137
|
/** Pure route data kinds. */
|
|
@@ -153,13 +155,14 @@ export declare function calcElementAndRoutingPoints(element: SRoutableElement, r
|
|
|
153
155
|
*/
|
|
154
156
|
export declare function calcElementAndRoute(element: SRoutableElement, routerRegistry?: EdgeRouterRegistry): ElementAndRoutingPoints;
|
|
155
157
|
/**
|
|
156
|
-
* Helper function to calculate the route for a given {@link SRoutableElement}.
|
|
158
|
+
* Helper function to calculate the route for a given {@link SRoutableElement} by filtering duplicate points.
|
|
157
159
|
* @param element The element to translate.
|
|
158
160
|
* @param routerRegistry the edge router registry.
|
|
159
161
|
* @param pointKinds the routing point kinds that should be considered.
|
|
162
|
+
* @param tolerance the tolerance applied to a point's coordinates to determine duplicates.
|
|
160
163
|
* @returns The corresponding route for the given element.
|
|
161
164
|
*/
|
|
162
|
-
export declare function calcRoute(element: SRoutableElement, routerRegistry: EdgeRouterRegistry, pointKinds?: string[]): RoutedPoint[] | undefined;
|
|
165
|
+
export declare function calcRoute(element: SRoutableElement, routerRegistry: EdgeRouterRegistry, pointKinds?: string[] | undefined, tolerance?: number): RoutedPoint[] | undefined;
|
|
163
166
|
/**
|
|
164
167
|
* Checks if the model is compatible with the passed type string.
|
|
165
168
|
* (either has the same type or a subtype of this type)
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OAAO,EAAE,gBAAgB,GAAG,uBAAuB,CAK5F;AACD,0BAA0B;AAC1B,eAAO,MAAM,kBAAkB,WAAY,CAAC;AAE5C,qCAAqC;AACrC,eAAO,MAAM,mBAAmB,UAAgC,CAAC;AAEjE,6BAA6B;AAC7B,eAAO,MAAM,WAAW,UAA+C,CAAC;AAExE;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,gBAAgB,EAAE,cAAc,CAAC,EAAE,kBAAkB,GAAG,uBAAuB,CAGnI;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,EAAE,cAAc,CAAC,EAAE,kBAAkB,GAAG,uBAAuB,CAS3H;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACrB,OAAO,EAAE,gBAAgB,EACzB,cAAc,EAAE,kBAAkB,EAClC,UAAU,GAAE,MAAM,EAAE,GAAG,SAA8B,EACrD,SAAS,SAAiB,GAC3B,WAAW,EAAE,GAAG,SAAS,CAkB3B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,mBAAmB,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAG5G;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAM5F"}
|
package/lib/utils/smodel-util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getElementTypeId = exports.hasCompatibleType = exports.calcRoute = exports.calcElementAndRoute = exports.calcElementAndRoutingPoints = exports.ROUTE_KINDS = exports.ROUTING_POINT_KINDS = exports.toElementAndRoutingPoints = exports.toElementAndBounds = exports.isSelectableAndBoundsAware = exports.isRoutingHandle = exports.isRoutable = exports.isNonRoutableSelectedBoundsAware = exports.isNonRoutableSelectedMovableBoundsAware = exports.removeCssClasses = exports.addCssClasses = exports.isNotUndefined = exports.hasSelectedElements = exports.getSelectedElementCount = exports.getElements = exports.getMatchingElements = exports.forEachElement = exports.filter = void 0;
|
|
3
|
+
exports.getElementTypeId = exports.hasCompatibleType = exports.calcRoute = exports.calcElementAndRoute = exports.calcElementAndRoutingPoints = exports.ROUTE_KINDS = exports.ROUTING_POINT_KINDS = exports.ALL_ROUTING_POINTS = exports.toElementAndRoutingPoints = exports.toElementAndBounds = exports.isSelectableAndBoundsAware = exports.isRoutingHandle = exports.isRoutable = exports.isNonRoutableSelectedBoundsAware = exports.isNonRoutableSelectedMovableBoundsAware = exports.removeCssClasses = exports.addCssClasses = exports.isNotUndefined = exports.hasSelectedElements = exports.getSelectedElementCount = exports.getElements = exports.getMatchingElements = exports.forEachElement = exports.filter = void 0;
|
|
4
4
|
/********************************************************************************
|
|
5
5
|
* Copyright (c) 2019-2023 EclipseSource and others.
|
|
6
6
|
*
|
|
@@ -195,6 +195,8 @@ function toElementAndRoutingPoints(element) {
|
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
exports.toElementAndRoutingPoints = toElementAndRoutingPoints;
|
|
198
|
+
/** All routing points. */
|
|
199
|
+
exports.ALL_ROUTING_POINTS = undefined;
|
|
198
200
|
/** Pure routing point data kinds. */
|
|
199
201
|
exports.ROUTING_POINT_KINDS = ['linear', 'bezier-junction'];
|
|
200
202
|
/** Pure route data kinds. */
|
|
@@ -233,14 +235,29 @@ function calcElementAndRoute(element, routerRegistry) {
|
|
|
233
235
|
}
|
|
234
236
|
exports.calcElementAndRoute = calcElementAndRoute;
|
|
235
237
|
/**
|
|
236
|
-
* Helper function to calculate the route for a given {@link SRoutableElement}.
|
|
238
|
+
* Helper function to calculate the route for a given {@link SRoutableElement} by filtering duplicate points.
|
|
237
239
|
* @param element The element to translate.
|
|
238
240
|
* @param routerRegistry the edge router registry.
|
|
239
241
|
* @param pointKinds the routing point kinds that should be considered.
|
|
242
|
+
* @param tolerance the tolerance applied to a point's coordinates to determine duplicates.
|
|
240
243
|
* @returns The corresponding route for the given element.
|
|
241
244
|
*/
|
|
242
|
-
function calcRoute(element, routerRegistry, pointKinds) {
|
|
243
|
-
|
|
245
|
+
function calcRoute(element, routerRegistry, pointKinds = exports.ALL_ROUTING_POINTS, tolerance = Number.EPSILON) {
|
|
246
|
+
const route = routerRegistry.get(element.routerKind).route(element);
|
|
247
|
+
const calculatedRoute = [];
|
|
248
|
+
for (const point of route) {
|
|
249
|
+
// only include points we are actually interested in
|
|
250
|
+
if (pointKinds && !pointKinds.includes(point.kind)) {
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
// check if we are a duplicate based on coordinates in the already calculated route
|
|
254
|
+
if (exports.ROUTING_POINT_KINDS.includes(point.kind) &&
|
|
255
|
+
calculatedRoute.find(calculatedPoint => _glsp_sprotty_1.Point.maxDistance(point, calculatedPoint) < tolerance)) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
calculatedRoute.push(point);
|
|
259
|
+
}
|
|
260
|
+
return calculatedRoute;
|
|
244
261
|
}
|
|
245
262
|
exports.calcRoute = calcRoute;
|
|
246
263
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smodel-util.js","sourceRoot":"","sources":["../../src/utils/smodel-util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAqBuB;AASvB;;;;;;GAMG;AACH,SAAgB,MAAM,CAAI,KAAqB,EAAE,SAAkC;IAC/E,OAAO,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAsC,CAAC;AAC9E,CAAC;AAFD,wBAEC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAC1B,KAAqB,EACrB,SAAkC,EAClC,QAAmD;IAEnD,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC;AAND,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AAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC3E,CAAC;AAHD,8CAGC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAmD;IAChF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,KAAe,CAAC;KAC1B;SAAM;QACH,OAAQ,KAAa,CAAC,MAAM,CAAW,CAAC;KAC3C;AACL,CAAC;AAND,4CAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/client",
|
|
3
|
-
"version": "1.1.0-next.
|
|
3
|
+
"version": "1.1.0-next.86cf8e6.253+86cf8e6",
|
|
4
4
|
"description": "A sprotty-based client for GLSP",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eclipse",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"watch": "tsc -w"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@eclipse-glsp/protocol": "1.1.0-next.
|
|
50
|
+
"@eclipse-glsp/protocol": "1.1.0-next.86cf8e6.253+86cf8e6",
|
|
51
51
|
"autocompleter": "5.1.0",
|
|
52
52
|
"lodash": "4.17.21",
|
|
53
53
|
"sprotty": "0.14.0-next.02bbac0.26"
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "86cf8e6fd1253778579f5fb92b55e62dea216974"
|
|
64
64
|
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2023 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import {
|
|
17
|
+
AbstractEdgeRouter,
|
|
18
|
+
EdgeRouterRegistry,
|
|
19
|
+
LinearRouteOptions,
|
|
20
|
+
Point,
|
|
21
|
+
ResolvedHandleMove,
|
|
22
|
+
RoutedPoint,
|
|
23
|
+
SEdge,
|
|
24
|
+
SGraph,
|
|
25
|
+
SNode,
|
|
26
|
+
SRoutableElement,
|
|
27
|
+
SRoutingHandle,
|
|
28
|
+
routingModule
|
|
29
|
+
} from '@eclipse-glsp/client';
|
|
30
|
+
import { expect } from 'chai';
|
|
31
|
+
import { Container } from 'inversify';
|
|
32
|
+
import { ALL_ROUTING_POINTS, ROUTE_KINDS, ROUTING_POINT_KINDS, calcRoute } from './smodel-util';
|
|
33
|
+
|
|
34
|
+
class TestRouter extends AbstractEdgeRouter {
|
|
35
|
+
kind = 'test-router';
|
|
36
|
+
|
|
37
|
+
route(edge: SRoutableElement): RoutedPoint[] {
|
|
38
|
+
const pureRoute = edge.routingPoints.map(
|
|
39
|
+
(point, idx) =>
|
|
40
|
+
<RoutedPoint>{
|
|
41
|
+
kind: 'linear',
|
|
42
|
+
...point,
|
|
43
|
+
pointIndex: idx
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
return [
|
|
47
|
+
{ kind: 'source', ...edge.source!.position },
|
|
48
|
+
...pureRoute,
|
|
49
|
+
{ kind: 'bezier-control-after', x: 999, y: 999, pointIndex: pureRoute.length },
|
|
50
|
+
{ kind: 'target', ...edge.target!.position }
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
createRoutingHandles(edge: SRoutableElement): void {
|
|
55
|
+
// do nothing
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protected getOptions(edge: SRoutableElement): LinearRouteOptions {
|
|
59
|
+
return {
|
|
60
|
+
minimalPointDistance: 0,
|
|
61
|
+
selfEdgeOffset: 0,
|
|
62
|
+
standardDistance: 0
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
protected getInnerHandlePosition(edge: SRoutableElement, route: RoutedPoint[], handle: SRoutingHandle): Point | undefined {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected applyInnerHandleMoves(edge: SRoutableElement, moves: ResolvedHandleMove[]): void {
|
|
71
|
+
// do nothing
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
describe('SModel Util', () => {
|
|
76
|
+
describe('calcRoute', () => {
|
|
77
|
+
const graph = new SGraph();
|
|
78
|
+
|
|
79
|
+
const source = new SNode();
|
|
80
|
+
source.id = 'node0';
|
|
81
|
+
source.position = { x: 0, y: 0 };
|
|
82
|
+
source.size = { width: 0, height: 0 };
|
|
83
|
+
graph.add(source);
|
|
84
|
+
|
|
85
|
+
const target = new SNode();
|
|
86
|
+
target.id = 'node1';
|
|
87
|
+
target.position = { x: 100, y: 100 };
|
|
88
|
+
target.size = { width: 0, height: 0 };
|
|
89
|
+
graph.add(target);
|
|
90
|
+
|
|
91
|
+
const edge = new SEdge();
|
|
92
|
+
edge.id = 'edge0';
|
|
93
|
+
edge.sourceId = 'node0';
|
|
94
|
+
edge.targetId = 'node1';
|
|
95
|
+
graph.add(edge);
|
|
96
|
+
|
|
97
|
+
edge.routerKind = 'test-router';
|
|
98
|
+
|
|
99
|
+
const container = new Container();
|
|
100
|
+
container.load(routingModule);
|
|
101
|
+
|
|
102
|
+
const routerRegistry = container.get<EdgeRouterRegistry>(EdgeRouterRegistry);
|
|
103
|
+
routerRegistry.register('test-router', new TestRouter());
|
|
104
|
+
|
|
105
|
+
it('should return complete route', () => {
|
|
106
|
+
edge.source!.position = { x: 0, y: 0 };
|
|
107
|
+
edge.target!.position = { x: 100, y: 100 };
|
|
108
|
+
edge.routingPoints = [
|
|
109
|
+
{ x: 20, y: 20 },
|
|
110
|
+
{ x: 30, y: 30 },
|
|
111
|
+
{ x: 40, y: 40 }
|
|
112
|
+
];
|
|
113
|
+
const route = calcRoute(edge, routerRegistry);
|
|
114
|
+
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
115
|
+
{ x: 0, y: 0, kind: 'source' },
|
|
116
|
+
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
117
|
+
{ x: 30, y: 30, kind: 'linear', pointIndex: 1 },
|
|
118
|
+
{ x: 40, y: 40, kind: 'linear', pointIndex: 2 },
|
|
119
|
+
{ x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 3 },
|
|
120
|
+
{ x: 100, y: 100, kind: 'target' }
|
|
121
|
+
]);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should filter duplicates with same coordinates', () => {
|
|
125
|
+
edge.source!.position = { x: 0, y: 0 };
|
|
126
|
+
edge.target!.position = { x: 100, y: 100 };
|
|
127
|
+
edge.routingPoints = [
|
|
128
|
+
{ x: 20, y: 20 },
|
|
129
|
+
{ x: 20, y: 20 },
|
|
130
|
+
{ x: 30, y: 30 },
|
|
131
|
+
{ x: 40, y: 40 }
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
const route = calcRoute(edge, routerRegistry);
|
|
135
|
+
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
136
|
+
{ x: 0, y: 0, kind: 'source' },
|
|
137
|
+
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
138
|
+
{ x: 30, y: 30, kind: 'linear', pointIndex: 2 },
|
|
139
|
+
{ x: 40, y: 40, kind: 'linear', pointIndex: 3 },
|
|
140
|
+
{ x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 4 },
|
|
141
|
+
{ x: 100, y: 100, kind: 'target' }
|
|
142
|
+
]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should not filter source and target even if duplicate coordinates', () => {
|
|
146
|
+
edge.source!.position = { x: 0, y: 0 };
|
|
147
|
+
edge.target!.position = { x: 0, y: 0 };
|
|
148
|
+
edge.routingPoints = [
|
|
149
|
+
{ x: 20, y: 20 },
|
|
150
|
+
{ x: 30, y: 30 },
|
|
151
|
+
{ x: 40, y: 40 }
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
const route = calcRoute(edge, routerRegistry);
|
|
155
|
+
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
156
|
+
{ x: 0, y: 0, kind: 'source' },
|
|
157
|
+
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
158
|
+
{ x: 30, y: 30, kind: 'linear', pointIndex: 1 },
|
|
159
|
+
{ x: 40, y: 40, kind: 'linear', pointIndex: 2 },
|
|
160
|
+
{ x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 3 },
|
|
161
|
+
{ x: 0, y: 0, kind: 'target' }
|
|
162
|
+
]);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should filter duplicates with same coordinates but allow tolerance', () => {
|
|
166
|
+
edge.source!.position = { x: 0, y: 0 };
|
|
167
|
+
edge.target!.position = { x: 100, y: 100 };
|
|
168
|
+
edge.routingPoints = [
|
|
169
|
+
{ x: 20, y: 20 },
|
|
170
|
+
{ x: 25, y: 25 },
|
|
171
|
+
{ x: 30, y: 30 },
|
|
172
|
+
{ x: 40, y: 40 }
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
const route = calcRoute(edge, routerRegistry, ALL_ROUTING_POINTS, 10);
|
|
176
|
+
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
177
|
+
{ x: 0, y: 0, kind: 'source' },
|
|
178
|
+
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
179
|
+
{ x: 30, y: 30, kind: 'linear', pointIndex: 2 },
|
|
180
|
+
{ x: 40, y: 40, kind: 'linear', pointIndex: 3 },
|
|
181
|
+
{ x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 4 },
|
|
182
|
+
{ x: 100, y: 100, kind: 'target' }
|
|
183
|
+
]);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('should allow filtering based on point type: ROUTE_KINDS', () => {
|
|
187
|
+
edge.source!.position = { x: 0, y: 0 };
|
|
188
|
+
edge.target!.position = { x: 100, y: 100 };
|
|
189
|
+
edge.routingPoints = [
|
|
190
|
+
{ x: 20, y: 20 },
|
|
191
|
+
{ x: 30, y: 30 },
|
|
192
|
+
{ x: 40, y: 40 }
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
const route = calcRoute(edge, routerRegistry, ROUTE_KINDS);
|
|
196
|
+
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
197
|
+
{ x: 0, y: 0, kind: 'source' },
|
|
198
|
+
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
199
|
+
{ x: 30, y: 30, kind: 'linear', pointIndex: 1 },
|
|
200
|
+
{ x: 40, y: 40, kind: 'linear', pointIndex: 2 },
|
|
201
|
+
{ x: 100, y: 100, kind: 'target' }
|
|
202
|
+
]);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('should allow filtering based on point type: ROUTING_POINT_KINDS', () => {
|
|
206
|
+
edge.source!.position = { x: 0, y: 0 };
|
|
207
|
+
edge.target!.position = { x: 100, y: 100 };
|
|
208
|
+
edge.routingPoints = [
|
|
209
|
+
{ x: 20, y: 20 },
|
|
210
|
+
{ x: 30, y: 30 },
|
|
211
|
+
{ x: 40, y: 40 }
|
|
212
|
+
];
|
|
213
|
+
|
|
214
|
+
const route = calcRoute(edge, routerRegistry, ROUTING_POINT_KINDS);
|
|
215
|
+
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
216
|
+
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
217
|
+
{ x: 30, y: 30, kind: 'linear', pointIndex: 1 },
|
|
218
|
+
{ x: 40, y: 40, kind: 'linear', pointIndex: 2 }
|
|
219
|
+
]);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
});
|
package/src/utils/smodel-util.ts
CHANGED
|
@@ -232,6 +232,8 @@ export function toElementAndRoutingPoints(element: SRoutableElement): ElementAnd
|
|
|
232
232
|
newRoutingPoints: element.routingPoints
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
+
/** All routing points. */
|
|
236
|
+
export const ALL_ROUTING_POINTS = undefined;
|
|
235
237
|
|
|
236
238
|
/** Pure routing point data kinds. */
|
|
237
239
|
export const ROUTING_POINT_KINDS = ['linear', 'bezier-junction'];
|
|
@@ -272,18 +274,36 @@ export function calcElementAndRoute(element: SRoutableElement, routerRegistry?:
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
/**
|
|
275
|
-
* Helper function to calculate the route for a given {@link SRoutableElement}.
|
|
277
|
+
* Helper function to calculate the route for a given {@link SRoutableElement} by filtering duplicate points.
|
|
276
278
|
* @param element The element to translate.
|
|
277
279
|
* @param routerRegistry the edge router registry.
|
|
278
280
|
* @param pointKinds the routing point kinds that should be considered.
|
|
281
|
+
* @param tolerance the tolerance applied to a point's coordinates to determine duplicates.
|
|
279
282
|
* @returns The corresponding route for the given element.
|
|
280
283
|
*/
|
|
281
|
-
export function calcRoute(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
284
|
+
export function calcRoute(
|
|
285
|
+
element: SRoutableElement,
|
|
286
|
+
routerRegistry: EdgeRouterRegistry,
|
|
287
|
+
pointKinds: string[] | undefined = ALL_ROUTING_POINTS,
|
|
288
|
+
tolerance = Number.EPSILON
|
|
289
|
+
): RoutedPoint[] | undefined {
|
|
290
|
+
const route = routerRegistry.get(element.routerKind).route(element);
|
|
291
|
+
const calculatedRoute: RoutedPoint[] = [];
|
|
292
|
+
for (const point of route) {
|
|
293
|
+
// only include points we are actually interested in
|
|
294
|
+
if (pointKinds && !pointKinds.includes(point.kind)) {
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
// check if we are a duplicate based on coordinates in the already calculated route
|
|
298
|
+
if (
|
|
299
|
+
ROUTING_POINT_KINDS.includes(point.kind) &&
|
|
300
|
+
calculatedRoute.find(calculatedPoint => Point.maxDistance(point, calculatedPoint) < tolerance)
|
|
301
|
+
) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
calculatedRoute.push(point);
|
|
305
|
+
}
|
|
306
|
+
return calculatedRoute;
|
|
287
307
|
}
|
|
288
308
|
|
|
289
309
|
/**
|