@knowvah/dot-engine 2.12.1 → 2.12.3
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/api/builder.d.ts +7 -1
- package/dist/api/builder.d.ts.map +1 -1
- package/dist/api.js +14 -7
- package/dist/api.js.map +2 -2
- package/dist/common/compass-port.d.ts.map +1 -1
- package/dist/common/edge-label-init.d.ts +26 -1
- package/dist/common/edge-label-init.d.ts.map +1 -1
- package/dist/common/graph-init.d.ts.map +1 -1
- package/dist/common/htmltable-label.d.ts.map +1 -1
- package/dist/common/htmltable-lex.d.ts +3 -1
- package/dist/common/htmltable-lex.d.ts.map +1 -1
- package/dist/common/htmltable-parse-image.d.ts +23 -0
- package/dist/common/htmltable-parse-image.d.ts.map +1 -0
- package/dist/common/htmltable-parse-state.d.ts +4 -0
- package/dist/common/htmltable-parse-state.d.ts.map +1 -1
- package/dist/common/htmltable-parse.d.ts +33 -2
- package/dist/common/htmltable-parse.d.ts.map +1 -1
- package/dist/common/nodeinit.d.ts +16 -2
- package/dist/common/nodeinit.d.ts.map +1 -1
- package/dist/common/poly-inside.d.ts.map +1 -1
- package/dist/common/splines-geom.d.ts +2 -1
- package/dist/common/splines-geom.d.ts.map +1 -1
- package/dist/common/splines-path-begin.d.ts.map +1 -1
- package/dist/common/splines-path-end.d.ts.map +1 -1
- package/dist/common/splines-routespl.d.ts +3 -0
- package/dist/common/splines-routespl.d.ts.map +1 -1
- package/dist/gvc/context.d.ts +8 -0
- package/dist/gvc/context.d.ts.map +1 -1
- package/dist/gvc/emit-gates.d.ts +5 -10
- package/dist/gvc/emit-gates.d.ts.map +1 -1
- package/dist/gvc/emit-xdot.d.ts +7 -6
- package/dist/gvc/emit-xdot.d.ts.map +1 -1
- package/dist/gvc/job.d.ts +5 -2
- package/dist/gvc/job.d.ts.map +1 -1
- package/dist/gvc/viewport.d.ts +10 -5
- package/dist/gvc/viewport.d.ts.map +1 -1
- package/dist/index.js +21565 -21326
- package/dist/index.js.map +4 -4
- package/dist/layout/dot/classify.d.ts.map +1 -1
- package/dist/layout/dot/edge-route-chain-views.d.ts +35 -0
- package/dist/layout/dot/edge-route-chain-views.d.ts.map +1 -0
- package/dist/layout/dot/edge-route-chain.d.ts +20 -16
- package/dist/layout/dot/edge-route-chain.d.ts.map +1 -1
- package/dist/layout/dot/edge-route-faithful.d.ts.map +1 -1
- package/dist/layout/dot/edge-route.d.ts +7 -3
- package/dist/layout/dot/edge-route.d.ts.map +1 -1
- package/dist/layout/dot/fastgr.d.ts +5 -3
- package/dist/layout/dot/fastgr.d.ts.map +1 -1
- package/dist/layout/dot/flat-adj-record.d.ts +22 -0
- package/dist/layout/dot/flat-adj-record.d.ts.map +1 -0
- package/dist/layout/dot/flat.d.ts +22 -7
- package/dist/layout/dot/flat.d.ts.map +1 -1
- package/dist/layout/dot/init.d.ts +49 -9
- package/dist/layout/dot/init.d.ts.map +1 -1
- package/dist/layout/dot/mincross-build.d.ts +6 -0
- package/dist/layout/dot/mincross-build.d.ts.map +1 -1
- package/dist/layout/dot/mincross-flat.d.ts +10 -1
- package/dist/layout/dot/mincross-flat.d.ts.map +1 -1
- package/dist/layout/dot/mincross.d.ts +6 -1
- package/dist/layout/dot/mincross.d.ts.map +1 -1
- package/dist/layout/dot/ns-subtree.d.ts +9 -6
- package/dist/layout/dot/ns-subtree.d.ts.map +1 -1
- package/dist/layout/dot/pack-components.d.ts +4 -3
- package/dist/layout/dot/pack-components.d.ts.map +1 -1
- package/dist/layout/dot/position-aux.d.ts +69 -21
- package/dist/layout/dot/position-aux.d.ts.map +1 -1
- package/dist/layout/dot/position-bbox.d.ts.map +1 -1
- package/dist/layout/dot/position-ycoords.d.ts.map +1 -1
- package/dist/layout/dot/position.d.ts.map +1 -1
- package/dist/layout/dot/rank-dot2.d.ts +7 -25
- package/dist/layout/dot/rank-dot2.d.ts.map +1 -1
- package/dist/layout/dot/self-loop.d.ts +11 -4
- package/dist/layout/dot/self-loop.d.ts.map +1 -1
- package/dist/layout/dot/splines-clone.d.ts +2 -1
- package/dist/layout/dot/splines-clone.d.ts.map +1 -1
- package/dist/layout/dot/splines-flat-labeled.d.ts.map +1 -1
- package/dist/layout/dot/splines-flat-multi.d.ts +11 -3
- package/dist/layout/dot/splines-flat-multi.d.ts.map +1 -1
- package/dist/layout/dot/splines-flat.d.ts +18 -0
- package/dist/layout/dot/splines-flat.d.ts.map +1 -1
- package/dist/layout/dot/splines-groups.d.ts.map +1 -1
- package/dist/layout/dot/splines-route.d.ts +6 -3
- package/dist/layout/dot/splines-route.d.ts.map +1 -1
- package/dist/layout/dot/straight-edges.d.ts.map +1 -1
- package/dist/layout/fdp/ports.d.ts.map +1 -1
- package/dist/layout/fdp/tlayout.d.ts +3 -0
- package/dist/layout/fdp/tlayout.d.ts.map +1 -1
- package/dist/layout/neato/__fixtures__/hier-imds.d.ts +5 -4
- package/dist/layout/neato/__fixtures__/hier-imds.d.ts.map +1 -1
- package/dist/layout/neato/__fixtures__/hier-majorization.d.ts +6 -5
- package/dist/layout/neato/__fixtures__/hier-majorization.d.ts.map +1 -1
- package/dist/layout/neato/conjgrad-mkernel.d.ts.map +1 -1
- package/dist/layout/neato/conjgrad.d.ts +7 -6
- package/dist/layout/neato/conjgrad.d.ts.map +1 -1
- package/dist/layout/neato/matrix-ops-dense.d.ts +1 -6
- package/dist/layout/neato/matrix-ops-dense.d.ts.map +1 -1
- package/dist/layout/neato/matrix-ops.d.ts +0 -6
- package/dist/layout/neato/matrix-ops.d.ts.map +1 -1
- package/dist/layout/neato/quad-prog-vpsc.d.ts.map +1 -1
- package/dist/layout/neato/sgd.d.ts.map +1 -1
- package/dist/model/cgraph-ops.d.ts +10 -2
- package/dist/model/cgraph-ops.d.ts.map +1 -1
- package/dist/model/edge.d.ts +7 -2
- package/dist/model/edge.d.ts.map +1 -1
- package/dist/model/edgeInfo.d.ts +17 -2
- package/dist/model/edgeInfo.d.ts.map +1 -1
- package/dist/model/graph.d.ts +4 -3
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/lazy-attrs.d.ts.map +1 -1
- package/dist/model/rankEntry.d.ts +3 -1
- package/dist/model/rankEntry.d.ts.map +1 -1
- package/dist/ortho/index.d.ts +0 -1
- package/dist/ortho/index.d.ts.map +1 -1
- package/dist/ortho/partition.d.ts +2 -4
- package/dist/ortho/partition.d.ts.map +1 -1
- package/dist/parser/builder.d.ts.map +1 -1
- package/dist/pathplan/route.d.ts +93 -0
- package/dist/pathplan/route.d.ts.map +1 -1
- package/dist/render/dot/agwrite.d.ts +26 -10
- package/dist/render/dot/agwrite.d.ts.map +1 -1
- package/dist/render/dot/attrs.d.ts +15 -4
- package/dist/render/dot/attrs.d.ts.map +1 -1
- package/dist/render/dot/types.d.ts +7 -2
- package/dist/render/dot/types.d.ts.map +1 -1
- package/dist/render/dot/write-back.d.ts +14 -0
- package/dist/render/dot/write-back.d.ts.map +1 -1
- package/dist/render/dot/xdot-ops.d.ts +20 -29
- package/dist/render/dot/xdot-ops.d.ts.map +1 -1
- package/dist/render/dot.d.ts +4 -2
- package/dist/render/dot.d.ts.map +1 -1
- package/dist/render/json-cluster-edge.d.ts +17 -4
- package/dist/render/json-cluster-edge.d.ts.map +1 -1
- package/dist/render/json-nonfinite.d.ts +17 -0
- package/dist/render/json-nonfinite.d.ts.map +1 -0
- package/dist/render/json.d.ts +4 -0
- package/dist/render/json.d.ts.map +1 -1
- package/dist/render/map.d.ts +3 -0
- package/dist/render/map.d.ts.map +1 -1
- package/dist/render/svg-graph.d.ts.map +1 -1
- package/dist/render/svg-id.d.ts +10 -1
- package/dist/render/svg-id.d.ts.map +1 -1
- package/dist/render/svg.d.ts +3 -1
- package/dist/render/svg.d.ts.map +1 -1
- package/dist/render.js +21517 -21278
- package/dist/render.js.map +4 -4
- package/dist/util/bsd-qsort.d.ts.map +1 -1
- package/dist/util/overflow.d.ts +37 -0
- package/dist/util/overflow.d.ts.map +1 -0
- package/dist/xdot/parse.d.ts.map +1 -1
- package/dist/xdot/strtod.d.ts +23 -0
- package/dist/xdot/strtod.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/api/builder.ts +8 -2
- package/src/common/compass-port.ts +36 -20
- package/src/common/edge-label-init.ts +43 -17
- package/src/common/graph-init.ts +11 -1
- package/src/common/htmltable-label.ts +9 -4
- package/src/common/htmltable-lex.ts +5 -2
- package/src/common/htmltable-parse-image.ts +69 -0
- package/src/common/htmltable-parse-state.ts +6 -0
- package/src/common/htmltable-parse.ts +34 -44
- package/src/common/nodeinit.ts +28 -8
- package/src/common/poly-inside.ts +11 -5
- package/src/common/splines-geom.ts +24 -6
- package/src/common/splines-path-begin.ts +4 -3
- package/src/common/splines-path-end.ts +4 -3
- package/src/common/splines-routespl.ts +32 -0
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.1 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.2 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.3 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.2 +18 -18
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.3 +12 -12
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.1 +20 -20
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.2 +31 -31
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.3 +33 -33
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.1 +10 -10
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.2 +28 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.3 +28 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.1 +21 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.2 +100 -102
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.3 +137 -139
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.1 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.2 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.3 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.1 +3 -3
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.2 +3 -3
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.3 +3 -3
- package/src/gvc/__fixtures__/rerender/regen.sh +6 -0
- package/src/gvc/context.ts +8 -0
- package/src/gvc/device.ts +6 -6
- package/src/gvc/emit-gates.ts +6 -15
- package/src/gvc/emit-xdot.ts +10 -11
- package/src/gvc/job.ts +5 -2
- package/src/gvc/viewport.ts +13 -7
- package/src/layout/dot/__fixtures__/flat-adj-aux-syms.native-16.1.json +1210 -0
- package/src/layout/dot/classify.ts +5 -2
- package/src/layout/dot/edge-route-chain-views.ts +120 -0
- package/src/layout/dot/edge-route-chain.ts +103 -117
- package/src/layout/dot/edge-route-faithful.ts +20 -5
- package/src/layout/dot/edge-route.ts +44 -49
- package/src/layout/dot/fastgr.ts +9 -3
- package/src/layout/dot/flat-adj-record.ts +68 -0
- package/src/layout/dot/flat.ts +38 -17
- package/src/layout/dot/init.ts +59 -13
- package/src/layout/dot/mincross-build.ts +14 -1
- package/src/layout/dot/mincross-flat.ts +15 -5
- package/src/layout/dot/mincross.ts +6 -2
- package/src/layout/dot/ns-subtree.ts +11 -7
- package/src/layout/dot/pack-components.ts +6 -4
- package/src/layout/dot/position-aux.ts +122 -42
- package/src/layout/dot/position-bbox.ts +14 -1
- package/src/layout/dot/position-ycoords.ts +7 -1
- package/src/layout/dot/position.ts +4 -1
- package/src/layout/dot/rank-dot2.ts +13 -94
- package/src/layout/dot/self-loop.ts +29 -11
- package/src/layout/dot/splines-clone.ts +8 -2
- package/src/layout/dot/splines-flat-labeled.ts +3 -2
- package/src/layout/dot/splines-flat-multi.ts +12 -4
- package/src/layout/dot/splines-flat.ts +9 -19
- package/src/layout/dot/splines-groups.ts +5 -3
- package/src/layout/dot/splines-route.ts +10 -11
- package/src/layout/dot/straight-edges.ts +5 -3
- package/src/layout/fdp/ports.ts +6 -2
- package/src/layout/fdp/tlayout.ts +6 -5
- package/src/layout/neato/__fixtures__/conjgrad-d.json +1 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.dot +141 -141
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.xdot +339 -339
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.dot +140 -140
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.xdot +323 -323
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.dot +141 -141
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.xdot +339 -339
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.dot +251 -251
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.xdot +535 -535
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.dot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.xdot +32 -32
- package/src/layout/neato/__fixtures__/dim/hier-dim4.dot +8 -8
- package/src/layout/neato/__fixtures__/dim/hier-dim4.xdot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.dot +17 -17
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.xdot +35 -35
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.dot +2 -2
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.xdot +2 -2
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.dot +11 -11
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.xdot +21 -21
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.dot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.xdot +26 -26
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.dot +13 -13
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.xdot +30 -30
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.dot +10 -10
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.xdot +19 -19
- package/src/layout/neato/__fixtures__/dim/smart-units.json +1 -1
- package/src/layout/neato/__fixtures__/hier/cases/dirnone.plain +10 -10
- package/src/layout/neato/__fixtures__/hier/cases/tdist.plain +12 -12
- package/src/layout/neato/__fixtures__/hier/hier-probe.plain +1 -1
- package/src/layout/neato/__fixtures__/hier/hier-probe.xdot +19 -19
- package/src/layout/neato/__fixtures__/hier-imds.ts +14 -13
- package/src/layout/neato/__fixtures__/hier-majorization.ts +24 -23
- package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.xdot +20 -20
- package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.xdot +8 -8
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.xdot +34 -34
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.xdot +32 -32
- package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.xdot +18 -18
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.xdot +13 -13
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.xdot +12 -12
- package/src/layout/neato/__fixtures__/models/hier-circuit.xdot +33 -33
- package/src/layout/neato/__fixtures__/models/hier-default.xdot +30 -30
- package/src/layout/neato/__fixtures__/models/hier-mds-nolen.xdot +30 -30
- package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.xdot +35 -35
- package/src/layout/neato/__fixtures__/models/hier-shortpath.xdot +30 -30
- package/src/layout/neato/conjgrad-mkernel.ts +6 -2
- package/src/layout/neato/conjgrad.ts +38 -35
- package/src/layout/neato/matrix-ops-dense.ts +2 -20
- package/src/layout/neato/matrix-ops.ts +0 -20
- package/src/layout/neato/quad-prog-vpsc.ts +7 -5
- package/src/layout/neato/sgd.ts +2 -1
- package/src/layout/neato/smart-ini-x.ts +15 -15
- package/src/layout/neato/stress-subspace.ts +5 -5
- package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/dim3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/regen.sh +2 -0
- package/src/model/cgraph-ops.ts +4 -3
- package/src/model/edge.ts +11 -4
- package/src/model/edgeInfo.ts +18 -2
- package/src/model/graph.ts +4 -3
- package/src/model/lazy-attrs.ts +3 -1
- package/src/model/rankEntry.ts +3 -1
- package/src/ortho/index.ts +0 -1
- package/src/ortho/partition.ts +10 -22
- package/src/parser/builder.ts +12 -3
- package/src/pathplan/route.ts +14 -4
- package/src/render/dot/agwrite.ts +45 -18
- package/src/render/dot/attrs.ts +18 -7
- package/src/render/dot/types.ts +7 -2
- package/src/render/dot/write-back.ts +27 -3
- package/src/render/dot/xdot-ops.ts +25 -56
- package/src/render/dot.ts +7 -5
- package/src/render/json-cluster-edge.ts +42 -5
- package/src/render/json-nonfinite.ts +51 -0
- package/src/render/json.ts +23 -26
- package/src/render/map.ts +3 -0
- package/src/render/svg-graph.ts +3 -15
- package/src/render/svg-id.ts +11 -2
- package/src/render/svg.ts +4 -1
- package/src/util/bsd-qsort.ts +2 -1
- package/src/util/overflow.ts +74 -0
- package/src/xdot/parse.ts +9 -19
- package/src/xdot/strtod.ts +167 -0
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import type {
|
|
11
11
|
HtmlCell,
|
|
12
12
|
HtmlCellContent,
|
|
13
|
-
HtmlImage,
|
|
14
13
|
HtmlLabel,
|
|
15
14
|
HtmlRow,
|
|
16
15
|
HtmlTable,
|
|
@@ -22,8 +21,9 @@ import type {
|
|
|
22
21
|
import { HtmlParseError } from './htmltable-types.js';
|
|
23
22
|
import { StderrLines } from './htmltable-attr-warn.js';
|
|
24
23
|
import type { ParseState } from './htmltable-parse-state.js';
|
|
25
|
-
import { consume, emitEof, emitWarnings, peek } from './htmltable-parse-state.js';
|
|
26
|
-
import { htmlErrorAtToken, tokenizeDeferred } from './htmltable-lex.js';
|
|
24
|
+
import { consume, consumedTag, emitEof, emitWarnings, peek } from './htmltable-parse-state.js';
|
|
25
|
+
import { HtmlLexError, htmlErrorAtToken, tokenizeDeferred } from './htmltable-lex.js';
|
|
26
|
+
import { scanCellImage } from './htmltable-parse-image.js';
|
|
27
27
|
import type { FontState } from './htmltable-parse-font.js';
|
|
28
28
|
import {
|
|
29
29
|
fontItemProps, inlineFontState, isInlineTag, mergeFontState, tableFont, wrapperFont,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
} from './htmltable-parse-attrs.js';
|
|
39
39
|
|
|
40
40
|
/** bison's default message for an unexpected token. @see lib/common/htmlparse.y */
|
|
41
|
-
const MSG_SYNTAX_ERROR = 'syntax error';
|
|
41
|
+
export const MSG_SYNTAX_ERROR = 'syntax error';
|
|
42
42
|
/** @see lib/common/htmlparse.y:288 (table rule) */
|
|
43
43
|
const MSG_TEXT_BEFORE_TABLE = 'Syntax error: non-space string used before <TABLE>';
|
|
44
44
|
/** @see lib/common/htmlparse.y:298 (table rule) */
|
|
@@ -50,17 +50,25 @@ const nonSpace = (text: string): boolean => /[^ ]/.test(text);
|
|
|
50
50
|
/** Text in `ctx->xb` that no token carried, which the table rule's nonSpace also reads. */
|
|
51
51
|
const heldNonSpace = (tbl: Token | undefined): boolean => tbl?.type === 'open' && nonSpace(tbl.heldText ?? '');
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* `e` as C prints it once `ctx->error` is set: htmlerror and the expat path
|
|
55
|
+
* print nothing more (a silent HtmlParseError); only lexerror still does.
|
|
56
|
+
* @see lib/common/htmllex.c:htmlerror
|
|
57
|
+
*/
|
|
58
|
+
const guarded = (s: ParseState, e: HtmlParseError): HtmlParseError =>
|
|
59
|
+
s.error === true && !(e instanceof HtmlLexError && e.unguarded) ? new HtmlParseError(e.tag) : e;
|
|
60
|
+
|
|
53
61
|
/**
|
|
54
62
|
* The parse failure C reports through `htmlerror` when the lexer last returned
|
|
55
63
|
* `tok`. At end of input the deferred lexical error is what C would hit next.
|
|
56
64
|
* A token without a recorded chunk yields a plain, silent HtmlParseError.
|
|
57
65
|
* @see lib/common/htmllex.c:htmlerror
|
|
58
66
|
*/
|
|
59
|
-
const parseError = (s: ParseState, tok: Token | undefined, message: string): HtmlParseError => {
|
|
67
|
+
export const parseError = (s: ParseState, tok: Token | undefined, message: string): HtmlParseError => {
|
|
60
68
|
// The lexer already ran for the token the error is reported at.
|
|
61
69
|
if (tok !== undefined) emitWarnings(s, tok);
|
|
62
70
|
else emitEof(s);
|
|
63
|
-
return (tok === undefined ? s.pending : htmlErrorAtToken(message, tok)) ?? new HtmlParseError(message);
|
|
71
|
+
return guarded(s, (tok === undefined ? s.pending : htmlErrorAtToken(message, tok)) ?? new HtmlParseError(message));
|
|
64
72
|
};
|
|
65
73
|
|
|
66
74
|
// ---------------------------------------------------------------------------
|
|
@@ -73,7 +81,7 @@ const parseError = (s: ParseState, tok: Token | undefined, message: string): Htm
|
|
|
73
81
|
* syntax error at that token.
|
|
74
82
|
* @see lib/common/htmlparse.y:br, image
|
|
75
83
|
*/
|
|
76
|
-
const consumeClose = (s: ParseState, tag: string): void => {
|
|
84
|
+
export const consumeClose = (s: ParseState, tag: string): void => {
|
|
77
85
|
const nxt = peek(s);
|
|
78
86
|
if (nxt === undefined) return;
|
|
79
87
|
if (nxt.type === 'close' && nxt.tag === tag) {
|
|
@@ -172,7 +180,7 @@ const fontTableWrapper = (s: ParseState): OpenToken | undefined => {
|
|
|
172
180
|
};
|
|
173
181
|
|
|
174
182
|
/** Consume strings; true when any is non-space (the table rule's nonSpace check). */
|
|
175
|
-
const skipStrings = (s: ParseState): boolean => {
|
|
183
|
+
export const skipStrings = (s: ParseState): boolean => {
|
|
176
184
|
let found = false;
|
|
177
185
|
for (let t = peek(s); t?.type === 'text'; t = peek(s)) {
|
|
178
186
|
consume(s);
|
|
@@ -210,29 +218,18 @@ const parseFontTable = (s: ParseState, open: OpenToken, fontStack: FontState[]):
|
|
|
210
218
|
const rejectTableAfterTag = (s: ParseState, start: number): void => {
|
|
211
219
|
const nxt = peek(s);
|
|
212
220
|
if (nxt?.type !== 'open' || nxt.tag !== 'TABLE') return;
|
|
213
|
-
if (s
|
|
214
|
-
throw parseError(s, nxt, MSG_SYNTAX_ERROR);
|
|
215
|
-
}
|
|
221
|
+
if (consumedTag(s, start)) throw parseError(s, nxt, MSG_SYNTAX_ERROR);
|
|
216
222
|
};
|
|
217
223
|
|
|
218
224
|
// ---------------------------------------------------------------------------
|
|
219
225
|
// Cell content helpers — mirrors htmlparse.y cell rule
|
|
220
226
|
// ---------------------------------------------------------------------------
|
|
221
227
|
|
|
222
|
-
const parseImgContent = (s: ParseState, t: OpenToken): HtmlImage => {
|
|
223
|
-
consume(s);
|
|
224
|
-
const img: HtmlImage = {
|
|
225
|
-
kind: 'image',
|
|
226
|
-
src: t.attrs['src'] ?? '',
|
|
227
|
-
scale: t.attrs['scale'],
|
|
228
|
-
};
|
|
229
|
-
consumeClose(s, 'IMG');
|
|
230
|
-
return img;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
228
|
/** What a cell holds so far: C's cell has exactly one child. */
|
|
234
|
-
interface CellScan {
|
|
229
|
+
export interface CellScan {
|
|
235
230
|
kind: 'none' | 'text' | 'table' | 'fonttable' | 'image';
|
|
231
|
+
/** Index of the cell's first token. */
|
|
232
|
+
start: number;
|
|
236
233
|
/** Non-space text before the nested table (checked when the table opens). */
|
|
237
234
|
textNonSpace: boolean;
|
|
238
235
|
/** Non-space text after the nested table (checked when the run ends). */
|
|
@@ -243,7 +240,6 @@ interface CellScan {
|
|
|
243
240
|
const scanCellTable = (
|
|
244
241
|
s: ParseState, t: Token, fontStack: FontState[], st: CellScan,
|
|
245
242
|
): HtmlCellContent[] => {
|
|
246
|
-
if (st.kind === 'image' || st.kind === 'table') throw parseError(s, t, MSG_SYNTAX_ERROR);
|
|
247
243
|
if (st.textNonSpace || heldNonSpace(t)) throw parseError(s, t, MSG_TEXT_BEFORE_TABLE);
|
|
248
244
|
const tbl = parseTable(s, fontStack);
|
|
249
245
|
st.kind = 'table';
|
|
@@ -269,18 +265,12 @@ const scanAfterTable = (s: ParseState, t: Token, st: CellScan): HtmlCellContent[
|
|
|
269
265
|
return [];
|
|
270
266
|
};
|
|
271
267
|
|
|
272
|
-
/** `image` as the cell's only child. */
|
|
273
|
-
const scanCellImage = (s: ParseState, t: OpenToken, st: CellScan): HtmlCellContent[] => {
|
|
274
|
-
if (st.kind !== 'none') throw parseError(s, t, MSG_SYNTAX_ERROR);
|
|
275
|
-
st.kind = 'image';
|
|
276
|
-
return [parseImgContent(s, t)];
|
|
277
|
-
};
|
|
278
|
-
|
|
279
268
|
/** One step of `cell: T_cell (fonttable | fonttext | image) T_end_cell`. */
|
|
280
269
|
const scanCellItem = (
|
|
281
270
|
s: ParseState, t: Token, fontStack: FontState[], st: CellScan,
|
|
282
271
|
): HtmlCellContent[] => {
|
|
283
|
-
|
|
272
|
+
// After an image only the cell's close may come: its opt_space took the strings.
|
|
273
|
+
if (st.kind === 'fonttable' || st.kind === 'image') throw parseError(s, t, MSG_SYNTAX_ERROR);
|
|
284
274
|
if (st.kind === 'table') return scanAfterTable(s, t, st);
|
|
285
275
|
const wrapper = st.kind === 'none' ? fontTableWrapper(s) : undefined;
|
|
286
276
|
if (wrapper !== undefined) {
|
|
@@ -289,7 +279,6 @@ const scanCellItem = (
|
|
|
289
279
|
}
|
|
290
280
|
if (t.type === 'open' && t.tag === 'TABLE') return scanCellTable(s, t, fontStack, st);
|
|
291
281
|
if (t.type === 'open' && t.tag === 'IMG') return scanCellImage(s, t, st);
|
|
292
|
-
if (st.kind === 'image') throw parseError(s, t, MSG_SYNTAX_ERROR);
|
|
293
282
|
return scanCellText(s, t, fontStack, st);
|
|
294
283
|
};
|
|
295
284
|
|
|
@@ -303,19 +292,18 @@ const endsCell = (s: ParseState, t: Token, st: CellScan): boolean => {
|
|
|
303
292
|
|
|
304
293
|
const parseCellContent = (s: ParseState, fontStack: FontState[]): HtmlCellContent[] => {
|
|
305
294
|
const content: HtmlCellContent[] = [];
|
|
306
|
-
const st: CellScan = { kind: 'none', textNonSpace: false, afterNonSpace: false };
|
|
295
|
+
const st: CellScan = { kind: 'none', start: s.pos, textNonSpace: false, afterNonSpace: false };
|
|
307
296
|
for (let t = peek(s); t !== undefined; t = peek(s)) {
|
|
308
297
|
if (endsCell(s, t, st)) break;
|
|
309
298
|
content.push(...scanCellItem(s, t, fontStack, st));
|
|
310
299
|
}
|
|
311
300
|
const nxt = peek(s);
|
|
312
301
|
if (nxt?.type === 'close' && nxt.tag === 'TD') consume(s);
|
|
313
|
-
// C models a cell child as a single object; the
|
|
314
|
-
//
|
|
315
|
-
// @see lib/common/htmltable.h:htmlcell_t.child
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
return content;
|
|
302
|
+
// C models a cell child as a single object; the table and image rules take
|
|
303
|
+
// the strings around them (opt_space), so a table or image IS the cell's
|
|
304
|
+
// sole content. @see lib/common/htmltable.h:htmlcell_t.child
|
|
305
|
+
const sole = content.find((c) => c.kind === 'table' || c.kind === 'image');
|
|
306
|
+
return sole !== undefined ? [sole] : content;
|
|
319
307
|
};
|
|
320
308
|
|
|
321
309
|
/** @see lib/common/htmlparse.y:cell rule / lib/common/htmllex.c:mkCell */
|
|
@@ -547,10 +535,12 @@ const parseTokens = (s: ParseState): HtmlLabel => {
|
|
|
547
535
|
return parseTextLabel(s, fontStack);
|
|
548
536
|
};
|
|
549
537
|
|
|
550
|
-
/** A parsed label and `ctx->
|
|
538
|
+
/** A parsed label with `ctx->warn` and `ctx->error`, from which `clearHTMLlexer` makes parseHTML's rv. */
|
|
551
539
|
export interface ParsedHtmlLabel {
|
|
552
540
|
label: HtmlLabel;
|
|
553
541
|
warn: boolean;
|
|
542
|
+
/** htmlerror printed but the parse went on: rv 3 with a label. */
|
|
543
|
+
error: boolean;
|
|
554
544
|
}
|
|
555
545
|
|
|
556
546
|
/**
|
|
@@ -566,11 +556,11 @@ export const parseHtmlLabelRv = (src: string, stderr: StderrLines): ParsedHtmlLa
|
|
|
566
556
|
const s: ParseState = { tokens, pos: 0, pending: error, stderr, emitted: new WeakSet(), warn: false, eof };
|
|
567
557
|
try {
|
|
568
558
|
const label = parseTokens(s);
|
|
569
|
-
if (error !== undefined) throw error;
|
|
570
|
-
return { label, warn: s.warn === true };
|
|
559
|
+
if (error !== undefined) throw guarded(s, error);
|
|
560
|
+
return { label, warn: s.warn === true, error: s.error === true };
|
|
571
561
|
} catch (e) {
|
|
572
562
|
// Running off the truncated stream means C's lexer would have hit the error.
|
|
573
|
-
if (error !== undefined && s.pos >= tokens.length) { emitEof(s); throw error; }
|
|
563
|
+
if (error !== undefined && s.pos >= tokens.length) { emitEof(s); throw guarded(s, error); }
|
|
574
564
|
throw e;
|
|
575
565
|
}
|
|
576
566
|
};
|
package/src/common/nodeinit.ts
CHANGED
|
@@ -160,11 +160,28 @@ export function polySizeParamsFromNode(
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
|
-
*
|
|
163
|
+
* Which of common_init_node's guarded symbols are bound. C tests N_xlabel
|
|
164
|
+
* before reading it (`N_xlabel && (str = agxget(n, N_xlabel)) && str[0]`), and
|
|
165
|
+
* make_flat_adj_edges' setState nulls it for the aux layout, so an aux node's
|
|
166
|
+
* copied `xlabel` is never read.
|
|
167
|
+
* @see lib/common/utils.c:common_init_node (443)
|
|
168
|
+
* @see lib/dotgen/dotsplines.c:setState
|
|
169
|
+
*/
|
|
170
|
+
export interface NodeInitSyms {
|
|
171
|
+
readonly nodeXlabel: boolean;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** N_xlabel bound, as graph_init leaves it. @see lib/common/input.c:graph_init */
|
|
175
|
+
export const BOUND_NODE_INIT_SYMS: NodeInitSyms = { nodeXlabel: true };
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Create ND_xlabel when N_xlabel is bound and the xlabel attr is non-empty,
|
|
179
|
+
* and set NODE_XLABEL.
|
|
164
180
|
* @see lib/common/utils.c:443-447
|
|
165
181
|
* @see lib/common/utils.c:447 — GD_has_labels scoped to agraphof(n) root
|
|
166
182
|
*/
|
|
167
|
-
function initNodeXLabel(n: Node, g: Graph, measurer: TextMeasurer): void {
|
|
183
|
+
function initNodeXLabel(n: Node, g: Graph, measurer: TextMeasurer, syms: NodeInitSyms): void {
|
|
184
|
+
if (!syms.nodeXlabel) return; // utils.c:443 — the `N_xlabel &&` guard
|
|
168
185
|
const str = nodeAttr(n, g, 'xlabel');
|
|
169
186
|
if (!str || str.length === 0) return;
|
|
170
187
|
const font = readFontAttrs(n, g);
|
|
@@ -228,7 +245,7 @@ function initPointSize(n: Node, g: Graph, shape: ShapeDesc & { polygon: PolygonT
|
|
|
228
245
|
* has no polygon descriptor to size against.
|
|
229
246
|
* @see lib/common/utils.c:common_init_node
|
|
230
247
|
*/
|
|
231
|
-
function initNodeFromLabel(n: Node, g: Graph, measurer: TextMeasurer): boolean {
|
|
248
|
+
function initNodeFromLabel(n: Node, g: Graph, measurer: TextMeasurer, syms: NodeInitSyms): boolean {
|
|
232
249
|
const shape = bindShape(nodeAttr(n, g, 'shape') ?? 'ellipse', nodeAttr(n, g, 'shapefile'));
|
|
233
250
|
n.info.shape = shape;
|
|
234
251
|
if (shape.kind === ShapeKind.SH_RECORD) {
|
|
@@ -237,12 +254,12 @@ function initNodeFromLabel(n: Node, g: Graph, measurer: TextMeasurer): boolean {
|
|
|
237
254
|
// only selects make_label's is_record flag and initfn=record_init — it is
|
|
238
255
|
// NOT a reason to skip the xlabel (utils.c:441/443/453).
|
|
239
256
|
recordMakeLabel(n, g, measurer);
|
|
240
|
-
initNodeXLabel(n, g, measurer);
|
|
257
|
+
initNodeXLabel(n, g, measurer, syms);
|
|
241
258
|
recordInit(n, g, measurer); // initfn: sets lw/rw/ht from the field tree
|
|
242
259
|
return true;
|
|
243
260
|
}
|
|
244
261
|
buildNodeLabel(n, g, measurer);
|
|
245
|
-
initNodeXLabel(n, g, measurer);
|
|
262
|
+
initNodeXLabel(n, g, measurer, syms);
|
|
246
263
|
// Layout-time poly_init warnings (once per layout; render-time polyInit is silent).
|
|
247
264
|
if (shape.kind !== ShapeKind.SH_POINT) warnPolyInitImages(n, g);
|
|
248
265
|
const poly = shape.polygon;
|
|
@@ -330,13 +347,16 @@ function initNodeDefaults(n: Node, g: Graph): void {
|
|
|
330
347
|
|
|
331
348
|
/**
|
|
332
349
|
* Initialise per-node geometry: shape-aware, label-driven sizing when a
|
|
333
|
-
* text measurer is available; width/height attr defaults otherwise.
|
|
350
|
+
* text measurer is available; width/height attr defaults otherwise. `syms`
|
|
351
|
+
* stands for the global symbol state common_init_node reads.
|
|
334
352
|
* @see lib/common/utils.c:common_init_node
|
|
335
353
|
* @see lib/common/utils.c:gv_nodesize
|
|
336
354
|
*/
|
|
337
|
-
export function commonInitNode(
|
|
355
|
+
export function commonInitNode(
|
|
356
|
+
n: Node, g: Graph, syms: NodeInitSyms = BOUND_NODE_INIT_SYMS,
|
|
357
|
+
): void {
|
|
338
358
|
const measurer = layoutMeasurer(g);
|
|
339
|
-
if (measurer !== undefined && initNodeFromLabel(n, g, measurer)) return;
|
|
359
|
+
if (measurer !== undefined && initNodeFromLabel(n, g, measurer, syms)) return;
|
|
340
360
|
initNodeDefaults(n, g);
|
|
341
361
|
}
|
|
342
362
|
|
|
@@ -20,6 +20,7 @@ import type { PolygonT } from './types.js';
|
|
|
20
20
|
import type { InsideContext } from './splines-geom.js';
|
|
21
21
|
import { polygonOutlineRing } from './poly-sizing.js';
|
|
22
22
|
import { ccwrotatepf } from '../model/geom.js';
|
|
23
|
+
import { fdivOverflow } from '../util/overflow.js';
|
|
23
24
|
|
|
24
25
|
/** Test if p0 and p1 are on the same side of the line L0-L1. @see shapes.c:same_side */
|
|
25
26
|
export function sameSide(p0: Point, p1: Point, L0: Point, L1: Point): boolean {
|
|
@@ -60,7 +61,12 @@ function insideDims(n: Node, xsize: number, ysize: number):
|
|
|
60
61
|
return { w, h, ow: 72 * n.info.outline_width || w, oh: 72 * n.info.outline_height || h };
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* C assigns `scalex = n_width` and then lets `fdiv_overflow` overwrite it
|
|
66
|
+
* with `n_width / xsize` when that quotient is finite (likewise `scaley`):
|
|
67
|
+
* `fdivOverflow(w, xsize) ?? w`.
|
|
68
|
+
* @see lib/common/shapes.c:poly_inside (scale setup, 2465-2469)
|
|
69
|
+
*/
|
|
64
70
|
function insideScale(n: Node, poly: PolygonT): InsideScale {
|
|
65
71
|
// C swaps the node extents for flipped (LR/RL) layouts. @see poly_inside (GD_flip)
|
|
66
72
|
const flip = n.root.info.flip === true;
|
|
@@ -74,8 +80,8 @@ function insideScale(n: Node, poly: PolygonT): InsideScale {
|
|
|
74
80
|
const xsize = flip ? h : w;
|
|
75
81
|
const ysize = flip ? w : h;
|
|
76
82
|
return {
|
|
77
|
-
scalex:
|
|
78
|
-
scaley:
|
|
83
|
+
scalex: fdivOverflow(w, xsize) ?? w,
|
|
84
|
+
scaley: fdivOverflow(h, ysize) ?? h,
|
|
79
85
|
boxURx: w / 2,
|
|
80
86
|
boxURy: h / 2,
|
|
81
87
|
};
|
|
@@ -85,8 +91,8 @@ function insideScale(n: Node, poly: PolygonT): InsideScale {
|
|
|
85
91
|
const ysize = flip ? lwrw : n.info.ht;
|
|
86
92
|
const { w, h, ow, oh } = insideDims(n, xsize, ysize);
|
|
87
93
|
return {
|
|
88
|
-
scalex:
|
|
89
|
-
scaley:
|
|
94
|
+
scalex: fdivOverflow(w, xsize) ?? w,
|
|
95
|
+
scaley: fdivOverflow(h, ysize) ?? h,
|
|
90
96
|
boxURx: ow / 2,
|
|
91
97
|
boxURy: oh / 2,
|
|
92
98
|
};
|
|
@@ -91,21 +91,39 @@ function expandByPoints(bb: Box, cp: Point[]): void {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* @see lib/common/emit.c:update_bb_bz
|
|
94
|
+
* How many times update_bb_bz attempts refinement of the control points.
|
|
95
|
+
* @see lib/common/emit.c:update_bb_bz (ATTEMPTS)
|
|
97
96
|
*/
|
|
98
|
-
|
|
97
|
+
const UPDATE_BB_BZ_ATTEMPTS = 10;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Expands bb by the segment cp, halving it until it is sufficiently refined.
|
|
101
|
+
* A segment still unrefined when `recurse` reaches 0 leaves bb as it is
|
|
102
|
+
* (graphviz 16.1.1, upstream issue 2780: huge coordinates never refine).
|
|
103
|
+
* @see lib/common/emit.c:update_bb_bz_core
|
|
104
|
+
*/
|
|
105
|
+
function updateBbBzCore(bb: Box, cp: Point[], recurse: number): void {
|
|
99
106
|
if (!anyOutside(bb, cp)) return;
|
|
100
107
|
if (checkControlPoints(cp)) {
|
|
101
108
|
expandByPoints(bb, cp);
|
|
102
109
|
return;
|
|
103
110
|
}
|
|
111
|
+
if (recurse === 0) return;
|
|
104
112
|
const left: Point[] = [];
|
|
105
113
|
const right: Point[] = [];
|
|
106
114
|
evalBezier(cp, 0.5, left, right);
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
updateBbBzCore(bb, left, recurse - 1);
|
|
116
|
+
updateBbBzCore(bb, right, recurse - 1);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Expands bb to contain the cubic Bezier segment cp by adaptively refining the
|
|
121
|
+
* segment to its true curve extent (not the control hull). Refinement stops
|
|
122
|
+
* after UPDATE_BB_BZ_ATTEMPTS levels (upstream issue 2780).
|
|
123
|
+
* @see lib/common/emit.c:update_bb_bz
|
|
124
|
+
*/
|
|
125
|
+
export function updateBbBz(bb: Box, cp: Point[]): void {
|
|
126
|
+
updateBbBzCore(bb, cp, UPDATE_BB_BZ_ATTEMPTS);
|
|
109
127
|
}
|
|
110
128
|
|
|
111
129
|
// ---------------------------------------------------------------------------
|
|
@@ -35,9 +35,10 @@ class BeginRegSide {
|
|
|
35
35
|
static topLeft(ctx: BeginCtx): void {
|
|
36
36
|
const { P, n, endp, ranksep } = ctx;
|
|
37
37
|
const b = endp.nb;
|
|
38
|
+
// C: GD_ranksep is int (types.h:335), so /2 truncates
|
|
38
39
|
endp.boxes[0] = {
|
|
39
40
|
ll: { x: b.ll.x - 1, y: P.start.p.y },
|
|
40
|
-
ur: { x: b.ur.x, y: n.info.coord.y + n.info.ht / 2 + ranksep / 2 },
|
|
41
|
+
ur: { x: b.ur.x, y: n.info.coord.y + n.info.ht / 2 + Math.trunc(ranksep / 2) },
|
|
41
42
|
};
|
|
42
43
|
endp.boxes[1] = {
|
|
43
44
|
ll: { x: b.ll.x - 1, y: n.info.coord.y - n.info.ht / 2 },
|
|
@@ -50,7 +51,7 @@ class BeginRegSide {
|
|
|
50
51
|
const b = endp.nb;
|
|
51
52
|
endp.boxes[0] = {
|
|
52
53
|
ll: { x: b.ll.x, y: P.start.p.y },
|
|
53
|
-
ur: { x: b.ur.x + 1, y: n.info.coord.y + n.info.ht / 2 + ranksep / 2 },
|
|
54
|
+
ur: { x: b.ur.x + 1, y: n.info.coord.y + n.info.ht / 2 + Math.trunc(ranksep / 2) },
|
|
54
55
|
};
|
|
55
56
|
endp.boxes[1] = {
|
|
56
57
|
ll: { x: n.info.coord.x + n.info.rw + (FUDGE - 2), y: n.info.coord.y - n.info.ht / 2 },
|
|
@@ -121,7 +122,7 @@ class BeginFlatSide {
|
|
|
121
122
|
const { P, n, endp, ranksep } = ctx;
|
|
122
123
|
if (endp.sidemask === TOP) {
|
|
123
124
|
endp.boxes[0] = {
|
|
124
|
-
ll: { x: P.start.p.x, y: n.info.coord.y - n.info.ht / 2 - ranksep / 2 },
|
|
125
|
+
ll: { x: P.start.p.x, y: n.info.coord.y - n.info.ht / 2 - Math.trunc(ranksep / 2) },
|
|
125
126
|
ur: { x: b.ur.x + 1, y: n.info.coord.y - n.info.ht / 2 },
|
|
126
127
|
};
|
|
127
128
|
endp.boxes[1] = {
|
|
@@ -45,8 +45,9 @@ class EndRegSide {
|
|
|
45
45
|
const { P, n, e, endp, ranksep } = ctx;
|
|
46
46
|
const b = endp.nb;
|
|
47
47
|
if (P.end.p.x < n.info.coord.x) {
|
|
48
|
+
// C: GD_ranksep is int (types.h:335), so /2 truncates
|
|
48
49
|
endp.boxes[0] = {
|
|
49
|
-
ll: { x: b.ll.x - 1, y: n.info.coord.y - n.info.ht / 2 - ranksep / 2 },
|
|
50
|
+
ll: { x: b.ll.x - 1, y: n.info.coord.y - n.info.ht / 2 - Math.trunc(ranksep / 2) },
|
|
50
51
|
ur: { x: b.ur.x, y: P.end.p.y },
|
|
51
52
|
};
|
|
52
53
|
endp.boxes[1] = {
|
|
@@ -55,7 +56,7 @@ class EndRegSide {
|
|
|
55
56
|
};
|
|
56
57
|
} else {
|
|
57
58
|
endp.boxes[0] = {
|
|
58
|
-
ll: { x: b.ll.x, y: n.info.coord.y - n.info.ht / 2 - ranksep / 2 },
|
|
59
|
+
ll: { x: b.ll.x, y: n.info.coord.y - n.info.ht / 2 - Math.trunc(ranksep / 2) },
|
|
59
60
|
ur: { x: b.ur.x + 1, y: P.end.p.y },
|
|
60
61
|
};
|
|
61
62
|
endp.boxes[1] = {
|
|
@@ -121,7 +122,7 @@ class EndFlatSide {
|
|
|
121
122
|
const { P, n, endp, ranksep } = ctx;
|
|
122
123
|
if (endp.sidemask === TOP) {
|
|
123
124
|
endp.boxes[0] = {
|
|
124
|
-
ll: { x: b.ll.x - 1, y: n.info.coord.y - n.info.ht / 2 - ranksep / 2 },
|
|
125
|
+
ll: { x: b.ll.x - 1, y: n.info.coord.y - n.info.ht / 2 - Math.trunc(ranksep / 2) },
|
|
125
126
|
ur: { x: P.end.p.x, y: n.info.coord.y - n.info.ht / 2 },
|
|
126
127
|
};
|
|
127
128
|
endp.boxes[1] = {
|
|
@@ -16,6 +16,7 @@ import type { Poly } from '../pathplan/types.js';
|
|
|
16
16
|
import { INIT_DELTA, LOOP_TRIES, ROUTESPL_FUDGE } from './splines-constants.js';
|
|
17
17
|
import { fma } from './fma.js';
|
|
18
18
|
import { agerrorf } from './agerr.js';
|
|
19
|
+
import { gfmt5 } from '../render/dot/xdot-ops.js';
|
|
19
20
|
|
|
20
21
|
// ---------------------------------------------------------------------------
|
|
21
22
|
// Stage-dump hook (diagnosis only; null in production — same pattern as
|
|
@@ -158,15 +159,46 @@ function clampPoint(p: Point, box: Box): void {
|
|
|
158
159
|
// checkPath
|
|
159
160
|
// ---------------------------------------------------------------------------
|
|
160
161
|
|
|
162
|
+
/** One port line of printpath: `(%.5g, %.5g), tangent angle: %.5g, %s`. */
|
|
163
|
+
function portText(port: Path['start']): string {
|
|
164
|
+
const constrained = port.constrained ? 'constrained' : 'not constrained';
|
|
165
|
+
return `(${gfmt5(port.p.x)}, ${gfmt5(port.p.y)}), tangent angle: ${gfmt5(port.theta)}, ${constrained}`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Dump a path: its box count, each box, and both ports. C writes these with
|
|
170
|
+
* plain `fprintf(stderr)`, not agerr, so they go straight to `console.error`
|
|
171
|
+
* (the channel of the `Error:` line checkpath prints just before them) and a
|
|
172
|
+
* caller-set `agseterrf` function does not receive them.
|
|
173
|
+
* @see lib/common/routespl.c:printpath
|
|
174
|
+
*/
|
|
175
|
+
function printPath(pp: Path): void {
|
|
176
|
+
console.error(`${pp.nbox} boxes:`);
|
|
177
|
+
for (let bi = 0; bi < pp.nbox; bi++) {
|
|
178
|
+
const { ll, ur } = pp.boxes[bi];
|
|
179
|
+
console.error(`${bi} (${gfmt5(ll.x)}, ${gfmt5(ll.y)}), (${gfmt5(ur.x)}, ${gfmt5(ur.y)})`);
|
|
180
|
+
}
|
|
181
|
+
console.error(`start port: ${portText(pp.start)}`);
|
|
182
|
+
console.error(`end port: ${portText(pp.end)}`);
|
|
183
|
+
}
|
|
184
|
+
|
|
161
185
|
/**
|
|
162
186
|
* Repairs minor errors in the box path (gaps, slight overlaps).
|
|
163
187
|
* Returns true on hard failure; false on success.
|
|
164
188
|
* Mutates boxes[] and pp in place.
|
|
165
189
|
*
|
|
190
|
+
* A path with no box left after the degenerate-box filter is a hard failure
|
|
191
|
+
* that reports the path (graphviz 16.1.1, upstream 2773, 2774, 2776, 2778).
|
|
192
|
+
*
|
|
166
193
|
* @see lib/common/routespl.c:checkpath
|
|
167
194
|
*/
|
|
168
195
|
export function checkPath(boxn: number, boxes: Box[], pp: Path): boolean {
|
|
169
196
|
const bn = removeDegenerateBoxes(boxes, boxn);
|
|
197
|
+
if (bn === 0) {
|
|
198
|
+
agerrorf('in checkpath, all bounding boxes are below threshold');
|
|
199
|
+
printPath(pp);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
170
202
|
if (boxes[0].ll.x > boxes[0].ur.x || boxes[0].ll.y > boxes[0].ur.y) return true;
|
|
171
203
|
|
|
172
204
|
for (let bi = 0; bi + 1 < bn; bi++) {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
graph 1 6.
|
|
2
|
-
node a
|
|
3
|
-
node b
|
|
4
|
-
node e
|
|
5
|
-
node c 1.
|
|
6
|
-
node d 1.
|
|
7
|
-
node p
|
|
8
|
-
node q
|
|
9
|
-
node r
|
|
10
|
-
node s
|
|
11
|
-
edge a a 7
|
|
12
|
-
edge a b
|
|
13
|
-
edge a e
|
|
14
|
-
edge a c 4
|
|
15
|
-
edge b c 4
|
|
16
|
-
edge c d 4 1.
|
|
17
|
-
edge p q
|
|
18
|
-
edge p r
|
|
19
|
-
edge p s 4
|
|
1
|
+
graph 1 6.8472 3.9
|
|
2
|
+
node a 2.4722 2.9167 0.75 0.5 a solid ellipse black lightgrey
|
|
3
|
+
node b 1.375 2.9167 0.75 0.5 b solid ellipse black lightgrey
|
|
4
|
+
node e 0.375 2.9167 0.75 0.5 e solid ellipse black lightgrey
|
|
5
|
+
node c 1.9167 1.9167 0.75 0.5 c solid ellipse black lightgrey
|
|
6
|
+
node d 1.9167 0.91667 0.75 0.5 d solid ellipse black lightgrey
|
|
7
|
+
node p 6.4722 1.25 0.75 0.5 p solid ellipse black lightgrey
|
|
8
|
+
node q 5.375 1.25 0.75 0.5 q solid ellipse black lightgrey
|
|
9
|
+
node r 4.375 1.25 0.75 0.5 r solid ellipse black lightgrey
|
|
10
|
+
node s 6.4722 0.25 0.75 0.5 s solid ellipse black lightgrey
|
|
11
|
+
edge a a 7 2.7745 3.0714 2.9425 3.1003 3.0972 3.0487 3.0972 2.9167 3.0972 2.828 3.0274 2.7756 2.9306 2.7595 solid black
|
|
12
|
+
edge a b 4 2.0939 2.9167 2.0353 2.9167 1.9738 2.9167 1.9124 2.9167 x 1.9236 3.075 solid black
|
|
13
|
+
edge a e 7 2.2964 3.1413 2.1207 3.3457 1.8304 3.6335 1.503 3.7556 1.1535 3.8858 0.81939 3.5617 0.60677 3.2792 zz 1.4167 3.7833 solid black
|
|
14
|
+
edge a c 4 2.3434 2.6773 2.2782 2.5632 2.1974 2.4218 2.1238 2.293 y 0.36111 0.66667 solid black
|
|
15
|
+
edge b c 4 1.5006 2.6773 1.5642 2.5632 1.6429 2.4218 1.7148 2.293 solid black
|
|
16
|
+
edge c d 4 1.9167 1.6625 1.9167 1.5612 1.9167 1.4406 1.9167 1.3269 solid black
|
|
17
|
+
edge p q 4 6.0939 1.25 6.0353 1.25 5.9738 1.25 5.9124 1.25 k 5.9236 1.4083 solid black
|
|
18
|
+
edge p r 7 6.2939 1.4747 6.1159 1.6791 5.8221 1.967 5.4923 2.0889 5.1466 2.2166 4.8177 1.8973 4.6074 1.6165 m 5.4167 2.1167 solid black
|
|
19
|
+
edge p s 4 6.4722 0.99579 6.4722 0.89454 6.4722 0.77398 6.4722 0.66022 solid black
|
|
20
20
|
stop
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
graph 1
|
|
2
|
-
node a
|
|
3
|
-
node b
|
|
4
|
-
node e
|
|
5
|
-
node c
|
|
6
|
-
node d
|
|
7
|
-
node p
|
|
8
|
-
node q
|
|
9
|
-
node r
|
|
10
|
-
node s
|
|
11
|
-
edge a a 14 8.
|
|
12
|
-
edge a b
|
|
13
|
-
edge a e
|
|
14
|
-
edge a c 11
|
|
15
|
-
edge b c 8
|
|
16
|
-
edge c d 8
|
|
17
|
-
edge p q
|
|
18
|
-
edge p r
|
|
19
|
-
edge p s
|
|
1
|
+
graph 1 10.444 7.2886
|
|
2
|
+
node a 9.8194 3.6528 0.75 0.5 a solid ellipse black lightgrey
|
|
3
|
+
node b 8.7222 3.6528 0.75 0.5 b solid ellipse black lightgrey
|
|
4
|
+
node e 5.7222 3.6528 0.75 0.5 e solid ellipse black lightgrey
|
|
5
|
+
node c 7.7222 3.6528 0.75 0.5 c solid ellipse black lightgrey
|
|
6
|
+
node d 6.7222 3.6528 0.75 0.5 d solid ellipse black lightgrey
|
|
7
|
+
node p 3.4722 0.25 0.75 0.5 p solid ellipse black lightgrey
|
|
8
|
+
node q 2.375 0.25 0.75 0.5 q solid ellipse black lightgrey
|
|
9
|
+
node r 1.375 0.25 0.75 0.5 r solid ellipse black lightgrey
|
|
10
|
+
node s 0.375 0.25 0.75 0.5 s solid ellipse black lightgrey
|
|
11
|
+
edge a a 14 8.4828 6.4742 8.6508 6.5031 8.8056 6.4515 8.8056 6.3194 8.8056 6.2307 8.7357 6.1783 8.6389 6.1623 10.173 3.7457 10.32 3.7521 10.444 3.7211 10.444 3.6528 10.444 3.6111 10.398 3.5833 10.329 3.5695 solid black
|
|
12
|
+
edge a b 8 9.4411 3.6528 9.3825 3.6528 9.321 3.6528 9.2596 3.6528 7.6208 6.3194 7.6821 6.3194 7.7436 6.3194 7.8023 6.3194 x 9.2708 3.8111 solid black
|
|
13
|
+
edge a e 17 9.6983 3.895 9.5826 4.0965 9.3874 4.3693 9.128 4.4917 8.5321 4.7727 6.8438 4.1212 6.2222 3.9028 6.2005 3.8951 6.1785 3.8868 6.1564 3.8779 6.3151 6.682 6.5277 6.9645 6.8619 7.2886 7.2113 7.1583 7.5387 7.0363 7.8291 6.7484 8.0047 6.544 zz 9.0417 4.5194 solid black
|
|
14
|
+
edge a c 11 9.6172 3.8703 9.4101 4.0756 9.0674 4.3696 8.7014 4.4917 8.3867 4.5966 8.1083 4.299 7.9296 4.0297 7.8321 5.6957 7.9057 5.8246 7.9865 5.9659 8.0517 6.0801 y 8.6528 4.5194 solid black
|
|
15
|
+
edge b c 8 8.3437 3.6528 8.3159 3.6528 8.2881 3.6528 8.2603 3.6528 7.4231 5.6957 7.3513 5.8246 7.2725 5.9659 7.209 6.0801 solid black
|
|
16
|
+
edge c d 8 7.3437 3.6528 7.3159 3.6528 7.2881 3.6528 7.2603 3.6528 7.625 4.7297 7.625 4.8434 7.625 4.964 7.625 5.0652 solid black
|
|
17
|
+
edge p q 8 3.0939 0.25 3.0353 0.25 2.9738 0.25 2.9124 0.25 6.2874 1.25 6.3488 1.25 6.4103 1.25 6.4689 1.25 k 2.9236 0.40833 solid black
|
|
18
|
+
edge p r 14 3.2939 0.47465 3.1159 0.6791 2.8221 0.967 2.4923 1.0889 2.1466 1.2166 1.8177 0.89726 1.6074 0.61649 4.9824 1.6165 5.1927 1.8973 5.5216 2.2166 5.8673 2.0889 6.1971 1.967 6.4909 1.6791 6.6689 1.4747 m 2.4167 1.1167 solid black
|
|
19
|
+
edge p s 14 3.2509 0.45635 3.1169 0.5668 2.9363 0.6918 2.75 0.75 2.0076 0.98191 1.7339 1.0074 1 0.75 0.88822 0.71079 0.78157 0.64225 0.68904 0.56825 6.8472 0.66022 6.8472 0.77398 6.8472 0.89454 6.8472 0.99579 solid black
|
|
20
20
|
stop
|