@knowvah/dot-engine 2.6.0 → 2.6.2
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/dist/common/bezier-arrows.d.ts +14 -0
- package/dist/common/bezier-arrows.d.ts.map +1 -0
- package/dist/common/pointset.d.ts +35 -0
- package/dist/common/pointset.d.ts.map +1 -0
- package/dist/common/postproc.d.ts.map +1 -1
- package/dist/common/splines-clip.d.ts.map +1 -1
- package/dist/index.js +156 -80
- package/dist/index.js.map +4 -4
- package/dist/layout/dot/splines.d.ts.map +1 -1
- package/dist/layout/pack/index.d.ts.map +1 -1
- package/dist/layout/pack/poly-place.d.ts.map +1 -1
- package/dist/model/geom.d.ts +9 -0
- package/dist/model/geom.d.ts.map +1 -1
- package/dist/render/dot.d.ts.map +1 -1
- package/dist/render/svg-edge-arrows.d.ts +30 -0
- package/dist/render/svg-edge-arrows.d.ts.map +1 -0
- package/dist/render/svg-helpers.d.ts.map +1 -1
- package/dist/render.js +156 -80
- package/dist/render.js.map +4 -4
- package/package.json +2 -2
- package/src/common/bezier-arrows.ts +58 -0
- package/src/common/pointset.ts +73 -0
- package/src/common/postproc.ts +9 -13
- package/src/common/splines-clip.ts +12 -8
- package/src/layout/dot/splines.ts +4 -0
- package/src/layout/pack/index.ts +4 -0
- package/src/layout/pack/poly-place.ts +42 -47
- package/src/model/geom.ts +10 -0
- package/src/render/dot.ts +6 -0
- package/src/render/svg-edge-arrows.ts +54 -0
- package/src/render/svg-helpers.ts +10 -44
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Edge } from '../model/edge.js';
|
|
2
|
+
import type { Bezier } from '../model/geom.js';
|
|
3
|
+
import type { ArrowDrawOp } from './arrows-types.js';
|
|
4
|
+
/** Edge end: `tail` pairs with a bezier's sflag/sp, `head` with eflag/ep. */
|
|
5
|
+
export type ArrowEnd = 'head' | 'tail';
|
|
6
|
+
/**
|
|
7
|
+
* The ops C's per-bezier loop draws right after `bz` for `end`, when the edge
|
|
8
|
+
* has several beziers flagged at that end; undefined otherwise (the caller's
|
|
9
|
+
* edge-level path applies).
|
|
10
|
+
*/
|
|
11
|
+
export declare function bezierEndOps(e: Edge, bz: Bezier, end: ArrowEnd): ArrowDrawOp[] | undefined;
|
|
12
|
+
/** Every arrow to draw for `end`, one op list per arrow, in bezier order. */
|
|
13
|
+
export declare function endArrowOps(e: Edge, end: ArrowEnd): ArrowDrawOp[][];
|
|
14
|
+
//# sourceMappingURL=bezier-arrows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bezier-arrows.d.ts","sourceRoot":"","sources":["../../src/common/bezier-arrows.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,6EAA6E;AAC7E,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAkBvC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,GAAG,WAAW,EAAE,GAAG,SAAS,CAG1F;AAED,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAG,WAAW,EAAE,EAAE,CAKnE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set of points, compared exactly on their double coordinates.
|
|
3
|
+
*
|
|
4
|
+
* C keeps the points in an ordered cdt dictionary (`Dtoset`) under `cmppair`:
|
|
5
|
+
* x first, then y, plain double `<`/`>`, so -0 and 0 are one key. Here the
|
|
6
|
+
* dictionary is a two-level `Map` keyed on the coordinates themselves. Map
|
|
7
|
+
* keys use SameValueZero, which also makes -0 and 0 one key. A lookup
|
|
8
|
+
* allocates nothing; packing calls it once per cell per candidate position.
|
|
9
|
+
*
|
|
10
|
+
* @see lib/common/pointset.c
|
|
11
|
+
*/
|
|
12
|
+
import type { Point } from '../model/geom.js';
|
|
13
|
+
/** @see lib/common/pointset.h:PointSet */
|
|
14
|
+
export declare class PointSet {
|
|
15
|
+
private readonly byX;
|
|
16
|
+
private n;
|
|
17
|
+
/**
|
|
18
|
+
* Insert (x, y). A duplicate keeps the point inserted first, as `dtinsert`
|
|
19
|
+
* returns the existing object and the new one is freed.
|
|
20
|
+
* @see lib/common/pointset.c:addPS
|
|
21
|
+
*/
|
|
22
|
+
addPS(x: number, y: number): void;
|
|
23
|
+
/** @see lib/common/pointset.c:inPS */
|
|
24
|
+
inPS(pt: Point): boolean;
|
|
25
|
+
/** @see lib/common/pointset.c:isInPS */
|
|
26
|
+
isInPS(x: number, y: number): boolean;
|
|
27
|
+
/** @see lib/common/pointset.c:sizeOf */
|
|
28
|
+
sizeOf(): number;
|
|
29
|
+
/**
|
|
30
|
+
* The points in dictionary order (`dtflatten` walks the ordered set).
|
|
31
|
+
* @see lib/common/pointset.c:pointsOf
|
|
32
|
+
*/
|
|
33
|
+
pointsOf(): Point[];
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=pointset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointset.d.ts","sourceRoot":"","sources":["../../src/common/pointset.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAW9C,0CAA0C;AAC1C,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAyC;IAC7D,OAAO,CAAC,CAAC,CAAK;IAEd;;;;OAIG;IACH,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAWjC,sCAAsC;IACtC,IAAI,CAAC,EAAE,EAAE,KAAK,GAAG,OAAO;IAIxB,wCAAwC;IACxC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;IAIrC,wCAAwC;IACxC,MAAM,IAAI,MAAM;IAIhB;;;OAGG;IACH,QAAQ,IAAI,KAAK,EAAE;CAOpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postproc.d.ts","sourceRoot":"","sources":["../../src/common/postproc.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"postproc.d.ts","sourceRoot":"","sources":["../../src/common/postproc.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAmJ/C;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAQ3D;AAyMD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAO9E;AAOD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,UAAO,GAAG,IAAI,CAiBrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"splines-clip.d.ts","sourceRoot":"","sources":["../../src/common/splines-clip.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAO,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAqB,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAS7C,gFAAgF;AAChF,eAAO,MAAM,QAAQ,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"splines-clip.d.ts","sourceRoot":"","sources":["../../src/common/splines-clip.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAO,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAqB,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAS7C,gFAAgF;AAChF,eAAO,MAAM,QAAQ,IAAI,CAAC;AAqa1B,2CAA2C;AAC3C,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAQrD;AAMD,iDAAiD;AACjD,wBAAgB,cAAc,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CA6BlG;AAED;;;GAGG;AACH,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAGxF,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAEvD"}
|
package/dist/index.js
CHANGED
|
@@ -18589,8 +18589,8 @@ var SplineClipHelper = class _SplineClipHelper {
|
|
|
18589
18589
|
sflag,
|
|
18590
18590
|
eflag
|
|
18591
18591
|
);
|
|
18592
|
-
if (sflag) _SplineClipHelper.stashArrow(orig, newspl.sp, ps[bounds.start], true, startEnd);
|
|
18593
|
-
if (eflag) _SplineClipHelper.stashArrow(orig, newspl.ep, ps[bounds.end + 3], false, endEnd);
|
|
18592
|
+
if (sflag) _SplineClipHelper.stashArrow(orig, newspl, newspl.sp, ps[bounds.start], true, startEnd);
|
|
18593
|
+
if (eflag) _SplineClipHelper.stashArrow(orig, newspl, newspl.ep, ps[bounds.end + 3], false, endEnd);
|
|
18594
18594
|
}
|
|
18595
18595
|
return;
|
|
18596
18596
|
}
|
|
@@ -18604,7 +18604,7 @@ var SplineClipHelper = class _SplineClipHelper {
|
|
|
18604
18604
|
sflag,
|
|
18605
18605
|
startEnd
|
|
18606
18606
|
);
|
|
18607
|
-
_SplineClipHelper.stashArrow(orig, newspl.sp, ps[bounds.start], true, startEnd);
|
|
18607
|
+
_SplineClipHelper.stashArrow(orig, newspl, newspl.sp, ps[bounds.start], true, startEnd);
|
|
18608
18608
|
}
|
|
18609
18609
|
if (eflag) {
|
|
18610
18610
|
bounds.end = _SplineClipHelper.arrowEndClip(
|
|
@@ -18616,7 +18616,7 @@ var SplineClipHelper = class _SplineClipHelper {
|
|
|
18616
18616
|
eflag,
|
|
18617
18617
|
endEnd
|
|
18618
18618
|
);
|
|
18619
|
-
_SplineClipHelper.stashArrow(orig, newspl.ep, ps[bounds.end + 3], false, endEnd);
|
|
18619
|
+
_SplineClipHelper.stashArrow(orig, newspl, newspl.ep, ps[bounds.end + 3], false, endEnd);
|
|
18620
18620
|
}
|
|
18621
18621
|
}
|
|
18622
18622
|
/**
|
|
@@ -18714,13 +18714,22 @@ var SplineClipHelper = class _SplineClipHelper {
|
|
|
18714
18714
|
spl.sp = p;
|
|
18715
18715
|
}
|
|
18716
18716
|
}
|
|
18717
|
-
/**
|
|
18718
|
-
|
|
18717
|
+
/**
|
|
18718
|
+
* Record an arrow on the edge end and on the bezier being installed. The
|
|
18719
|
+
* edge slot holds the latest arrow; the bezier keeps its own, since C draws
|
|
18720
|
+
* one per flagged bezier (see common/bezier-arrows.ts).
|
|
18721
|
+
*/
|
|
18722
|
+
static stashArrow(e, bz, tip2, base, isTail, attrEnd) {
|
|
18719
18723
|
const dir = { x: base.x - tip2.x, y: base.y - tip2.y };
|
|
18720
18724
|
const end = attrEnd ?? (isTail ? "tail" : "head");
|
|
18721
18725
|
const ops = arrowDrawOpsForEnd(e, end, tip2, dir, _SplineClipHelper.renderPenwidth(e));
|
|
18722
|
-
if (isTail)
|
|
18723
|
-
|
|
18726
|
+
if (isTail) {
|
|
18727
|
+
e.info.tailArrowOps = ops;
|
|
18728
|
+
bz.sArrowOps = ops;
|
|
18729
|
+
} else {
|
|
18730
|
+
e.info.headArrowOps = ops;
|
|
18731
|
+
bz.eArrowOps = ops;
|
|
18732
|
+
}
|
|
18724
18733
|
}
|
|
18725
18734
|
static clipSide(n, box, ps, pn, tail) {
|
|
18726
18735
|
const fn = _SplineClipHelper.getInsideFn(n);
|
|
@@ -25497,6 +25506,47 @@ function orthoRoundedPolylines(pts, radius) {
|
|
|
25497
25506
|
return [...segmentPolylines(pts, corners), ...cornerArcPolylines(corners, radius)];
|
|
25498
25507
|
}
|
|
25499
25508
|
|
|
25509
|
+
// src/common/bezier-arrows.ts
|
|
25510
|
+
var flagOf = (bz, end) => end === "head" ? bz.eflag : bz.sflag;
|
|
25511
|
+
var ownOps = (bz, end) => end === "head" ? bz.eArrowOps : bz.sArrowOps;
|
|
25512
|
+
var edgeOps = (e, end) => end === "head" ? e.info.headArrowOps : e.info.tailArrowOps;
|
|
25513
|
+
function flaggedBeziers(e, end) {
|
|
25514
|
+
const list = e.info.spl?.list ?? [];
|
|
25515
|
+
return list.filter((bz) => bz !== void 0 && flagOf(bz, end) !== 0);
|
|
25516
|
+
}
|
|
25517
|
+
function multiFlagged(e, end) {
|
|
25518
|
+
return flaggedBeziers(e, end).length > 1;
|
|
25519
|
+
}
|
|
25520
|
+
function bezierEndOps(e, bz, end) {
|
|
25521
|
+
if (flagOf(bz, end) === 0 || !multiFlagged(e, end)) return void 0;
|
|
25522
|
+
return ownOps(bz, end) ?? edgeOps(e, end);
|
|
25523
|
+
}
|
|
25524
|
+
function endArrowOps(e, end) {
|
|
25525
|
+
const lists = multiFlagged(e, end) ? flaggedBeziers(e, end).map((bz) => ownOps(bz, end) ?? edgeOps(e, end)) : [edgeOps(e, end)];
|
|
25526
|
+
return lists.filter((ops) => ops !== void 0 && ops.length > 0);
|
|
25527
|
+
}
|
|
25528
|
+
|
|
25529
|
+
// src/render/svg-edge-arrows.ts
|
|
25530
|
+
function emitBezierEndArrow(e, bz, end, st, p) {
|
|
25531
|
+
const tail = end === "tail";
|
|
25532
|
+
const flag = tail ? bz.sflag : bz.eflag;
|
|
25533
|
+
const done = tail ? st.tailDone : st.headDone;
|
|
25534
|
+
const edgeOps2 = tail ? e.info.tailArrowOps : e.info.headArrowOps;
|
|
25535
|
+
const ops = bezierEndOps(e, bz, end) ?? (flag !== 0 && !done && edgeOps2?.length ? edgeOps2 : void 0);
|
|
25536
|
+
if (ops === void 0) return;
|
|
25537
|
+
emitArrowOps(ops, p.penColor, p.job, p.pw, p.opacity);
|
|
25538
|
+
if (tail) st.tailDone = true;
|
|
25539
|
+
else st.headDone = true;
|
|
25540
|
+
}
|
|
25541
|
+
function emitRemainingArrows(e, st, p) {
|
|
25542
|
+
if (!st.tailDone && e.info.tailArrowOps?.length) {
|
|
25543
|
+
emitArrowOps(e.info.tailArrowOps, p.penColor, p.job, p.pw, p.opacity);
|
|
25544
|
+
}
|
|
25545
|
+
if (!st.headDone && e.info.headArrowOps?.length) {
|
|
25546
|
+
emitArrowOps(e.info.headArrowOps, p.penColor, p.job, p.pw, p.opacity);
|
|
25547
|
+
}
|
|
25548
|
+
}
|
|
25549
|
+
|
|
25500
25550
|
// src/render/svg-graph.ts
|
|
25501
25551
|
var SVG_XML_DECL = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n';
|
|
25502
25552
|
var SVG_DOCTYPE = '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"\n "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n';
|
|
@@ -26028,40 +26078,21 @@ function svgEdgePath(e, job) {
|
|
|
26028
26078
|
if (spl === void 0 || spl.size === 0) return;
|
|
26029
26079
|
const obj = job.obj;
|
|
26030
26080
|
const stroke = obj !== null ? paintStr(obj, false) : "black";
|
|
26081
|
+
const paint = {
|
|
26082
|
+
job,
|
|
26083
|
+
penColor: stroke,
|
|
26084
|
+
opacity: obj !== null ? colorOpacity(obj.penColor) : null,
|
|
26085
|
+
pw: obj !== null ? obj.penWidth : 1
|
|
26086
|
+
};
|
|
26031
26087
|
const st = { tailDone: false, headDone: false };
|
|
26032
26088
|
for (let si = 0; si < spl.size; si++) {
|
|
26033
26089
|
const bz = spl.list[si];
|
|
26034
26090
|
if (bz === void 0 || bz.size < 4) continue;
|
|
26035
26091
|
emitOneBezierPath(bz, stroke, job);
|
|
26036
|
-
|
|
26037
|
-
|
|
26038
|
-
emitRemainingArrows(e, job, st);
|
|
26039
|
-
}
|
|
26040
|
-
function emitBezierArrows(e, bz, job, st) {
|
|
26041
|
-
const obj = job.obj;
|
|
26042
|
-
const penColor = obj !== null ? paintStr(obj, false) : "black";
|
|
26043
|
-
const opacity = obj !== null ? colorOpacity(obj.penColor) : null;
|
|
26044
|
-
const pw = obj !== null ? obj.penWidth : 1;
|
|
26045
|
-
if (bz.sflag !== 0 && !st.tailDone && e.info.tailArrowOps?.length) {
|
|
26046
|
-
emitArrowOps(e.info.tailArrowOps, penColor, job, pw, opacity);
|
|
26047
|
-
st.tailDone = true;
|
|
26048
|
-
}
|
|
26049
|
-
if (bz.eflag !== 0 && !st.headDone && e.info.headArrowOps?.length) {
|
|
26050
|
-
emitArrowOps(e.info.headArrowOps, penColor, job, pw, opacity);
|
|
26051
|
-
st.headDone = true;
|
|
26052
|
-
}
|
|
26053
|
-
}
|
|
26054
|
-
function emitRemainingArrows(e, job, st) {
|
|
26055
|
-
const obj = job.obj;
|
|
26056
|
-
const penColor = obj !== null ? paintStr(obj, false) : "black";
|
|
26057
|
-
const opacity = obj !== null ? colorOpacity(obj.penColor) : null;
|
|
26058
|
-
const pw = obj !== null ? obj.penWidth : 1;
|
|
26059
|
-
if (!st.tailDone && e.info.tailArrowOps?.length) {
|
|
26060
|
-
emitArrowOps(e.info.tailArrowOps, penColor, job, pw, opacity);
|
|
26061
|
-
}
|
|
26062
|
-
if (!st.headDone && e.info.headArrowOps?.length) {
|
|
26063
|
-
emitArrowOps(e.info.headArrowOps, penColor, job, pw, opacity);
|
|
26092
|
+
emitBezierEndArrow(e, bz, "tail", st, paint);
|
|
26093
|
+
emitBezierEndArrow(e, bz, "head", st, paint);
|
|
26064
26094
|
}
|
|
26095
|
+
emitRemainingArrows(e, st, paint);
|
|
26065
26096
|
}
|
|
26066
26097
|
function emitOneBezierPath(bz, stroke, job) {
|
|
26067
26098
|
const obj = job.obj;
|
|
@@ -33420,6 +33451,10 @@ function mapEdge(e) {
|
|
|
33420
33451
|
mapLabelPos(e.info.tail_label);
|
|
33421
33452
|
e.info.headArrowOps = mapArrowOps(e.info.headArrowOps);
|
|
33422
33453
|
e.info.tailArrowOps = mapArrowOps(e.info.tailArrowOps);
|
|
33454
|
+
for (const bz of spl.list) {
|
|
33455
|
+
if (bz.sArrowOps) bz.sArrowOps = mapArrowOps(bz.sArrowOps);
|
|
33456
|
+
if (bz.eArrowOps) bz.eArrowOps = mapArrowOps(bz.eArrowOps);
|
|
33457
|
+
}
|
|
33423
33458
|
}
|
|
33424
33459
|
function rotateBb(bb, rankdir) {
|
|
33425
33460
|
if (rankdir === RANKDIR_LR || rankdir === RANKDIR_BT) {
|
|
@@ -37345,6 +37380,11 @@ function swapBezier(b) {
|
|
|
37345
37380
|
const sp = b.sp;
|
|
37346
37381
|
b.sp = b.ep;
|
|
37347
37382
|
b.ep = sp;
|
|
37383
|
+
if (b.sArrowOps !== void 0 || b.eArrowOps !== void 0) {
|
|
37384
|
+
const so = b.sArrowOps;
|
|
37385
|
+
b.sArrowOps = b.eArrowOps;
|
|
37386
|
+
b.eArrowOps = so;
|
|
37387
|
+
}
|
|
37348
37388
|
}
|
|
37349
37389
|
function swapSpline(s) {
|
|
37350
37390
|
s.list.reverse();
|
|
@@ -38048,6 +38088,57 @@ function polyRects(ng, bbs, pinfo) {
|
|
|
38048
38088
|
return places;
|
|
38049
38089
|
}
|
|
38050
38090
|
|
|
38091
|
+
// src/common/pointset.ts
|
|
38092
|
+
function cmpPair(a, b) {
|
|
38093
|
+
if (a.x > b.x) return 1;
|
|
38094
|
+
if (a.x < b.x) return -1;
|
|
38095
|
+
if (a.y > b.y) return 1;
|
|
38096
|
+
if (a.y < b.y) return -1;
|
|
38097
|
+
return 0;
|
|
38098
|
+
}
|
|
38099
|
+
var PointSet = class {
|
|
38100
|
+
byX = /* @__PURE__ */ new Map();
|
|
38101
|
+
n = 0;
|
|
38102
|
+
/**
|
|
38103
|
+
* Insert (x, y). A duplicate keeps the point inserted first, as `dtinsert`
|
|
38104
|
+
* returns the existing object and the new one is freed.
|
|
38105
|
+
* @see lib/common/pointset.c:addPS
|
|
38106
|
+
*/
|
|
38107
|
+
addPS(x, y) {
|
|
38108
|
+
let col = this.byX.get(x);
|
|
38109
|
+
if (col === void 0) {
|
|
38110
|
+
col = /* @__PURE__ */ new Map();
|
|
38111
|
+
this.byX.set(x, col);
|
|
38112
|
+
}
|
|
38113
|
+
if (col.has(y)) return;
|
|
38114
|
+
col.set(y, { x, y });
|
|
38115
|
+
this.n++;
|
|
38116
|
+
}
|
|
38117
|
+
/** @see lib/common/pointset.c:inPS */
|
|
38118
|
+
inPS(pt) {
|
|
38119
|
+
return this.byX.get(pt.x)?.has(pt.y) ?? false;
|
|
38120
|
+
}
|
|
38121
|
+
/** @see lib/common/pointset.c:isInPS */
|
|
38122
|
+
isInPS(x, y) {
|
|
38123
|
+
return this.byX.get(x)?.has(y) ?? false;
|
|
38124
|
+
}
|
|
38125
|
+
/** @see lib/common/pointset.c:sizeOf */
|
|
38126
|
+
sizeOf() {
|
|
38127
|
+
return this.n;
|
|
38128
|
+
}
|
|
38129
|
+
/**
|
|
38130
|
+
* The points in dictionary order (`dtflatten` walks the ordered set).
|
|
38131
|
+
* @see lib/common/pointset.c:pointsOf
|
|
38132
|
+
*/
|
|
38133
|
+
pointsOf() {
|
|
38134
|
+
const pts = [];
|
|
38135
|
+
for (const col of this.byX.values()) {
|
|
38136
|
+
for (const p of col.values()) pts.push({ x: p.x, y: p.y });
|
|
38137
|
+
}
|
|
38138
|
+
return pts.sort(cmpPair);
|
|
38139
|
+
}
|
|
38140
|
+
};
|
|
38141
|
+
|
|
38051
38142
|
// src/layout/pack/poly-place.ts
|
|
38052
38143
|
var C_AVG = 100;
|
|
38053
38144
|
function grid(x, s) {
|
|
@@ -38059,21 +38150,6 @@ function cval2(v, s) {
|
|
|
38059
38150
|
function cell(p, s) {
|
|
38060
38151
|
return { x: cval2(p.x, s), y: cval2(p.y, s) };
|
|
38061
38152
|
}
|
|
38062
|
-
var PointSet = class {
|
|
38063
|
-
m = /* @__PURE__ */ new Map();
|
|
38064
|
-
add(x, y) {
|
|
38065
|
-
this.m.set(`${x},${y}`, { x, y });
|
|
38066
|
-
}
|
|
38067
|
-
has(p) {
|
|
38068
|
-
return this.m.has(`${p.x},${p.y}`);
|
|
38069
|
-
}
|
|
38070
|
-
points() {
|
|
38071
|
-
return [...this.m.values()];
|
|
38072
|
-
}
|
|
38073
|
-
get size() {
|
|
38074
|
-
return this.m.size;
|
|
38075
|
-
}
|
|
38076
|
-
};
|
|
38077
38153
|
function computeStep2(bbs, margin) {
|
|
38078
38154
|
const a = C_AVG * bbs.length - 1;
|
|
38079
38155
|
let b = 0;
|
|
@@ -38091,7 +38167,7 @@ function computeStep2(bbs, margin) {
|
|
|
38091
38167
|
function lineXDominant(st, ps) {
|
|
38092
38168
|
let d = st.ay - (st.ax >> 1);
|
|
38093
38169
|
for (; ; ) {
|
|
38094
|
-
ps.
|
|
38170
|
+
ps.addPS(st.x, st.y);
|
|
38095
38171
|
if (st.x === st.x2) return;
|
|
38096
38172
|
if (d >= 0) {
|
|
38097
38173
|
st.y += st.sy;
|
|
@@ -38104,7 +38180,7 @@ function lineXDominant(st, ps) {
|
|
|
38104
38180
|
function lineYDominant(st, ps) {
|
|
38105
38181
|
let d = st.ax - (st.ay >> 1);
|
|
38106
38182
|
for (; ; ) {
|
|
38107
|
-
ps.
|
|
38183
|
+
ps.addPS(st.x, st.y);
|
|
38108
38184
|
if (st.y === st.y2) return;
|
|
38109
38185
|
if (d >= 0) {
|
|
38110
38186
|
st.x += st.sx;
|
|
@@ -38136,7 +38212,7 @@ function fillLine(p, q, ps) {
|
|
|
38136
38212
|
}
|
|
38137
38213
|
function fillRect(LL, UR, ps) {
|
|
38138
38214
|
for (let x = LL.x; x <= UR.x; x++) {
|
|
38139
|
-
for (let y = LL.y; y <= UR.y; y++) ps.
|
|
38215
|
+
for (let y = LL.y; y <= UR.y; y++) ps.addPS(x, y);
|
|
38140
38216
|
}
|
|
38141
38217
|
}
|
|
38142
38218
|
function roundedCell(p, ssize) {
|
|
@@ -38188,7 +38264,7 @@ function genBox3(bb0, ssize, margin, center) {
|
|
|
38188
38264
|
const UR = roundedCell({ x: center.x + bbW + margin, y: center.y + bbH + margin }, ssize);
|
|
38189
38265
|
fillRect(LL, UR, ps);
|
|
38190
38266
|
return {
|
|
38191
|
-
cells: ps.
|
|
38267
|
+
cells: ps.pointsOf(),
|
|
38192
38268
|
perim: grid(bb0.ur.x - bb0.ll.x + 2 * margin, ssize) + grid(bb0.ur.y - bb0.ll.y + 2 * margin, ssize),
|
|
38193
38269
|
index: 0
|
|
38194
38270
|
};
|
|
@@ -38220,42 +38296,38 @@ function genPoly(root, g, bb, ssize, pinfo, center) {
|
|
|
38220
38296
|
};
|
|
38221
38297
|
for (const n of g.nodes.values()) coverNode(n, ctx);
|
|
38222
38298
|
return {
|
|
38223
|
-
cells: ps.
|
|
38299
|
+
cells: ps.pointsOf(),
|
|
38224
38300
|
perim: grid(bb.ur.x - bb.ll.x + 2 * pinfo.margin, ssize) + grid(bb.ur.y - bb.ll.y + 2 * pinfo.margin, ssize),
|
|
38225
38301
|
index: 0
|
|
38226
38302
|
};
|
|
38227
38303
|
}
|
|
38228
38304
|
function fits2(x, y, info, ctx) {
|
|
38229
38305
|
for (const c of info.cells) {
|
|
38230
|
-
if (ctx.ps.
|
|
38306
|
+
if (ctx.ps.isInPS(c.x + x, c.y + y)) return false;
|
|
38231
38307
|
}
|
|
38232
38308
|
const bb = ctx.bbs[info.index];
|
|
38233
38309
|
const LL = { x: cround(bb.ll.x), y: cround(bb.ll.y) };
|
|
38234
38310
|
ctx.places[info.index] = { x: Math.imul(ctx.step, x) - LL.x, y: Math.imul(ctx.step, y) - LL.y };
|
|
38235
|
-
for (const c of info.cells) ctx.ps.
|
|
38311
|
+
for (const c of info.cells) ctx.ps.addPS(c.x + x, c.y + y);
|
|
38236
38312
|
return true;
|
|
38237
38313
|
}
|
|
38238
|
-
function
|
|
38239
|
-
|
|
38240
|
-
|
|
38241
|
-
|
|
38242
|
-
|
|
38243
|
-
|
|
38244
|
-
|
|
38245
|
-
|
|
38246
|
-
|
|
38247
|
-
|
|
38248
|
-
|
|
38249
|
-
|
|
38250
|
-
|
|
38251
|
-
for (; x < bnd; x++) yield [x, y];
|
|
38252
|
-
for (; y < bnd; y++) yield [x, y];
|
|
38253
|
-
for (; x > -bnd; x--) yield [x, y];
|
|
38254
|
-
for (; y > 0; y--) yield [x, y];
|
|
38314
|
+
function leg(c, dx, dy, end, info, ctx) {
|
|
38315
|
+
for (; (dx !== 0 ? c.x : c.y) !== end; c.x += dx, c.y += dy) {
|
|
38316
|
+
if (fits2(c.x, c.y, info, ctx)) return true;
|
|
38317
|
+
}
|
|
38318
|
+
return false;
|
|
38319
|
+
}
|
|
38320
|
+
function ringWide(bnd, info, ctx) {
|
|
38321
|
+
const c = { x: 0, y: -bnd };
|
|
38322
|
+
return leg(c, 1, 0, bnd, info, ctx) || leg(c, 0, 1, bnd, info, ctx) || leg(c, -1, 0, -bnd, info, ctx) || leg(c, 0, -1, -bnd, info, ctx) || leg(c, 1, 0, 0, info, ctx);
|
|
38323
|
+
}
|
|
38324
|
+
function ringTall(bnd, info, ctx) {
|
|
38325
|
+
const c = { x: -bnd, y: 0 };
|
|
38326
|
+
return leg(c, 0, -1, -bnd, info, ctx) || leg(c, 1, 0, bnd, info, ctx) || leg(c, 0, 1, bnd, info, ctx) || leg(c, -1, 0, -bnd, info, ctx) || leg(c, 0, -1, 0, info, ctx);
|
|
38255
38327
|
}
|
|
38256
38328
|
function placeFixed(info, ctx, center) {
|
|
38257
38329
|
ctx.places[info.index] = { x: -center.x, y: -center.y };
|
|
38258
|
-
for (const c of info.cells) ctx.ps.
|
|
38330
|
+
for (const c of info.cells) ctx.ps.addPS(c.x, c.y);
|
|
38259
38331
|
}
|
|
38260
38332
|
function placeGraph2(i, info, ctx) {
|
|
38261
38333
|
const bb = ctx.bbs[info.index];
|
|
@@ -38267,10 +38339,7 @@ function placeGraph2(i, info, ctx) {
|
|
|
38267
38339
|
if (fits2(0, 0, info, ctx)) return;
|
|
38268
38340
|
const wide = Math.ceil(bb.ur.x - bb.ll.x) >= Math.ceil(bb.ur.y - bb.ll.y);
|
|
38269
38341
|
for (let bnd = 1; ; bnd++) {
|
|
38270
|
-
|
|
38271
|
-
for (const [x, y] of ring) {
|
|
38272
|
-
if (fits2(x, y, info, ctx)) return;
|
|
38273
|
-
}
|
|
38342
|
+
if (wide ? ringWide(bnd, info, ctx) : ringTall(bnd, info, ctx)) return;
|
|
38274
38343
|
}
|
|
38275
38344
|
}
|
|
38276
38345
|
function polyGraphs(gs, root, pinfo, bbs) {
|
|
@@ -38471,6 +38540,10 @@ function shiftEdgePoints(e, dx, dy) {
|
|
|
38471
38540
|
const shiftOps = (ops) => ops?.map((op) => mapArrowOpPoints(op, (p) => ({ x: p.x + dx, y: p.y + dy })));
|
|
38472
38541
|
e.info.headArrowOps = shiftOps(e.info.headArrowOps);
|
|
38473
38542
|
e.info.tailArrowOps = shiftOps(e.info.tailArrowOps);
|
|
38543
|
+
for (const bz of spl.list) {
|
|
38544
|
+
if (bz.sArrowOps) bz.sArrowOps = shiftOps(bz.sArrowOps);
|
|
38545
|
+
if (bz.eArrowOps) bz.eArrowOps = shiftOps(bz.eArrowOps);
|
|
38546
|
+
}
|
|
38474
38547
|
}
|
|
38475
38548
|
function shiftOneGraph(g, dx, dy) {
|
|
38476
38549
|
for (const n of g.nodes.values()) {
|
|
@@ -54113,6 +54186,9 @@ var XdotRenderer = class extends EdgeDrawBase {
|
|
|
54113
54186
|
headArrowColor = c.headColor;
|
|
54114
54187
|
} else {
|
|
54115
54188
|
this.emitPlainSpline(e, spl.list, edraw, job);
|
|
54189
|
+
for (const ops of endArrowOps(e, "tail")) this.emitArrows(this.bufs[2 /* TDraw */], ops, job, 2 /* TDraw */);
|
|
54190
|
+
for (const ops of endArrowOps(e, "head")) this.emitArrows(this.bufs[3 /* HDraw */], ops, job, 3 /* HDraw */);
|
|
54191
|
+
return;
|
|
54116
54192
|
}
|
|
54117
54193
|
this.emitArrows(this.bufs[2 /* TDraw */], e.info.tailArrowOps, job, 2 /* TDraw */, tailArrowColor);
|
|
54118
54194
|
this.emitArrows(this.bufs[3 /* HDraw */], e.info.headArrowOps, job, 3 /* HDraw */, headArrowColor);
|