@linkiez/dxf-renew 7.0.0 → 7.2.0
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/.eslintrc.json +1 -16
- package/.github/instructions/code-patterns.instructions.md +1 -1
- package/.github/instructions/exdxf.instruction.md +161 -0
- package/.github/instructions/tdd.instructions.md +271 -0
- package/.yarn/install-state.gz +0 -0
- package/ARCHITECTURE.md +163 -0
- package/CHANGELOG.md +39 -0
- package/CONTRIBUTING.md +16 -14
- package/README.md +113 -16
- package/{PLAN.md → ROADMAP.md} +244 -102
- package/dist/dxf.js +2212 -454
- package/docs/EZDXF_REFERENCE_SITEMAP.md +55 -0
- package/docs/FIXTURE_VALIDATION_EZDXF.md +62 -0
- package/lib/Helper.cjs +6 -2
- package/lib/Helper.cjs.map +3 -3
- package/lib/Helper.js +6 -2
- package/lib/Helper.js.map +2 -2
- package/lib/denormalise.cjs +131 -91
- package/lib/denormalise.cjs.map +2 -2
- package/lib/denormalise.js +131 -91
- package/lib/denormalise.js.map +2 -2
- package/lib/dimensionToSVG.cjs +318 -53
- package/lib/dimensionToSVG.cjs.map +3 -3
- package/lib/dimensionToSVG.js +316 -52
- package/lib/dimensionToSVG.js.map +2 -2
- package/lib/entityToPolyline.cjs +95 -0
- package/lib/entityToPolyline.cjs.map +3 -3
- package/lib/entityToPolyline.js +95 -0
- package/lib/entityToPolyline.js.map +2 -2
- package/lib/handlers/entities.cjs +111 -27
- package/lib/handlers/entities.cjs.map +3 -3
- package/lib/handlers/entities.js +111 -27
- package/lib/handlers/entities.js.map +3 -3
- package/lib/handlers/entity/dgnUnderlay.cjs +106 -0
- package/lib/handlers/entity/dgnUnderlay.cjs.map +7 -0
- package/lib/handlers/entity/dgnUnderlay.js +71 -0
- package/lib/handlers/entity/dgnUnderlay.js.map +7 -0
- package/lib/handlers/entity/dimension.cjs +24 -0
- package/lib/handlers/entity/dimension.cjs.map +2 -2
- package/lib/handlers/entity/dimension.js +24 -0
- package/lib/handlers/entity/dimension.js.map +2 -2
- package/lib/handlers/entity/dwfUnderlay.cjs +106 -0
- package/lib/handlers/entity/dwfUnderlay.cjs.map +7 -0
- package/lib/handlers/entity/dwfUnderlay.js +71 -0
- package/lib/handlers/entity/dwfUnderlay.js.map +7 -0
- package/lib/handlers/entity/image.cjs +123 -0
- package/lib/handlers/entity/image.cjs.map +7 -0
- package/lib/handlers/entity/image.js +88 -0
- package/lib/handlers/entity/image.js.map +7 -0
- package/lib/handlers/entity/leader.cjs +148 -0
- package/lib/handlers/entity/leader.cjs.map +7 -0
- package/lib/handlers/entity/leader.js +113 -0
- package/lib/handlers/entity/leader.js.map +7 -0
- package/lib/handlers/entity/mleader.cjs +69 -0
- package/lib/handlers/entity/mleader.cjs.map +7 -0
- package/lib/handlers/entity/mleader.js +34 -0
- package/lib/handlers/entity/mleader.js.map +7 -0
- package/lib/handlers/entity/mline.cjs +91 -0
- package/lib/handlers/entity/mline.cjs.map +7 -0
- package/lib/handlers/entity/mline.js +56 -0
- package/lib/handlers/entity/mline.js.map +7 -0
- package/lib/handlers/entity/oleframe.cjs +98 -0
- package/lib/handlers/entity/oleframe.cjs.map +7 -0
- package/lib/handlers/entity/oleframe.js +63 -0
- package/lib/handlers/entity/oleframe.js.map +7 -0
- package/lib/handlers/entity/pdfUnderlay.cjs +106 -0
- package/lib/handlers/entity/pdfUnderlay.cjs.map +7 -0
- package/lib/handlers/entity/pdfUnderlay.js +71 -0
- package/lib/handlers/entity/pdfUnderlay.js.map +7 -0
- package/lib/handlers/entity/ray.cjs +81 -0
- package/lib/handlers/entity/ray.cjs.map +7 -0
- package/lib/handlers/entity/ray.js +46 -0
- package/lib/handlers/entity/ray.js.map +7 -0
- package/lib/handlers/entity/region.cjs +67 -0
- package/lib/handlers/entity/region.cjs.map +7 -0
- package/lib/handlers/entity/region.js +32 -0
- package/lib/handlers/entity/region.js.map +7 -0
- package/lib/handlers/entity/shape.cjs +95 -0
- package/lib/handlers/entity/shape.cjs.map +7 -0
- package/lib/handlers/entity/shape.js +60 -0
- package/lib/handlers/entity/shape.js.map +7 -0
- package/lib/handlers/entity/table.cjs +71 -0
- package/lib/handlers/entity/table.cjs.map +7 -0
- package/lib/handlers/entity/table.js +36 -0
- package/lib/handlers/entity/table.js.map +7 -0
- package/lib/handlers/entity/tolerance.cjs +90 -0
- package/lib/handlers/entity/tolerance.cjs.map +7 -0
- package/lib/handlers/entity/tolerance.js +55 -0
- package/lib/handlers/entity/tolerance.js.map +7 -0
- package/lib/handlers/entity/trace.cjs +101 -0
- package/lib/handlers/entity/trace.cjs.map +7 -0
- package/lib/handlers/entity/trace.js +66 -0
- package/lib/handlers/entity/trace.js.map +7 -0
- package/lib/handlers/entity/wipeout.cjs +122 -0
- package/lib/handlers/entity/wipeout.cjs.map +7 -0
- package/lib/handlers/entity/wipeout.js +87 -0
- package/lib/handlers/entity/wipeout.js.map +7 -0
- package/lib/handlers/entity/xline.cjs +81 -0
- package/lib/handlers/entity/xline.cjs.map +7 -0
- package/lib/handlers/entity/xline.js +46 -0
- package/lib/handlers/entity/xline.js.map +7 -0
- package/lib/handlers/objects.cjs +299 -136
- package/lib/handlers/objects.cjs.map +2 -2
- package/lib/handlers/objects.js +299 -136
- package/lib/handlers/objects.js.map +2 -2
- package/lib/handlers/tables.cjs +96 -17
- package/lib/handlers/tables.cjs.map +2 -2
- package/lib/handlers/tables.js +96 -17
- package/lib/handlers/tables.js.map +2 -2
- package/lib/index.cjs +5 -2
- package/lib/index.cjs.map +3 -3
- package/lib/index.js +18 -16
- package/lib/index.js.map +3 -3
- package/lib/toJson.cjs +29 -0
- package/lib/toJson.cjs.map +7 -0
- package/lib/toJson.js +9 -0
- package/lib/toJson.js.map +7 -0
- package/lib/toSVG.cjs +105 -11
- package/lib/toSVG.cjs.map +3 -3
- package/lib/toSVG.js +106 -12
- package/lib/toSVG.js.map +2 -2
- package/lib/types/dimension-entity.cjs.map +1 -1
- package/lib/types/entity.cjs.map +1 -1
- package/lib/types/helper.cjs.map +1 -1
- package/lib/types/image-entity.cjs +17 -0
- package/lib/types/image-entity.cjs.map +7 -0
- package/lib/types/image-entity.js +1 -0
- package/lib/types/image-entity.js.map +7 -0
- package/lib/types/index.cjs +28 -0
- package/lib/types/index.cjs.map +2 -2
- package/lib/types/index.js +14 -0
- package/lib/types/index.js.map +2 -2
- package/lib/types/leader-entity.cjs +17 -0
- package/lib/types/leader-entity.cjs.map +7 -0
- package/lib/types/leader-entity.js +1 -0
- package/lib/types/leader-entity.js.map +7 -0
- package/lib/types/mleader-entity.cjs +17 -0
- package/lib/types/mleader-entity.cjs.map +7 -0
- package/lib/types/mleader-entity.js +1 -0
- package/lib/types/mleader-entity.js.map +7 -0
- package/lib/types/mline-entity.cjs +17 -0
- package/lib/types/mline-entity.cjs.map +7 -0
- package/lib/types/mline-entity.js +1 -0
- package/lib/types/mline-entity.js.map +7 -0
- package/lib/types/oleframe-entity.cjs +17 -0
- package/lib/types/oleframe-entity.cjs.map +7 -0
- package/lib/types/oleframe-entity.js +1 -0
- package/lib/types/oleframe-entity.js.map +7 -0
- package/lib/types/options.cjs.map +1 -1
- package/lib/types/ray-entity.cjs +17 -0
- package/lib/types/ray-entity.cjs.map +7 -0
- package/lib/types/ray-entity.js +1 -0
- package/lib/types/ray-entity.js.map +7 -0
- package/lib/types/region-entity.cjs +17 -0
- package/lib/types/region-entity.cjs.map +7 -0
- package/lib/types/region-entity.js +1 -0
- package/lib/types/region-entity.js.map +7 -0
- package/lib/types/shape-entity.cjs +17 -0
- package/lib/types/shape-entity.cjs.map +7 -0
- package/lib/types/shape-entity.js +1 -0
- package/lib/types/shape-entity.js.map +7 -0
- package/lib/types/table-entity.cjs +17 -0
- package/lib/types/table-entity.cjs.map +7 -0
- package/lib/types/table-entity.js +1 -0
- package/lib/types/table-entity.js.map +7 -0
- package/lib/types/tables.cjs.map +1 -1
- package/lib/types/tolerance-entity.cjs +17 -0
- package/lib/types/tolerance-entity.cjs.map +7 -0
- package/lib/types/tolerance-entity.js +1 -0
- package/lib/types/tolerance-entity.js.map +7 -0
- package/lib/types/trace-entity.cjs +17 -0
- package/lib/types/trace-entity.cjs.map +7 -0
- package/lib/types/trace-entity.js +1 -0
- package/lib/types/trace-entity.js.map +7 -0
- package/lib/types/underlay-entity.cjs +17 -0
- package/lib/types/underlay-entity.cjs.map +7 -0
- package/lib/types/underlay-entity.js +1 -0
- package/lib/types/underlay-entity.js.map +7 -0
- package/lib/types/wipeout-entity.cjs +17 -0
- package/lib/types/wipeout-entity.cjs.map +7 -0
- package/lib/types/wipeout-entity.js +1 -0
- package/lib/types/wipeout-entity.js.map +7 -0
- package/lib/types/xline-entity.cjs +17 -0
- package/lib/types/xline-entity.cjs.map +7 -0
- package/lib/types/xline-entity.js +1 -0
- package/lib/types/xline-entity.js.map +7 -0
- package/lib/util/escapeXmlText.cjs +27 -0
- package/lib/util/escapeXmlText.cjs.map +7 -0
- package/lib/util/escapeXmlText.js +7 -0
- package/lib/util/escapeXmlText.js.map +7 -0
- package/package.json +9 -18
- package/playwright.config.cjs +20 -0
- package/src/Helper.ts +8 -3
- package/src/denormalise.ts +182 -116
- package/src/dimensionToSVG.ts +466 -54
- package/src/entityToPolyline.ts +124 -2
- package/src/handlers/entities.ts +129 -34
- package/src/handlers/entity/dgnUnderlay.ts +94 -0
- package/src/handlers/entity/dimension.ts +27 -1
- package/src/handlers/entity/dwfUnderlay.ts +94 -0
- package/src/handlers/entity/image.ts +118 -0
- package/src/handlers/entity/leader.ts +153 -0
- package/src/handlers/entity/mleader.ts +46 -0
- package/src/handlers/entity/mline.ts +74 -0
- package/src/handlers/entity/oleframe.ts +62 -0
- package/src/handlers/entity/pdfUnderlay.ts +94 -0
- package/src/handlers/entity/ray.ts +52 -0
- package/src/handlers/entity/region.ts +42 -0
- package/src/handlers/entity/shape.ts +73 -0
- package/src/handlers/entity/table.ts +49 -0
- package/src/handlers/entity/tolerance.ts +75 -0
- package/src/handlers/entity/trace.ts +72 -0
- package/src/handlers/entity/wipeout.ts +114 -0
- package/src/handlers/entity/xline.ts +52 -0
- package/src/handlers/objects.ts +379 -139
- package/src/handlers/tables.ts +134 -21
- package/src/index.ts +9 -18
- package/src/toJson.ts +8 -0
- package/src/toSVG.ts +143 -10
- package/src/types/dimension-entity.ts +11 -0
- package/src/types/entity.ts +30 -0
- package/src/types/helper.ts +2 -1
- package/src/types/image-entity.ts +35 -0
- package/src/types/index.ts +14 -0
- package/src/types/leader-entity.ts +40 -0
- package/src/types/mleader-entity.ts +8 -0
- package/src/types/mline-entity.ts +12 -0
- package/src/types/oleframe-entity.ts +40 -0
- package/src/types/options.ts +48 -0
- package/src/types/ray-entity.ts +12 -0
- package/src/types/region-entity.ts +11 -0
- package/src/types/shape-entity.ts +19 -0
- package/src/types/table-entity.ts +14 -0
- package/src/types/tables.ts +160 -0
- package/src/types/tolerance-entity.ts +20 -0
- package/src/types/trace-entity.ts +14 -0
- package/src/types/underlay-entity.ts +35 -0
- package/src/types/wipeout-entity.ts +20 -0
- package/src/types/xline-entity.ts +12 -0
- package/src/util/escapeXmlText.ts +10 -0
- package/tools/browser_test_server.cjs +87 -0
- package/tools/ezdxf_generate_dimensions_all_types.py +246 -0
- package/tools/ezdxf_generate_dimensions_angular_3p.py +59 -0
- package/tools/ezdxf_generate_dimensions_large_scale.py +87 -0
- package/tools/ezdxf_regenerate_problem_fixtures.py +184 -0
- package/tools/ezdxf_validate_fixtures.py +165 -0
- package/docs/DIMENSION_SUMMARY.md +0 -248
- package/docs/DIMENSION_SUMMARY.pt-BR.md +0 -248
- package/docs/IMPLEMENTED-2D-ENTITIES.md +0 -54
- package/docs/IMPLEMENTED-2D-ENTITIES.pt-BR.md +0 -54
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.md +0 -241
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.pt-BR.md +0 -169
package/dist/dxf.js
CHANGED
|
@@ -1391,8 +1391,8 @@ var dxf = (() => {
|
|
|
1391
1391
|
"node_modules/lodash/_Set.js"(exports, module) {
|
|
1392
1392
|
var getNative = require_getNative();
|
|
1393
1393
|
var root = require_root();
|
|
1394
|
-
var
|
|
1395
|
-
module.exports =
|
|
1394
|
+
var Set2 = getNative(root, "Set");
|
|
1395
|
+
module.exports = Set2;
|
|
1396
1396
|
}
|
|
1397
1397
|
});
|
|
1398
1398
|
|
|
@@ -1412,7 +1412,7 @@ var dxf = (() => {
|
|
|
1412
1412
|
var DataView = require_DataView();
|
|
1413
1413
|
var Map = require_Map();
|
|
1414
1414
|
var Promise2 = require_Promise();
|
|
1415
|
-
var
|
|
1415
|
+
var Set2 = require_Set();
|
|
1416
1416
|
var WeakMap = require_WeakMap();
|
|
1417
1417
|
var baseGetTag = require_baseGetTag();
|
|
1418
1418
|
var toSource = require_toSource();
|
|
@@ -1425,10 +1425,10 @@ var dxf = (() => {
|
|
|
1425
1425
|
var dataViewCtorString = toSource(DataView);
|
|
1426
1426
|
var mapCtorString = toSource(Map);
|
|
1427
1427
|
var promiseCtorString = toSource(Promise2);
|
|
1428
|
-
var setCtorString = toSource(
|
|
1428
|
+
var setCtorString = toSource(Set2);
|
|
1429
1429
|
var weakMapCtorString = toSource(WeakMap);
|
|
1430
1430
|
var getTag = baseGetTag;
|
|
1431
|
-
if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag ||
|
|
1431
|
+
if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
|
|
1432
1432
|
getTag = function(value) {
|
|
1433
1433
|
var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
|
|
1434
1434
|
if (ctorString) {
|
|
@@ -2730,6 +2730,7 @@ var dxf = (() => {
|
|
|
2730
2730
|
denormalise: () => denormalise,
|
|
2731
2731
|
groupEntitiesByLayer: () => groupEntitiesByLayer,
|
|
2732
2732
|
parseString: () => parseString,
|
|
2733
|
+
toJson: () => toJson,
|
|
2733
2734
|
toPolylines: () => toPolylines,
|
|
2734
2735
|
toSVG: () => toSVG
|
|
2735
2736
|
});
|
|
@@ -2742,6 +2743,9 @@ var dxf = (() => {
|
|
|
2742
2743
|
};
|
|
2743
2744
|
var config_default = config;
|
|
2744
2745
|
|
|
2746
|
+
// src/denormalise.ts
|
|
2747
|
+
var import_cloneDeep = __toESM(require_cloneDeep(), 1);
|
|
2748
|
+
|
|
2745
2749
|
// src/util/logger.ts
|
|
2746
2750
|
function info(...args) {
|
|
2747
2751
|
if (config_default.verbose) {
|
|
@@ -2762,6 +2766,172 @@ var dxf = (() => {
|
|
|
2762
2766
|
error
|
|
2763
2767
|
};
|
|
2764
2768
|
|
|
2769
|
+
// src/denormalise.ts
|
|
2770
|
+
function adjustLineForBlockBasePoint(entity, block) {
|
|
2771
|
+
const line = entity;
|
|
2772
|
+
line.start.x -= block.x;
|
|
2773
|
+
line.start.y -= block.y;
|
|
2774
|
+
line.end.x -= block.x;
|
|
2775
|
+
line.end.y -= block.y;
|
|
2776
|
+
}
|
|
2777
|
+
function adjustPolylineForBlockBasePoint(entity, block) {
|
|
2778
|
+
const poly = entity;
|
|
2779
|
+
for (const v of poly.vertices) {
|
|
2780
|
+
if (v.x !== void 0) v.x -= block.x;
|
|
2781
|
+
if (v.y !== void 0) v.y -= block.y;
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
function adjustCircleForBlockBasePoint(entity, block) {
|
|
2785
|
+
const circle2 = entity;
|
|
2786
|
+
circle2.x -= block.x;
|
|
2787
|
+
circle2.y -= block.y;
|
|
2788
|
+
}
|
|
2789
|
+
function adjustEllipseForBlockBasePoint(entity, block) {
|
|
2790
|
+
const ellipse2 = entity;
|
|
2791
|
+
ellipse2.x -= block.x;
|
|
2792
|
+
ellipse2.y -= block.y;
|
|
2793
|
+
}
|
|
2794
|
+
function adjustArcForBlockBasePoint(entity, block) {
|
|
2795
|
+
const arc2 = entity;
|
|
2796
|
+
arc2.x -= block.x;
|
|
2797
|
+
arc2.y -= block.y;
|
|
2798
|
+
}
|
|
2799
|
+
function adjustSplineForBlockBasePoint(entity, block) {
|
|
2800
|
+
const spline = entity;
|
|
2801
|
+
for (const cp of spline.controlPoints) {
|
|
2802
|
+
cp.x -= block.x;
|
|
2803
|
+
cp.y -= block.y;
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
function adjustTextForBlockBasePoint(entity, block) {
|
|
2807
|
+
const text2 = entity;
|
|
2808
|
+
if (text2.x !== void 0) text2.x -= block.x;
|
|
2809
|
+
if (text2.y !== void 0) text2.y -= block.y;
|
|
2810
|
+
if (text2.x2 !== void 0) text2.x2 -= block.x;
|
|
2811
|
+
if (text2.y2 !== void 0) text2.y2 -= block.y;
|
|
2812
|
+
}
|
|
2813
|
+
function adjustMTextForBlockBasePoint(entity, block) {
|
|
2814
|
+
const mtext2 = entity;
|
|
2815
|
+
if (mtext2.x !== void 0) mtext2.x -= block.x;
|
|
2816
|
+
if (mtext2.y !== void 0) mtext2.y -= block.y;
|
|
2817
|
+
}
|
|
2818
|
+
function adjustDimensionForBlockBasePoint(entity, block) {
|
|
2819
|
+
const dim = entity;
|
|
2820
|
+
dim.start.x -= block.x;
|
|
2821
|
+
dim.start.y -= block.y;
|
|
2822
|
+
dim.textMidpoint.x -= block.x;
|
|
2823
|
+
dim.textMidpoint.y -= block.y;
|
|
2824
|
+
dim.measureStart.x -= block.x;
|
|
2825
|
+
dim.measureStart.y -= block.y;
|
|
2826
|
+
dim.measureEnd.x -= block.x;
|
|
2827
|
+
dim.measureEnd.y -= block.y;
|
|
2828
|
+
}
|
|
2829
|
+
var BLOCK_BASEPOINT_ADJUSTERS = {
|
|
2830
|
+
LINE: adjustLineForBlockBasePoint,
|
|
2831
|
+
LWPOLYLINE: adjustPolylineForBlockBasePoint,
|
|
2832
|
+
POLYLINE: adjustPolylineForBlockBasePoint,
|
|
2833
|
+
CIRCLE: adjustCircleForBlockBasePoint,
|
|
2834
|
+
ELLIPSE: adjustEllipseForBlockBasePoint,
|
|
2835
|
+
ARC: adjustArcForBlockBasePoint,
|
|
2836
|
+
SPLINE: adjustSplineForBlockBasePoint,
|
|
2837
|
+
TEXT: adjustTextForBlockBasePoint,
|
|
2838
|
+
MTEXT: adjustMTextForBlockBasePoint,
|
|
2839
|
+
DIMENSION: adjustDimensionForBlockBasePoint
|
|
2840
|
+
};
|
|
2841
|
+
function applyBlockBasePointAdjustment(entity, block) {
|
|
2842
|
+
const adjust = BLOCK_BASEPOINT_ADJUSTERS[entity.type];
|
|
2843
|
+
if (adjust) adjust(entity, block);
|
|
2844
|
+
}
|
|
2845
|
+
function computeRectangularArrayVectors(insert) {
|
|
2846
|
+
const rowCount = insert.rowCount ?? 1;
|
|
2847
|
+
const columnCount = insert.columnCount ?? 1;
|
|
2848
|
+
const rowSpacing = insert.rowSpacing ?? 0;
|
|
2849
|
+
const columnSpacing = insert.columnSpacing ?? 0;
|
|
2850
|
+
const rotation = insert.rotation ?? 0;
|
|
2851
|
+
if (rowCount <= 1 && columnCount <= 1) {
|
|
2852
|
+
return { rowVec: { x: 0, y: 0 }, colVec: { x: 0, y: 0 } };
|
|
2853
|
+
}
|
|
2854
|
+
const cos = Math.cos(rotation * Math.PI / 180);
|
|
2855
|
+
const sin = Math.sin(rotation * Math.PI / 180);
|
|
2856
|
+
return {
|
|
2857
|
+
rowVec: { x: -sin * rowSpacing, y: cos * rowSpacing },
|
|
2858
|
+
colVec: { x: cos * columnSpacing, y: sin * columnSpacing }
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2861
|
+
function expandInsert(insert, blocksByName, transforms, gatherEntities) {
|
|
2862
|
+
const block = blocksByName[insert.block];
|
|
2863
|
+
if (!block) {
|
|
2864
|
+
logger_default.error("no block found for insert. block:", insert.block);
|
|
2865
|
+
return [];
|
|
2866
|
+
}
|
|
2867
|
+
const rowCount = insert.rowCount ?? 1;
|
|
2868
|
+
const columnCount = insert.columnCount ?? 1;
|
|
2869
|
+
const { rowVec, colVec } = computeRectangularArrayVectors(insert);
|
|
2870
|
+
const current = [];
|
|
2871
|
+
for (let r = 0; r < rowCount; r++) {
|
|
2872
|
+
for (let c = 0; c < columnCount; c++) {
|
|
2873
|
+
const t = {
|
|
2874
|
+
x: insert.x + rowVec.x * r + colVec.x * c,
|
|
2875
|
+
y: insert.y + rowVec.y * r + colVec.y * c,
|
|
2876
|
+
scaleX: insert.scaleX,
|
|
2877
|
+
scaleY: insert.scaleY,
|
|
2878
|
+
scaleZ: insert.scaleZ,
|
|
2879
|
+
extrusionX: insert.extrusionX,
|
|
2880
|
+
extrusionY: insert.extrusionY,
|
|
2881
|
+
extrusionZ: insert.extrusionZ,
|
|
2882
|
+
rotation: insert.rotation
|
|
2883
|
+
};
|
|
2884
|
+
const transforms2 = transforms.slice(0);
|
|
2885
|
+
transforms2.push(t);
|
|
2886
|
+
const blockEntities = block.entities.map((be) => {
|
|
2887
|
+
const be2 = (0, import_cloneDeep.default)(be);
|
|
2888
|
+
be2.layer = insert.layer;
|
|
2889
|
+
applyBlockBasePointAdjustment(be2, block);
|
|
2890
|
+
return be2;
|
|
2891
|
+
});
|
|
2892
|
+
current.push(...gatherEntities(blockEntities, transforms2));
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
return current;
|
|
2896
|
+
}
|
|
2897
|
+
function denormalise(parseResult) {
|
|
2898
|
+
const blocksByName = parseResult.blocks.reduce(
|
|
2899
|
+
(acc, b) => {
|
|
2900
|
+
acc[b.name] = b;
|
|
2901
|
+
return acc;
|
|
2902
|
+
},
|
|
2903
|
+
{}
|
|
2904
|
+
);
|
|
2905
|
+
const gatherEntities = (entities, transforms) => {
|
|
2906
|
+
const current = [];
|
|
2907
|
+
for (const e of entities) {
|
|
2908
|
+
if (e.type === "INSERT") {
|
|
2909
|
+
current.push(
|
|
2910
|
+
...expandInsert(e, blocksByName, transforms, gatherEntities)
|
|
2911
|
+
);
|
|
2912
|
+
} else {
|
|
2913
|
+
const e2 = (0, import_cloneDeep.default)(e);
|
|
2914
|
+
e2.transforms = transforms.slice().reverse();
|
|
2915
|
+
current.push(e2);
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
return current;
|
|
2919
|
+
};
|
|
2920
|
+
return gatherEntities(parseResult.entities, []);
|
|
2921
|
+
}
|
|
2922
|
+
|
|
2923
|
+
// src/groupEntitiesByLayer.ts
|
|
2924
|
+
function groupEntitiesByLayer(entities) {
|
|
2925
|
+
return entities.reduce((acc, entity) => {
|
|
2926
|
+
const layer = entity.layer ?? "0";
|
|
2927
|
+
if (!acc[layer]) {
|
|
2928
|
+
acc[layer] = [];
|
|
2929
|
+
}
|
|
2930
|
+
acc[layer].push(entity);
|
|
2931
|
+
return acc;
|
|
2932
|
+
}, {});
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2765
2935
|
// src/handlers/entity/common.ts
|
|
2766
2936
|
function parseCommonEntityProperties(type, value) {
|
|
2767
2937
|
switch (type) {
|
|
@@ -3316,9 +3486,75 @@ var dxf = (() => {
|
|
|
3316
3486
|
};
|
|
3317
3487
|
var circle_default = { TYPE: TYPE6, process: process6 };
|
|
3318
3488
|
|
|
3319
|
-
// src/handlers/entity/
|
|
3320
|
-
var TYPE7 = "
|
|
3489
|
+
// src/handlers/entity/dgnUnderlay.ts
|
|
3490
|
+
var TYPE7 = "DGNUNDERLAY";
|
|
3321
3491
|
var process7 = (tuples) => {
|
|
3492
|
+
return tuples.reduce(
|
|
3493
|
+
(entity, tuple) => {
|
|
3494
|
+
const type = tuple[0];
|
|
3495
|
+
const value = tuple[1];
|
|
3496
|
+
switch (type) {
|
|
3497
|
+
case 340:
|
|
3498
|
+
entity.underlayDefinitionHandle = String(value);
|
|
3499
|
+
break;
|
|
3500
|
+
case 10:
|
|
3501
|
+
entity.insertionPoint.x = value;
|
|
3502
|
+
break;
|
|
3503
|
+
case 20:
|
|
3504
|
+
entity.insertionPoint.y = value;
|
|
3505
|
+
break;
|
|
3506
|
+
case 30:
|
|
3507
|
+
entity.insertionPoint.z = value;
|
|
3508
|
+
break;
|
|
3509
|
+
case 41:
|
|
3510
|
+
entity.scale.x = value;
|
|
3511
|
+
break;
|
|
3512
|
+
case 42:
|
|
3513
|
+
entity.scale.y = value;
|
|
3514
|
+
break;
|
|
3515
|
+
case 43:
|
|
3516
|
+
entity.scale.z = value;
|
|
3517
|
+
break;
|
|
3518
|
+
case 50:
|
|
3519
|
+
entity.rotation = value;
|
|
3520
|
+
break;
|
|
3521
|
+
case 210:
|
|
3522
|
+
entity.normal.x = value;
|
|
3523
|
+
break;
|
|
3524
|
+
case 220:
|
|
3525
|
+
entity.normal.y = value;
|
|
3526
|
+
break;
|
|
3527
|
+
case 230:
|
|
3528
|
+
entity.normal.z = value;
|
|
3529
|
+
break;
|
|
3530
|
+
case 280:
|
|
3531
|
+
entity.flags = value;
|
|
3532
|
+
break;
|
|
3533
|
+
case 281:
|
|
3534
|
+
entity.contrast = value;
|
|
3535
|
+
break;
|
|
3536
|
+
case 282:
|
|
3537
|
+
entity.fade = value;
|
|
3538
|
+
break;
|
|
3539
|
+
default:
|
|
3540
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
3541
|
+
break;
|
|
3542
|
+
}
|
|
3543
|
+
return entity;
|
|
3544
|
+
},
|
|
3545
|
+
{
|
|
3546
|
+
type: TYPE7,
|
|
3547
|
+
insertionPoint: { x: 0, y: 0, z: 0 },
|
|
3548
|
+
scale: { x: 1, y: 1, z: 1 },
|
|
3549
|
+
normal: { x: 0, y: 0, z: 1 }
|
|
3550
|
+
}
|
|
3551
|
+
);
|
|
3552
|
+
};
|
|
3553
|
+
var dgnUnderlay_default = { TYPE: TYPE7, process: process7 };
|
|
3554
|
+
|
|
3555
|
+
// src/handlers/entity/dimension.ts
|
|
3556
|
+
var TYPE8 = "DIMENSION";
|
|
3557
|
+
var process8 = (tuples) => {
|
|
3322
3558
|
return tuples.reduce(
|
|
3323
3559
|
(entity, tuple) => {
|
|
3324
3560
|
const type = tuple[0];
|
|
@@ -3369,6 +3605,30 @@ var dxf = (() => {
|
|
|
3369
3605
|
case 34:
|
|
3370
3606
|
entity.measureEnd.z = value;
|
|
3371
3607
|
break;
|
|
3608
|
+
case 15:
|
|
3609
|
+
entity.angleVertex = entity.angleVertex || { x: 0, y: 0, z: 0 };
|
|
3610
|
+
entity.angleVertex.x = value;
|
|
3611
|
+
break;
|
|
3612
|
+
case 25:
|
|
3613
|
+
entity.angleVertex = entity.angleVertex || { x: 0, y: 0, z: 0 };
|
|
3614
|
+
entity.angleVertex.y = value;
|
|
3615
|
+
break;
|
|
3616
|
+
case 35:
|
|
3617
|
+
entity.angleVertex = entity.angleVertex || { x: 0, y: 0, z: 0 };
|
|
3618
|
+
entity.angleVertex.z = value;
|
|
3619
|
+
break;
|
|
3620
|
+
case 16:
|
|
3621
|
+
entity.arcPoint = entity.arcPoint || { x: 0, y: 0, z: 0 };
|
|
3622
|
+
entity.arcPoint.x = value;
|
|
3623
|
+
break;
|
|
3624
|
+
case 26:
|
|
3625
|
+
entity.arcPoint = entity.arcPoint || { x: 0, y: 0, z: 0 };
|
|
3626
|
+
entity.arcPoint.y = value;
|
|
3627
|
+
break;
|
|
3628
|
+
case 36:
|
|
3629
|
+
entity.arcPoint = entity.arcPoint || { x: 0, y: 0, z: 0 };
|
|
3630
|
+
entity.arcPoint.z = value;
|
|
3631
|
+
break;
|
|
3372
3632
|
case 50:
|
|
3373
3633
|
entity.rotation = value;
|
|
3374
3634
|
break;
|
|
@@ -3429,7 +3689,7 @@ var dxf = (() => {
|
|
|
3429
3689
|
return entity;
|
|
3430
3690
|
},
|
|
3431
3691
|
{
|
|
3432
|
-
type:
|
|
3692
|
+
type: TYPE8,
|
|
3433
3693
|
start: { x: 0, y: 0, z: 0 },
|
|
3434
3694
|
measureStart: { x: 0, y: 0, z: 0 },
|
|
3435
3695
|
measureEnd: { x: 0, y: 0, z: 0 },
|
|
@@ -3477,11 +3737,77 @@ var dxf = (() => {
|
|
|
3477
3737
|
userDefinedLocation
|
|
3478
3738
|
};
|
|
3479
3739
|
}
|
|
3480
|
-
var dimension_default = { TYPE:
|
|
3740
|
+
var dimension_default = { TYPE: TYPE8, process: process8 };
|
|
3741
|
+
|
|
3742
|
+
// src/handlers/entity/dwfUnderlay.ts
|
|
3743
|
+
var TYPE9 = "DWFUNDERLAY";
|
|
3744
|
+
var process9 = (tuples) => {
|
|
3745
|
+
return tuples.reduce(
|
|
3746
|
+
(entity, tuple) => {
|
|
3747
|
+
const type = tuple[0];
|
|
3748
|
+
const value = tuple[1];
|
|
3749
|
+
switch (type) {
|
|
3750
|
+
case 340:
|
|
3751
|
+
entity.underlayDefinitionHandle = String(value);
|
|
3752
|
+
break;
|
|
3753
|
+
case 10:
|
|
3754
|
+
entity.insertionPoint.x = value;
|
|
3755
|
+
break;
|
|
3756
|
+
case 20:
|
|
3757
|
+
entity.insertionPoint.y = value;
|
|
3758
|
+
break;
|
|
3759
|
+
case 30:
|
|
3760
|
+
entity.insertionPoint.z = value;
|
|
3761
|
+
break;
|
|
3762
|
+
case 41:
|
|
3763
|
+
entity.scale.x = value;
|
|
3764
|
+
break;
|
|
3765
|
+
case 42:
|
|
3766
|
+
entity.scale.y = value;
|
|
3767
|
+
break;
|
|
3768
|
+
case 43:
|
|
3769
|
+
entity.scale.z = value;
|
|
3770
|
+
break;
|
|
3771
|
+
case 50:
|
|
3772
|
+
entity.rotation = value;
|
|
3773
|
+
break;
|
|
3774
|
+
case 210:
|
|
3775
|
+
entity.normal.x = value;
|
|
3776
|
+
break;
|
|
3777
|
+
case 220:
|
|
3778
|
+
entity.normal.y = value;
|
|
3779
|
+
break;
|
|
3780
|
+
case 230:
|
|
3781
|
+
entity.normal.z = value;
|
|
3782
|
+
break;
|
|
3783
|
+
case 280:
|
|
3784
|
+
entity.flags = value;
|
|
3785
|
+
break;
|
|
3786
|
+
case 281:
|
|
3787
|
+
entity.contrast = value;
|
|
3788
|
+
break;
|
|
3789
|
+
case 282:
|
|
3790
|
+
entity.fade = value;
|
|
3791
|
+
break;
|
|
3792
|
+
default:
|
|
3793
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
3794
|
+
break;
|
|
3795
|
+
}
|
|
3796
|
+
return entity;
|
|
3797
|
+
},
|
|
3798
|
+
{
|
|
3799
|
+
type: TYPE9,
|
|
3800
|
+
insertionPoint: { x: 0, y: 0, z: 0 },
|
|
3801
|
+
scale: { x: 1, y: 1, z: 1 },
|
|
3802
|
+
normal: { x: 0, y: 0, z: 1 }
|
|
3803
|
+
}
|
|
3804
|
+
);
|
|
3805
|
+
};
|
|
3806
|
+
var dwfUnderlay_default = { TYPE: TYPE9, process: process9 };
|
|
3481
3807
|
|
|
3482
3808
|
// src/handlers/entity/ellipse.ts
|
|
3483
|
-
var
|
|
3484
|
-
var
|
|
3809
|
+
var TYPE10 = "ELLIPSE";
|
|
3810
|
+
var process10 = (tuples) => {
|
|
3485
3811
|
return tuples.reduce(
|
|
3486
3812
|
(entity, tuple) => {
|
|
3487
3813
|
const type = tuple[0];
|
|
@@ -3521,14 +3847,14 @@ var dxf = (() => {
|
|
|
3521
3847
|
return entity;
|
|
3522
3848
|
},
|
|
3523
3849
|
{
|
|
3524
|
-
type:
|
|
3850
|
+
type: TYPE10
|
|
3525
3851
|
}
|
|
3526
3852
|
);
|
|
3527
3853
|
};
|
|
3528
|
-
var ellipse_default = { TYPE:
|
|
3854
|
+
var ellipse_default = { TYPE: TYPE10, process: process10 };
|
|
3529
3855
|
|
|
3530
3856
|
// src/handlers/entity/hatch.ts
|
|
3531
|
-
var
|
|
3857
|
+
var TYPE11 = "HATCH";
|
|
3532
3858
|
var status = "IDLE";
|
|
3533
3859
|
var drawEntity = {};
|
|
3534
3860
|
var drawType = 0;
|
|
@@ -3536,7 +3862,7 @@ var dxf = (() => {
|
|
|
3536
3862
|
var seed = null;
|
|
3537
3863
|
var loop = { references: [], entities: [] };
|
|
3538
3864
|
var polyPoint = null;
|
|
3539
|
-
var
|
|
3865
|
+
var process11 = (tuples) => {
|
|
3540
3866
|
status = "IDLE";
|
|
3541
3867
|
drawEntity = {};
|
|
3542
3868
|
drawType = 0;
|
|
@@ -3745,7 +4071,7 @@ var dxf = (() => {
|
|
|
3745
4071
|
return entity;
|
|
3746
4072
|
},
|
|
3747
4073
|
{
|
|
3748
|
-
type:
|
|
4074
|
+
type: TYPE11,
|
|
3749
4075
|
elevation: { x: 0, y: 0, z: 0 },
|
|
3750
4076
|
extrusionDir: { x: 0, y: 0, z: 1 },
|
|
3751
4077
|
pattern: {
|
|
@@ -3775,7 +4101,7 @@ var dxf = (() => {
|
|
|
3775
4101
|
}
|
|
3776
4102
|
);
|
|
3777
4103
|
};
|
|
3778
|
-
var hatch_default = { TYPE:
|
|
4104
|
+
var hatch_default = { TYPE: TYPE11, process: process11 };
|
|
3779
4105
|
function createDrawEntity(type) {
|
|
3780
4106
|
if (isPolyline) return {};
|
|
3781
4107
|
switch (type) {
|
|
@@ -3957,9 +4283,92 @@ var dxf = (() => {
|
|
|
3957
4283
|
}
|
|
3958
4284
|
}
|
|
3959
4285
|
|
|
4286
|
+
// src/handlers/entity/image.ts
|
|
4287
|
+
var TYPE12 = "IMAGE";
|
|
4288
|
+
var process12 = (tuples) => {
|
|
4289
|
+
return tuples.reduce(
|
|
4290
|
+
(entity, tuple) => {
|
|
4291
|
+
const type = tuple[0];
|
|
4292
|
+
const value = tuple[1];
|
|
4293
|
+
switch (type) {
|
|
4294
|
+
case 90:
|
|
4295
|
+
entity.classVersion = value;
|
|
4296
|
+
break;
|
|
4297
|
+
case 10:
|
|
4298
|
+
entity.insertionPoint.x = value;
|
|
4299
|
+
break;
|
|
4300
|
+
case 20:
|
|
4301
|
+
entity.insertionPoint.y = value;
|
|
4302
|
+
break;
|
|
4303
|
+
case 30:
|
|
4304
|
+
entity.insertionPoint.z = value;
|
|
4305
|
+
break;
|
|
4306
|
+
case 11:
|
|
4307
|
+
entity.uVector.x = value;
|
|
4308
|
+
break;
|
|
4309
|
+
case 21:
|
|
4310
|
+
entity.uVector.y = value;
|
|
4311
|
+
break;
|
|
4312
|
+
case 31:
|
|
4313
|
+
entity.uVector.z = value;
|
|
4314
|
+
break;
|
|
4315
|
+
case 12:
|
|
4316
|
+
entity.vVector.x = value;
|
|
4317
|
+
break;
|
|
4318
|
+
case 22:
|
|
4319
|
+
entity.vVector.y = value;
|
|
4320
|
+
break;
|
|
4321
|
+
case 32:
|
|
4322
|
+
entity.vVector.z = value;
|
|
4323
|
+
break;
|
|
4324
|
+
case 13:
|
|
4325
|
+
entity.pixelSizeX = value;
|
|
4326
|
+
break;
|
|
4327
|
+
case 23:
|
|
4328
|
+
entity.pixelSizeY = value;
|
|
4329
|
+
break;
|
|
4330
|
+
case 340:
|
|
4331
|
+
entity.imageDefHandle = String(value);
|
|
4332
|
+
break;
|
|
4333
|
+
case 360:
|
|
4334
|
+
entity.imageDefReactorHandle = String(value);
|
|
4335
|
+
break;
|
|
4336
|
+
case 70:
|
|
4337
|
+
entity.displayProperties = value;
|
|
4338
|
+
break;
|
|
4339
|
+
case 280:
|
|
4340
|
+
entity.clippingState = value;
|
|
4341
|
+
break;
|
|
4342
|
+
case 281:
|
|
4343
|
+
entity.brightness = value;
|
|
4344
|
+
break;
|
|
4345
|
+
case 282:
|
|
4346
|
+
entity.contrast = value;
|
|
4347
|
+
break;
|
|
4348
|
+
case 283:
|
|
4349
|
+
entity.fade = value;
|
|
4350
|
+
break;
|
|
4351
|
+
default:
|
|
4352
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
4353
|
+
break;
|
|
4354
|
+
}
|
|
4355
|
+
return entity;
|
|
4356
|
+
},
|
|
4357
|
+
{
|
|
4358
|
+
type: TYPE12,
|
|
4359
|
+
insertionPoint: {},
|
|
4360
|
+
uVector: {},
|
|
4361
|
+
vVector: {},
|
|
4362
|
+
pixelSizeX: 0,
|
|
4363
|
+
pixelSizeY: 0
|
|
4364
|
+
}
|
|
4365
|
+
);
|
|
4366
|
+
};
|
|
4367
|
+
var image_default = { TYPE: TYPE12, process: process12 };
|
|
4368
|
+
|
|
3960
4369
|
// src/handlers/entity/insert.ts
|
|
3961
|
-
var
|
|
3962
|
-
var
|
|
4370
|
+
var TYPE13 = "INSERT";
|
|
4371
|
+
var process13 = (tuples) => {
|
|
3963
4372
|
return tuples.reduce(
|
|
3964
4373
|
(entity, tuple) => {
|
|
3965
4374
|
const type = tuple[0];
|
|
@@ -4017,36 +4426,144 @@ var dxf = (() => {
|
|
|
4017
4426
|
return entity;
|
|
4018
4427
|
},
|
|
4019
4428
|
{
|
|
4020
|
-
type:
|
|
4429
|
+
type: TYPE13
|
|
4021
4430
|
}
|
|
4022
4431
|
);
|
|
4023
4432
|
};
|
|
4024
|
-
var insert_default = { TYPE:
|
|
4433
|
+
var insert_default = { TYPE: TYPE13, process: process13 };
|
|
4025
4434
|
|
|
4026
|
-
// src/handlers/entity/
|
|
4027
|
-
var
|
|
4028
|
-
|
|
4435
|
+
// src/handlers/entity/leader.ts
|
|
4436
|
+
var TYPE14 = "LEADER";
|
|
4437
|
+
function ensureVector3(entity, key) {
|
|
4438
|
+
if (!entity[key]) entity[key] = { x: 0, y: 0, z: 0 };
|
|
4439
|
+
return entity[key];
|
|
4440
|
+
}
|
|
4441
|
+
var process14 = (tuples) => {
|
|
4029
4442
|
return tuples.reduce(
|
|
4030
4443
|
(entity, tuple) => {
|
|
4031
4444
|
const type = tuple[0];
|
|
4032
4445
|
const value = tuple[1];
|
|
4033
4446
|
switch (type) {
|
|
4034
|
-
case
|
|
4035
|
-
entity.
|
|
4447
|
+
case 3:
|
|
4448
|
+
entity.dimensionStyleName = String(value);
|
|
4036
4449
|
break;
|
|
4037
|
-
case
|
|
4038
|
-
entity.
|
|
4450
|
+
case 71:
|
|
4451
|
+
entity.arrowheadFlag = value;
|
|
4039
4452
|
break;
|
|
4040
|
-
case
|
|
4041
|
-
entity.
|
|
4453
|
+
case 72:
|
|
4454
|
+
entity.pathType = value;
|
|
4042
4455
|
break;
|
|
4043
|
-
case
|
|
4044
|
-
entity.
|
|
4456
|
+
case 73:
|
|
4457
|
+
entity.creationFlag = value;
|
|
4045
4458
|
break;
|
|
4046
|
-
case
|
|
4047
|
-
entity.
|
|
4459
|
+
case 74:
|
|
4460
|
+
entity.hooklineDirectionFlag = value;
|
|
4048
4461
|
break;
|
|
4049
|
-
case
|
|
4462
|
+
case 75:
|
|
4463
|
+
entity.hooklineFlag = value;
|
|
4464
|
+
break;
|
|
4465
|
+
case 40:
|
|
4466
|
+
entity.textHeight = value;
|
|
4467
|
+
break;
|
|
4468
|
+
case 41:
|
|
4469
|
+
entity.textWidth = value;
|
|
4470
|
+
break;
|
|
4471
|
+
case 76:
|
|
4472
|
+
entity.vertexCount = value;
|
|
4473
|
+
break;
|
|
4474
|
+
case 10:
|
|
4475
|
+
entity.vertices.push({ x: value, y: 0, z: 0 });
|
|
4476
|
+
break;
|
|
4477
|
+
case 20: {
|
|
4478
|
+
const current = entity.vertices[entity.vertices.length - 1];
|
|
4479
|
+
if (current) current.y = value;
|
|
4480
|
+
break;
|
|
4481
|
+
}
|
|
4482
|
+
case 30: {
|
|
4483
|
+
const current = entity.vertices[entity.vertices.length - 1];
|
|
4484
|
+
if (current) current.z = value;
|
|
4485
|
+
break;
|
|
4486
|
+
}
|
|
4487
|
+
case 77:
|
|
4488
|
+
entity.color = value;
|
|
4489
|
+
break;
|
|
4490
|
+
case 340:
|
|
4491
|
+
entity.annotationHandle = String(value);
|
|
4492
|
+
break;
|
|
4493
|
+
case 210:
|
|
4494
|
+
ensureVector3(entity, "normal").x = value;
|
|
4495
|
+
break;
|
|
4496
|
+
case 220:
|
|
4497
|
+
ensureVector3(entity, "normal").y = value;
|
|
4498
|
+
break;
|
|
4499
|
+
case 230:
|
|
4500
|
+
ensureVector3(entity, "normal").z = value;
|
|
4501
|
+
break;
|
|
4502
|
+
case 211:
|
|
4503
|
+
ensureVector3(entity, "horizontalDirection").x = value;
|
|
4504
|
+
break;
|
|
4505
|
+
case 221:
|
|
4506
|
+
ensureVector3(entity, "horizontalDirection").y = value;
|
|
4507
|
+
break;
|
|
4508
|
+
case 231:
|
|
4509
|
+
ensureVector3(entity, "horizontalDirection").z = value;
|
|
4510
|
+
break;
|
|
4511
|
+
case 212:
|
|
4512
|
+
ensureVector3(entity, "blockOffset").x = value;
|
|
4513
|
+
break;
|
|
4514
|
+
case 222:
|
|
4515
|
+
ensureVector3(entity, "blockOffset").y = value;
|
|
4516
|
+
break;
|
|
4517
|
+
case 232:
|
|
4518
|
+
ensureVector3(entity, "blockOffset").z = value;
|
|
4519
|
+
break;
|
|
4520
|
+
case 213:
|
|
4521
|
+
ensureVector3(entity, "annotationOffset").x = value;
|
|
4522
|
+
break;
|
|
4523
|
+
case 223:
|
|
4524
|
+
ensureVector3(entity, "annotationOffset").y = value;
|
|
4525
|
+
break;
|
|
4526
|
+
case 233:
|
|
4527
|
+
ensureVector3(entity, "annotationOffset").z = value;
|
|
4528
|
+
break;
|
|
4529
|
+
default:
|
|
4530
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
4531
|
+
break;
|
|
4532
|
+
}
|
|
4533
|
+
return entity;
|
|
4534
|
+
},
|
|
4535
|
+
{
|
|
4536
|
+
type: TYPE14,
|
|
4537
|
+
vertices: []
|
|
4538
|
+
}
|
|
4539
|
+
);
|
|
4540
|
+
};
|
|
4541
|
+
var leader_default = { TYPE: TYPE14, process: process14 };
|
|
4542
|
+
|
|
4543
|
+
// src/handlers/entity/line.ts
|
|
4544
|
+
var TYPE15 = "LINE";
|
|
4545
|
+
var process15 = (tuples) => {
|
|
4546
|
+
return tuples.reduce(
|
|
4547
|
+
(entity, tuple) => {
|
|
4548
|
+
const type = tuple[0];
|
|
4549
|
+
const value = tuple[1];
|
|
4550
|
+
switch (type) {
|
|
4551
|
+
case 10:
|
|
4552
|
+
entity.start.x = value;
|
|
4553
|
+
break;
|
|
4554
|
+
case 20:
|
|
4555
|
+
entity.start.y = value;
|
|
4556
|
+
break;
|
|
4557
|
+
case 30:
|
|
4558
|
+
entity.start.z = value;
|
|
4559
|
+
break;
|
|
4560
|
+
case 39:
|
|
4561
|
+
entity.thickness = value;
|
|
4562
|
+
break;
|
|
4563
|
+
case 11:
|
|
4564
|
+
entity.end.x = value;
|
|
4565
|
+
break;
|
|
4566
|
+
case 21:
|
|
4050
4567
|
entity.end.y = value;
|
|
4051
4568
|
break;
|
|
4052
4569
|
case 31:
|
|
@@ -4059,17 +4576,17 @@ var dxf = (() => {
|
|
|
4059
4576
|
return entity;
|
|
4060
4577
|
},
|
|
4061
4578
|
{
|
|
4062
|
-
type:
|
|
4579
|
+
type: TYPE15,
|
|
4063
4580
|
start: {},
|
|
4064
4581
|
end: {}
|
|
4065
4582
|
}
|
|
4066
4583
|
);
|
|
4067
4584
|
};
|
|
4068
|
-
var line_default = { TYPE:
|
|
4585
|
+
var line_default = { TYPE: TYPE15, process: process15 };
|
|
4069
4586
|
|
|
4070
4587
|
// src/handlers/entity/lwpolyline.ts
|
|
4071
|
-
var
|
|
4072
|
-
var
|
|
4588
|
+
var TYPE16 = "LWPOLYLINE";
|
|
4589
|
+
var process16 = (tuples) => {
|
|
4073
4590
|
let vertex;
|
|
4074
4591
|
return tuples.reduce(
|
|
4075
4592
|
(entity, tuple) => {
|
|
@@ -4102,16 +4619,96 @@ var dxf = (() => {
|
|
|
4102
4619
|
return entity;
|
|
4103
4620
|
},
|
|
4104
4621
|
{
|
|
4105
|
-
type:
|
|
4622
|
+
type: TYPE16,
|
|
4106
4623
|
vertices: []
|
|
4107
4624
|
}
|
|
4108
4625
|
);
|
|
4109
4626
|
};
|
|
4110
|
-
var lwpolyline_default = { TYPE:
|
|
4627
|
+
var lwpolyline_default = { TYPE: TYPE16, process: process16 };
|
|
4628
|
+
|
|
4629
|
+
// src/handlers/entity/mleader.ts
|
|
4630
|
+
var TYPE17 = "MLEADER";
|
|
4631
|
+
var process17 = (tuples) => {
|
|
4632
|
+
return tuples.reduce(
|
|
4633
|
+
(entity, tuple) => {
|
|
4634
|
+
const code = tuple[0];
|
|
4635
|
+
const value = tuple[1];
|
|
4636
|
+
switch (code) {
|
|
4637
|
+
// Style name
|
|
4638
|
+
case 2:
|
|
4639
|
+
entity.styleName = String(value);
|
|
4640
|
+
break;
|
|
4641
|
+
// Text string (simplified). MLEADER text can also be stored in more complex structures.
|
|
4642
|
+
case 1:
|
|
4643
|
+
entity.text = String(value);
|
|
4644
|
+
break;
|
|
4645
|
+
default:
|
|
4646
|
+
Object.assign(entity, parseCommonEntityProperties(code, value));
|
|
4647
|
+
break;
|
|
4648
|
+
}
|
|
4649
|
+
return entity;
|
|
4650
|
+
},
|
|
4651
|
+
{
|
|
4652
|
+
type: TYPE17
|
|
4653
|
+
}
|
|
4654
|
+
);
|
|
4655
|
+
};
|
|
4656
|
+
var mleader_default = { TYPE: TYPE17, process: process17 };
|
|
4657
|
+
|
|
4658
|
+
// src/handlers/entity/mline.ts
|
|
4659
|
+
var TYPE18 = "MLINE";
|
|
4660
|
+
function ensurePoint3(entity, key) {
|
|
4661
|
+
entity[key] ??= {};
|
|
4662
|
+
return entity[key];
|
|
4663
|
+
}
|
|
4664
|
+
var process18 = (tuples) => {
|
|
4665
|
+
return tuples.reduce(
|
|
4666
|
+
(entity, tuple) => {
|
|
4667
|
+
const code = tuple[0];
|
|
4668
|
+
const value = tuple[1];
|
|
4669
|
+
switch (code) {
|
|
4670
|
+
// Start point
|
|
4671
|
+
case 10:
|
|
4672
|
+
ensurePoint3(entity, "startPoint").x = value;
|
|
4673
|
+
break;
|
|
4674
|
+
case 20:
|
|
4675
|
+
ensurePoint3(entity, "startPoint").y = value;
|
|
4676
|
+
break;
|
|
4677
|
+
case 30:
|
|
4678
|
+
ensurePoint3(entity, "startPoint").z = value;
|
|
4679
|
+
break;
|
|
4680
|
+
// End point
|
|
4681
|
+
case 11:
|
|
4682
|
+
ensurePoint3(entity, "endPoint").x = value;
|
|
4683
|
+
break;
|
|
4684
|
+
case 21:
|
|
4685
|
+
ensurePoint3(entity, "endPoint").y = value;
|
|
4686
|
+
break;
|
|
4687
|
+
case 31:
|
|
4688
|
+
ensurePoint3(entity, "endPoint").z = value;
|
|
4689
|
+
break;
|
|
4690
|
+
case 71:
|
|
4691
|
+
entity.vertexCount = value;
|
|
4692
|
+
break;
|
|
4693
|
+
case 2:
|
|
4694
|
+
entity.styleName = String(value);
|
|
4695
|
+
break;
|
|
4696
|
+
default:
|
|
4697
|
+
Object.assign(entity, parseCommonEntityProperties(code, value));
|
|
4698
|
+
break;
|
|
4699
|
+
}
|
|
4700
|
+
return entity;
|
|
4701
|
+
},
|
|
4702
|
+
{
|
|
4703
|
+
type: TYPE18
|
|
4704
|
+
}
|
|
4705
|
+
);
|
|
4706
|
+
};
|
|
4707
|
+
var mline_default = { TYPE: TYPE18, process: process18 };
|
|
4111
4708
|
|
|
4112
4709
|
// src/handlers/entity/ole2Frame.ts
|
|
4113
|
-
var
|
|
4114
|
-
var
|
|
4710
|
+
var TYPE19 = "OLE2FRAME";
|
|
4711
|
+
var process19 = (tuples) => {
|
|
4115
4712
|
return tuples.reduce(
|
|
4116
4713
|
(entity, tuple) => {
|
|
4117
4714
|
const type = tuple[0];
|
|
@@ -4160,16 +4757,140 @@ var dxf = (() => {
|
|
|
4160
4757
|
return entity;
|
|
4161
4758
|
},
|
|
4162
4759
|
{
|
|
4163
|
-
type:
|
|
4760
|
+
type: TYPE19,
|
|
4164
4761
|
data: ""
|
|
4165
4762
|
}
|
|
4166
4763
|
);
|
|
4167
4764
|
};
|
|
4168
|
-
var ole2Frame_default = { TYPE:
|
|
4765
|
+
var ole2Frame_default = { TYPE: TYPE19, process: process19 };
|
|
4766
|
+
|
|
4767
|
+
// src/handlers/entity/oleframe.ts
|
|
4768
|
+
var TYPE20 = "OLEFRAME";
|
|
4769
|
+
var process20 = (tuples) => {
|
|
4770
|
+
return tuples.reduce(
|
|
4771
|
+
(entity, tuple) => {
|
|
4772
|
+
const type = tuple[0];
|
|
4773
|
+
const value = tuple[1];
|
|
4774
|
+
switch (type) {
|
|
4775
|
+
case 70:
|
|
4776
|
+
entity.version = value;
|
|
4777
|
+
break;
|
|
4778
|
+
case 3:
|
|
4779
|
+
entity.name = value;
|
|
4780
|
+
break;
|
|
4781
|
+
case 10:
|
|
4782
|
+
entity.upperLeftX = value;
|
|
4783
|
+
break;
|
|
4784
|
+
case 20:
|
|
4785
|
+
entity.upperLeftY = value;
|
|
4786
|
+
break;
|
|
4787
|
+
case 30:
|
|
4788
|
+
entity.upperLeftZ = value;
|
|
4789
|
+
break;
|
|
4790
|
+
case 11:
|
|
4791
|
+
entity.lowerRightX = value;
|
|
4792
|
+
break;
|
|
4793
|
+
case 21:
|
|
4794
|
+
entity.lowerRightY = value;
|
|
4795
|
+
break;
|
|
4796
|
+
case 31:
|
|
4797
|
+
entity.lowerRightZ = value;
|
|
4798
|
+
break;
|
|
4799
|
+
case 71:
|
|
4800
|
+
entity.objectType = value;
|
|
4801
|
+
break;
|
|
4802
|
+
case 72:
|
|
4803
|
+
entity.tile = value;
|
|
4804
|
+
break;
|
|
4805
|
+
case 90:
|
|
4806
|
+
entity.length = value;
|
|
4807
|
+
break;
|
|
4808
|
+
case 310:
|
|
4809
|
+
entity.data += String(value);
|
|
4810
|
+
break;
|
|
4811
|
+
default:
|
|
4812
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
4813
|
+
break;
|
|
4814
|
+
}
|
|
4815
|
+
return entity;
|
|
4816
|
+
},
|
|
4817
|
+
{
|
|
4818
|
+
type: TYPE20,
|
|
4819
|
+
data: ""
|
|
4820
|
+
}
|
|
4821
|
+
);
|
|
4822
|
+
};
|
|
4823
|
+
var oleframe_default = { TYPE: TYPE20, process: process20 };
|
|
4824
|
+
|
|
4825
|
+
// src/handlers/entity/pdfUnderlay.ts
|
|
4826
|
+
var TYPE21 = "PDFUNDERLAY";
|
|
4827
|
+
var process21 = (tuples) => {
|
|
4828
|
+
return tuples.reduce(
|
|
4829
|
+
(entity, tuple) => {
|
|
4830
|
+
const type = tuple[0];
|
|
4831
|
+
const value = tuple[1];
|
|
4832
|
+
switch (type) {
|
|
4833
|
+
case 340:
|
|
4834
|
+
entity.underlayDefinitionHandle = String(value);
|
|
4835
|
+
break;
|
|
4836
|
+
case 10:
|
|
4837
|
+
entity.insertionPoint.x = value;
|
|
4838
|
+
break;
|
|
4839
|
+
case 20:
|
|
4840
|
+
entity.insertionPoint.y = value;
|
|
4841
|
+
break;
|
|
4842
|
+
case 30:
|
|
4843
|
+
entity.insertionPoint.z = value;
|
|
4844
|
+
break;
|
|
4845
|
+
case 41:
|
|
4846
|
+
entity.scale.x = value;
|
|
4847
|
+
break;
|
|
4848
|
+
case 42:
|
|
4849
|
+
entity.scale.y = value;
|
|
4850
|
+
break;
|
|
4851
|
+
case 43:
|
|
4852
|
+
entity.scale.z = value;
|
|
4853
|
+
break;
|
|
4854
|
+
case 50:
|
|
4855
|
+
entity.rotation = value;
|
|
4856
|
+
break;
|
|
4857
|
+
case 210:
|
|
4858
|
+
entity.normal.x = value;
|
|
4859
|
+
break;
|
|
4860
|
+
case 220:
|
|
4861
|
+
entity.normal.y = value;
|
|
4862
|
+
break;
|
|
4863
|
+
case 230:
|
|
4864
|
+
entity.normal.z = value;
|
|
4865
|
+
break;
|
|
4866
|
+
case 280:
|
|
4867
|
+
entity.flags = value;
|
|
4868
|
+
break;
|
|
4869
|
+
case 281:
|
|
4870
|
+
entity.contrast = value;
|
|
4871
|
+
break;
|
|
4872
|
+
case 282:
|
|
4873
|
+
entity.fade = value;
|
|
4874
|
+
break;
|
|
4875
|
+
default:
|
|
4876
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
4877
|
+
break;
|
|
4878
|
+
}
|
|
4879
|
+
return entity;
|
|
4880
|
+
},
|
|
4881
|
+
{
|
|
4882
|
+
type: TYPE21,
|
|
4883
|
+
insertionPoint: { x: 0, y: 0, z: 0 },
|
|
4884
|
+
scale: { x: 1, y: 1, z: 1 },
|
|
4885
|
+
normal: { x: 0, y: 0, z: 1 }
|
|
4886
|
+
}
|
|
4887
|
+
);
|
|
4888
|
+
};
|
|
4889
|
+
var pdfUnderlay_default = { TYPE: TYPE21, process: process21 };
|
|
4169
4890
|
|
|
4170
4891
|
// src/handlers/entity/point.ts
|
|
4171
|
-
var
|
|
4172
|
-
var
|
|
4892
|
+
var TYPE22 = "POINT";
|
|
4893
|
+
var process22 = (tuples) => {
|
|
4173
4894
|
return tuples.reduce(
|
|
4174
4895
|
(entity, tuple) => {
|
|
4175
4896
|
const type = tuple[0];
|
|
@@ -4194,15 +4915,15 @@ var dxf = (() => {
|
|
|
4194
4915
|
return entity;
|
|
4195
4916
|
},
|
|
4196
4917
|
{
|
|
4197
|
-
type:
|
|
4918
|
+
type: TYPE22
|
|
4198
4919
|
}
|
|
4199
4920
|
);
|
|
4200
4921
|
};
|
|
4201
|
-
var point_default = { TYPE:
|
|
4922
|
+
var point_default = { TYPE: TYPE22, process: process22 };
|
|
4202
4923
|
|
|
4203
4924
|
// src/handlers/entity/polyline.ts
|
|
4204
|
-
var
|
|
4205
|
-
var
|
|
4925
|
+
var TYPE23 = "POLYLINE";
|
|
4926
|
+
var process23 = (tuples) => {
|
|
4206
4927
|
return tuples.reduce(
|
|
4207
4928
|
(entity, tuple) => {
|
|
4208
4929
|
const type = tuple[0];
|
|
@@ -4223,16 +4944,139 @@ var dxf = (() => {
|
|
|
4223
4944
|
return entity;
|
|
4224
4945
|
},
|
|
4225
4946
|
{
|
|
4226
|
-
type:
|
|
4947
|
+
type: TYPE23,
|
|
4227
4948
|
vertices: []
|
|
4228
4949
|
}
|
|
4229
4950
|
);
|
|
4230
4951
|
};
|
|
4231
|
-
var polyline_default = { TYPE:
|
|
4952
|
+
var polyline_default = { TYPE: TYPE23, process: process23 };
|
|
4953
|
+
|
|
4954
|
+
// src/handlers/entity/ray.ts
|
|
4955
|
+
var TYPE24 = "RAY";
|
|
4956
|
+
var process24 = (tuples) => {
|
|
4957
|
+
return tuples.reduce(
|
|
4958
|
+
(entity, tuple) => {
|
|
4959
|
+
const type = tuple[0];
|
|
4960
|
+
const value = tuple[1];
|
|
4961
|
+
switch (type) {
|
|
4962
|
+
case 10:
|
|
4963
|
+
entity.start.x = value;
|
|
4964
|
+
break;
|
|
4965
|
+
case 20:
|
|
4966
|
+
entity.start.y = value;
|
|
4967
|
+
break;
|
|
4968
|
+
case 30:
|
|
4969
|
+
entity.start.z = value;
|
|
4970
|
+
break;
|
|
4971
|
+
case 11:
|
|
4972
|
+
entity.direction.x = value;
|
|
4973
|
+
break;
|
|
4974
|
+
case 21:
|
|
4975
|
+
entity.direction.y = value;
|
|
4976
|
+
break;
|
|
4977
|
+
case 31:
|
|
4978
|
+
entity.direction.z = value;
|
|
4979
|
+
break;
|
|
4980
|
+
default:
|
|
4981
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
4982
|
+
break;
|
|
4983
|
+
}
|
|
4984
|
+
return entity;
|
|
4985
|
+
},
|
|
4986
|
+
{
|
|
4987
|
+
type: TYPE24,
|
|
4988
|
+
start: {},
|
|
4989
|
+
direction: {}
|
|
4990
|
+
}
|
|
4991
|
+
);
|
|
4992
|
+
};
|
|
4993
|
+
var ray_default = { TYPE: TYPE24, process: process24 };
|
|
4994
|
+
|
|
4995
|
+
// src/handlers/entity/region.ts
|
|
4996
|
+
var TYPE25 = "REGION";
|
|
4997
|
+
var process25 = (tuples) => {
|
|
4998
|
+
return tuples.reduce(
|
|
4999
|
+
(entity, tuple) => {
|
|
5000
|
+
const code = tuple[0];
|
|
5001
|
+
const value = tuple[1];
|
|
5002
|
+
switch (code) {
|
|
5003
|
+
// ACIS data text (first line: 1, additional lines: 3)
|
|
5004
|
+
case 1:
|
|
5005
|
+
case 3:
|
|
5006
|
+
entity.acisData ??= [];
|
|
5007
|
+
entity.acisData.push(String(value));
|
|
5008
|
+
break;
|
|
5009
|
+
default:
|
|
5010
|
+
Object.assign(entity, parseCommonEntityProperties(code, value));
|
|
5011
|
+
break;
|
|
5012
|
+
}
|
|
5013
|
+
return entity;
|
|
5014
|
+
},
|
|
5015
|
+
{
|
|
5016
|
+
type: TYPE25
|
|
5017
|
+
}
|
|
5018
|
+
);
|
|
5019
|
+
};
|
|
5020
|
+
var region_default = { TYPE: TYPE25, process: process25 };
|
|
5021
|
+
|
|
5022
|
+
// src/handlers/entity/shape.ts
|
|
5023
|
+
var TYPE26 = "SHAPE";
|
|
5024
|
+
var process26 = (tuples) => {
|
|
5025
|
+
return tuples.reduce(
|
|
5026
|
+
(entity, tuple) => {
|
|
5027
|
+
const type = tuple[0];
|
|
5028
|
+
const value = tuple[1];
|
|
5029
|
+
switch (type) {
|
|
5030
|
+
case 10:
|
|
5031
|
+
entity.insertionPoint.x = value;
|
|
5032
|
+
break;
|
|
5033
|
+
case 20:
|
|
5034
|
+
entity.insertionPoint.y = value;
|
|
5035
|
+
break;
|
|
5036
|
+
case 30:
|
|
5037
|
+
entity.insertionPoint.z = value;
|
|
5038
|
+
break;
|
|
5039
|
+
case 2:
|
|
5040
|
+
entity.name = String(value);
|
|
5041
|
+
break;
|
|
5042
|
+
case 39:
|
|
5043
|
+
entity.thickness = value;
|
|
5044
|
+
break;
|
|
5045
|
+
case 40:
|
|
5046
|
+
entity.size = value;
|
|
5047
|
+
break;
|
|
5048
|
+
case 41:
|
|
5049
|
+
entity.relativeXScale = value;
|
|
5050
|
+
break;
|
|
5051
|
+
case 50:
|
|
5052
|
+
entity.rotation = value;
|
|
5053
|
+
break;
|
|
5054
|
+
case 51:
|
|
5055
|
+
entity.oblique = value;
|
|
5056
|
+
break;
|
|
5057
|
+
case 210:
|
|
5058
|
+
entity.extrusionX = value;
|
|
5059
|
+
break;
|
|
5060
|
+
case 220:
|
|
5061
|
+
entity.extrusionY = value;
|
|
5062
|
+
break;
|
|
5063
|
+
default:
|
|
5064
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
5065
|
+
break;
|
|
5066
|
+
}
|
|
5067
|
+
return entity;
|
|
5068
|
+
},
|
|
5069
|
+
{
|
|
5070
|
+
type: TYPE26,
|
|
5071
|
+
insertionPoint: {}
|
|
5072
|
+
}
|
|
5073
|
+
);
|
|
5074
|
+
};
|
|
5075
|
+
var shape_default = { TYPE: TYPE26, process: process26 };
|
|
4232
5076
|
|
|
4233
5077
|
// src/handlers/entity/solid.ts
|
|
4234
|
-
var
|
|
4235
|
-
var
|
|
5078
|
+
var TYPE27 = "SOLID";
|
|
5079
|
+
var process27 = (tuples) => {
|
|
4236
5080
|
return tuples.reduce(
|
|
4237
5081
|
(entity, tuple) => {
|
|
4238
5082
|
const type = tuple[0];
|
|
@@ -4284,16 +5128,16 @@ var dxf = (() => {
|
|
|
4284
5128
|
return entity;
|
|
4285
5129
|
},
|
|
4286
5130
|
{
|
|
4287
|
-
type:
|
|
5131
|
+
type: TYPE27,
|
|
4288
5132
|
corners: [{}, {}, {}, {}]
|
|
4289
5133
|
}
|
|
4290
5134
|
);
|
|
4291
5135
|
};
|
|
4292
|
-
var solid_default = { TYPE:
|
|
5136
|
+
var solid_default = { TYPE: TYPE27, process: process27 };
|
|
4293
5137
|
|
|
4294
5138
|
// src/handlers/entity/spline.ts
|
|
4295
|
-
var
|
|
4296
|
-
var
|
|
5139
|
+
var TYPE28 = "SPLINE";
|
|
5140
|
+
var process28 = (tuples) => {
|
|
4297
5141
|
let controlPoint;
|
|
4298
5142
|
return tuples.reduce(
|
|
4299
5143
|
(entity, tuple) => {
|
|
@@ -4352,17 +5196,48 @@ var dxf = (() => {
|
|
|
4352
5196
|
return entity;
|
|
4353
5197
|
},
|
|
4354
5198
|
{
|
|
4355
|
-
type:
|
|
5199
|
+
type: TYPE28,
|
|
4356
5200
|
controlPoints: [],
|
|
4357
5201
|
knots: []
|
|
4358
5202
|
}
|
|
4359
5203
|
);
|
|
4360
5204
|
};
|
|
4361
|
-
var spline_default = { TYPE:
|
|
5205
|
+
var spline_default = { TYPE: TYPE28, process: process28 };
|
|
5206
|
+
|
|
5207
|
+
// src/handlers/entity/table.ts
|
|
5208
|
+
var TYPE29 = "TABLE";
|
|
5209
|
+
var process29 = (tuples) => {
|
|
5210
|
+
return tuples.reduce(
|
|
5211
|
+
(entity, tuple) => {
|
|
5212
|
+
const code = tuple[0];
|
|
5213
|
+
const value = tuple[1];
|
|
5214
|
+
switch (code) {
|
|
5215
|
+
case 90:
|
|
5216
|
+
entity.rows = value;
|
|
5217
|
+
break;
|
|
5218
|
+
case 91:
|
|
5219
|
+
entity.columns = value;
|
|
5220
|
+
break;
|
|
5221
|
+
case 1:
|
|
5222
|
+
entity.cellText ??= [];
|
|
5223
|
+
entity.cellText.push(String(value));
|
|
5224
|
+
break;
|
|
5225
|
+
default:
|
|
5226
|
+
Object.assign(entity, parseCommonEntityProperties(code, value));
|
|
5227
|
+
break;
|
|
5228
|
+
}
|
|
5229
|
+
return entity;
|
|
5230
|
+
},
|
|
5231
|
+
{
|
|
5232
|
+
type: TYPE29
|
|
5233
|
+
}
|
|
5234
|
+
);
|
|
5235
|
+
};
|
|
5236
|
+
var table_default = { TYPE: TYPE29, process: process29 };
|
|
4362
5237
|
|
|
4363
5238
|
// src/handlers/entity/threeDFace.ts
|
|
4364
|
-
var
|
|
4365
|
-
var
|
|
5239
|
+
var TYPE30 = "3DFACE";
|
|
5240
|
+
var process30 = (tuples) => {
|
|
4366
5241
|
return tuples.reduce(
|
|
4367
5242
|
(entity, tuple) => {
|
|
4368
5243
|
const type = tuple[0];
|
|
@@ -4372,37 +5247,148 @@ var dxf = (() => {
|
|
|
4372
5247
|
entity.vertices[0].x = value;
|
|
4373
5248
|
break;
|
|
4374
5249
|
case 20:
|
|
4375
|
-
entity.vertices[0].y = value;
|
|
5250
|
+
entity.vertices[0].y = value;
|
|
5251
|
+
break;
|
|
5252
|
+
case 30:
|
|
5253
|
+
entity.vertices[0].z = value;
|
|
5254
|
+
break;
|
|
5255
|
+
case 11:
|
|
5256
|
+
entity.vertices[1].x = value;
|
|
5257
|
+
break;
|
|
5258
|
+
case 21:
|
|
5259
|
+
entity.vertices[1].y = value;
|
|
5260
|
+
break;
|
|
5261
|
+
case 31:
|
|
5262
|
+
entity.vertices[1].z = value;
|
|
5263
|
+
break;
|
|
5264
|
+
case 12:
|
|
5265
|
+
entity.vertices[2].x = value;
|
|
5266
|
+
break;
|
|
5267
|
+
case 22:
|
|
5268
|
+
entity.vertices[2].y = value;
|
|
5269
|
+
break;
|
|
5270
|
+
case 32:
|
|
5271
|
+
entity.vertices[2].z = value;
|
|
5272
|
+
break;
|
|
5273
|
+
case 13:
|
|
5274
|
+
entity.vertices[3].x = value;
|
|
5275
|
+
break;
|
|
5276
|
+
case 23:
|
|
5277
|
+
entity.vertices[3].y = value;
|
|
5278
|
+
break;
|
|
5279
|
+
case 33:
|
|
5280
|
+
entity.vertices[3].z = value;
|
|
5281
|
+
break;
|
|
5282
|
+
default:
|
|
5283
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
5284
|
+
break;
|
|
5285
|
+
}
|
|
5286
|
+
return entity;
|
|
5287
|
+
},
|
|
5288
|
+
{
|
|
5289
|
+
type: TYPE30,
|
|
5290
|
+
vertices: [{}, {}, {}, {}]
|
|
5291
|
+
}
|
|
5292
|
+
);
|
|
5293
|
+
};
|
|
5294
|
+
var threeDFace_default = { TYPE: TYPE30, process: process30 };
|
|
5295
|
+
|
|
5296
|
+
// src/handlers/entity/tolerance.ts
|
|
5297
|
+
var TYPE31 = "TOLERANCE";
|
|
5298
|
+
function ensureVector32(entity, key) {
|
|
5299
|
+
entity[key] ??= { x: 0, y: 0, z: 0 };
|
|
5300
|
+
return entity[key];
|
|
5301
|
+
}
|
|
5302
|
+
var process31 = (tuples) => {
|
|
5303
|
+
return tuples.reduce(
|
|
5304
|
+
(entity, tuple) => {
|
|
5305
|
+
const code = tuple[0];
|
|
5306
|
+
const value = tuple[1];
|
|
5307
|
+
switch (code) {
|
|
5308
|
+
case 3:
|
|
5309
|
+
entity.dimensionStyleName = String(value);
|
|
5310
|
+
break;
|
|
5311
|
+
case 10:
|
|
5312
|
+
ensureVector32(entity, "insertionPoint").x = value;
|
|
5313
|
+
break;
|
|
5314
|
+
case 20:
|
|
5315
|
+
ensureVector32(entity, "insertionPoint").y = value;
|
|
5316
|
+
break;
|
|
5317
|
+
case 30:
|
|
5318
|
+
ensureVector32(entity, "insertionPoint").z = value;
|
|
5319
|
+
break;
|
|
5320
|
+
case 1:
|
|
5321
|
+
entity.text = String(value);
|
|
5322
|
+
break;
|
|
5323
|
+
case 11:
|
|
5324
|
+
ensureVector32(entity, "xAxisDirection").x = value;
|
|
5325
|
+
break;
|
|
5326
|
+
case 21:
|
|
5327
|
+
ensureVector32(entity, "xAxisDirection").y = value;
|
|
5328
|
+
break;
|
|
5329
|
+
case 31:
|
|
5330
|
+
ensureVector32(entity, "xAxisDirection").z = value;
|
|
5331
|
+
break;
|
|
5332
|
+
default:
|
|
5333
|
+
Object.assign(entity, parseCommonEntityProperties(code, value));
|
|
5334
|
+
break;
|
|
5335
|
+
}
|
|
5336
|
+
return entity;
|
|
5337
|
+
},
|
|
5338
|
+
{
|
|
5339
|
+
type: TYPE31,
|
|
5340
|
+
insertionPoint: { x: 0, y: 0, z: 0 }
|
|
5341
|
+
}
|
|
5342
|
+
);
|
|
5343
|
+
};
|
|
5344
|
+
var tolerance_default = { TYPE: TYPE31, process: process31 };
|
|
5345
|
+
|
|
5346
|
+
// src/handlers/entity/trace.ts
|
|
5347
|
+
var TYPE32 = "TRACE";
|
|
5348
|
+
var process32 = (tuples) => {
|
|
5349
|
+
return tuples.reduce(
|
|
5350
|
+
(entity, tuple) => {
|
|
5351
|
+
const type = tuple[0];
|
|
5352
|
+
const value = tuple[1];
|
|
5353
|
+
switch (type) {
|
|
5354
|
+
case 10:
|
|
5355
|
+
entity.corners[0].x = value;
|
|
5356
|
+
break;
|
|
5357
|
+
case 20:
|
|
5358
|
+
entity.corners[0].y = value;
|
|
4376
5359
|
break;
|
|
4377
5360
|
case 30:
|
|
4378
|
-
entity.
|
|
5361
|
+
entity.corners[0].z = value;
|
|
4379
5362
|
break;
|
|
4380
5363
|
case 11:
|
|
4381
|
-
entity.
|
|
5364
|
+
entity.corners[1].x = value;
|
|
4382
5365
|
break;
|
|
4383
5366
|
case 21:
|
|
4384
|
-
entity.
|
|
5367
|
+
entity.corners[1].y = value;
|
|
4385
5368
|
break;
|
|
4386
5369
|
case 31:
|
|
4387
|
-
entity.
|
|
5370
|
+
entity.corners[1].z = value;
|
|
4388
5371
|
break;
|
|
4389
5372
|
case 12:
|
|
4390
|
-
entity.
|
|
5373
|
+
entity.corners[2].x = value;
|
|
4391
5374
|
break;
|
|
4392
5375
|
case 22:
|
|
4393
|
-
entity.
|
|
5376
|
+
entity.corners[2].y = value;
|
|
4394
5377
|
break;
|
|
4395
5378
|
case 32:
|
|
4396
|
-
entity.
|
|
5379
|
+
entity.corners[2].z = value;
|
|
4397
5380
|
break;
|
|
4398
5381
|
case 13:
|
|
4399
|
-
entity.
|
|
5382
|
+
entity.corners[3].x = value;
|
|
4400
5383
|
break;
|
|
4401
5384
|
case 23:
|
|
4402
|
-
entity.
|
|
5385
|
+
entity.corners[3].y = value;
|
|
4403
5386
|
break;
|
|
4404
5387
|
case 33:
|
|
4405
|
-
entity.
|
|
5388
|
+
entity.corners[3].z = value;
|
|
5389
|
+
break;
|
|
5390
|
+
case 39:
|
|
5391
|
+
entity.thickness = value;
|
|
4406
5392
|
break;
|
|
4407
5393
|
default:
|
|
4408
5394
|
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
@@ -4411,22 +5397,22 @@ var dxf = (() => {
|
|
|
4411
5397
|
return entity;
|
|
4412
5398
|
},
|
|
4413
5399
|
{
|
|
4414
|
-
type:
|
|
4415
|
-
|
|
5400
|
+
type: TYPE32,
|
|
5401
|
+
corners: [{}, {}, {}, {}]
|
|
4416
5402
|
}
|
|
4417
5403
|
);
|
|
4418
5404
|
};
|
|
4419
|
-
var
|
|
5405
|
+
var trace_default = { TYPE: TYPE32, process: process32 };
|
|
4420
5406
|
|
|
4421
5407
|
// src/handlers/entity/vertex.ts
|
|
4422
|
-
var
|
|
5408
|
+
var TYPE33 = "VERTEX";
|
|
4423
5409
|
var ensureFaces = (entity) => {
|
|
4424
5410
|
entity.faces = entity.faces || [];
|
|
4425
5411
|
if ("x" in entity && !entity.x) delete entity.x;
|
|
4426
5412
|
if ("y" in entity && !entity.y) delete entity.y;
|
|
4427
5413
|
if ("z" in entity && !entity.z) delete entity.z;
|
|
4428
5414
|
};
|
|
4429
|
-
var
|
|
5415
|
+
var process33 = (tuples) => {
|
|
4430
5416
|
return tuples.reduce((entity, tuple) => {
|
|
4431
5417
|
const type = tuple[0];
|
|
4432
5418
|
const value = tuple[1];
|
|
@@ -4465,11 +5451,11 @@ var dxf = (() => {
|
|
|
4465
5451
|
return entity;
|
|
4466
5452
|
}, {});
|
|
4467
5453
|
};
|
|
4468
|
-
var vertex_default = { TYPE:
|
|
5454
|
+
var vertex_default = { TYPE: TYPE33, process: process33 };
|
|
4469
5455
|
|
|
4470
5456
|
// src/handlers/entity/viewport.ts
|
|
4471
|
-
var
|
|
4472
|
-
var
|
|
5457
|
+
var TYPE34 = "VIEWPORT";
|
|
5458
|
+
var process34 = (tuples) => {
|
|
4473
5459
|
return tuples.reduce(
|
|
4474
5460
|
(entity, tuple) => {
|
|
4475
5461
|
const type = tuple[0];
|
|
@@ -4567,7 +5553,7 @@ var dxf = (() => {
|
|
|
4567
5553
|
return entity;
|
|
4568
5554
|
},
|
|
4569
5555
|
{
|
|
4570
|
-
type:
|
|
5556
|
+
type: TYPE34,
|
|
4571
5557
|
center: {},
|
|
4572
5558
|
centerDCS: {},
|
|
4573
5559
|
snap: {},
|
|
@@ -4578,22 +5564,158 @@ var dxf = (() => {
|
|
|
4578
5564
|
}
|
|
4579
5565
|
);
|
|
4580
5566
|
};
|
|
4581
|
-
var viewport_default = { TYPE:
|
|
5567
|
+
var viewport_default = { TYPE: TYPE34, process: process34 };
|
|
5568
|
+
|
|
5569
|
+
// src/handlers/entity/wipeout.ts
|
|
5570
|
+
var TYPE35 = "WIPEOUT";
|
|
5571
|
+
var process35 = (tuples) => {
|
|
5572
|
+
let pendingBoundaryX = null;
|
|
5573
|
+
return tuples.reduce(
|
|
5574
|
+
(entity, tuple) => {
|
|
5575
|
+
const type = tuple[0];
|
|
5576
|
+
const value = tuple[1];
|
|
5577
|
+
switch (type) {
|
|
5578
|
+
case 90:
|
|
5579
|
+
entity.classVersion = value;
|
|
5580
|
+
break;
|
|
5581
|
+
case 10:
|
|
5582
|
+
entity.insertionPoint.x = value;
|
|
5583
|
+
break;
|
|
5584
|
+
case 20:
|
|
5585
|
+
entity.insertionPoint.y = value;
|
|
5586
|
+
break;
|
|
5587
|
+
case 30:
|
|
5588
|
+
entity.insertionPoint.z = value;
|
|
5589
|
+
break;
|
|
5590
|
+
case 11:
|
|
5591
|
+
entity.uVector.x = value;
|
|
5592
|
+
break;
|
|
5593
|
+
case 21:
|
|
5594
|
+
entity.uVector.y = value;
|
|
5595
|
+
break;
|
|
5596
|
+
case 31:
|
|
5597
|
+
entity.uVector.z = value;
|
|
5598
|
+
break;
|
|
5599
|
+
case 12:
|
|
5600
|
+
entity.vVector.x = value;
|
|
5601
|
+
break;
|
|
5602
|
+
case 22:
|
|
5603
|
+
entity.vVector.y = value;
|
|
5604
|
+
break;
|
|
5605
|
+
case 32:
|
|
5606
|
+
entity.vVector.z = value;
|
|
5607
|
+
break;
|
|
5608
|
+
case 13:
|
|
5609
|
+
entity.imageSizePixels ??= { u: 0, v: 0 };
|
|
5610
|
+
entity.imageSizePixels.u = value;
|
|
5611
|
+
break;
|
|
5612
|
+
case 23:
|
|
5613
|
+
entity.imageSizePixels ??= { u: 0, v: 0 };
|
|
5614
|
+
entity.imageSizePixels.v = value;
|
|
5615
|
+
break;
|
|
5616
|
+
case 70:
|
|
5617
|
+
entity.displayProperties = value;
|
|
5618
|
+
break;
|
|
5619
|
+
case 280:
|
|
5620
|
+
entity.clippingState = value;
|
|
5621
|
+
break;
|
|
5622
|
+
case 71:
|
|
5623
|
+
entity.clipBoundaryType = value;
|
|
5624
|
+
break;
|
|
5625
|
+
case 14:
|
|
5626
|
+
pendingBoundaryX = value;
|
|
5627
|
+
break;
|
|
5628
|
+
case 24:
|
|
5629
|
+
if (pendingBoundaryX !== null) {
|
|
5630
|
+
entity.clipBoundaryVertices ??= [];
|
|
5631
|
+
entity.clipBoundaryVertices.push({ x: pendingBoundaryX, y: value });
|
|
5632
|
+
pendingBoundaryX = null;
|
|
5633
|
+
}
|
|
5634
|
+
break;
|
|
5635
|
+
default:
|
|
5636
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
5637
|
+
break;
|
|
5638
|
+
}
|
|
5639
|
+
return entity;
|
|
5640
|
+
},
|
|
5641
|
+
{
|
|
5642
|
+
type: TYPE35,
|
|
5643
|
+
insertionPoint: {},
|
|
5644
|
+
uVector: {},
|
|
5645
|
+
vVector: {}
|
|
5646
|
+
}
|
|
5647
|
+
);
|
|
5648
|
+
};
|
|
5649
|
+
var wipeout_default = { TYPE: TYPE35, process: process35 };
|
|
5650
|
+
|
|
5651
|
+
// src/handlers/entity/xline.ts
|
|
5652
|
+
var TYPE36 = "XLINE";
|
|
5653
|
+
var process36 = (tuples) => {
|
|
5654
|
+
return tuples.reduce(
|
|
5655
|
+
(entity, tuple) => {
|
|
5656
|
+
const type = tuple[0];
|
|
5657
|
+
const value = tuple[1];
|
|
5658
|
+
switch (type) {
|
|
5659
|
+
case 10:
|
|
5660
|
+
entity.basePoint.x = value;
|
|
5661
|
+
break;
|
|
5662
|
+
case 20:
|
|
5663
|
+
entity.basePoint.y = value;
|
|
5664
|
+
break;
|
|
5665
|
+
case 30:
|
|
5666
|
+
entity.basePoint.z = value;
|
|
5667
|
+
break;
|
|
5668
|
+
case 11:
|
|
5669
|
+
entity.direction.x = value;
|
|
5670
|
+
break;
|
|
5671
|
+
case 21:
|
|
5672
|
+
entity.direction.y = value;
|
|
5673
|
+
break;
|
|
5674
|
+
case 31:
|
|
5675
|
+
entity.direction.z = value;
|
|
5676
|
+
break;
|
|
5677
|
+
default:
|
|
5678
|
+
Object.assign(entity, parseCommonEntityProperties(type, value));
|
|
5679
|
+
break;
|
|
5680
|
+
}
|
|
5681
|
+
return entity;
|
|
5682
|
+
},
|
|
5683
|
+
{
|
|
5684
|
+
type: TYPE36,
|
|
5685
|
+
basePoint: {},
|
|
5686
|
+
direction: {}
|
|
5687
|
+
}
|
|
5688
|
+
);
|
|
5689
|
+
};
|
|
5690
|
+
var xline_default = { TYPE: TYPE36, process: process36 };
|
|
4582
5691
|
|
|
4583
5692
|
// src/handlers/entities.ts
|
|
4584
5693
|
var handlers = [
|
|
4585
5694
|
point_default,
|
|
4586
5695
|
line_default,
|
|
4587
5696
|
lwpolyline_default,
|
|
5697
|
+
mline_default,
|
|
5698
|
+
mleader_default,
|
|
4588
5699
|
polyline_default,
|
|
4589
5700
|
vertex_default,
|
|
4590
5701
|
circle_default,
|
|
4591
5702
|
arc_default,
|
|
4592
5703
|
ellipse_default,
|
|
4593
5704
|
spline_default,
|
|
5705
|
+
table_default,
|
|
4594
5706
|
solid_default,
|
|
5707
|
+
trace_default,
|
|
4595
5708
|
hatch_default,
|
|
5709
|
+
image_default,
|
|
5710
|
+
leader_default,
|
|
5711
|
+
ray_default,
|
|
5712
|
+
region_default,
|
|
5713
|
+
dwfUnderlay_default,
|
|
5714
|
+
dgnUnderlay_default,
|
|
5715
|
+
pdfUnderlay_default,
|
|
5716
|
+
shape_default,
|
|
4596
5717
|
mtext_default,
|
|
5718
|
+
tolerance_default,
|
|
4597
5719
|
attdef_default,
|
|
4598
5720
|
attrib_default,
|
|
4599
5721
|
text_default,
|
|
@@ -4601,13 +5723,92 @@ var dxf = (() => {
|
|
|
4601
5723
|
dimension_default,
|
|
4602
5724
|
threeDFace_default,
|
|
4603
5725
|
viewport_default,
|
|
4604
|
-
ole2Frame_default
|
|
5726
|
+
ole2Frame_default,
|
|
5727
|
+
oleframe_default,
|
|
5728
|
+
xline_default,
|
|
5729
|
+
wipeout_default
|
|
4605
5730
|
].reduce((acc, mod) => {
|
|
4606
5731
|
acc[mod.TYPE] = mod;
|
|
4607
5732
|
return acc;
|
|
4608
5733
|
}, {});
|
|
5734
|
+
var EntityGroupProcessor = class {
|
|
5735
|
+
constructor() {
|
|
5736
|
+
this.entities = [];
|
|
5737
|
+
}
|
|
5738
|
+
getEntities() {
|
|
5739
|
+
return this.entities;
|
|
5740
|
+
}
|
|
5741
|
+
finalize() {
|
|
5742
|
+
this.flushOpenPolyline("DXF ended with an open POLYLINE (missing SEQEND); flushing open polyline");
|
|
5743
|
+
}
|
|
5744
|
+
processGroup(tuples) {
|
|
5745
|
+
const entityType = String(tuples[0][1]);
|
|
5746
|
+
const contentTuples = tuples.slice(1);
|
|
5747
|
+
switch (entityType) {
|
|
5748
|
+
case "SEQEND":
|
|
5749
|
+
this.endSequence();
|
|
5750
|
+
break;
|
|
5751
|
+
case "POLYLINE":
|
|
5752
|
+
this.startPolyline(contentTuples);
|
|
5753
|
+
break;
|
|
5754
|
+
case "VERTEX":
|
|
5755
|
+
this.addVertex(contentTuples);
|
|
5756
|
+
break;
|
|
5757
|
+
default:
|
|
5758
|
+
this.addEntity(entityType, contentTuples);
|
|
5759
|
+
break;
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
5762
|
+
parseEntity(entityType, contentTuples) {
|
|
5763
|
+
const handler = handlers[entityType];
|
|
5764
|
+
if (!handler) {
|
|
5765
|
+
logger_default.warn("unsupported type in ENTITIES section:", entityType);
|
|
5766
|
+
return void 0;
|
|
5767
|
+
}
|
|
5768
|
+
return handler.process(contentTuples);
|
|
5769
|
+
}
|
|
5770
|
+
flushOpenPolyline(reason) {
|
|
5771
|
+
if (!this.currentPolyline) return;
|
|
5772
|
+
logger_default.warn(reason);
|
|
5773
|
+
this.currentPolyline = void 0;
|
|
5774
|
+
}
|
|
5775
|
+
endSequence() {
|
|
5776
|
+
this.currentPolyline = void 0;
|
|
5777
|
+
}
|
|
5778
|
+
startPolyline(contentTuples) {
|
|
5779
|
+
this.flushOpenPolyline(
|
|
5780
|
+
"POLYLINE started while previous POLYLINE is still open; flushing previous polyline"
|
|
5781
|
+
);
|
|
5782
|
+
const e = this.parseEntity("POLYLINE", contentTuples);
|
|
5783
|
+
if (!e) return;
|
|
5784
|
+
this.currentPolyline = e;
|
|
5785
|
+
this.entities.push(e);
|
|
5786
|
+
}
|
|
5787
|
+
addVertex(contentTuples) {
|
|
5788
|
+
const e = this.parseEntity("VERTEX", contentTuples);
|
|
5789
|
+
if (!e) return;
|
|
5790
|
+
if (!this.currentPolyline) {
|
|
5791
|
+
logger_default.error("ignoring invalid VERTEX entity");
|
|
5792
|
+
return;
|
|
5793
|
+
}
|
|
5794
|
+
this.currentPolyline.vertices.push(e);
|
|
5795
|
+
}
|
|
5796
|
+
addEntity(entityType, contentTuples) {
|
|
5797
|
+
this.flushOpenPolyline("POLYLINE sequence ended without SEQEND; flushing open polyline");
|
|
5798
|
+
const e = this.parseEntity(entityType, contentTuples);
|
|
5799
|
+
if (!e) return;
|
|
5800
|
+
this.entities.push(e);
|
|
5801
|
+
}
|
|
5802
|
+
};
|
|
5803
|
+
function processEntityGroups(entityGroups) {
|
|
5804
|
+
const processor = new EntityGroupProcessor();
|
|
5805
|
+
for (const tuples of entityGroups) {
|
|
5806
|
+
processor.processGroup(tuples);
|
|
5807
|
+
}
|
|
5808
|
+
processor.finalize();
|
|
5809
|
+
return processor.getEntities();
|
|
5810
|
+
}
|
|
4609
5811
|
function parseEntities(tuples) {
|
|
4610
|
-
const entities = [];
|
|
4611
5812
|
const entityGroups = [];
|
|
4612
5813
|
let currentEntityTuples = [];
|
|
4613
5814
|
for (const tuple of tuples) {
|
|
@@ -4618,31 +5819,7 @@ var dxf = (() => {
|
|
|
4618
5819
|
}
|
|
4619
5820
|
currentEntityTuples.push(tuple);
|
|
4620
5821
|
}
|
|
4621
|
-
|
|
4622
|
-
for (const tuples2 of entityGroups) {
|
|
4623
|
-
const entityType = tuples2[0][1];
|
|
4624
|
-
const contentTuples = tuples2.slice(1);
|
|
4625
|
-
if (entityType in handlers) {
|
|
4626
|
-
const e = handlers[entityType].process(contentTuples);
|
|
4627
|
-
if (entityType === "POLYLINE") {
|
|
4628
|
-
currentPolyline = e;
|
|
4629
|
-
entities.push(e);
|
|
4630
|
-
} else if (entityType === "VERTEX") {
|
|
4631
|
-
if (currentPolyline) {
|
|
4632
|
-
currentPolyline.vertices.push(e);
|
|
4633
|
-
} else {
|
|
4634
|
-
logger_default.error("ignoring invalid VERTEX entity");
|
|
4635
|
-
}
|
|
4636
|
-
} else if (entityType === "SEQEND") {
|
|
4637
|
-
currentPolyline = void 0;
|
|
4638
|
-
} else {
|
|
4639
|
-
entities.push(e);
|
|
4640
|
-
}
|
|
4641
|
-
} else {
|
|
4642
|
-
logger_default.warn("unsupported type in ENTITIES section:", entityType);
|
|
4643
|
-
}
|
|
4644
|
-
}
|
|
4645
|
-
return entities;
|
|
5822
|
+
return processEntityGroups(entityGroups);
|
|
4646
5823
|
}
|
|
4647
5824
|
|
|
4648
5825
|
// src/handlers/blocks.ts
|
|
@@ -4776,150 +5953,313 @@ var dxf = (() => {
|
|
|
4776
5953
|
}
|
|
4777
5954
|
|
|
4778
5955
|
// src/handlers/objects.ts
|
|
4779
|
-
function
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
layouts: []
|
|
4783
|
-
};
|
|
4784
|
-
let layout;
|
|
5956
|
+
function groupObjectsByZero(tuples) {
|
|
5957
|
+
const groups = [];
|
|
5958
|
+
let current;
|
|
4785
5959
|
for (const tuple of tuples) {
|
|
5960
|
+
const code = tuple[0];
|
|
5961
|
+
if (code === 0) {
|
|
5962
|
+
if (current && current.length > 0) groups.push(current);
|
|
5963
|
+
current = [tuple];
|
|
5964
|
+
continue;
|
|
5965
|
+
}
|
|
5966
|
+
if (!current) continue;
|
|
5967
|
+
current.push(tuple);
|
|
5968
|
+
}
|
|
5969
|
+
if (current && current.length > 0) groups.push(current);
|
|
5970
|
+
return groups;
|
|
5971
|
+
}
|
|
5972
|
+
var LAYOUT_FLOAT_FIELDS = {
|
|
5973
|
+
10: "minLimitX",
|
|
5974
|
+
20: "minLimitY",
|
|
5975
|
+
11: "maxLimitX",
|
|
5976
|
+
21: "maxLimitY",
|
|
5977
|
+
12: "x",
|
|
5978
|
+
22: "y",
|
|
5979
|
+
32: "z",
|
|
5980
|
+
14: "minX",
|
|
5981
|
+
24: "minY",
|
|
5982
|
+
34: "minZ",
|
|
5983
|
+
15: "maxX",
|
|
5984
|
+
25: "maxY",
|
|
5985
|
+
35: "maxZ",
|
|
5986
|
+
146: "elevation",
|
|
5987
|
+
13: "ucsX",
|
|
5988
|
+
23: "ucsY",
|
|
5989
|
+
33: "ucsZ",
|
|
5990
|
+
16: "ucsXaxisX",
|
|
5991
|
+
26: "ucsXaxisY",
|
|
5992
|
+
36: "ucsXaxisZ",
|
|
5993
|
+
17: "ucsYaxisX",
|
|
5994
|
+
27: "ucsYaxisY",
|
|
5995
|
+
37: "ucsYaxisZ"
|
|
5996
|
+
};
|
|
5997
|
+
var LAYOUT_DIRECT_FIELDS = {
|
|
5998
|
+
1: "name",
|
|
5999
|
+
5: "handle",
|
|
6000
|
+
71: "tabOrder",
|
|
6001
|
+
330: "tableRecord",
|
|
6002
|
+
331: "lastActiveViewport",
|
|
6003
|
+
333: "shadePlot"
|
|
6004
|
+
};
|
|
6005
|
+
var LAYOUT_UCS_TYPE = {
|
|
6006
|
+
0: "NOT ORTHOGRAPHIC",
|
|
6007
|
+
1: "TOP",
|
|
6008
|
+
2: "BOTTOM",
|
|
6009
|
+
3: "FRONT",
|
|
6010
|
+
4: "BACK",
|
|
6011
|
+
5: "LEFT",
|
|
6012
|
+
6: "RIGHT"
|
|
6013
|
+
};
|
|
6014
|
+
function consumeLayoutStartTuple(current, tuple) {
|
|
6015
|
+
if (tuple[1] === "LAYOUT") return { state: "layout", layout: {} };
|
|
6016
|
+
return { state: "IDLE", layout: current.layout };
|
|
6017
|
+
}
|
|
6018
|
+
function consumeLayoutSubclassTuple(current, tuple) {
|
|
6019
|
+
if (tuple[0] === 100 && tuple[1] === "AcDbLayout") return { state: "AcDbLayout", layout: current.layout };
|
|
6020
|
+
return current;
|
|
6021
|
+
}
|
|
6022
|
+
function applyLayoutFieldTuple(layout, tuple) {
|
|
6023
|
+
const type = tuple[0];
|
|
6024
|
+
const value = tuple[1];
|
|
6025
|
+
const floatKey = LAYOUT_FLOAT_FIELDS[type];
|
|
6026
|
+
if (floatKey) {
|
|
6027
|
+
;
|
|
6028
|
+
layout[floatKey] = Number.parseFloat(String(value));
|
|
6029
|
+
return;
|
|
6030
|
+
}
|
|
6031
|
+
const directKey = LAYOUT_DIRECT_FIELDS[type];
|
|
6032
|
+
if (directKey) {
|
|
6033
|
+
;
|
|
6034
|
+
layout[directKey] = value;
|
|
6035
|
+
return;
|
|
6036
|
+
}
|
|
6037
|
+
if (type === 70) {
|
|
6038
|
+
layout.flag = value === 1 ? "PSLTSCALE" : "LIMCHECK";
|
|
6039
|
+
return;
|
|
6040
|
+
}
|
|
6041
|
+
if (type === 76) {
|
|
6042
|
+
const ucsType = LAYOUT_UCS_TYPE[Number(value)];
|
|
6043
|
+
if (ucsType) layout.ucsType = ucsType;
|
|
6044
|
+
}
|
|
6045
|
+
}
|
|
6046
|
+
function consumeLayoutTuple(current, tuple) {
|
|
6047
|
+
if (tuple[0] === 0) return consumeLayoutStartTuple(current, tuple);
|
|
6048
|
+
if (current.state === "layout") return consumeLayoutSubclassTuple(current, tuple);
|
|
6049
|
+
if (current.state === "AcDbLayout" && current.layout) applyLayoutFieldTuple(current.layout, tuple);
|
|
6050
|
+
return current;
|
|
6051
|
+
}
|
|
6052
|
+
function parseLayoutObject(group) {
|
|
6053
|
+
let current = { state: "IDLE" };
|
|
6054
|
+
for (const tuple of group) current = consumeLayoutTuple(current, tuple);
|
|
6055
|
+
return current.layout;
|
|
6056
|
+
}
|
|
6057
|
+
function parseDictionaryObject(group) {
|
|
6058
|
+
if (group[0]?.[1] !== "DICTIONARY") return void 0;
|
|
6059
|
+
const dict = {
|
|
6060
|
+
type: "DICTIONARY",
|
|
6061
|
+
entries: {}
|
|
6062
|
+
};
|
|
6063
|
+
let pendingKey;
|
|
6064
|
+
for (const tuple of group.slice(1)) {
|
|
4786
6065
|
const type = tuple[0];
|
|
4787
6066
|
const value = tuple[1];
|
|
4788
|
-
if (type ===
|
|
4789
|
-
|
|
6067
|
+
if (type === 5) {
|
|
6068
|
+
dict.handle = value;
|
|
6069
|
+
continue;
|
|
4790
6070
|
}
|
|
4791
|
-
if (
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
objects.layouts.push(layout);
|
|
6071
|
+
if (type === 330) {
|
|
6072
|
+
dict.ownerHandle = value;
|
|
6073
|
+
continue;
|
|
4795
6074
|
}
|
|
4796
|
-
if (
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
if (value === "AcDbLayout") state = "AcDbLayout";
|
|
4800
|
-
break;
|
|
4801
|
-
}
|
|
6075
|
+
if (type === 3) {
|
|
6076
|
+
pendingKey = String(value);
|
|
6077
|
+
continue;
|
|
4802
6078
|
}
|
|
4803
|
-
if (
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
layout.name = value;
|
|
4807
|
-
break;
|
|
4808
|
-
case 5:
|
|
4809
|
-
layout.handle = value;
|
|
4810
|
-
break;
|
|
4811
|
-
case 10:
|
|
4812
|
-
layout.minLimitX = Number.parseFloat(String(value));
|
|
4813
|
-
break;
|
|
4814
|
-
case 20:
|
|
4815
|
-
layout.minLimitY = Number.parseFloat(String(value));
|
|
4816
|
-
break;
|
|
4817
|
-
case 11:
|
|
4818
|
-
layout.maxLimitX = Number.parseFloat(String(value));
|
|
4819
|
-
break;
|
|
4820
|
-
case 21:
|
|
4821
|
-
layout.maxLimitY = Number.parseFloat(String(value));
|
|
4822
|
-
break;
|
|
4823
|
-
case 12:
|
|
4824
|
-
layout.x = Number.parseFloat(String(value));
|
|
4825
|
-
break;
|
|
4826
|
-
case 22:
|
|
4827
|
-
layout.y = Number.parseFloat(String(value));
|
|
4828
|
-
break;
|
|
4829
|
-
case 32:
|
|
4830
|
-
layout.z = Number.parseFloat(String(value));
|
|
4831
|
-
break;
|
|
4832
|
-
case 14:
|
|
4833
|
-
layout.minX = Number.parseFloat(String(value));
|
|
4834
|
-
break;
|
|
4835
|
-
case 24:
|
|
4836
|
-
layout.minY = Number.parseFloat(String(value));
|
|
4837
|
-
break;
|
|
4838
|
-
case 34:
|
|
4839
|
-
layout.minZ = Number.parseFloat(String(value));
|
|
4840
|
-
break;
|
|
4841
|
-
case 15:
|
|
4842
|
-
layout.maxX = Number.parseFloat(String(value));
|
|
4843
|
-
break;
|
|
4844
|
-
case 25:
|
|
4845
|
-
layout.maxY = Number.parseFloat(String(value));
|
|
4846
|
-
break;
|
|
4847
|
-
case 35:
|
|
4848
|
-
layout.maxZ = Number.parseFloat(String(value));
|
|
4849
|
-
break;
|
|
4850
|
-
case 70:
|
|
4851
|
-
layout.flag = value === 1 ? "PSLTSCALE" : "LIMCHECK";
|
|
4852
|
-
break;
|
|
4853
|
-
case 71:
|
|
4854
|
-
layout.tabOrder = value;
|
|
4855
|
-
break;
|
|
4856
|
-
case 146:
|
|
4857
|
-
layout.elevation = Number.parseFloat(String(value));
|
|
4858
|
-
break;
|
|
4859
|
-
case 13:
|
|
4860
|
-
layout.ucsX = Number.parseFloat(String(value));
|
|
4861
|
-
break;
|
|
4862
|
-
case 23:
|
|
4863
|
-
layout.ucsY = Number.parseFloat(String(value));
|
|
4864
|
-
break;
|
|
4865
|
-
case 33:
|
|
4866
|
-
layout.ucsZ = Number.parseFloat(String(value));
|
|
4867
|
-
break;
|
|
4868
|
-
case 16:
|
|
4869
|
-
layout.ucsXaxisX = Number.parseFloat(String(value));
|
|
4870
|
-
break;
|
|
4871
|
-
case 26:
|
|
4872
|
-
layout.ucsXaxisY = Number.parseFloat(String(value));
|
|
4873
|
-
break;
|
|
4874
|
-
case 36:
|
|
4875
|
-
layout.ucsXaxisZ = Number.parseFloat(String(value));
|
|
4876
|
-
break;
|
|
4877
|
-
case 17:
|
|
4878
|
-
layout.ucsYaxisX = Number.parseFloat(String(value));
|
|
4879
|
-
break;
|
|
4880
|
-
case 27:
|
|
4881
|
-
layout.ucsYaxisY = Number.parseFloat(String(value));
|
|
4882
|
-
break;
|
|
4883
|
-
case 37:
|
|
4884
|
-
layout.ucsYaxisZ = Number.parseFloat(String(value));
|
|
4885
|
-
break;
|
|
4886
|
-
case 76:
|
|
4887
|
-
switch (value) {
|
|
4888
|
-
case 0:
|
|
4889
|
-
layout.ucsType = "NOT ORTHOGRAPHIC";
|
|
4890
|
-
break;
|
|
4891
|
-
case 1:
|
|
4892
|
-
layout.ucsType = "TOP";
|
|
4893
|
-
break;
|
|
4894
|
-
case 2:
|
|
4895
|
-
layout.ucsType = "BOTTOM";
|
|
4896
|
-
break;
|
|
4897
|
-
case 3:
|
|
4898
|
-
layout.ucsType = "FRONT";
|
|
4899
|
-
break;
|
|
4900
|
-
case 4:
|
|
4901
|
-
layout.ucsType = "BACK";
|
|
4902
|
-
break;
|
|
4903
|
-
case 5:
|
|
4904
|
-
layout.ucsType = "LEFT";
|
|
4905
|
-
break;
|
|
4906
|
-
case 6:
|
|
4907
|
-
layout.ucsType = "RIGHT";
|
|
4908
|
-
break;
|
|
4909
|
-
}
|
|
4910
|
-
break;
|
|
4911
|
-
case 330:
|
|
4912
|
-
layout.tableRecord = value;
|
|
4913
|
-
break;
|
|
4914
|
-
case 331:
|
|
4915
|
-
layout.lastActiveViewport = value;
|
|
4916
|
-
break;
|
|
4917
|
-
case 333:
|
|
4918
|
-
layout.shadePlot = value;
|
|
4919
|
-
break;
|
|
4920
|
-
}
|
|
6079
|
+
if ((type === 350 || type === 360) && pendingKey) {
|
|
6080
|
+
dict.entries[pendingKey] = String(value);
|
|
6081
|
+
pendingKey = void 0;
|
|
4921
6082
|
}
|
|
4922
6083
|
}
|
|
6084
|
+
return dict;
|
|
6085
|
+
}
|
|
6086
|
+
function parseXRecordObject(group) {
|
|
6087
|
+
if (group[0]?.[1] !== "XRECORD") return void 0;
|
|
6088
|
+
const tuples = group.slice(1);
|
|
6089
|
+
const xRecord = {
|
|
6090
|
+
type: "XRECORD",
|
|
6091
|
+
tuples
|
|
6092
|
+
};
|
|
6093
|
+
for (const tuple of tuples) {
|
|
6094
|
+
const type = tuple[0];
|
|
6095
|
+
const value = tuple[1];
|
|
6096
|
+
if (type === 5) xRecord.handle = value;
|
|
6097
|
+
if (type === 330) xRecord.ownerHandle = value;
|
|
6098
|
+
}
|
|
6099
|
+
return xRecord;
|
|
6100
|
+
}
|
|
6101
|
+
function parseImageDefObject(group) {
|
|
6102
|
+
if (group[0]?.[1] !== "IMAGEDEF") return void 0;
|
|
6103
|
+
const tuples = group.slice(1);
|
|
6104
|
+
const imageDef = {
|
|
6105
|
+
type: "IMAGEDEF",
|
|
6106
|
+
tuples
|
|
6107
|
+
};
|
|
6108
|
+
for (const tuple of tuples) {
|
|
6109
|
+
const type = tuple[0];
|
|
6110
|
+
const value = tuple[1];
|
|
6111
|
+
if (type === 5) imageDef.handle = value;
|
|
6112
|
+
if (type === 330 && imageDef.ownerHandle === void 0) imageDef.ownerHandle = value;
|
|
6113
|
+
if (type === 1) imageDef.fileName = String(value);
|
|
6114
|
+
if (type === 10) imageDef.pixelSizeX = Number(value);
|
|
6115
|
+
if (type === 20) imageDef.pixelSizeY = Number(value);
|
|
6116
|
+
}
|
|
6117
|
+
return imageDef;
|
|
6118
|
+
}
|
|
6119
|
+
function parseImageDefReactorObject(group) {
|
|
6120
|
+
if (group[0]?.[1] !== "IMAGEDEF_REACTOR") return void 0;
|
|
6121
|
+
const tuples = group.slice(1);
|
|
6122
|
+
const reactor = {
|
|
6123
|
+
type: "IMAGEDEF_REACTOR",
|
|
6124
|
+
tuples
|
|
6125
|
+
};
|
|
6126
|
+
for (const tuple of tuples) {
|
|
6127
|
+
const type = tuple[0];
|
|
6128
|
+
const value = tuple[1];
|
|
6129
|
+
if (type === 5) reactor.handle = value;
|
|
6130
|
+
if (type === 330) reactor.imageHandle = value;
|
|
6131
|
+
}
|
|
6132
|
+
return reactor;
|
|
6133
|
+
}
|
|
6134
|
+
function parseDimAssocObject(group) {
|
|
6135
|
+
if (group[0]?.[1] !== "DIMASSOC") return void 0;
|
|
6136
|
+
const tuples = group.slice(1);
|
|
6137
|
+
const dimAssoc = {
|
|
6138
|
+
type: "DIMASSOC",
|
|
6139
|
+
tuples
|
|
6140
|
+
};
|
|
6141
|
+
for (const tuple of tuples) {
|
|
6142
|
+
const type = tuple[0];
|
|
6143
|
+
const value = tuple[1];
|
|
6144
|
+
if (type === 5) dimAssoc.handle = value;
|
|
6145
|
+
if (type === 330) dimAssoc.ownerHandle = value;
|
|
6146
|
+
}
|
|
6147
|
+
return dimAssoc;
|
|
6148
|
+
}
|
|
6149
|
+
function parseFieldObject(group) {
|
|
6150
|
+
if (group[0]?.[1] !== "FIELD") return void 0;
|
|
6151
|
+
const tuples = group.slice(1);
|
|
6152
|
+
const field = {
|
|
6153
|
+
type: "FIELD",
|
|
6154
|
+
tuples
|
|
6155
|
+
};
|
|
6156
|
+
for (const tuple of tuples) {
|
|
6157
|
+
const type = tuple[0];
|
|
6158
|
+
const value = tuple[1];
|
|
6159
|
+
if (type === 5) field.handle = value;
|
|
6160
|
+
if (type === 330) field.ownerHandle = value;
|
|
6161
|
+
}
|
|
6162
|
+
return field;
|
|
6163
|
+
}
|
|
6164
|
+
var UNDERLAY_DEFINITION_OBJECT_TYPES = /* @__PURE__ */ new Set([
|
|
6165
|
+
"UNDERLAYDEFINITION",
|
|
6166
|
+
"PDFDEFINITION",
|
|
6167
|
+
"DWFDEFINITION",
|
|
6168
|
+
"DGNDEFINITION"
|
|
6169
|
+
]);
|
|
6170
|
+
function parseUnderlayDefinitionObject(group) {
|
|
6171
|
+
const objectType = group[0]?.[1];
|
|
6172
|
+
if (typeof objectType !== "string") return void 0;
|
|
6173
|
+
if (!UNDERLAY_DEFINITION_OBJECT_TYPES.has(objectType)) return void 0;
|
|
6174
|
+
const tuples = group.slice(1);
|
|
6175
|
+
const def = {
|
|
6176
|
+
type: objectType,
|
|
6177
|
+
tuples
|
|
6178
|
+
};
|
|
6179
|
+
for (const tuple of tuples) {
|
|
6180
|
+
const type = tuple[0];
|
|
6181
|
+
const value = tuple[1];
|
|
6182
|
+
if (type === 5) def.handle = value;
|
|
6183
|
+
if (type === 330 && def.ownerHandle === void 0) def.ownerHandle = value;
|
|
6184
|
+
if (type === 1) def.fileName = String(value);
|
|
6185
|
+
if (type === 2) def.underlayName = String(value);
|
|
6186
|
+
}
|
|
6187
|
+
return def;
|
|
6188
|
+
}
|
|
6189
|
+
var OBJECT_GROUP_HANDLERS = {
|
|
6190
|
+
LAYOUT: (objects, group) => {
|
|
6191
|
+
const layout = parseLayoutObject(group);
|
|
6192
|
+
if (layout) objects.layouts.push(layout);
|
|
6193
|
+
},
|
|
6194
|
+
DICTIONARY: (objects, group) => {
|
|
6195
|
+
const dict = parseDictionaryObject(group);
|
|
6196
|
+
const handle = dict?.handle ? String(dict.handle) : void 0;
|
|
6197
|
+
if (dict && handle) objects.dictionaries[handle] = dict;
|
|
6198
|
+
},
|
|
6199
|
+
XRECORD: (objects, group) => {
|
|
6200
|
+
const xRecord = parseXRecordObject(group);
|
|
6201
|
+
const handle = xRecord?.handle ? String(xRecord.handle) : void 0;
|
|
6202
|
+
if (xRecord && handle) objects.xRecords[handle] = xRecord;
|
|
6203
|
+
},
|
|
6204
|
+
IMAGEDEF: (objects, group) => {
|
|
6205
|
+
const imageDef = parseImageDefObject(group);
|
|
6206
|
+
const handle = imageDef?.handle ? String(imageDef.handle) : void 0;
|
|
6207
|
+
if (imageDef && handle) objects.imageDefs[handle] = imageDef;
|
|
6208
|
+
},
|
|
6209
|
+
IMAGEDEF_REACTOR: (objects, group) => {
|
|
6210
|
+
const reactor = parseImageDefReactorObject(group);
|
|
6211
|
+
const handle = reactor?.handle ? String(reactor.handle) : void 0;
|
|
6212
|
+
if (reactor && handle) objects.imageDefReactors[handle] = reactor;
|
|
6213
|
+
},
|
|
6214
|
+
UNDERLAYDEFINITION: (objects, group) => {
|
|
6215
|
+
const def = parseUnderlayDefinitionObject(group);
|
|
6216
|
+
const handle = def?.handle ? String(def.handle) : void 0;
|
|
6217
|
+
if (def && handle) objects.underlayDefinitions[handle] = def;
|
|
6218
|
+
},
|
|
6219
|
+
PDFDEFINITION: (objects, group) => {
|
|
6220
|
+
const def = parseUnderlayDefinitionObject(group);
|
|
6221
|
+
const handle = def?.handle ? String(def.handle) : void 0;
|
|
6222
|
+
if (def && handle) objects.underlayDefinitions[handle] = def;
|
|
6223
|
+
},
|
|
6224
|
+
DWFDEFINITION: (objects, group) => {
|
|
6225
|
+
const def = parseUnderlayDefinitionObject(group);
|
|
6226
|
+
const handle = def?.handle ? String(def.handle) : void 0;
|
|
6227
|
+
if (def && handle) objects.underlayDefinitions[handle] = def;
|
|
6228
|
+
},
|
|
6229
|
+
DGNDEFINITION: (objects, group) => {
|
|
6230
|
+
const def = parseUnderlayDefinitionObject(group);
|
|
6231
|
+
const handle = def?.handle ? String(def.handle) : void 0;
|
|
6232
|
+
if (def && handle) objects.underlayDefinitions[handle] = def;
|
|
6233
|
+
},
|
|
6234
|
+
DIMASSOC: (objects, group) => {
|
|
6235
|
+
const dimAssoc = parseDimAssocObject(group);
|
|
6236
|
+
const handle = dimAssoc?.handle ? String(dimAssoc.handle) : void 0;
|
|
6237
|
+
if (dimAssoc && handle) objects.dimAssocs[handle] = dimAssoc;
|
|
6238
|
+
},
|
|
6239
|
+
FIELD: (objects, group) => {
|
|
6240
|
+
const field = parseFieldObject(group);
|
|
6241
|
+
const handle = field?.handle ? String(field.handle) : void 0;
|
|
6242
|
+
if (field && handle) objects.fields[handle] = field;
|
|
6243
|
+
}
|
|
6244
|
+
};
|
|
6245
|
+
function parseObjects(tuples) {
|
|
6246
|
+
const objects = {
|
|
6247
|
+
layouts: [],
|
|
6248
|
+
dictionaries: {},
|
|
6249
|
+
xRecords: {},
|
|
6250
|
+
imageDefs: {},
|
|
6251
|
+
imageDefReactors: {},
|
|
6252
|
+
underlayDefinitions: {},
|
|
6253
|
+
dimAssocs: {},
|
|
6254
|
+
fields: {}
|
|
6255
|
+
};
|
|
6256
|
+
const groups = groupObjectsByZero(tuples);
|
|
6257
|
+
for (const group of groups) {
|
|
6258
|
+
const objectType = group[0]?.[1];
|
|
6259
|
+
if (typeof objectType !== "string") continue;
|
|
6260
|
+
const handler = OBJECT_GROUP_HANDLERS[objectType];
|
|
6261
|
+
if (handler) handler(objects, group);
|
|
6262
|
+
}
|
|
4923
6263
|
return objects;
|
|
4924
6264
|
}
|
|
4925
6265
|
|
|
@@ -5081,6 +6421,7 @@ var dxf = (() => {
|
|
|
5081
6421
|
const type = tuple[0];
|
|
5082
6422
|
const value = tuple[1];
|
|
5083
6423
|
switch (type) {
|
|
6424
|
+
// NOSONAR
|
|
5084
6425
|
case 2:
|
|
5085
6426
|
vport.name = value;
|
|
5086
6427
|
break;
|
|
@@ -5194,12 +6535,89 @@ var dxf = (() => {
|
|
|
5194
6535
|
}
|
|
5195
6536
|
);
|
|
5196
6537
|
};
|
|
6538
|
+
var appIdHandler = (tuples) => {
|
|
6539
|
+
return tuples.reduce(
|
|
6540
|
+
(appId, tuple) => {
|
|
6541
|
+
const type = tuple[0];
|
|
6542
|
+
const value = tuple[1];
|
|
6543
|
+
switch (type) {
|
|
6544
|
+
case 2:
|
|
6545
|
+
appId.name = value;
|
|
6546
|
+
break;
|
|
6547
|
+
case 70:
|
|
6548
|
+
appId.flags = value;
|
|
6549
|
+
break;
|
|
6550
|
+
default:
|
|
6551
|
+
}
|
|
6552
|
+
return appId;
|
|
6553
|
+
},
|
|
6554
|
+
{ type: "APPID" }
|
|
6555
|
+
);
|
|
6556
|
+
};
|
|
6557
|
+
var blockRecordHandler = (tuples) => {
|
|
6558
|
+
return tuples.reduce(
|
|
6559
|
+
(blockRecord, tuple) => {
|
|
6560
|
+
const type = tuple[0];
|
|
6561
|
+
const value = tuple[1];
|
|
6562
|
+
switch (type) {
|
|
6563
|
+
case 2:
|
|
6564
|
+
blockRecord.name = value;
|
|
6565
|
+
break;
|
|
6566
|
+
case 70:
|
|
6567
|
+
blockRecord.flags = value;
|
|
6568
|
+
break;
|
|
6569
|
+
default:
|
|
6570
|
+
}
|
|
6571
|
+
return blockRecord;
|
|
6572
|
+
},
|
|
6573
|
+
{ type: "BLOCK_RECORD" }
|
|
6574
|
+
);
|
|
6575
|
+
};
|
|
6576
|
+
var ucsHandler = (tuples) => {
|
|
6577
|
+
return tuples.reduce(
|
|
6578
|
+
(ucs, tuple) => {
|
|
6579
|
+
const type = tuple[0];
|
|
6580
|
+
const value = tuple[1];
|
|
6581
|
+
switch (type) {
|
|
6582
|
+
case 2:
|
|
6583
|
+
ucs.name = value;
|
|
6584
|
+
break;
|
|
6585
|
+
case 70:
|
|
6586
|
+
ucs.flags = value;
|
|
6587
|
+
break;
|
|
6588
|
+
default:
|
|
6589
|
+
}
|
|
6590
|
+
return ucs;
|
|
6591
|
+
},
|
|
6592
|
+
{ type: "UCS" }
|
|
6593
|
+
);
|
|
6594
|
+
};
|
|
6595
|
+
var viewHandler = (tuples) => {
|
|
6596
|
+
return tuples.reduce(
|
|
6597
|
+
(view, tuple) => {
|
|
6598
|
+
const type = tuple[0];
|
|
6599
|
+
const value = tuple[1];
|
|
6600
|
+
switch (type) {
|
|
6601
|
+
case 2:
|
|
6602
|
+
view.name = value;
|
|
6603
|
+
break;
|
|
6604
|
+
case 70:
|
|
6605
|
+
view.flags = value;
|
|
6606
|
+
break;
|
|
6607
|
+
default:
|
|
6608
|
+
}
|
|
6609
|
+
return view;
|
|
6610
|
+
},
|
|
6611
|
+
{ type: "VIEW" }
|
|
6612
|
+
);
|
|
6613
|
+
};
|
|
5197
6614
|
var dimStyleHandler = (tuples) => {
|
|
5198
6615
|
return tuples.reduce(
|
|
5199
6616
|
(dimStyle, tuple) => {
|
|
5200
6617
|
const type = tuple[0];
|
|
5201
6618
|
const value = tuple[1];
|
|
5202
6619
|
switch (type) {
|
|
6620
|
+
// NOSONAR
|
|
5203
6621
|
case 2:
|
|
5204
6622
|
dimStyle.name = value;
|
|
5205
6623
|
break;
|
|
@@ -5450,30 +6868,31 @@ var dxf = (() => {
|
|
|
5450
6868
|
tableTuples.push(tuple);
|
|
5451
6869
|
}
|
|
5452
6870
|
}
|
|
5453
|
-
|
|
5454
|
-
let layersTuples = [];
|
|
5455
|
-
let vPortTuples = [];
|
|
5456
|
-
let ltypeTuples = [];
|
|
5457
|
-
let dimStyleTuples = [];
|
|
6871
|
+
const groupsByName = {};
|
|
5458
6872
|
for (const group of tableGroups) {
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
6873
|
+
const name = String(group[0]?.[1] ?? "");
|
|
6874
|
+
if (!name) continue;
|
|
6875
|
+
groupsByName[name] = group;
|
|
6876
|
+
}
|
|
6877
|
+
const stylesTuples = groupsByName.STYLE ?? [];
|
|
6878
|
+
const layersTuples = groupsByName.LAYER ?? [];
|
|
6879
|
+
const vPortTuples = groupsByName.VPORT ?? [];
|
|
6880
|
+
const ltypeTuples = groupsByName.LTYPE ?? [];
|
|
6881
|
+
const dimStyleTuples = groupsByName.DIMSTYLE ?? [];
|
|
6882
|
+
const appIdTuples = groupsByName.APPID ?? [];
|
|
6883
|
+
const blockRecordTuples = groupsByName.BLOCK_RECORD ?? [];
|
|
6884
|
+
const ucsTuples = groupsByName.UCS ?? [];
|
|
6885
|
+
const viewTuples = groupsByName.VIEW ?? [];
|
|
5471
6886
|
return {
|
|
5472
6887
|
layers: tableHandler(layersTuples, "LAYER", layerHandler),
|
|
5473
6888
|
styles: tableHandler(stylesTuples, "STYLE", styleHandler),
|
|
5474
6889
|
vports: tableHandler(vPortTuples, "VPORT", vPortHandler),
|
|
5475
6890
|
ltypes: tableHandler(ltypeTuples, "LTYPE", ltypeHandler),
|
|
5476
|
-
dimStyles: tableHandler(dimStyleTuples, "DIMSTYLE", dimStyleHandler)
|
|
6891
|
+
dimStyles: tableHandler(dimStyleTuples, "DIMSTYLE", dimStyleHandler),
|
|
6892
|
+
appids: tableHandler(appIdTuples, "APPID", appIdHandler),
|
|
6893
|
+
blockRecords: tableHandler(blockRecordTuples, "BLOCK_RECORD", blockRecordHandler),
|
|
6894
|
+
ucs: tableHandler(ucsTuples, "UCS", ucsHandler),
|
|
6895
|
+
views: tableHandler(viewTuples, "VIEW", viewHandler)
|
|
5477
6896
|
};
|
|
5478
6897
|
}
|
|
5479
6898
|
|
|
@@ -5557,131 +6976,11 @@ var dxf = (() => {
|
|
|
5557
6976
|
return result;
|
|
5558
6977
|
}
|
|
5559
6978
|
|
|
5560
|
-
// src/
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
const
|
|
5564
|
-
|
|
5565
|
-
acc[b.name] = b;
|
|
5566
|
-
return acc;
|
|
5567
|
-
},
|
|
5568
|
-
{}
|
|
5569
|
-
);
|
|
5570
|
-
const gatherEntities = (entities, transforms) => {
|
|
5571
|
-
let current = [];
|
|
5572
|
-
for (const e of entities) {
|
|
5573
|
-
if (e.type === "INSERT") {
|
|
5574
|
-
const insert = e;
|
|
5575
|
-
const block = blocksByName[insert.block];
|
|
5576
|
-
if (!block) {
|
|
5577
|
-
logger_default.error("no block found for insert. block:", insert.block);
|
|
5578
|
-
continue;
|
|
5579
|
-
}
|
|
5580
|
-
const rowCount = insert.rowCount ?? 1;
|
|
5581
|
-
const columnCount = insert.columnCount ?? 1;
|
|
5582
|
-
const rowSpacing = insert.rowSpacing ?? 0;
|
|
5583
|
-
const columnSpacing = insert.columnSpacing ?? 0;
|
|
5584
|
-
const rotation = insert.rotation ?? 0;
|
|
5585
|
-
let rowVec;
|
|
5586
|
-
let colVec;
|
|
5587
|
-
if (rowCount > 1 || columnCount > 1) {
|
|
5588
|
-
const cos = Math.cos(rotation * Math.PI / 180);
|
|
5589
|
-
const sin = Math.sin(rotation * Math.PI / 180);
|
|
5590
|
-
rowVec = { x: -sin * rowSpacing, y: cos * rowSpacing };
|
|
5591
|
-
colVec = { x: cos * columnSpacing, y: sin * columnSpacing };
|
|
5592
|
-
} else {
|
|
5593
|
-
rowVec = { x: 0, y: 0 };
|
|
5594
|
-
colVec = { x: 0, y: 0 };
|
|
5595
|
-
}
|
|
5596
|
-
for (let r = 0; r < rowCount; r++) {
|
|
5597
|
-
for (let c = 0; c < columnCount; c++) {
|
|
5598
|
-
const t = {
|
|
5599
|
-
x: insert.x + rowVec.x * r + colVec.x * c,
|
|
5600
|
-
y: insert.y + rowVec.y * r + colVec.y * c,
|
|
5601
|
-
scaleX: insert.scaleX,
|
|
5602
|
-
scaleY: insert.scaleY,
|
|
5603
|
-
scaleZ: insert.scaleZ,
|
|
5604
|
-
extrusionX: insert.extrusionX,
|
|
5605
|
-
extrusionY: insert.extrusionY,
|
|
5606
|
-
extrusionZ: insert.extrusionZ,
|
|
5607
|
-
rotation: insert.rotation
|
|
5608
|
-
};
|
|
5609
|
-
const transforms2 = transforms.slice(0);
|
|
5610
|
-
transforms2.push(t);
|
|
5611
|
-
const blockEntities = block.entities.map((be) => {
|
|
5612
|
-
const be2 = (0, import_cloneDeep.default)(be);
|
|
5613
|
-
be2.layer = insert.layer;
|
|
5614
|
-
switch (be2.type) {
|
|
5615
|
-
case "LINE": {
|
|
5616
|
-
const line = be2;
|
|
5617
|
-
line.start.x -= block.x;
|
|
5618
|
-
line.start.y -= block.y;
|
|
5619
|
-
line.end.x -= block.x;
|
|
5620
|
-
line.end.y -= block.y;
|
|
5621
|
-
break;
|
|
5622
|
-
}
|
|
5623
|
-
case "LWPOLYLINE":
|
|
5624
|
-
case "POLYLINE": {
|
|
5625
|
-
const poly = be2;
|
|
5626
|
-
for (const v of poly.vertices) {
|
|
5627
|
-
if (v.x !== void 0) v.x -= block.x;
|
|
5628
|
-
if (v.y !== void 0) v.y -= block.y;
|
|
5629
|
-
}
|
|
5630
|
-
break;
|
|
5631
|
-
}
|
|
5632
|
-
case "CIRCLE": {
|
|
5633
|
-
const circle2 = be2;
|
|
5634
|
-
circle2.x -= block.x;
|
|
5635
|
-
circle2.y -= block.y;
|
|
5636
|
-
break;
|
|
5637
|
-
}
|
|
5638
|
-
case "ELLIPSE": {
|
|
5639
|
-
const ellipse2 = be2;
|
|
5640
|
-
ellipse2.x -= block.x;
|
|
5641
|
-
ellipse2.y -= block.y;
|
|
5642
|
-
break;
|
|
5643
|
-
}
|
|
5644
|
-
case "ARC": {
|
|
5645
|
-
const arc2 = be2;
|
|
5646
|
-
arc2.x -= block.x;
|
|
5647
|
-
arc2.y -= block.y;
|
|
5648
|
-
break;
|
|
5649
|
-
}
|
|
5650
|
-
case "SPLINE": {
|
|
5651
|
-
const spline = be2;
|
|
5652
|
-
for (const cp of spline.controlPoints) {
|
|
5653
|
-
cp.x -= block.x;
|
|
5654
|
-
cp.y -= block.y;
|
|
5655
|
-
}
|
|
5656
|
-
break;
|
|
5657
|
-
}
|
|
5658
|
-
}
|
|
5659
|
-
return be2;
|
|
5660
|
-
});
|
|
5661
|
-
current = current.concat(gatherEntities(blockEntities, transforms2));
|
|
5662
|
-
}
|
|
5663
|
-
}
|
|
5664
|
-
} else {
|
|
5665
|
-
const e2 = (0, import_cloneDeep.default)(e);
|
|
5666
|
-
e2.transforms = transforms.slice().reverse();
|
|
5667
|
-
current.push(e2);
|
|
5668
|
-
}
|
|
5669
|
-
}
|
|
5670
|
-
return current;
|
|
5671
|
-
};
|
|
5672
|
-
return gatherEntities(parseResult.entities, []);
|
|
5673
|
-
}
|
|
5674
|
-
|
|
5675
|
-
// src/groupEntitiesByLayer.ts
|
|
5676
|
-
function groupEntitiesByLayer(entities) {
|
|
5677
|
-
return entities.reduce((acc, entity) => {
|
|
5678
|
-
const layer = entity.layer ?? "0";
|
|
5679
|
-
if (!acc[layer]) {
|
|
5680
|
-
acc[layer] = [];
|
|
5681
|
-
}
|
|
5682
|
-
acc[layer].push(entity);
|
|
5683
|
-
return acc;
|
|
5684
|
-
}, {});
|
|
6979
|
+
// src/toJson.ts
|
|
6980
|
+
function toJson(parsed, options = {}) {
|
|
6981
|
+
const shouldPrettyPrint = options.pretty === true;
|
|
6982
|
+
const indentation = shouldPrettyPrint ? options.space ?? 2 : void 0;
|
|
6983
|
+
return JSON.stringify(parsed, null, indentation);
|
|
5685
6984
|
}
|
|
5686
6985
|
|
|
5687
6986
|
// src/toPolylines.ts
|
|
@@ -5973,12 +7272,95 @@ var dxf = (() => {
|
|
|
5973
7272
|
function entityToPolyline(entity, options) {
|
|
5974
7273
|
options = options || {};
|
|
5975
7274
|
let polyline2;
|
|
7275
|
+
const INFINITE_LINE_LENGTH = 1e3;
|
|
7276
|
+
const normalize2 = (x, y) => {
|
|
7277
|
+
const len = Math.hypot(x, y);
|
|
7278
|
+
if (len === 0) return null;
|
|
7279
|
+
return { x: x / len, y: y / len };
|
|
7280
|
+
};
|
|
5976
7281
|
if (entity.type === "LINE") {
|
|
5977
7282
|
polyline2 = [
|
|
5978
7283
|
[entity.start.x, entity.start.y],
|
|
5979
7284
|
[entity.end.x, entity.end.y]
|
|
5980
7285
|
];
|
|
5981
7286
|
}
|
|
7287
|
+
if (entity.type === "LEADER") {
|
|
7288
|
+
if (entity.vertices.length >= 2) {
|
|
7289
|
+
polyline2 = entity.vertices.map((v) => [v.x, v.y]);
|
|
7290
|
+
} else {
|
|
7291
|
+
logger_default.warn("LEADER entity with insufficient vertices");
|
|
7292
|
+
polyline2 = [];
|
|
7293
|
+
}
|
|
7294
|
+
}
|
|
7295
|
+
if (entity.type === "RAY") {
|
|
7296
|
+
const dir = normalize2(entity.direction.x, entity.direction.y);
|
|
7297
|
+
if (dir === null) {
|
|
7298
|
+
logger_default.warn("RAY entity with zero direction vector");
|
|
7299
|
+
polyline2 = [];
|
|
7300
|
+
} else {
|
|
7301
|
+
polyline2 = [
|
|
7302
|
+
[entity.start.x, entity.start.y],
|
|
7303
|
+
[
|
|
7304
|
+
entity.start.x + dir.x * INFINITE_LINE_LENGTH,
|
|
7305
|
+
entity.start.y + dir.y * INFINITE_LINE_LENGTH
|
|
7306
|
+
]
|
|
7307
|
+
];
|
|
7308
|
+
}
|
|
7309
|
+
}
|
|
7310
|
+
if (entity.type === "XLINE") {
|
|
7311
|
+
const dir = normalize2(entity.direction.x, entity.direction.y);
|
|
7312
|
+
if (dir === null) {
|
|
7313
|
+
logger_default.warn("XLINE entity with zero direction vector");
|
|
7314
|
+
polyline2 = [];
|
|
7315
|
+
} else {
|
|
7316
|
+
polyline2 = [
|
|
7317
|
+
[
|
|
7318
|
+
entity.basePoint.x - dir.x * INFINITE_LINE_LENGTH,
|
|
7319
|
+
entity.basePoint.y - dir.y * INFINITE_LINE_LENGTH
|
|
7320
|
+
],
|
|
7321
|
+
[
|
|
7322
|
+
entity.basePoint.x + dir.x * INFINITE_LINE_LENGTH,
|
|
7323
|
+
entity.basePoint.y + dir.y * INFINITE_LINE_LENGTH
|
|
7324
|
+
]
|
|
7325
|
+
];
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
7328
|
+
if (entity.type === "SHAPE") {
|
|
7329
|
+
const x = entity.insertionPoint?.x ?? 0;
|
|
7330
|
+
const y = entity.insertionPoint?.y ?? 0;
|
|
7331
|
+
const size = entity.size ?? 0;
|
|
7332
|
+
const scaleX = entity.relativeXScale ?? 1;
|
|
7333
|
+
const length = size * scaleX;
|
|
7334
|
+
polyline2 = [
|
|
7335
|
+
[x, y],
|
|
7336
|
+
[x + length, y]
|
|
7337
|
+
];
|
|
7338
|
+
}
|
|
7339
|
+
if (entity.type === "WIPEOUT") {
|
|
7340
|
+
const verts = entity.clipBoundaryVertices;
|
|
7341
|
+
if (!verts || verts.length < 2) {
|
|
7342
|
+
logger_default.warn("WIPEOUT entity with missing clip boundary vertices");
|
|
7343
|
+
polyline2 = [];
|
|
7344
|
+
} else {
|
|
7345
|
+
const insX = entity.insertionPoint?.x ?? 0;
|
|
7346
|
+
const insY = entity.insertionPoint?.y ?? 0;
|
|
7347
|
+
const ux = entity.uVector?.x ?? 1;
|
|
7348
|
+
const uy = entity.uVector?.y ?? 0;
|
|
7349
|
+
const vx = entity.vVector?.x ?? 0;
|
|
7350
|
+
const vy = entity.vVector?.y ?? 1;
|
|
7351
|
+
polyline2 = verts.map((p) => [
|
|
7352
|
+
insX + ux * p.x + vx * p.y,
|
|
7353
|
+
insY + uy * p.x + vy * p.y
|
|
7354
|
+
]);
|
|
7355
|
+
if (polyline2.length > 0) {
|
|
7356
|
+
const first = polyline2[0];
|
|
7357
|
+
const last = polyline2[polyline2.length - 1];
|
|
7358
|
+
if (first[0] !== last[0] || first[1] !== last[1]) {
|
|
7359
|
+
polyline2.push(first);
|
|
7360
|
+
}
|
|
7361
|
+
}
|
|
7362
|
+
}
|
|
7363
|
+
}
|
|
5982
7364
|
if (entity.type === "LWPOLYLINE" || entity.type === "POLYLINE") {
|
|
5983
7365
|
polyline2 = [];
|
|
5984
7366
|
if (entity.polyfaceMesh) {
|
|
@@ -6063,6 +7445,18 @@ var dxf = (() => {
|
|
|
6063
7445
|
entity.weights
|
|
6064
7446
|
);
|
|
6065
7447
|
}
|
|
7448
|
+
if (entity.type === "SOLID" || entity.type === "TRACE") {
|
|
7449
|
+
const corners = entity.corners ?? entity.points;
|
|
7450
|
+
if (corners && corners.length >= 4) {
|
|
7451
|
+
polyline2 = [
|
|
7452
|
+
[corners[0].x, corners[0].y],
|
|
7453
|
+
[corners[1].x, corners[1].y],
|
|
7454
|
+
[corners[2].x, corners[2].y],
|
|
7455
|
+
[corners[3].x, corners[3].y],
|
|
7456
|
+
[corners[0].x, corners[0].y]
|
|
7457
|
+
];
|
|
7458
|
+
}
|
|
7459
|
+
}
|
|
6066
7460
|
if (!polyline2) {
|
|
6067
7461
|
logger_default.warn("unsupported entity for converting to polyline:", entity.type);
|
|
6068
7462
|
return [];
|
|
@@ -6367,6 +7761,173 @@ var dxf = (() => {
|
|
|
6367
7761
|
|
|
6368
7762
|
// src/dimensionToSVG.ts
|
|
6369
7763
|
var import_vecks3 = __toESM(require_lib(), 1);
|
|
7764
|
+
|
|
7765
|
+
// src/util/escapeXmlText.ts
|
|
7766
|
+
function escapeXmlText(value) {
|
|
7767
|
+
return value.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""").split("'").join("'");
|
|
7768
|
+
}
|
|
7769
|
+
|
|
7770
|
+
// src/dimensionToSVG.ts
|
|
7771
|
+
var DEFAULT_DIMENSION_DECIMALS = 2;
|
|
7772
|
+
var AUTOSCALE_VIEWPORT_REFERENCE = 40;
|
|
7773
|
+
var computeViewportAutoScaleFactor = (viewport, options) => {
|
|
7774
|
+
const viewportMin = Math.min(Math.abs(viewport.width), Math.abs(viewport.height));
|
|
7775
|
+
if (!Number.isFinite(viewportMin) || viewportMin <= 0) return 1;
|
|
7776
|
+
const reference = options?.dimension?.autoScaleViewportReference;
|
|
7777
|
+
const safeReference = Number.isFinite(reference) && (reference ?? 0) > 0 ? reference : AUTOSCALE_VIEWPORT_REFERENCE;
|
|
7778
|
+
return viewportMin / safeReference;
|
|
7779
|
+
};
|
|
7780
|
+
var getViewportMin = (viewport) => {
|
|
7781
|
+
const viewportMin = Math.min(Math.abs(viewport.width), Math.abs(viewport.height));
|
|
7782
|
+
return Number.isFinite(viewportMin) ? viewportMin : Number.NaN;
|
|
7783
|
+
};
|
|
7784
|
+
var getViewportPercentageSize = (viewport, percent) => {
|
|
7785
|
+
if (!Number.isFinite(percent) || (percent ?? 0) <= 0) return void 0;
|
|
7786
|
+
const viewportMin = getViewportMin(viewport);
|
|
7787
|
+
if (!Number.isFinite(viewportMin) || viewportMin <= 0) return void 0;
|
|
7788
|
+
return viewportMin * (percent / 100);
|
|
7789
|
+
};
|
|
7790
|
+
var getDimensionGeometryBBox = (entity) => {
|
|
7791
|
+
const bbox = new import_vecks3.Box2();
|
|
7792
|
+
const points = [
|
|
7793
|
+
entity.start,
|
|
7794
|
+
entity.angleVertex,
|
|
7795
|
+
entity.arcPoint,
|
|
7796
|
+
entity.textMidpoint,
|
|
7797
|
+
entity.measureStart,
|
|
7798
|
+
entity.measureEnd
|
|
7799
|
+
];
|
|
7800
|
+
for (const p of points) {
|
|
7801
|
+
if (!p) continue;
|
|
7802
|
+
const x = p.x;
|
|
7803
|
+
const y = p.y;
|
|
7804
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) continue;
|
|
7805
|
+
bbox.expandByPoint({ x, y });
|
|
7806
|
+
}
|
|
7807
|
+
return bbox;
|
|
7808
|
+
};
|
|
7809
|
+
var getScaledDimensionSizes = (dimStyle, options, viewport) => {
|
|
7810
|
+
const autoScale = options?.dimension?.autoScale === true;
|
|
7811
|
+
const baseArrowSize = dimStyle?.dimAsz ?? 2.5;
|
|
7812
|
+
const baseTextHeight = dimStyle?.dimTxt ?? 2.5;
|
|
7813
|
+
const baseExtLineOffset = dimStyle?.dimExo ?? 0.625;
|
|
7814
|
+
const baseExtLineExtension = dimStyle?.dimExe ?? 1.25;
|
|
7815
|
+
if (!autoScale || !viewport) {
|
|
7816
|
+
return {
|
|
7817
|
+
arrowSize: baseArrowSize,
|
|
7818
|
+
textHeight: baseTextHeight,
|
|
7819
|
+
extLineOffset: baseExtLineOffset,
|
|
7820
|
+
extLineExtension: baseExtLineExtension
|
|
7821
|
+
};
|
|
7822
|
+
}
|
|
7823
|
+
const scale = computeViewportAutoScaleFactor(viewport, options);
|
|
7824
|
+
const perc = options?.dimension?.autoScaleViewportPercentages;
|
|
7825
|
+
const arrowFromPct = getViewportPercentageSize(viewport, perc?.arrowSize);
|
|
7826
|
+
const textFromPct = getViewportPercentageSize(viewport, perc?.textHeight);
|
|
7827
|
+
const offsetFromPct = getViewportPercentageSize(viewport, perc?.extLineOffset);
|
|
7828
|
+
const extensionFromPct = getViewportPercentageSize(viewport, perc?.extLineExtension);
|
|
7829
|
+
return {
|
|
7830
|
+
arrowSize: arrowFromPct ?? baseArrowSize * scale,
|
|
7831
|
+
textHeight: textFromPct ?? baseTextHeight * scale,
|
|
7832
|
+
extLineOffset: offsetFromPct ?? baseExtLineOffset * scale,
|
|
7833
|
+
extLineExtension: extensionFromPct ?? baseExtLineExtension * scale
|
|
7834
|
+
};
|
|
7835
|
+
};
|
|
7836
|
+
var formatDimensionValue = (value, decimals = DEFAULT_DIMENSION_DECIMALS) => {
|
|
7837
|
+
if (!Number.isFinite(value)) return "";
|
|
7838
|
+
const rounded = round10(value, -decimals);
|
|
7839
|
+
return rounded.toFixed(decimals);
|
|
7840
|
+
};
|
|
7841
|
+
var computeRadiusFallback = (entity) => {
|
|
7842
|
+
const cx = entity.start?.x ?? 0;
|
|
7843
|
+
const cy = entity.start?.y ?? 0;
|
|
7844
|
+
const x1 = entity.measureStart?.x ?? 0;
|
|
7845
|
+
const y1 = entity.measureStart?.y ?? 0;
|
|
7846
|
+
const x2 = entity.measureEnd?.x ?? 0;
|
|
7847
|
+
const y2 = entity.measureEnd?.y ?? 0;
|
|
7848
|
+
const r1 = Math.hypot(x1 - cx, y1 - cy);
|
|
7849
|
+
const r2 = Math.hypot(x2 - cx, y2 - cy);
|
|
7850
|
+
const chord = Math.hypot(x2 - x1, y2 - y1);
|
|
7851
|
+
return Math.max(r1, r2, chord);
|
|
7852
|
+
};
|
|
7853
|
+
var computeLinearDistance = (x1, y1, x2, y2) => Math.hypot(x2 - x1, y2 - y1);
|
|
7854
|
+
var computeAngularDegreesMinimal = (cx, cy, x1, y1, x2, y2) => {
|
|
7855
|
+
const a1 = Math.atan2(y1 - cy, x1 - cx);
|
|
7856
|
+
const a2 = Math.atan2(y2 - cy, x2 - cx);
|
|
7857
|
+
let delta = Math.abs(a2 - a1);
|
|
7858
|
+
while (delta > Math.PI * 2) delta -= Math.PI * 2;
|
|
7859
|
+
if (delta > Math.PI) delta = Math.PI * 2 - delta;
|
|
7860
|
+
return delta * 180 / Math.PI;
|
|
7861
|
+
};
|
|
7862
|
+
var computeAngularDegreesCCW = (cx, cy, x1, y1, x2, y2) => {
|
|
7863
|
+
const a1 = Math.atan2(y1 - cy, x1 - cx);
|
|
7864
|
+
const a2 = Math.atan2(y2 - cy, x2 - cx);
|
|
7865
|
+
let delta = a2 - a1;
|
|
7866
|
+
while (delta < 0) delta += Math.PI * 2;
|
|
7867
|
+
while (delta >= Math.PI * 2) delta -= Math.PI * 2;
|
|
7868
|
+
return delta * 180 / Math.PI;
|
|
7869
|
+
};
|
|
7870
|
+
var computeDimensionMeasurement = (entity) => {
|
|
7871
|
+
const x1 = entity.measureStart?.x ?? 0;
|
|
7872
|
+
const y1 = entity.measureStart?.y ?? 0;
|
|
7873
|
+
const x2 = entity.measureEnd?.x ?? 0;
|
|
7874
|
+
const y2 = entity.measureEnd?.y ?? 0;
|
|
7875
|
+
switch (entity.dimensionType) {
|
|
7876
|
+
case 0:
|
|
7877
|
+
case 1:
|
|
7878
|
+
case 6: {
|
|
7879
|
+
const dist = computeLinearDistance(x1, y1, x2, y2);
|
|
7880
|
+
return formatDimensionValue(dist);
|
|
7881
|
+
}
|
|
7882
|
+
case 3: {
|
|
7883
|
+
const dist = computeLinearDistance(x1, y1, x2, y2);
|
|
7884
|
+
if (dist > 0) return formatDimensionValue(dist);
|
|
7885
|
+
const radius = computeRadiusFallback(entity);
|
|
7886
|
+
return formatDimensionValue(radius * 2);
|
|
7887
|
+
}
|
|
7888
|
+
case 4: {
|
|
7889
|
+
const dist = computeLinearDistance(x1, y1, x2, y2);
|
|
7890
|
+
if (dist > 0) return formatDimensionValue(dist);
|
|
7891
|
+
const radius = computeRadiusFallback(entity);
|
|
7892
|
+
return formatDimensionValue(radius);
|
|
7893
|
+
}
|
|
7894
|
+
case 2: {
|
|
7895
|
+
const cx = entity.start?.x ?? 0;
|
|
7896
|
+
const cy = entity.start?.y ?? 0;
|
|
7897
|
+
const degrees = computeAngularDegreesMinimal(cx, cy, x1, y1, x2, y2);
|
|
7898
|
+
const formatted = formatDimensionValue(degrees);
|
|
7899
|
+
return formatted ? `${formatted}\xB0` : "";
|
|
7900
|
+
}
|
|
7901
|
+
case 5: {
|
|
7902
|
+
const cx = entity.angleVertex?.x ?? 0;
|
|
7903
|
+
const cy = entity.angleVertex?.y ?? 0;
|
|
7904
|
+
const degrees = computeAngularDegreesCCW(cx, cy, x1, y1, x2, y2);
|
|
7905
|
+
const formatted = formatDimensionValue(degrees);
|
|
7906
|
+
return formatted ? `${formatted}\xB0` : "";
|
|
7907
|
+
}
|
|
7908
|
+
default:
|
|
7909
|
+
return "";
|
|
7910
|
+
}
|
|
7911
|
+
};
|
|
7912
|
+
var resolveDimensionText = (entity) => {
|
|
7913
|
+
const raw = typeof entity.text === "string" ? entity.text : "";
|
|
7914
|
+
const trimmed = raw.trim();
|
|
7915
|
+
const measured = computeDimensionMeasurement(entity);
|
|
7916
|
+
if (!trimmed) return measured;
|
|
7917
|
+
if (trimmed.includes("<>")) {
|
|
7918
|
+
return trimmed.split("<>").join(measured);
|
|
7919
|
+
}
|
|
7920
|
+
return trimmed;
|
|
7921
|
+
};
|
|
7922
|
+
var expandBBoxForMarker = (bbox, x, y, size) => {
|
|
7923
|
+
bbox.expandByPoint({ x: x - size, y: y - size });
|
|
7924
|
+
bbox.expandByPoint({ x: x + size, y: y + size });
|
|
7925
|
+
};
|
|
7926
|
+
var expandBBoxForText = (bbox, x, y, height, content) => {
|
|
7927
|
+
const textWidth = content.length * height * 0.6;
|
|
7928
|
+
bbox.expandByPoint({ x: x - textWidth / 2, y: y - height });
|
|
7929
|
+
bbox.expandByPoint({ x: x + textWidth / 2, y: y + height });
|
|
7930
|
+
};
|
|
6370
7931
|
function colorNumberToSVG(colorNumber) {
|
|
6371
7932
|
if (colorNumber === void 0 || colorNumber < 0) {
|
|
6372
7933
|
return "currentColor";
|
|
@@ -6389,38 +7950,117 @@ var dxf = (() => {
|
|
|
6389
7950
|
extLineWeight: dimStyle?.dimLwe ?? 0.5
|
|
6390
7951
|
};
|
|
6391
7952
|
}
|
|
6392
|
-
function dimensionToSVG(entity, dimStyle) {
|
|
7953
|
+
function dimensionToSVG(entity, dimStyle, options, viewport) {
|
|
6393
7954
|
switch (entity.dimensionType) {
|
|
6394
7955
|
case 0:
|
|
6395
7956
|
// Rotated, horizontal, or vertical
|
|
6396
7957
|
case 1:
|
|
6397
|
-
return renderLinearDimension(entity, dimStyle);
|
|
7958
|
+
return renderLinearDimension(entity, dimStyle, options, viewport);
|
|
6398
7959
|
case 2:
|
|
6399
|
-
return renderAngularDimension(entity, dimStyle);
|
|
7960
|
+
return renderAngularDimension(entity, dimStyle, options, viewport);
|
|
7961
|
+
case 5:
|
|
7962
|
+
return renderAngular3PointDimension(entity, dimStyle, options, viewport);
|
|
6400
7963
|
case 3:
|
|
6401
|
-
return renderDiameterDimension(entity, dimStyle);
|
|
7964
|
+
return renderDiameterDimension(entity, dimStyle, options, viewport);
|
|
6402
7965
|
case 4:
|
|
6403
|
-
return renderRadialDimension(entity, dimStyle);
|
|
7966
|
+
return renderRadialDimension(entity, dimStyle, options, viewport);
|
|
6404
7967
|
case 6:
|
|
6405
|
-
return renderOrdinateDimension(entity, dimStyle);
|
|
7968
|
+
return renderOrdinateDimension(entity, dimStyle, options, viewport);
|
|
6406
7969
|
default:
|
|
6407
7970
|
return renderFallbackDimension(entity);
|
|
6408
7971
|
}
|
|
6409
7972
|
}
|
|
6410
|
-
function
|
|
6411
|
-
const
|
|
6412
|
-
|
|
7973
|
+
function renderAngular3PointDimension(entity, dimStyle, options, viewport) {
|
|
7974
|
+
const bbox = new import_vecks3.Box2();
|
|
7975
|
+
const elements = [];
|
|
7976
|
+
const markers = [];
|
|
7977
|
+
const { arrowSize, textHeight } = getScaledDimensionSizes(dimStyle, options, viewport);
|
|
7978
|
+
const { dimLineColor, extLineColor, textColor, dimLineWeight, extLineWeight } = getDimensionColors(dimStyle);
|
|
7979
|
+
const vertexX = entity.angleVertex?.x ?? 0;
|
|
7980
|
+
const vertexY = entity.angleVertex?.y ?? 0;
|
|
7981
|
+
const x1 = entity.measureStart?.x ?? 0;
|
|
7982
|
+
const y1 = entity.measureStart?.y ?? 0;
|
|
7983
|
+
const x2 = entity.measureEnd?.x ?? 0;
|
|
7984
|
+
const y2 = entity.measureEnd?.y ?? 0;
|
|
7985
|
+
const startArcX = entity.start?.x ?? 0;
|
|
7986
|
+
const startArcY = entity.start?.y ?? 0;
|
|
7987
|
+
const arcPointX = entity.arcPoint?.x;
|
|
7988
|
+
const arcPointY = entity.arcPoint?.y;
|
|
7989
|
+
const arcPointRadius = Number.isFinite(arcPointX) && Number.isFinite(arcPointY) ? Math.hypot(arcPointX - vertexX, arcPointY - vertexY) : Number.NaN;
|
|
7990
|
+
const useArcPoint = Number.isFinite(arcPointRadius) && arcPointRadius > 1e-9;
|
|
7991
|
+
const arcLocationX = useArcPoint ? arcPointX : startArcX;
|
|
7992
|
+
const arcLocationY = useArcPoint ? arcPointY : startArcY;
|
|
7993
|
+
const textX = entity.textMidpoint?.x ?? arcLocationX;
|
|
7994
|
+
const textY = entity.textMidpoint?.y ?? arcLocationY;
|
|
7995
|
+
bbox.expandByPoint({ x: vertexX, y: vertexY });
|
|
7996
|
+
bbox.expandByPoint({ x: x1, y: y1 });
|
|
7997
|
+
bbox.expandByPoint({ x: x2, y: y2 });
|
|
7998
|
+
bbox.expandByPoint({ x: arcLocationX, y: arcLocationY });
|
|
7999
|
+
bbox.expandByPoint({ x: textX, y: textY });
|
|
8000
|
+
const a1 = Math.atan2(y1 - vertexY, x1 - vertexX);
|
|
8001
|
+
const a2 = Math.atan2(y2 - vertexY, x2 - vertexX);
|
|
8002
|
+
let radius = Math.hypot(arcLocationX - vertexX, arcLocationY - vertexY);
|
|
8003
|
+
if (!Number.isFinite(radius) || radius <= 1e-9) {
|
|
8004
|
+
radius = Math.hypot(textX - vertexX, textY - vertexY);
|
|
8005
|
+
}
|
|
8006
|
+
if (!Number.isFinite(radius) || radius <= 1e-9) {
|
|
8007
|
+
radius = Math.max(
|
|
8008
|
+
Math.hypot(x1 - vertexX, y1 - vertexY),
|
|
8009
|
+
Math.hypot(x2 - vertexX, y2 - vertexY)
|
|
8010
|
+
);
|
|
8011
|
+
}
|
|
8012
|
+
const arcStartX = vertexX + radius * Math.cos(a1);
|
|
8013
|
+
const arcStartY = vertexY + radius * Math.sin(a1);
|
|
8014
|
+
const arcEndX = vertexX + radius * Math.cos(a2);
|
|
8015
|
+
const arcEndY = vertexY + radius * Math.sin(a2);
|
|
8016
|
+
bbox.expandByPoint({ x: arcStartX, y: arcStartY });
|
|
8017
|
+
bbox.expandByPoint({ x: arcEndX, y: arcEndY });
|
|
8018
|
+
const markerId1 = `dim-angular-3p-arrow-start-${Date.now()}`;
|
|
8019
|
+
const markerId2 = `dim-angular-3p-arrow-end-${Date.now()}`;
|
|
8020
|
+
markers.push(
|
|
8021
|
+
createArrowMarker(markerId1, arrowSize, dimLineColor, "backward"),
|
|
8022
|
+
createArrowMarker(markerId2, arrowSize, dimLineColor, "forward")
|
|
8023
|
+
);
|
|
8024
|
+
elements.push(
|
|
8025
|
+
`<line x1="${x1}" y1="${y1}" x2="${arcStartX}" y2="${arcStartY}" stroke="${extLineColor}" stroke-width="${extLineWeight}" />`,
|
|
8026
|
+
`<line x1="${x2}" y1="${y2}" x2="${arcEndX}" y2="${arcEndY}" stroke="${extLineColor}" stroke-width="${extLineWeight}" />`
|
|
8027
|
+
);
|
|
8028
|
+
let delta = a2 - a1;
|
|
8029
|
+
while (delta < 0) delta += Math.PI * 2;
|
|
8030
|
+
while (delta >= Math.PI * 2) delta -= Math.PI * 2;
|
|
8031
|
+
const largeArcFlag = delta > Math.PI ? 1 : 0;
|
|
8032
|
+
const sweepFlag = 1;
|
|
8033
|
+
expandBBoxForMarker(bbox, arcStartX, arcStartY, arrowSize);
|
|
8034
|
+
expandBBoxForMarker(bbox, arcEndX, arcEndY, arrowSize);
|
|
8035
|
+
elements.push(
|
|
8036
|
+
`<path d="M ${arcStartX} ${arcStartY} A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${arcEndX} ${arcEndY}" fill="none" stroke="${dimLineColor}" stroke-width="${dimLineWeight}" marker-start="url(#${markerId1})" marker-end="url(#${markerId2})" />`
|
|
8037
|
+
);
|
|
8038
|
+
const resolvedText = resolveDimensionText(entity);
|
|
8039
|
+
if (resolvedText) {
|
|
8040
|
+
const midAngle = a1 + delta / 2;
|
|
8041
|
+
const textRotation = midAngle * 180 / Math.PI;
|
|
8042
|
+
expandBBoxForText(bbox, textX, textY, textHeight, resolvedText);
|
|
8043
|
+
elements.push(
|
|
8044
|
+
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${escapeXmlText(resolvedText)}</text>`
|
|
8045
|
+
);
|
|
8046
|
+
}
|
|
8047
|
+
return {
|
|
8048
|
+
bbox,
|
|
8049
|
+
element: `<defs>${markers.join("")}</defs><g>${elements.join("")}</g>`
|
|
8050
|
+
};
|
|
8051
|
+
}
|
|
8052
|
+
function createArrowMarker(id, size, color, direction = "forward") {
|
|
8053
|
+
const arrowPath = direction === "forward" ? `M 0 0 L ${size} ${size / 2} L 0 ${size} z` : `M ${size} 0 L 0 ${size / 2} L ${size} ${size} z`;
|
|
8054
|
+
const refX = direction === "forward" ? size : 0;
|
|
8055
|
+
return `<marker id="${id}" markerWidth="${size}" markerHeight="${size}" refX="${refX}" refY="${size / 2}" orient="auto" markerUnits="userSpaceOnUse">
|
|
6413
8056
|
<path d="${arrowPath}" fill="${color}" />
|
|
6414
8057
|
</marker>`;
|
|
6415
8058
|
}
|
|
6416
|
-
function renderLinearDimension(entity, dimStyle) {
|
|
8059
|
+
function renderLinearDimension(entity, dimStyle, options, viewport) {
|
|
6417
8060
|
const bbox = new import_vecks3.Box2();
|
|
6418
8061
|
const elements = [];
|
|
6419
8062
|
const markers = [];
|
|
6420
|
-
const arrowSize = dimStyle
|
|
6421
|
-
const textHeight = dimStyle?.dimTxt ?? 2.5;
|
|
6422
|
-
const extLineOffset = dimStyle?.dimExo ?? 0.625;
|
|
6423
|
-
const extLineExtension = dimStyle?.dimExe ?? 1.25;
|
|
8063
|
+
const { arrowSize, textHeight, extLineOffset, extLineExtension } = getScaledDimensionSizes(dimStyle, options, viewport);
|
|
6424
8064
|
const { dimLineColor, extLineColor, textColor, dimLineWeight, extLineWeight } = getDimensionColors(dimStyle);
|
|
6425
8065
|
const defPoint1X = entity.measureStart?.x ?? 0;
|
|
6426
8066
|
const defPoint1Y = entity.measureStart?.y ?? 0;
|
|
@@ -6443,8 +8083,8 @@ var dxf = (() => {
|
|
|
6443
8083
|
const markerId1 = `dim-arrow-start-${Date.now()}`;
|
|
6444
8084
|
const markerId2 = `dim-arrow-end-${Date.now()}`;
|
|
6445
8085
|
markers.push(
|
|
6446
|
-
createArrowMarker(markerId1, arrowSize, dimLineColor),
|
|
6447
|
-
createArrowMarker(markerId2, arrowSize, dimLineColor)
|
|
8086
|
+
createArrowMarker(markerId1, arrowSize, dimLineColor, "backward"),
|
|
8087
|
+
createArrowMarker(markerId2, arrowSize, dimLineColor, "forward")
|
|
6448
8088
|
);
|
|
6449
8089
|
const extLine1StartX = defPoint1X + Math.cos(perpAngle) * extLineOffset;
|
|
6450
8090
|
const extLine1StartY = defPoint1Y + Math.sin(perpAngle) * extLineOffset;
|
|
@@ -6454,15 +8094,23 @@ var dxf = (() => {
|
|
|
6454
8094
|
const extLine2StartY = defPoint2Y + Math.sin(perpAngle) * extLineOffset;
|
|
6455
8095
|
const extLine2EndX = dimLine2X + Math.cos(perpAngle) * extLineExtension;
|
|
6456
8096
|
const extLine2EndY = dimLine2Y + Math.sin(perpAngle) * extLineExtension;
|
|
8097
|
+
bbox.expandByPoint({ x: extLine1StartX, y: extLine1StartY });
|
|
8098
|
+
bbox.expandByPoint({ x: extLine1EndX, y: extLine1EndY });
|
|
8099
|
+
bbox.expandByPoint({ x: extLine2StartX, y: extLine2StartY });
|
|
8100
|
+
bbox.expandByPoint({ x: extLine2EndX, y: extLine2EndY });
|
|
8101
|
+
expandBBoxForMarker(bbox, dimLine1X, dimLine1Y, arrowSize);
|
|
8102
|
+
expandBBoxForMarker(bbox, dimLine2X, dimLine2Y, arrowSize);
|
|
6457
8103
|
elements.push(
|
|
6458
8104
|
`<line x1="${extLine1StartX}" y1="${extLine1StartY}" x2="${extLine1EndX}" y2="${extLine1EndY}" stroke="${extLineColor}" stroke-width="${extLineWeight}" />`,
|
|
6459
8105
|
`<line x1="${extLine2StartX}" y1="${extLine2StartY}" x2="${extLine2EndX}" y2="${extLine2EndY}" stroke="${extLineColor}" stroke-width="${extLineWeight}" />`,
|
|
6460
8106
|
`<line x1="${dimLine1X}" y1="${dimLine1Y}" x2="${dimLine2X}" y2="${dimLine2Y}" stroke="${dimLineColor}" stroke-width="${dimLineWeight}" marker-start="url(#${markerId1})" marker-end="url(#${markerId2})" />`
|
|
6461
8107
|
);
|
|
6462
|
-
|
|
8108
|
+
const resolvedText = resolveDimensionText(entity);
|
|
8109
|
+
if (resolvedText) {
|
|
6463
8110
|
const textRotation = angle * 180 / Math.PI;
|
|
8111
|
+
expandBBoxForText(bbox, textX, textY, textHeight, resolvedText);
|
|
6464
8112
|
elements.push(
|
|
6465
|
-
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${
|
|
8113
|
+
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${escapeXmlText(resolvedText)}</text>`
|
|
6466
8114
|
);
|
|
6467
8115
|
}
|
|
6468
8116
|
return {
|
|
@@ -6470,12 +8118,11 @@ var dxf = (() => {
|
|
|
6470
8118
|
element: `<defs>${markers.join("")}</defs><g>${elements.join("")}</g>`
|
|
6471
8119
|
};
|
|
6472
8120
|
}
|
|
6473
|
-
function renderAngularDimension(entity, dimStyle) {
|
|
8121
|
+
function renderAngularDimension(entity, dimStyle, options, viewport) {
|
|
6474
8122
|
const bbox = new import_vecks3.Box2();
|
|
6475
8123
|
const elements = [];
|
|
6476
8124
|
const markers = [];
|
|
6477
|
-
const arrowSize = dimStyle
|
|
6478
|
-
const textHeight = dimStyle?.dimTxt ?? 2.5;
|
|
8125
|
+
const { arrowSize, textHeight } = getScaledDimensionSizes(dimStyle, options, viewport);
|
|
6479
8126
|
const { dimLineColor, extLineColor, textColor, dimLineWeight, extLineWeight } = getDimensionColors(dimStyle);
|
|
6480
8127
|
const centerX = entity.start?.x ?? 0;
|
|
6481
8128
|
const centerY = entity.start?.y ?? 0;
|
|
@@ -6492,8 +8139,8 @@ var dxf = (() => {
|
|
|
6492
8139
|
const markerId1 = `dim-angular-arrow-start-${Date.now()}`;
|
|
6493
8140
|
const markerId2 = `dim-angular-arrow-end-${Date.now()}`;
|
|
6494
8141
|
markers.push(
|
|
6495
|
-
createArrowMarker(markerId1, arrowSize, dimLineColor),
|
|
6496
|
-
createArrowMarker(markerId2, arrowSize, dimLineColor)
|
|
8142
|
+
createArrowMarker(markerId1, arrowSize, dimLineColor, "backward"),
|
|
8143
|
+
createArrowMarker(markerId2, arrowSize, dimLineColor, "forward")
|
|
6497
8144
|
);
|
|
6498
8145
|
elements.push(
|
|
6499
8146
|
`<line x1="${centerX}" y1="${centerY}" x2="${x1}" y2="${y1}" stroke="${extLineColor}" stroke-width="${extLineWeight}" />`,
|
|
@@ -6510,11 +8157,13 @@ var dxf = (() => {
|
|
|
6510
8157
|
elements.push(
|
|
6511
8158
|
`<path d="M ${arcStartX} ${arcStartY} A ${radius} ${radius} 0 ${largeArcFlag} 1 ${arcEndX} ${arcEndY}" fill="none" stroke="${dimLineColor}" stroke-width="${dimLineWeight}" marker-start="url(#${markerId1})" marker-end="url(#${markerId2})" />`
|
|
6512
8159
|
);
|
|
6513
|
-
|
|
8160
|
+
const resolvedText = resolveDimensionText(entity);
|
|
8161
|
+
if (resolvedText) {
|
|
6514
8162
|
const midAngle = (startAngle + endAngle) / 2;
|
|
6515
8163
|
const textRotation = midAngle * 180 / Math.PI;
|
|
8164
|
+
expandBBoxForText(bbox, textX, textY, textHeight, resolvedText);
|
|
6516
8165
|
elements.push(
|
|
6517
|
-
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${
|
|
8166
|
+
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${escapeXmlText(resolvedText)}</text>`
|
|
6518
8167
|
);
|
|
6519
8168
|
}
|
|
6520
8169
|
return {
|
|
@@ -6522,12 +8171,11 @@ var dxf = (() => {
|
|
|
6522
8171
|
element: `<defs>${markers.join("")}</defs><g>${elements.join("")}</g>`
|
|
6523
8172
|
};
|
|
6524
8173
|
}
|
|
6525
|
-
function renderDiameterDimension(entity, dimStyle) {
|
|
8174
|
+
function renderDiameterDimension(entity, dimStyle, options, viewport) {
|
|
6526
8175
|
const bbox = new import_vecks3.Box2();
|
|
6527
8176
|
const elements = [];
|
|
6528
8177
|
const markers = [];
|
|
6529
|
-
const arrowSize = dimStyle
|
|
6530
|
-
const textHeight = dimStyle?.dimTxt ?? 2.5;
|
|
8178
|
+
const { arrowSize, textHeight } = getScaledDimensionSizes(dimStyle, options, viewport);
|
|
6531
8179
|
const { dimLineColor, textColor, dimLineWeight } = getDimensionColors(dimStyle);
|
|
6532
8180
|
const x1 = entity.measureStart?.x ?? 0;
|
|
6533
8181
|
const y1 = entity.measureStart?.y ?? 0;
|
|
@@ -6538,28 +8186,33 @@ var dxf = (() => {
|
|
|
6538
8186
|
bbox.expandByPoint({ x: x1, y: y1 });
|
|
6539
8187
|
bbox.expandByPoint({ x: x2, y: y2 });
|
|
6540
8188
|
bbox.expandByPoint({ x: textX, y: textY });
|
|
6541
|
-
const
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
8189
|
+
const diameterLen = Math.hypot(x2 - x1, y2 - y1);
|
|
8190
|
+
if (Number.isFinite(diameterLen) && diameterLen > 1e-6) {
|
|
8191
|
+
const markerId = `dim-diameter-arrow-${Date.now()}`;
|
|
8192
|
+
markers.push(createArrowMarker(markerId, arrowSize, dimLineColor, "backward"));
|
|
8193
|
+
elements.push(
|
|
8194
|
+
`<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${dimLineColor}" stroke-width="${dimLineWeight}" marker-end="url(#${markerId})" />`
|
|
8195
|
+
);
|
|
8196
|
+
expandBBoxForMarker(bbox, x2, y2, arrowSize);
|
|
8197
|
+
}
|
|
8198
|
+
const resolvedText = resolveDimensionText(entity);
|
|
8199
|
+
const diameterText = resolvedText ? `\u2300${resolvedText}` : "\u2300";
|
|
6547
8200
|
const angle = Math.atan2(y2 - y1, x2 - x1);
|
|
6548
8201
|
const textRotation = angle * 180 / Math.PI;
|
|
8202
|
+
expandBBoxForText(bbox, textX, textY, textHeight, diameterText);
|
|
6549
8203
|
elements.push(
|
|
6550
|
-
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${diameterText}</text>`
|
|
8204
|
+
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${escapeXmlText(diameterText)}</text>`
|
|
6551
8205
|
);
|
|
6552
8206
|
return {
|
|
6553
8207
|
bbox,
|
|
6554
8208
|
element: `<defs>${markers.join("")}</defs><g>${elements.join("")}</g>`
|
|
6555
8209
|
};
|
|
6556
8210
|
}
|
|
6557
|
-
function renderRadialDimension(entity, dimStyle) {
|
|
8211
|
+
function renderRadialDimension(entity, dimStyle, options, viewport) {
|
|
6558
8212
|
const bbox = new import_vecks3.Box2();
|
|
6559
8213
|
const elements = [];
|
|
6560
8214
|
const markers = [];
|
|
6561
|
-
const arrowSize = dimStyle
|
|
6562
|
-
const textHeight = dimStyle?.dimTxt ?? 2.5;
|
|
8215
|
+
const { arrowSize, textHeight } = getScaledDimensionSizes(dimStyle, options, viewport);
|
|
6563
8216
|
const { dimLineColor, textColor, dimLineWeight } = getDimensionColors(dimStyle);
|
|
6564
8217
|
const x1 = entity.measureStart?.x ?? 0;
|
|
6565
8218
|
const y1 = entity.measureStart?.y ?? 0;
|
|
@@ -6570,26 +8223,32 @@ var dxf = (() => {
|
|
|
6570
8223
|
bbox.expandByPoint({ x: x1, y: y1 });
|
|
6571
8224
|
bbox.expandByPoint({ x: x2, y: y2 });
|
|
6572
8225
|
bbox.expandByPoint({ x: textX, y: textY });
|
|
6573
|
-
const
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
8226
|
+
const radiusLen = Math.hypot(x2 - x1, y2 - y1);
|
|
8227
|
+
if (Number.isFinite(radiusLen) && radiusLen > 1e-6) {
|
|
8228
|
+
const markerId = `dim-radius-arrow-${Date.now()}`;
|
|
8229
|
+
markers.push(createArrowMarker(markerId, arrowSize, dimLineColor, "backward"));
|
|
8230
|
+
elements.push(
|
|
8231
|
+
`<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${dimLineColor}" stroke-width="${dimLineWeight}" marker-end="url(#${markerId})" />`
|
|
8232
|
+
);
|
|
8233
|
+
expandBBoxForMarker(bbox, x2, y2, arrowSize);
|
|
8234
|
+
}
|
|
8235
|
+
const resolvedText = resolveDimensionText(entity);
|
|
8236
|
+
const radiusText = resolvedText ? `R${resolvedText}` : "R";
|
|
6579
8237
|
const angle = Math.atan2(y2 - y1, x2 - x1);
|
|
6580
8238
|
const textRotation = angle * 180 / Math.PI;
|
|
8239
|
+
expandBBoxForText(bbox, textX, textY, textHeight, radiusText);
|
|
6581
8240
|
elements.push(
|
|
6582
|
-
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${radiusText}</text>`
|
|
8241
|
+
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${escapeXmlText(radiusText)}</text>`
|
|
6583
8242
|
);
|
|
6584
8243
|
return {
|
|
6585
8244
|
bbox,
|
|
6586
8245
|
element: `<defs>${markers.join("")}</defs><g>${elements.join("")}</g>`
|
|
6587
8246
|
};
|
|
6588
8247
|
}
|
|
6589
|
-
function renderOrdinateDimension(entity, dimStyle) {
|
|
8248
|
+
function renderOrdinateDimension(entity, dimStyle, options, viewport) {
|
|
6590
8249
|
const bbox = new import_vecks3.Box2();
|
|
6591
8250
|
const elements = [];
|
|
6592
|
-
const textHeight = dimStyle
|
|
8251
|
+
const { textHeight } = getScaledDimensionSizes(dimStyle, options, viewport);
|
|
6593
8252
|
const { dimLineColor, textColor, dimLineWeight } = getDimensionColors(dimStyle);
|
|
6594
8253
|
const x1 = entity.measureStart?.x ?? 0;
|
|
6595
8254
|
const y1 = entity.measureStart?.y ?? 0;
|
|
@@ -6603,11 +8262,13 @@ var dxf = (() => {
|
|
|
6603
8262
|
elements.push(
|
|
6604
8263
|
`<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${dimLineColor}" stroke-width="${dimLineWeight}" />`
|
|
6605
8264
|
);
|
|
6606
|
-
|
|
8265
|
+
const resolvedText = resolveDimensionText(entity);
|
|
8266
|
+
if (resolvedText) {
|
|
6607
8267
|
const angle = Math.atan2(y2 - y1, x2 - x1);
|
|
6608
8268
|
const textRotation = angle * 180 / Math.PI;
|
|
8269
|
+
expandBBoxForText(bbox, textX, textY, textHeight, resolvedText);
|
|
6609
8270
|
elements.push(
|
|
6610
|
-
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${
|
|
8271
|
+
`<text x="${textX}" y="${textY}" font-size="${textHeight}" fill="${textColor}" text-anchor="middle" transform="rotate(${-textRotation} ${textX} ${textY}) scale(1,-1) translate(0 ${-2 * textY})">${escapeXmlText(resolvedText)}</text>`
|
|
6611
8272
|
);
|
|
6612
8273
|
}
|
|
6613
8274
|
return {
|
|
@@ -6622,9 +8283,10 @@ var dxf = (() => {
|
|
|
6622
8283
|
const textX = entity.textMidpoint.x ?? 0;
|
|
6623
8284
|
const textY = entity.textMidpoint.y ?? 0;
|
|
6624
8285
|
bbox.expandByPoint({ x: textX, y: textY });
|
|
6625
|
-
|
|
8286
|
+
const resolvedText = resolveDimensionText(entity);
|
|
8287
|
+
if (resolvedText) {
|
|
6626
8288
|
elements.push(
|
|
6627
|
-
`<text x="${textX}" y="${textY}" font-size="2.5" text-anchor="middle" transform="scale(1,-1) translate(0 ${-2 * textY})">${
|
|
8289
|
+
`<text x="${textX}" y="${textY}" font-size="2.5" text-anchor="middle" transform="scale(1,-1) translate(0 ${-2 * textY})">${escapeXmlText(resolvedText)}</text>`
|
|
6628
8290
|
);
|
|
6629
8291
|
}
|
|
6630
8292
|
}
|
|
@@ -6884,6 +8546,23 @@ var dxf = (() => {
|
|
|
6884
8546
|
entity.transforms ?? []
|
|
6885
8547
|
);
|
|
6886
8548
|
};
|
|
8549
|
+
var leader = (entity) => {
|
|
8550
|
+
if (!entity.vertices || entity.vertices.length < 2) return null;
|
|
8551
|
+
const bbox0 = entity.vertices.reduce(
|
|
8552
|
+
(acc, p) => acc.expandByPoint({ x: p.x, y: p.y }),
|
|
8553
|
+
new import_vecks5.Box2()
|
|
8554
|
+
);
|
|
8555
|
+
const d = entity.vertices.reduce((acc, p, i) => {
|
|
8556
|
+
acc += i === 0 ? "M" : "L";
|
|
8557
|
+
acc += p.x + "," + p.y;
|
|
8558
|
+
return acc;
|
|
8559
|
+
}, "");
|
|
8560
|
+
return transformBoundingBoxAndElement(
|
|
8561
|
+
bbox0,
|
|
8562
|
+
`<path d="${d}" />`,
|
|
8563
|
+
entity.transforms ?? []
|
|
8564
|
+
);
|
|
8565
|
+
};
|
|
6887
8566
|
var circle = (entity) => {
|
|
6888
8567
|
const bbox0 = new import_vecks5.Box2().expandByPoint({
|
|
6889
8568
|
x: entity.x + entity.r,
|
|
@@ -7023,7 +8702,7 @@ var dxf = (() => {
|
|
|
7023
8702
|
const textWidth = content.length * height * 0.6;
|
|
7024
8703
|
const bbox0 = new import_vecks5.Box2().expandByPoint({ x, y }).expandByPoint({ x: x + textWidth, y: y + height });
|
|
7025
8704
|
const rotationDegrees = rotation * 180 / Math.PI;
|
|
7026
|
-
const element0 = `<text x="${x}" y="${y}" font-size="${height}" transform="rotate(${-rotationDegrees} ${x} ${y}) scale(1,-1) translate(0 ${-2 * y})">${content}</text>`;
|
|
8705
|
+
const element0 = `<text x="${x}" y="${y}" font-size="${height}" transform="rotate(${-rotationDegrees} ${x} ${y}) scale(1,-1) translate(0 ${-2 * y})">${escapeXmlText(content)}</text>`;
|
|
7027
8706
|
const { bbox, element } = addFlipXIfApplicable(entity, {
|
|
7028
8707
|
bbox: bbox0,
|
|
7029
8708
|
element: element0
|
|
@@ -7039,15 +8718,47 @@ var dxf = (() => {
|
|
|
7039
8718
|
const bbox0 = new import_vecks5.Box2().expandByPoint({ x, y }).expandByPoint({ x: x + textWidth, y: y + height });
|
|
7040
8719
|
const rotation = entity.xAxisX !== void 0 && entity.xAxisY !== void 0 ? Math.atan2(entity.xAxisY, entity.xAxisX) : 0;
|
|
7041
8720
|
const rotationDegrees = rotation * 180 / Math.PI;
|
|
7042
|
-
const element0 = `<text x="${x}" y="${y}" font-size="${height}" transform="rotate(${-rotationDegrees} ${x} ${y}) scale(1,-1) translate(0 ${-2 * y})">${content}</text>`;
|
|
8721
|
+
const element0 = `<text x="${x}" y="${y}" font-size="${height}" transform="rotate(${-rotationDegrees} ${x} ${y}) scale(1,-1) translate(0 ${-2 * y})">${escapeXmlText(content)}</text>`;
|
|
8722
|
+
const { bbox, element } = addFlipXIfApplicable(entity, {
|
|
8723
|
+
bbox: bbox0,
|
|
8724
|
+
element: element0
|
|
8725
|
+
});
|
|
8726
|
+
return transformBoundingBoxAndElement(bbox, element, entity.transforms ?? []);
|
|
8727
|
+
};
|
|
8728
|
+
var tolerance = (entity) => {
|
|
8729
|
+
const x = entity.insertionPoint?.x ?? 0;
|
|
8730
|
+
const y = entity.insertionPoint?.y ?? 0;
|
|
8731
|
+
const height = 1;
|
|
8732
|
+
const content = entity.text ?? "";
|
|
8733
|
+
const rotation = entity.xAxisDirection ? Math.atan2(entity.xAxisDirection.y, entity.xAxisDirection.x) : 0;
|
|
8734
|
+
const rotationDegrees = rotation * 180 / Math.PI;
|
|
8735
|
+
const textWidth = content.length * height * 0.6;
|
|
8736
|
+
const bbox0 = new import_vecks5.Box2().expandByPoint({ x, y }).expandByPoint({ x: x + textWidth, y: y + height });
|
|
8737
|
+
const element0 = `<text x="${x}" y="${y}" font-size="${height}" transform="rotate(${-rotationDegrees} ${x} ${y}) scale(1,-1) translate(0 ${-2 * y})">${escapeXmlText(content)}</text>`;
|
|
8738
|
+
const { bbox, element } = addFlipXIfApplicable(entity, {
|
|
8739
|
+
bbox: bbox0,
|
|
8740
|
+
element: element0
|
|
8741
|
+
});
|
|
8742
|
+
return transformBoundingBoxAndElement(bbox, element, entity.transforms ?? []);
|
|
8743
|
+
};
|
|
8744
|
+
var shape = (entity) => {
|
|
8745
|
+
const x = entity.insertionPoint?.x ?? 0;
|
|
8746
|
+
const y = entity.insertionPoint?.y ?? 0;
|
|
8747
|
+
const height = entity.size ?? 1;
|
|
8748
|
+
const rotation = entity.rotation ?? 0;
|
|
8749
|
+
const content = entity.name ?? "";
|
|
8750
|
+
const textWidth = content.length * height * 0.6;
|
|
8751
|
+
const bbox0 = new import_vecks5.Box2().expandByPoint({ x, y }).expandByPoint({ x: x + textWidth, y: y + height });
|
|
8752
|
+
const rotationDegrees = rotation * 180 / Math.PI;
|
|
8753
|
+
const element0 = `<text x="${x}" y="${y}" font-size="${height}" transform="rotate(${-rotationDegrees} ${x} ${y}) scale(1,-1) translate(0 ${-2 * y})">${escapeXmlText(content)}</text>`;
|
|
7043
8754
|
const { bbox, element } = addFlipXIfApplicable(entity, {
|
|
7044
8755
|
bbox: bbox0,
|
|
7045
8756
|
element: element0
|
|
7046
8757
|
});
|
|
7047
8758
|
return transformBoundingBoxAndElement(bbox, element, entity.transforms ?? []);
|
|
7048
8759
|
};
|
|
7049
|
-
var dimension = (entity, dimStyle) => {
|
|
7050
|
-
const result = dimensionToSVG(entity, dimStyle);
|
|
8760
|
+
var dimension = (entity, dimStyle, options, viewport) => {
|
|
8761
|
+
const result = dimensionToSVG(entity, dimStyle, options, viewport);
|
|
7051
8762
|
return transformBoundingBoxAndElement(
|
|
7052
8763
|
result.bbox,
|
|
7053
8764
|
result.element,
|
|
@@ -7086,7 +8797,7 @@ var dxf = (() => {
|
|
|
7086
8797
|
const element = `<g>${paths.join("")}</g>`;
|
|
7087
8798
|
return transformBoundingBoxAndElement(bbox, element, entity.transforms ?? []);
|
|
7088
8799
|
};
|
|
7089
|
-
var entityToBoundsAndElement = (entity, dimStyles) => {
|
|
8800
|
+
var entityToBoundsAndElement = (entity, dimStyles, options, viewport) => {
|
|
7090
8801
|
switch (entity.type) {
|
|
7091
8802
|
case "CIRCLE":
|
|
7092
8803
|
return circle(entity);
|
|
@@ -7102,7 +8813,7 @@ var dxf = (() => {
|
|
|
7102
8813
|
const dimEntity = entity;
|
|
7103
8814
|
const styleName = typeof dimEntity.styleName === "string" ? dimEntity.styleName : void 0;
|
|
7104
8815
|
const dimStyle = styleName && dimStyles ? dimStyles[styleName] : void 0;
|
|
7105
|
-
return dimension(dimEntity, dimStyle);
|
|
8816
|
+
return dimension(dimEntity, dimStyle, options, viewport);
|
|
7106
8817
|
}
|
|
7107
8818
|
case "SPLINE": {
|
|
7108
8819
|
const splineEntity = entity;
|
|
@@ -7120,33 +8831,77 @@ var dxf = (() => {
|
|
|
7120
8831
|
}
|
|
7121
8832
|
}
|
|
7122
8833
|
case "LINE":
|
|
8834
|
+
case "RAY":
|
|
8835
|
+
case "XLINE":
|
|
7123
8836
|
case "POLYLINE": {
|
|
7124
8837
|
return polyline(entity);
|
|
7125
8838
|
}
|
|
8839
|
+
case "SOLID":
|
|
8840
|
+
case "TRACE": {
|
|
8841
|
+
return polyline(entity);
|
|
8842
|
+
}
|
|
7126
8843
|
case "LWPOLYLINE": {
|
|
7127
8844
|
return lwpolyline(entity);
|
|
7128
8845
|
}
|
|
8846
|
+
case "WIPEOUT": {
|
|
8847
|
+
return polyline(entity);
|
|
8848
|
+
}
|
|
8849
|
+
case "LEADER": {
|
|
8850
|
+
return leader(entity);
|
|
8851
|
+
}
|
|
8852
|
+
case "TOLERANCE": {
|
|
8853
|
+
return tolerance(entity);
|
|
8854
|
+
}
|
|
8855
|
+
case "SHAPE": {
|
|
8856
|
+
return shape(entity);
|
|
8857
|
+
}
|
|
7129
8858
|
default:
|
|
7130
8859
|
logger_default.warn("entity type not supported in SVG rendering:", entity.type);
|
|
7131
8860
|
return null;
|
|
7132
8861
|
}
|
|
7133
8862
|
};
|
|
7134
|
-
function toSVG(parsed) {
|
|
8863
|
+
function toSVG(parsed, options = {}) {
|
|
7135
8864
|
const entities = denormalise(parsed);
|
|
7136
8865
|
const dimStyles = parsed.tables.dimStyles;
|
|
8866
|
+
const geometryBBox = entities.reduce((acc, entity) => {
|
|
8867
|
+
if (entity.type === "DIMENSION") {
|
|
8868
|
+
const bbox2 = getDimensionGeometryBBox(entity);
|
|
8869
|
+
if (bbox2.valid) {
|
|
8870
|
+
acc.expandByPoint(bbox2.min);
|
|
8871
|
+
acc.expandByPoint(bbox2.max);
|
|
8872
|
+
}
|
|
8873
|
+
return acc;
|
|
8874
|
+
}
|
|
8875
|
+
const boundsAndElement = entityToBoundsAndElement(entity, dimStyles, options);
|
|
8876
|
+
if (boundsAndElement?.bbox.valid) {
|
|
8877
|
+
acc.expandByPoint(boundsAndElement.bbox.min);
|
|
8878
|
+
acc.expandByPoint(boundsAndElement.bbox.max);
|
|
8879
|
+
}
|
|
8880
|
+
return acc;
|
|
8881
|
+
}, new import_vecks5.Box2());
|
|
8882
|
+
const viewport = geometryBBox.valid ? {
|
|
8883
|
+
width: geometryBBox.max.x - geometryBBox.min.x,
|
|
8884
|
+
height: geometryBBox.max.y - geometryBBox.min.y
|
|
8885
|
+
} : {
|
|
8886
|
+
width: 0,
|
|
8887
|
+
height: 0
|
|
8888
|
+
};
|
|
7137
8889
|
const { bbox, elements } = entities.reduce(
|
|
7138
8890
|
(acc, entity) => {
|
|
7139
8891
|
const rgb = getRGBForEntity(parsed.tables.layers, entity);
|
|
7140
|
-
const boundsAndElement = entityToBoundsAndElement(entity, dimStyles);
|
|
8892
|
+
const boundsAndElement = entityToBoundsAndElement(entity, dimStyles, options, viewport);
|
|
7141
8893
|
if (boundsAndElement) {
|
|
7142
8894
|
const { bbox: bbox2, element } = boundsAndElement;
|
|
7143
8895
|
if (bbox2.valid) {
|
|
7144
8896
|
acc.bbox.expandByPoint(bbox2.min);
|
|
7145
8897
|
acc.bbox.expandByPoint(bbox2.max);
|
|
7146
8898
|
}
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
8899
|
+
const color = rgbToColorAttribute(rgb);
|
|
8900
|
+
if (entity.type === "SOLID" || entity.type === "TRACE") {
|
|
8901
|
+
acc.elements.push(`<g fill="${color}" stroke="none">${element}</g>`);
|
|
8902
|
+
} else {
|
|
8903
|
+
acc.elements.push(`<g stroke="${color}">${element}</g>`);
|
|
8904
|
+
}
|
|
7150
8905
|
}
|
|
7151
8906
|
return acc;
|
|
7152
8907
|
},
|
|
@@ -7223,8 +8978,11 @@ var dxf = (() => {
|
|
|
7223
8978
|
}
|
|
7224
8979
|
return this._groups;
|
|
7225
8980
|
}
|
|
7226
|
-
toSVG() {
|
|
7227
|
-
return toSVG(this.parsed);
|
|
8981
|
+
toSVG(options) {
|
|
8982
|
+
return toSVG(this.parsed, options);
|
|
8983
|
+
}
|
|
8984
|
+
toJson(options) {
|
|
8985
|
+
return toJson(this.parsed, options);
|
|
7228
8986
|
}
|
|
7229
8987
|
toPolylines() {
|
|
7230
8988
|
return toPolylines(this.parsed);
|