Skip to content

Commit

Permalink
Ignore bezier line segments in intersection finder
Browse files Browse the repository at this point in the history
eclipse-sprotty#287

Change-Id: I1ab416244ca42b09d51c3d2125378980e7dfd069
Signed-off-by: Philip Langer <[email protected]>
  • Loading branch information
planger committed May 10, 2022
1 parent ce52cc2 commit 1760ca2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,24 @@ export class IntersectionFinder implements IEdgeRoutePostprocessor {
*/
find(routing: EdgeRouting): Intersection[] {
const eventQueue = new TinyQueue<SweepEvent>(undefined, checkWhichEventIsLeft);
routing.routes.forEach((route, routeId) => addRoute(routeId, route, eventQueue));
routing.routes.forEach((route, routeId) => {
if (this.isSupportedRoute(route)) {
addRoute(routeId, route, eventQueue);
}
});
return runSweep(eventQueue);
}

/**
* Specifies whether or not a specific route should be included in this intersection search or not.
*
* As this intersection finder only supports linear line segments, this method only returns `true`
* for routes that only contain routed points, which are either 'source', 'target' or 'linear'.
*/
protected isSupportedRoute(route: RoutedPoint[]): boolean {
return route.find(point => point.kind !== 'source' && point.kind !== 'target' && point.kind !== 'linear') === undefined;
}

protected addToRouting(intersections: Intersection[], routing: EdgeRouting) {
for (const intersection of intersections) {
const routable1 = routing.get(intersection.routable1);
Expand Down
8 changes: 6 additions & 2 deletions packages/sprotty/src/graph/views.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,12 @@ export class PolylineEdgeViewWithGapsOnIntersections extends JumpingPolylineEdge
protected skipOffsetBefore = 3;
protected skipOffsetAfter = 3;

protected createJumpPath(intersectionPoint: Point, lineSegment: PointToPointLine): string {
return "";
protected shouldDrawLineJumpOnIntersection(currentLineSegment: PointToPointLine, otherLineSegment: PointToPointLine) {
return false;
}

protected shouldDrawLineGapOnIntersection(currentLineSegment: PointToPointLine, otherLineSegment: PointToPointLine) {
return Math.abs(currentLineSegment.slopeOrMax) >= Math.abs(otherLineSegment.slopeOrMax);
}

protected createGapPath(intersectionPoint: Point, lineSegment: PointToPointLine): string {
Expand Down

0 comments on commit 1760ca2

Please sign in to comment.