#5237 Fix for weird line intersection

This commit is contained in:
Knut Sveidqvist 2024-08-22 16:29:23 +02:00
parent 53bff117aa
commit 19d46fc823
2 changed files with 24 additions and 14 deletions

View File

@ -429,19 +429,22 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod
const tail = startNode;
var head = endNode;
if (head.intersect && tail.intersect) {
points = points.slice(1, edge.points.length - 1);
points.unshift(tail.intersect(points[0]));
log.debug(
'Last point APA12',
edge.start,
'-->',
edge.end,
points[points.length - 1],
head,
head.intersect(points[points.length - 1])
);
points.push(head.intersect(points[points.length - 1]));
if (head.intersect && tail.intersect && points.length > 2) {
const initialStartPoint = Object.assign({}, points[0]);
const newEnd = head.intersect(points[points.length - 2]);
const newStart = tail.intersect(points[1]);
if (newStart.x && newStart.y) {
points.unshift(newStart);
} else {
points.unshift(initialStartPoint);
}
if (newEnd.x && newEnd.y) {
const lastPoint = points[points.length - 1];
if (lastPoint.x !== newEnd.x && lastPoint.y !== newEnd.y) {
points.push(newEnd);
}
}
}
if (edge.toCluster) {
log.info('to cluster abc88', clusterDb.get(edge.toCluster));

View File

@ -63,7 +63,14 @@ export const question = async (parent: SVGAElement, node: Node): Promise<SVGAEle
updateNodeBounds(node, polygon);
node.intersect = function (point) {
log.info('Intersect called SPLIT');
log.debug(
'APA12 Intersect called SPLIT\npoint:',
point,
'\nnode:\n',
node,
'\nres:',
intersect.polygon(node, points, point)
);
return intersect.polygon(node, points, point);
};