5237 Bugfix for intersect calculation in dagre

This commit is contained in:
Knut Sveidqvist 2024-06-11 14:47:47 +02:00
parent 5f110e4cde
commit 8cbceb611a
3 changed files with 21 additions and 21 deletions

View File

@ -96,7 +96,7 @@ end
</pre </pre
> >
<pre id="diagram" class="mermaid"> <pre id="diagram" class="mermaid">
flowchart LR flowchart RL
subgraph Apa["Apa"] subgraph Apa["Apa"]
subgraph Gorilla subgraph Gorilla
A["Start"] A["Start"]
@ -200,12 +200,12 @@ flowchart LR
if_state --> True : if n >= 0 if_state --> True : if n >= 0
</pre </pre
> >
<pre id="diagram" class="mermaid2"> <pre id="diagram" class="mermaid">
%%{init: {"layout": "dagre", "mergeEdges": true} }%% %%{init: {"layout": "dagre", "mergeEdges": true} }%%
stateDiagram stateDiagram
direction TB direction TB
State T1 { State T1 {
T11 --> T12 T12--> T11
} }
T1 --> T2 T1 --> T2
T11 --> T2 T11 --> T2
@ -221,16 +221,17 @@ State T1 {
} }
</pre </pre
> >
<pre id="diagram" class="mermaid2"> <pre id="diagram" class="mermaid">
%%{init: {"layout": "elk", "mergeEdges": true} }%% %%{init: {"layouts": "elk2", "mergeEdges": true} }%%
stateDiagram stateDiagram
direction TB State S1 {
State T1 { direction TB
T11 S11
} }
S1 --> S2
</pre </pre
> >
<pre id="diagram" class="mermaid2"> <pre id="diagram" class="mermaid">
%%{init: {"layout": "elk", "mergeEdges": true} }%% %%{init: {"layout": "elk", "mergeEdges": true} }%%
stateDiagram stateDiagram
State T1 { State T1 {
@ -240,7 +241,7 @@ State T1 {
} }
</pre </pre
> >
<pre id="diagram" class="mermaid2"> <pre id="diagram" class="mermaid">
%%{init: {"layout": "elk", "mergeEdges": true} }%% %%{init: {"layout": "elk", "mergeEdges": true} }%%
stateDiagram stateDiagram
[*] --> T1 [*] --> T1
@ -294,7 +295,7 @@ stateDiagram-v2
// handdrawnSeed: 12, // handdrawnSeed: 12,
// look: 'handdrawn', // look: 'handdrawn',
// 'elk.nodePlacement.strategy': 'NETWORK_SIMPLEX', // 'elk.nodePlacement.strategy': 'NETWORK_SIMPLEX',
// layout: 'dagre', layout: 'dagre',
// layout: 'elk', // layout: 'elk',
// layout: 'fixed', // layout: 'fixed',
// htmlLabels: false, // htmlLabels: false,

View File

@ -162,7 +162,7 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
node.x -= 8; node.x -= 8;
log.info( log.info(
'A tainted cluster node XBX', 'A pure cluster node XBX',
v, v,
node.id, node.id,
node.width, node.width,
@ -188,7 +188,7 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
// A cluster in the non-recursive way // A cluster in the non-recursive way
log.info( log.info(
'A pure cluster node with children XBX', 'A tainted cluster node with children XBX',
v, v,
node.id, node.id,
node.width, node.width,

View File

@ -272,7 +272,6 @@ export const intersection = (node, outsidePoint, insidePoint) => {
// log.warn(); // log.warn();
if (Math.abs(y - outsidePoint.y) * w > Math.abs(x - outsidePoint.x) * h) { if (Math.abs(y - outsidePoint.y) * w > Math.abs(x - outsidePoint.x) * h) {
// Intersection is top or bottom of rect. // Intersection is top or bottom of rect.
// let q = insidePoint.y < outsidePoint.y ? outsidePoint.y - h - y : y - h - outsidePoint.y;
let q = insidePoint.y < outsidePoint.y ? outsidePoint.y - h - y : y - h - outsidePoint.y; let q = insidePoint.y < outsidePoint.y ? outsidePoint.y - h - y : y - h - outsidePoint.y;
r = (R * q) / Q; r = (R * q) / Q;
const res = { const res = {
@ -280,10 +279,10 @@ export const intersection = (node, outsidePoint, insidePoint) => {
y: insidePoint.y < outsidePoint.y ? insidePoint.y + Q - q : insidePoint.y - Q + q, y: insidePoint.y < outsidePoint.y ? insidePoint.y + Q - q : insidePoint.y - Q + q,
}; };
if (r === 0) { // if (r === 0) {
res.x = outsidePoint.x; // res.x = outsidePoint.x;
res.y = outsidePoint.y; // res.y = outsidePoint.y;
} // }
if (R === 0) { if (R === 0) {
res.x = outsidePoint.x; res.x = outsidePoint.x;
} }
@ -291,7 +290,7 @@ export const intersection = (node, outsidePoint, insidePoint) => {
res.y = outsidePoint.y; res.y = outsidePoint.y;
} }
log.warn(`abc89 top/bot calc, Q ${Q}, q ${q}, R ${R}, r ${r}`, res); log.warn(`abc89 top/bot calc, Q ${Q}, q ${q}, R ${R}, r ${r}`, res, 'apa');
return res; return res;
} else { } else {
@ -346,7 +345,7 @@ const cutPathAtIntersect = (_points, boundaryNode) => {
// Calc the intersection coord between the point anf the last point outside the rect // Calc the intersection coord between the point anf the last point outside the rect
const inter = intersection(boundaryNode, lastPointOutside, point); const inter = intersection(boundaryNode, lastPointOutside, point);
log.warn('abc88 inside', point, lastPointOutside, inter); log.warn('abc88 inside', point, lastPointOutside, inter);
log.warn('abc88 intersection', inter); log.warn('abc88 intersection', inter, boundaryNode);
// // Check case where the intersection is the same as the last point // // Check case where the intersection is the same as the last point
let pointPresent = false; let pointPresent = false;