@linkiez/dxf-renew 5.3.1
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/.eslintignore +17 -0
- package/.eslintrc.json +61 -0
- package/.gitattributes +4 -0
- package/.github/instructions/project-en_US.instructions.md +352 -0
- package/.github/workflows/release.yml +110 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +1 -0
- package/.prettierignore +1 -0
- package/.prettierrc.json +6 -0
- package/.releaserc.json +76 -0
- package/.travis.yml +6 -0
- package/.yarn/install-state.gz +0 -0
- package/.yarnrc.yml +1 -0
- package/CHANGELOG.md +134 -0
- package/CONTRIBUTING.md +271 -0
- package/LICENSE +21 -0
- package/PLAN.md +517 -0
- package/README.md +306 -0
- package/build.mjs +66 -0
- package/commitlint.config.js +25 -0
- package/dist/dxf.js +7234 -0
- package/docs/CODE_PATTERNS.md +182 -0
- package/docs/DIMENSION_SUMMARY.md +248 -0
- package/docs/DIMENSION_SUMMARY.pt-BR.md +248 -0
- package/docs/IMPLEMENTED-2D-ENTITIES.md +54 -0
- package/docs/IMPLEMENTED-2D-ENTITIES.pt-BR.md +54 -0
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.md +241 -0
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.pt-BR.md +169 -0
- package/docs/autocad_2012_pdf_dxf-reference_enu.md +8272 -0
- package/examples/dxf.html +36 -0
- package/examples/example.es5.js +30 -0
- package/examples/example.es6.js +30 -0
- package/examples/text-dimension-viewer.html +133 -0
- package/lib/Helper.cjs +89 -0
- package/lib/Helper.cjs.map +7 -0
- package/lib/Helper.js +59 -0
- package/lib/Helper.js.map +7 -0
- package/lib/applyTransforms.cjs +59 -0
- package/lib/applyTransforms.cjs.map +7 -0
- package/lib/applyTransforms.js +39 -0
- package/lib/applyTransforms.js.map +7 -0
- package/lib/cli.cjs +53 -0
- package/lib/cli.cjs.map +7 -0
- package/lib/cli.js +29 -0
- package/lib/cli.js.map +7 -0
- package/lib/config.cjs +30 -0
- package/lib/config.cjs.map +7 -0
- package/lib/config.js +10 -0
- package/lib/config.js.map +7 -0
- package/lib/constants.cjs +39 -0
- package/lib/constants.cjs.map +7 -0
- package/lib/constants.js +15 -0
- package/lib/constants.js.map +7 -0
- package/lib/denormalise.cjs +148 -0
- package/lib/denormalise.cjs.map +7 -0
- package/lib/denormalise.js +118 -0
- package/lib/denormalise.js.map +7 -0
- package/lib/dimensionToSVG.cjs +307 -0
- package/lib/dimensionToSVG.cjs.map +7 -0
- package/lib/dimensionToSVG.js +273 -0
- package/lib/dimensionToSVG.js.map +7 -0
- package/lib/entityToPolyline.cjs +248 -0
- package/lib/entityToPolyline.cjs.map +7 -0
- package/lib/entityToPolyline.js +213 -0
- package/lib/entityToPolyline.js.map +7 -0
- package/lib/getRGBForEntity.cjs +53 -0
- package/lib/getRGBForEntity.cjs.map +7 -0
- package/lib/getRGBForEntity.js +23 -0
- package/lib/getRGBForEntity.js.map +7 -0
- package/lib/groupEntitiesByLayer.cjs +34 -0
- package/lib/groupEntitiesByLayer.cjs.map +7 -0
- package/lib/groupEntitiesByLayer.js +14 -0
- package/lib/groupEntitiesByLayer.js.map +7 -0
- package/lib/handlers/blocks.cjs +93 -0
- package/lib/handlers/blocks.cjs.map +7 -0
- package/lib/handlers/blocks.js +63 -0
- package/lib/handlers/blocks.js.map +7 -0
- package/lib/handlers/entities.cjs +118 -0
- package/lib/handlers/entities.cjs.map +7 -0
- package/lib/handlers/entities.js +88 -0
- package/lib/handlers/entities.js.map +7 -0
- package/lib/handlers/entity/arc.cjs +82 -0
- package/lib/handlers/entity/arc.cjs.map +7 -0
- package/lib/handlers/entity/arc.js +47 -0
- package/lib/handlers/entity/arc.js.map +7 -0
- package/lib/handlers/entity/attdef.cjs +318 -0
- package/lib/handlers/entity/attdef.cjs.map +7 -0
- package/lib/handlers/entity/attdef.js +282 -0
- package/lib/handlers/entity/attdef.js.map +7 -0
- package/lib/handlers/entity/attrib.cjs +52 -0
- package/lib/handlers/entity/attrib.cjs.map +7 -0
- package/lib/handlers/entity/attrib.js +27 -0
- package/lib/handlers/entity/attrib.js.map +7 -0
- package/lib/handlers/entity/circle.cjs +73 -0
- package/lib/handlers/entity/circle.cjs.map +7 -0
- package/lib/handlers/entity/circle.js +38 -0
- package/lib/handlers/entity/circle.js.map +7 -0
- package/lib/handlers/entity/common.cjs +83 -0
- package/lib/handlers/entity/common.cjs.map +7 -0
- package/lib/handlers/entity/common.js +63 -0
- package/lib/handlers/entity/common.js.map +7 -0
- package/lib/handlers/entity/dimension.cjs +203 -0
- package/lib/handlers/entity/dimension.cjs.map +7 -0
- package/lib/handlers/entity/dimension.js +168 -0
- package/lib/handlers/entity/dimension.js.map +7 -0
- package/lib/handlers/entity/ellipse.cjs +88 -0
- package/lib/handlers/entity/ellipse.cjs.map +7 -0
- package/lib/handlers/entity/ellipse.js +53 -0
- package/lib/handlers/entity/ellipse.js.map +7 -0
- package/lib/handlers/entity/hatch.cjs +470 -0
- package/lib/handlers/entity/hatch.cjs.map +7 -0
- package/lib/handlers/entity/hatch.js +435 -0
- package/lib/handlers/entity/hatch.js.map +7 -0
- package/lib/handlers/entity/insert.cjs +106 -0
- package/lib/handlers/entity/insert.cjs.map +7 -0
- package/lib/handlers/entity/insert.js +71 -0
- package/lib/handlers/entity/insert.js.map +7 -0
- package/lib/handlers/entity/line.cjs +84 -0
- package/lib/handlers/entity/line.cjs.map +7 -0
- package/lib/handlers/entity/line.js +49 -0
- package/lib/handlers/entity/line.js.map +7 -0
- package/lib/handlers/entity/lwpolyline.cjs +82 -0
- package/lib/handlers/entity/lwpolyline.cjs.map +7 -0
- package/lib/handlers/entity/lwpolyline.js +47 -0
- package/lib/handlers/entity/lwpolyline.js.map +7 -0
- package/lib/handlers/entity/mtext.cjs +121 -0
- package/lib/handlers/entity/mtext.cjs.map +7 -0
- package/lib/handlers/entity/mtext.js +85 -0
- package/lib/handlers/entity/mtext.js.map +7 -0
- package/lib/handlers/entity/ole2Frame.cjs +98 -0
- package/lib/handlers/entity/ole2Frame.cjs.map +7 -0
- package/lib/handlers/entity/ole2Frame.js +63 -0
- package/lib/handlers/entity/ole2Frame.js.map +7 -0
- package/lib/handlers/entity/point.cjs +73 -0
- package/lib/handlers/entity/point.cjs.map +7 -0
- package/lib/handlers/entity/point.js +38 -0
- package/lib/handlers/entity/point.js.map +7 -0
- package/lib/handlers/entity/polyline.cjs +70 -0
- package/lib/handlers/entity/polyline.cjs.map +7 -0
- package/lib/handlers/entity/polyline.js +35 -0
- package/lib/handlers/entity/polyline.js.map +7 -0
- package/lib/handlers/entity/solid.cjs +101 -0
- package/lib/handlers/entity/solid.cjs.map +7 -0
- package/lib/handlers/entity/solid.js +66 -0
- package/lib/handlers/entity/solid.js.map +7 -0
- package/lib/handlers/entity/spline.cjs +109 -0
- package/lib/handlers/entity/spline.cjs.map +7 -0
- package/lib/handlers/entity/spline.js +74 -0
- package/lib/handlers/entity/spline.js.map +7 -0
- package/lib/handlers/entity/text.cjs +85 -0
- package/lib/handlers/entity/text.cjs.map +7 -0
- package/lib/handlers/entity/text.js +49 -0
- package/lib/handlers/entity/text.js.map +7 -0
- package/lib/handlers/entity/threeDFace.cjs +98 -0
- package/lib/handlers/entity/threeDFace.cjs.map +7 -0
- package/lib/handlers/entity/threeDFace.js +63 -0
- package/lib/handlers/entity/threeDFace.js.map +7 -0
- package/lib/handlers/entity/vertex.cjs +78 -0
- package/lib/handlers/entity/vertex.cjs.map +7 -0
- package/lib/handlers/entity/vertex.js +53 -0
- package/lib/handlers/entity/vertex.js.map +7 -0
- package/lib/handlers/entity/viewport.cjs +153 -0
- package/lib/handlers/entity/viewport.cjs.map +7 -0
- package/lib/handlers/entity/viewport.js +118 -0
- package/lib/handlers/entity/viewport.js.map +7 -0
- package/lib/handlers/header.cjs +92 -0
- package/lib/handlers/header.cjs.map +7 -0
- package/lib/handlers/header.js +72 -0
- package/lib/handlers/header.js.map +7 -0
- package/lib/handlers/objects.cjs +170 -0
- package/lib/handlers/objects.cjs.map +7 -0
- package/lib/handlers/objects.js +150 -0
- package/lib/handlers/objects.js.map +7 -0
- package/lib/handlers/tables.cjs +587 -0
- package/lib/handlers/tables.cjs.map +7 -0
- package/lib/handlers/tables.js +557 -0
- package/lib/handlers/tables.js.map +7 -0
- package/lib/index.cjs +60 -0
- package/lib/index.cjs.map +7 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +7 -0
- package/lib/parseString.cjs +118 -0
- package/lib/parseString.cjs.map +7 -0
- package/lib/parseString.js +88 -0
- package/lib/parseString.js.map +7 -0
- package/lib/toPolylines.cjs +69 -0
- package/lib/toPolylines.cjs.map +7 -0
- package/lib/toPolylines.js +39 -0
- package/lib/toPolylines.js.map +7 -0
- package/lib/toSVG.cjs +395 -0
- package/lib/toSVG.cjs.map +7 -0
- package/lib/toSVG.js +361 -0
- package/lib/toSVG.js.map +7 -0
- package/lib/types/arc-entity.cjs +17 -0
- package/lib/types/arc-entity.cjs.map +7 -0
- package/lib/types/arc-entity.js +1 -0
- package/lib/types/arc-entity.js.map +7 -0
- package/lib/types/base-entity.cjs +17 -0
- package/lib/types/base-entity.cjs.map +7 -0
- package/lib/types/base-entity.js +1 -0
- package/lib/types/base-entity.js.map +7 -0
- package/lib/types/circle-entity.cjs +17 -0
- package/lib/types/circle-entity.cjs.map +7 -0
- package/lib/types/circle-entity.js +1 -0
- package/lib/types/circle-entity.js.map +7 -0
- package/lib/types/common.cjs +17 -0
- package/lib/types/common.cjs.map +7 -0
- package/lib/types/common.js +1 -0
- package/lib/types/common.js.map +7 -0
- package/lib/types/dimension-entity.cjs +17 -0
- package/lib/types/dimension-entity.cjs.map +7 -0
- package/lib/types/dimension-entity.js +1 -0
- package/lib/types/dimension-entity.js.map +7 -0
- package/lib/types/dxf.cjs +17 -0
- package/lib/types/dxf.cjs.map +7 -0
- package/lib/types/dxf.js +1 -0
- package/lib/types/dxf.js.map +7 -0
- package/lib/types/ellipse-entity.cjs +17 -0
- package/lib/types/ellipse-entity.cjs.map +7 -0
- package/lib/types/ellipse-entity.js +1 -0
- package/lib/types/ellipse-entity.js.map +7 -0
- package/lib/types/entity.cjs +17 -0
- package/lib/types/entity.cjs.map +7 -0
- package/lib/types/entity.js +1 -0
- package/lib/types/entity.js.map +7 -0
- package/lib/types/handler-internal.cjs +17 -0
- package/lib/types/handler-internal.cjs.map +7 -0
- package/lib/types/handler-internal.js +1 -0
- package/lib/types/handler-internal.js.map +7 -0
- package/lib/types/handler.cjs +17 -0
- package/lib/types/handler.cjs.map +7 -0
- package/lib/types/handler.js +1 -0
- package/lib/types/handler.js.map +7 -0
- package/lib/types/hatch-entity.cjs +17 -0
- package/lib/types/hatch-entity.cjs.map +7 -0
- package/lib/types/hatch-entity.js +1 -0
- package/lib/types/hatch-entity.js.map +7 -0
- package/lib/types/helper.cjs +17 -0
- package/lib/types/helper.cjs.map +7 -0
- package/lib/types/helper.js +1 -0
- package/lib/types/helper.js.map +7 -0
- package/lib/types/index.cjs +77 -0
- package/lib/types/index.cjs.map +7 -0
- package/lib/types/index.js +29 -0
- package/lib/types/index.js.map +7 -0
- package/lib/types/insert-entity.cjs +17 -0
- package/lib/types/insert-entity.cjs.map +7 -0
- package/lib/types/insert-entity.js +1 -0
- package/lib/types/insert-entity.js.map +7 -0
- package/lib/types/layer-groups.cjs +17 -0
- package/lib/types/layer-groups.cjs.map +7 -0
- package/lib/types/layer-groups.js +1 -0
- package/lib/types/layer-groups.js.map +7 -0
- package/lib/types/line-entity.cjs +17 -0
- package/lib/types/line-entity.cjs.map +7 -0
- package/lib/types/line-entity.js +1 -0
- package/lib/types/line-entity.js.map +7 -0
- package/lib/types/mtext-entity.cjs +17 -0
- package/lib/types/mtext-entity.cjs.map +7 -0
- package/lib/types/mtext-entity.js +1 -0
- package/lib/types/mtext-entity.js.map +7 -0
- package/lib/types/ole2frame-entity.cjs +17 -0
- package/lib/types/ole2frame-entity.cjs.map +7 -0
- package/lib/types/ole2frame-entity.js +1 -0
- package/lib/types/ole2frame-entity.js.map +7 -0
- package/lib/types/options.cjs +17 -0
- package/lib/types/options.cjs.map +7 -0
- package/lib/types/options.js +1 -0
- package/lib/types/options.js.map +7 -0
- package/lib/types/point-entity.cjs +17 -0
- package/lib/types/point-entity.cjs.map +7 -0
- package/lib/types/point-entity.js +1 -0
- package/lib/types/point-entity.js.map +7 -0
- package/lib/types/polyline-entity.cjs +17 -0
- package/lib/types/polyline-entity.cjs.map +7 -0
- package/lib/types/polyline-entity.js +1 -0
- package/lib/types/polyline-entity.js.map +7 -0
- package/lib/types/polylines.cjs +17 -0
- package/lib/types/polylines.cjs.map +7 -0
- package/lib/types/polylines.js +1 -0
- package/lib/types/polylines.js.map +7 -0
- package/lib/types/solid-entity.cjs +17 -0
- package/lib/types/solid-entity.cjs.map +7 -0
- package/lib/types/solid-entity.js +1 -0
- package/lib/types/solid-entity.js.map +7 -0
- package/lib/types/spline-entity.cjs +17 -0
- package/lib/types/spline-entity.cjs.map +7 -0
- package/lib/types/spline-entity.js +1 -0
- package/lib/types/spline-entity.js.map +7 -0
- package/lib/types/svg.cjs +17 -0
- package/lib/types/svg.cjs.map +7 -0
- package/lib/types/svg.js +1 -0
- package/lib/types/svg.js.map +7 -0
- package/lib/types/tables.cjs +17 -0
- package/lib/types/tables.cjs.map +7 -0
- package/lib/types/tables.js +1 -0
- package/lib/types/tables.js.map +7 -0
- package/lib/types/text-entity.cjs +17 -0
- package/lib/types/text-entity.cjs.map +7 -0
- package/lib/types/text-entity.js +1 -0
- package/lib/types/text-entity.js.map +7 -0
- package/lib/types/util-types.cjs +17 -0
- package/lib/types/util-types.cjs.map +7 -0
- package/lib/types/util-types.js +1 -0
- package/lib/types/util-types.js.map +7 -0
- package/lib/types/vecks.d.cjs +2 -0
- package/lib/types/vecks.d.cjs.map +7 -0
- package/lib/types/vecks.d.js +1 -0
- package/lib/types/vecks.d.js.map +7 -0
- package/lib/types/viewport-entity.cjs +17 -0
- package/lib/types/viewport-entity.cjs.map +7 -0
- package/lib/types/viewport-entity.js +1 -0
- package/lib/types/viewport-entity.js.map +7 -0
- package/lib/types.cjs +23 -0
- package/lib/types.cjs.map +7 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +7 -0
- package/lib/util/bSpline.cjs +95 -0
- package/lib/util/bSpline.cjs.map +7 -0
- package/lib/util/bSpline.js +65 -0
- package/lib/util/bSpline.js.map +7 -0
- package/lib/util/colors.cjs +283 -0
- package/lib/util/colors.cjs.map +7 -0
- package/lib/util/colors.js +263 -0
- package/lib/util/colors.js.map +7 -0
- package/lib/util/createArcForLWPolyline.cjs +84 -0
- package/lib/util/createArcForLWPolyline.cjs.map +7 -0
- package/lib/util/createArcForLWPolyline.js +64 -0
- package/lib/util/createArcForLWPolyline.js.map +7 -0
- package/lib/util/dxfColorToRGB.cjs +115 -0
- package/lib/util/dxfColorToRGB.cjs.map +7 -0
- package/lib/util/dxfColorToRGB.js +90 -0
- package/lib/util/dxfColorToRGB.js.map +7 -0
- package/lib/util/insertKnot.cjs +77 -0
- package/lib/util/insertKnot.cjs.map +7 -0
- package/lib/util/insertKnot.js +57 -0
- package/lib/util/insertKnot.js.map +7 -0
- package/lib/util/logger.cjs +53 -0
- package/lib/util/logger.cjs.map +7 -0
- package/lib/util/logger.js +23 -0
- package/lib/util/logger.js.map +7 -0
- package/lib/util/rgbToColorAttribute.cjs +32 -0
- package/lib/util/rgbToColorAttribute.cjs.map +7 -0
- package/lib/util/rgbToColorAttribute.js +12 -0
- package/lib/util/rgbToColorAttribute.js.map +7 -0
- package/lib/util/rotate.cjs +30 -0
- package/lib/util/rotate.cjs.map +7 -0
- package/lib/util/rotate.js +10 -0
- package/lib/util/rotate.js.map +7 -0
- package/lib/util/round10.cjs +38 -0
- package/lib/util/round10.cjs.map +7 -0
- package/lib/util/round10.js +18 -0
- package/lib/util/round10.js.map +7 -0
- package/lib/util/toPiecewiseBezier.cjs +90 -0
- package/lib/util/toPiecewiseBezier.cjs.map +7 -0
- package/lib/util/toPiecewiseBezier.js +54 -0
- package/lib/util/toPiecewiseBezier.js.map +7 -0
- package/lib/util/transformBoundingBoxAndElement.cjs +80 -0
- package/lib/util/transformBoundingBoxAndElement.cjs.map +7 -0
- package/lib/util/transformBoundingBoxAndElement.js +60 -0
- package/lib/util/transformBoundingBoxAndElement.js.map +7 -0
- package/package.json +127 -0
- package/src/Helper.ts +71 -0
- package/src/applyTransforms.ts +54 -0
- package/src/cli.ts +41 -0
- package/src/config.ts +10 -0
- package/src/constants.ts +14 -0
- package/src/denormalise.ts +153 -0
- package/src/dimensionToSVG.ts +427 -0
- package/src/entityToPolyline.ts +338 -0
- package/src/getRGBForEntity.ts +28 -0
- package/src/groupEntitiesByLayer.ts +14 -0
- package/src/handlers/blocks.ts +65 -0
- package/src/handlers/entities.ts +111 -0
- package/src/handlers/entity/arc.ts +61 -0
- package/src/handlers/entity/attdef.ts +284 -0
- package/src/handlers/entity/attrib.ts +29 -0
- package/src/handlers/entity/circle.ts +47 -0
- package/src/handlers/entity/common.ts +79 -0
- package/src/handlers/entity/dimension.ts +217 -0
- package/src/handlers/entity/ellipse.ts +55 -0
- package/src/handlers/entity/hatch.ts +471 -0
- package/src/handlers/entity/insert.ts +73 -0
- package/src/handlers/entity/line.ts +56 -0
- package/src/handlers/entity/lwpolyline.ts +54 -0
- package/src/handlers/entity/mtext.ts +150 -0
- package/src/handlers/entity/ole2Frame.ts +64 -0
- package/src/handlers/entity/point.ts +47 -0
- package/src/handlers/entity/polyline.ts +49 -0
- package/src/handlers/entity/solid.ts +73 -0
- package/src/handlers/entity/spline.ts +103 -0
- package/src/handlers/entity/text.ts +83 -0
- package/src/handlers/entity/threeDFace.ts +69 -0
- package/src/handlers/entity/vertex.ts +55 -0
- package/src/handlers/entity/viewport.ts +119 -0
- package/src/handlers/header.ts +73 -0
- package/src/handlers/objects.ts +152 -0
- package/src/handlers/tables.ts +581 -0
- package/src/index.ts +19 -0
- package/src/parseString.ts +97 -0
- package/src/toPolylines.ts +47 -0
- package/src/toSVG.ts +518 -0
- package/src/types/README.md +91 -0
- package/src/types/arc-entity.ts +10 -0
- package/src/types/base-entity.ts +25 -0
- package/src/types/circle-entity.ts +8 -0
- package/src/types/common.ts +37 -0
- package/src/types/dimension-entity.ts +23 -0
- package/src/types/dxf.ts +64 -0
- package/src/types/ellipse-entity.ts +13 -0
- package/src/types/entity.ts +32 -0
- package/src/types/handler-internal.ts +51 -0
- package/src/types/handler.ts +10 -0
- package/src/types/hatch-entity.ts +127 -0
- package/src/types/helper.ts +12 -0
- package/src/types/index.ts +53 -0
- package/src/types/insert-entity.ts +19 -0
- package/src/types/layer-groups.ts +8 -0
- package/src/types/line-entity.ts +10 -0
- package/src/types/mtext-entity.ts +35 -0
- package/src/types/ole2frame-entity.ts +35 -0
- package/src/types/options.ts +17 -0
- package/src/types/point-entity.ts +7 -0
- package/src/types/polyline-entity.ts +20 -0
- package/src/types/polylines.ts +22 -0
- package/src/types/solid-entity.ts +9 -0
- package/src/types/spline-entity.ts +12 -0
- package/src/types/svg.ts +31 -0
- package/src/types/tables.ts +414 -0
- package/src/types/text-entity.ts +23 -0
- package/src/types/util-types.ts +27 -0
- package/src/types/vecks.d.ts +29 -0
- package/src/types/viewport-entity.ts +81 -0
- package/src/types.ts +5 -0
- package/src/util/bSpline.ts +97 -0
- package/src/util/colors.ts +266 -0
- package/src/util/createArcForLWPolyline.ts +93 -0
- package/src/util/diagram.png +0 -0
- package/src/util/dxfColorToRGB.ts +106 -0
- package/src/util/insertKnot.ts +69 -0
- package/src/util/logger.ts +23 -0
- package/src/util/rgbToColorAttribute.ts +14 -0
- package/src/util/rotate.ts +14 -0
- package/src/util/round10.ts +24 -0
- package/src/util/toPiecewiseBezier.ts +70 -0
- package/src/util/transformBoundingBoxAndElement.ts +74 -0
- package/tsconfig.json +34 -0
package/lib/config.cjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var config_exports = {};
|
|
20
|
+
__export(config_exports, {
|
|
21
|
+
default: () => config_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(config_exports);
|
|
24
|
+
const config = {
|
|
25
|
+
verbose: false,
|
|
26
|
+
interpolationsPerSplineSegment: 100,
|
|
27
|
+
layers: []
|
|
28
|
+
};
|
|
29
|
+
var config_default = config;
|
|
30
|
+
//# sourceMappingURL=config.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/config.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Config } from './types'\n\nconst config: Config = {\n verbose: false,\n interpolationsPerSplineSegment: 100,\n layers: [],\n}\n\nexport default config\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,MAAM,SAAiB;AAAA,EACrB,SAAS;AAAA,EACT,gCAAgC;AAAA,EAChC,QAAQ,CAAC;AACX;AAEA,IAAO,iBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/config.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Config } from './types'\n\nconst config: Config = {\n verbose: false,\n interpolationsPerSplineSegment: 100,\n layers: [],\n}\n\nexport default config\n\n"],
|
|
5
|
+
"mappings": "AAEA,MAAM,SAAiB;AAAA,EACrB,SAAS;AAAA,EACT,gCAAgC;AAAA,EAChC,QAAQ,CAAC;AACX;AAEA,IAAO,iBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
ZERO_TRANSFORM: () => ZERO_TRANSFORM
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(constants_exports);
|
|
24
|
+
const ZERO_TRANSFORM = {
|
|
25
|
+
x: 0,
|
|
26
|
+
y: 0,
|
|
27
|
+
scaleX: 1,
|
|
28
|
+
scaleY: 1,
|
|
29
|
+
scaleZ: 1,
|
|
30
|
+
rotation: 0,
|
|
31
|
+
extrusionX: 0,
|
|
32
|
+
extrusionY: 0,
|
|
33
|
+
extrusionZ: 1
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
ZERO_TRANSFORM
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/constants.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ZeroTransform } from './types'\n\nexport const ZERO_TRANSFORM: ZeroTransform = {\n x: 0,\n y: 0,\n scaleX: 1,\n scaleY: 1,\n scaleZ: 1,\n rotation: 0,\n extrusionX: 0,\n extrusionY: 0,\n extrusionZ: 1,\n}\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,iBAAgC;AAAA,EAC3C,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/constants.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ZeroTransform } from './types'\n\nexport const ZERO_TRANSFORM: ZeroTransform = {\n x: 0,\n y: 0,\n scaleX: 1,\n scaleY: 1,\n scaleZ: 1,\n rotation: 0,\n extrusionX: 0,\n extrusionY: 0,\n extrusionZ: 1,\n}\n\n"],
|
|
5
|
+
"mappings": "AAEO,MAAM,iBAAgC;AAAA,EAC3C,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var denormalise_exports = {};
|
|
30
|
+
__export(denormalise_exports, {
|
|
31
|
+
default: () => denormalise
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(denormalise_exports);
|
|
34
|
+
var import_cloneDeep = __toESM(require("lodash/cloneDeep"), 1);
|
|
35
|
+
var import_logger = __toESM(require("./util/logger"), 1);
|
|
36
|
+
function denormalise(parseResult) {
|
|
37
|
+
const blocksByName = parseResult.blocks.reduce(
|
|
38
|
+
(acc, b) => {
|
|
39
|
+
acc[b.name] = b;
|
|
40
|
+
return acc;
|
|
41
|
+
},
|
|
42
|
+
{}
|
|
43
|
+
);
|
|
44
|
+
const gatherEntities = (entities, transforms) => {
|
|
45
|
+
let current = [];
|
|
46
|
+
for (const e of entities) {
|
|
47
|
+
if (e.type === "INSERT") {
|
|
48
|
+
const insert = e;
|
|
49
|
+
const block = blocksByName[insert.block];
|
|
50
|
+
if (!block) {
|
|
51
|
+
import_logger.default.error("no block found for insert. block:", insert.block);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const rowCount = insert.rowCount ?? 1;
|
|
55
|
+
const columnCount = insert.columnCount ?? 1;
|
|
56
|
+
const rowSpacing = insert.rowSpacing ?? 0;
|
|
57
|
+
const columnSpacing = insert.columnSpacing ?? 0;
|
|
58
|
+
const rotation = insert.rotation ?? 0;
|
|
59
|
+
let rowVec;
|
|
60
|
+
let colVec;
|
|
61
|
+
if (rowCount > 1 || columnCount > 1) {
|
|
62
|
+
const cos = Math.cos(rotation * Math.PI / 180);
|
|
63
|
+
const sin = Math.sin(rotation * Math.PI / 180);
|
|
64
|
+
rowVec = { x: -sin * rowSpacing, y: cos * rowSpacing };
|
|
65
|
+
colVec = { x: cos * columnSpacing, y: sin * columnSpacing };
|
|
66
|
+
} else {
|
|
67
|
+
rowVec = { x: 0, y: 0 };
|
|
68
|
+
colVec = { x: 0, y: 0 };
|
|
69
|
+
}
|
|
70
|
+
for (let r = 0; r < rowCount; r++) {
|
|
71
|
+
for (let c = 0; c < columnCount; c++) {
|
|
72
|
+
const t = {
|
|
73
|
+
x: insert.x + rowVec.x * r + colVec.x * c,
|
|
74
|
+
y: insert.y + rowVec.y * r + colVec.y * c,
|
|
75
|
+
scaleX: insert.scaleX,
|
|
76
|
+
scaleY: insert.scaleY,
|
|
77
|
+
scaleZ: insert.scaleZ,
|
|
78
|
+
extrusionX: insert.extrusionX,
|
|
79
|
+
extrusionY: insert.extrusionY,
|
|
80
|
+
extrusionZ: insert.extrusionZ,
|
|
81
|
+
rotation: insert.rotation
|
|
82
|
+
};
|
|
83
|
+
const transforms2 = transforms.slice(0);
|
|
84
|
+
transforms2.push(t);
|
|
85
|
+
const blockEntities = block.entities.map((be) => {
|
|
86
|
+
const be2 = (0, import_cloneDeep.default)(be);
|
|
87
|
+
be2.layer = insert.layer;
|
|
88
|
+
switch (be2.type) {
|
|
89
|
+
case "LINE": {
|
|
90
|
+
const line = be2;
|
|
91
|
+
line.start.x -= block.x;
|
|
92
|
+
line.start.y -= block.y;
|
|
93
|
+
line.end.x -= block.x;
|
|
94
|
+
line.end.y -= block.y;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case "LWPOLYLINE":
|
|
98
|
+
case "POLYLINE": {
|
|
99
|
+
const poly = be2;
|
|
100
|
+
for (const v of poly.vertices) {
|
|
101
|
+
if (v.x !== void 0) v.x -= block.x;
|
|
102
|
+
if (v.y !== void 0) v.y -= block.y;
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "CIRCLE": {
|
|
107
|
+
const circle = be2;
|
|
108
|
+
circle.x -= block.x;
|
|
109
|
+
circle.y -= block.y;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case "ELLIPSE": {
|
|
113
|
+
const ellipse = be2;
|
|
114
|
+
ellipse.x -= block.x;
|
|
115
|
+
ellipse.y -= block.y;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "ARC": {
|
|
119
|
+
const arc = be2;
|
|
120
|
+
arc.x -= block.x;
|
|
121
|
+
arc.y -= block.y;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case "SPLINE": {
|
|
125
|
+
const spline = be2;
|
|
126
|
+
for (const cp of spline.controlPoints) {
|
|
127
|
+
cp.x -= block.x;
|
|
128
|
+
cp.y -= block.y;
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return be2;
|
|
134
|
+
});
|
|
135
|
+
current = current.concat(gatherEntities(blockEntities, transforms2));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
const e2 = (0, import_cloneDeep.default)(e);
|
|
140
|
+
e2.transforms = transforms.slice().reverse();
|
|
141
|
+
current.push(e2);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return current;
|
|
145
|
+
};
|
|
146
|
+
return gatherEntities(parseResult.entities, []);
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=denormalise.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/denormalise.ts"],
|
|
4
|
+
"sourcesContent": ["import cloneDeep from 'lodash/cloneDeep'\n\nimport logger from './util/logger'\n\nimport type {\n ArcEntity,\n Block,\n CircleEntity,\n EllipseEntity,\n Entity,\n InsertEntity,\n LineEntity,\n ParsedDXF,\n PolylineEntity,\n SplineEntity,\n Transform,\n} from './types'\n\nexport default function denormalise(parseResult: ParsedDXF): Entity[] {\n const blocksByName = parseResult.blocks.reduce(\n (acc: { [name: string]: Block }, b: Block) => {\n acc[b.name] = b\n return acc\n },\n {},\n )\n\n const gatherEntities = (\n entities: Entity[],\n transforms: Transform[],\n ): Entity[] => {\n let current: Entity[] = []\n for (const e of entities) {\n if (e.type === 'INSERT') {\n const insert = e as InsertEntity\n const block = blocksByName[insert.block]\n if (!block) {\n logger.error('no block found for insert. block:', insert.block)\n continue\n }\n\n const rowCount = insert.rowCount ?? 1\n const columnCount = insert.columnCount ?? 1\n const rowSpacing = insert.rowSpacing ?? 0\n const columnSpacing = insert.columnSpacing ?? 0\n const rotation = insert.rotation ?? 0\n\n // It appears that the rectangular array is affected by rotation, but NOT by scale.\n let rowVec: { x: number; y: number }\n let colVec: { x: number; y: number }\n if (rowCount > 1 || columnCount > 1) {\n const cos = Math.cos((rotation * Math.PI) / 180)\n const sin = Math.sin((rotation * Math.PI) / 180)\n rowVec = { x: -sin * rowSpacing, y: cos * rowSpacing }\n colVec = { x: cos * columnSpacing, y: sin * columnSpacing }\n } else {\n rowVec = { x: 0, y: 0 }\n colVec = { x: 0, y: 0 }\n }\n\n // For rectangular arrays, add the block entities for each location in the array\n for (let r = 0; r < rowCount; r++) {\n for (let c = 0; c < columnCount; c++) {\n // Adjust insert transform by row and column for rectangular arrays\n const t: Transform = {\n x: insert.x + rowVec.x * r + colVec.x * c,\n y: insert.y + rowVec.y * r + colVec.y * c,\n scaleX: insert.scaleX,\n scaleY: insert.scaleY,\n scaleZ: insert.scaleZ,\n extrusionX: insert.extrusionX,\n extrusionY: insert.extrusionY,\n extrusionZ: insert.extrusionZ,\n rotation: insert.rotation,\n }\n // Add the insert transform and recursively add entities\n const transforms2 = transforms.slice(0)\n transforms2.push(t)\n\n // Use the insert layer\n const blockEntities = block.entities.map((be: Entity) => {\n const be2 = cloneDeep(be)\n be2.layer = insert.layer\n // https://github.com/bjnortier/dxf/issues/52\n // See Issue 52. If we don't modify the\n // entity coordinates here it creates an issue with the\n // transformation matrices (which are only applied AFTER\n // block insertion modifications has been applied).\n switch (be2.type) {\n case 'LINE': {\n const line = be2 as LineEntity\n line.start.x -= block.x\n line.start.y -= block.y\n line.end.x -= block.x\n line.end.y -= block.y\n break\n }\n case 'LWPOLYLINE':\n case 'POLYLINE': {\n const poly = be2 as PolylineEntity\n for (const v of poly.vertices) {\n if (v.x !== undefined) v.x -= block.x\n if (v.y !== undefined) v.y -= block.y\n }\n break\n }\n case 'CIRCLE': {\n const circle = be2 as CircleEntity\n circle.x -= block.x\n circle.y -= block.y\n break\n }\n case 'ELLIPSE': {\n const ellipse = be2 as EllipseEntity\n ellipse.x -= block.x\n ellipse.y -= block.y\n break\n }\n case 'ARC': {\n const arc = be2 as ArcEntity\n arc.x -= block.x\n arc.y -= block.y\n break\n }\n case 'SPLINE': {\n const spline = be2 as SplineEntity\n for (const cp of spline.controlPoints) {\n cp.x -= block.x\n cp.y -= block.y\n }\n break\n }\n }\n return be2\n })\n current = current.concat(gatherEntities(blockEntities, transforms2))\n }\n }\n } else {\n // Top-level entity. Clone and add the transforms\n // The transforms are reversed so they occur in\n // order of application - i.e. the transform of the\n // top-level insert is applied last\n const e2 = cloneDeep(e)\n e2.transforms = transforms.slice().reverse()\n current.push(e2)\n }\n }\n return current\n }\n\n return gatherEntities(parseResult.entities, [])\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AAEtB,oBAAmB;AAgBJ,SAAR,YAA6B,aAAkC;AACpE,QAAM,eAAe,YAAY,OAAO;AAAA,IACtC,CAAC,KAAgC,MAAa;AAC5C,UAAI,EAAE,IAAI,IAAI;AACd,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,iBAAiB,CACrB,UACA,eACa;AACb,QAAI,UAAoB,CAAC;AACzB,eAAW,KAAK,UAAU;AACxB,UAAI,EAAE,SAAS,UAAU;AACvB,cAAM,SAAS;AACf,cAAM,QAAQ,aAAa,OAAO,KAAK;AACvC,YAAI,CAAC,OAAO;AACV,wBAAAA,QAAO,MAAM,qCAAqC,OAAO,KAAK;AAC9D;AAAA,QACF;AAEA,cAAM,WAAW,OAAO,YAAY;AACpC,cAAM,cAAc,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eep";
|
|
2
|
+
import logger from "./util/logger";
|
|
3
|
+
function denormalise(parseResult) {
|
|
4
|
+
const blocksByName = parseResult.blocks.reduce(
|
|
5
|
+
(acc, b) => {
|
|
6
|
+
acc[b.name] = b;
|
|
7
|
+
return acc;
|
|
8
|
+
},
|
|
9
|
+
{}
|
|
10
|
+
);
|
|
11
|
+
const gatherEntities = (entities, transforms) => {
|
|
12
|
+
let current = [];
|
|
13
|
+
for (const e of entities) {
|
|
14
|
+
if (e.type === "INSERT") {
|
|
15
|
+
const insert = e;
|
|
16
|
+
const block = blocksByName[insert.block];
|
|
17
|
+
if (!block) {
|
|
18
|
+
logger.error("no block found for insert. block:", insert.block);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const rowCount = insert.rowCount ?? 1;
|
|
22
|
+
const columnCount = insert.columnCount ?? 1;
|
|
23
|
+
const rowSpacing = insert.rowSpacing ?? 0;
|
|
24
|
+
const columnSpacing = insert.columnSpacing ?? 0;
|
|
25
|
+
const rotation = insert.rotation ?? 0;
|
|
26
|
+
let rowVec;
|
|
27
|
+
let colVec;
|
|
28
|
+
if (rowCount > 1 || columnCount > 1) {
|
|
29
|
+
const cos = Math.cos(rotation * Math.PI / 180);
|
|
30
|
+
const sin = Math.sin(rotation * Math.PI / 180);
|
|
31
|
+
rowVec = { x: -sin * rowSpacing, y: cos * rowSpacing };
|
|
32
|
+
colVec = { x: cos * columnSpacing, y: sin * columnSpacing };
|
|
33
|
+
} else {
|
|
34
|
+
rowVec = { x: 0, y: 0 };
|
|
35
|
+
colVec = { x: 0, y: 0 };
|
|
36
|
+
}
|
|
37
|
+
for (let r = 0; r < rowCount; r++) {
|
|
38
|
+
for (let c = 0; c < columnCount; c++) {
|
|
39
|
+
const t = {
|
|
40
|
+
x: insert.x + rowVec.x * r + colVec.x * c,
|
|
41
|
+
y: insert.y + rowVec.y * r + colVec.y * c,
|
|
42
|
+
scaleX: insert.scaleX,
|
|
43
|
+
scaleY: insert.scaleY,
|
|
44
|
+
scaleZ: insert.scaleZ,
|
|
45
|
+
extrusionX: insert.extrusionX,
|
|
46
|
+
extrusionY: insert.extrusionY,
|
|
47
|
+
extrusionZ: insert.extrusionZ,
|
|
48
|
+
rotation: insert.rotation
|
|
49
|
+
};
|
|
50
|
+
const transforms2 = transforms.slice(0);
|
|
51
|
+
transforms2.push(t);
|
|
52
|
+
const blockEntities = block.entities.map((be) => {
|
|
53
|
+
const be2 = cloneDeep(be);
|
|
54
|
+
be2.layer = insert.layer;
|
|
55
|
+
switch (be2.type) {
|
|
56
|
+
case "LINE": {
|
|
57
|
+
const line = be2;
|
|
58
|
+
line.start.x -= block.x;
|
|
59
|
+
line.start.y -= block.y;
|
|
60
|
+
line.end.x -= block.x;
|
|
61
|
+
line.end.y -= block.y;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case "LWPOLYLINE":
|
|
65
|
+
case "POLYLINE": {
|
|
66
|
+
const poly = be2;
|
|
67
|
+
for (const v of poly.vertices) {
|
|
68
|
+
if (v.x !== void 0) v.x -= block.x;
|
|
69
|
+
if (v.y !== void 0) v.y -= block.y;
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case "CIRCLE": {
|
|
74
|
+
const circle = be2;
|
|
75
|
+
circle.x -= block.x;
|
|
76
|
+
circle.y -= block.y;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case "ELLIPSE": {
|
|
80
|
+
const ellipse = be2;
|
|
81
|
+
ellipse.x -= block.x;
|
|
82
|
+
ellipse.y -= block.y;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case "ARC": {
|
|
86
|
+
const arc = be2;
|
|
87
|
+
arc.x -= block.x;
|
|
88
|
+
arc.y -= block.y;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case "SPLINE": {
|
|
92
|
+
const spline = be2;
|
|
93
|
+
for (const cp of spline.controlPoints) {
|
|
94
|
+
cp.x -= block.x;
|
|
95
|
+
cp.y -= block.y;
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return be2;
|
|
101
|
+
});
|
|
102
|
+
current = current.concat(gatherEntities(blockEntities, transforms2));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
const e2 = cloneDeep(e);
|
|
107
|
+
e2.transforms = transforms.slice().reverse();
|
|
108
|
+
current.push(e2);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return current;
|
|
112
|
+
};
|
|
113
|
+
return gatherEntities(parseResult.entities, []);
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
denormalise as default
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=denormalise.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/denormalise.ts"],
|
|
4
|
+
"sourcesContent": ["import cloneDeep from 'lodash/cloneDeep'\n\nimport logger from './util/logger'\n\nimport type {\n ArcEntity,\n Block,\n CircleEntity,\n EllipseEntity,\n Entity,\n InsertEntity,\n LineEntity,\n ParsedDXF,\n PolylineEntity,\n SplineEntity,\n Transform,\n} from './types'\n\nexport default function denormalise(parseResult: ParsedDXF): Entity[] {\n const blocksByName = parseResult.blocks.reduce(\n (acc: { [name: string]: Block }, b: Block) => {\n acc[b.name] = b\n return acc\n },\n {},\n )\n\n const gatherEntities = (\n entities: Entity[],\n transforms: Transform[],\n ): Entity[] => {\n let current: Entity[] = []\n for (const e of entities) {\n if (e.type === 'INSERT') {\n const insert = e as InsertEntity\n const block = blocksByName[insert.block]\n if (!block) {\n logger.error('no block found for insert. block:', insert.block)\n continue\n }\n\n const rowCount = insert.rowCount ?? 1\n const columnCount = insert.columnCount ?? 1\n const rowSpacing = insert.rowSpacing ?? 0\n const columnSpacing = insert.columnSpacing ?? 0\n const rotation = insert.rotation ?? 0\n\n // It appears that the rectangular array is affected by rotation, but NOT by scale.\n let rowVec: { x: number; y: number }\n let colVec: { x: number; y: number }\n if (rowCount > 1 || columnCount > 1) {\n const cos = Math.cos((rotation * Math.PI) / 180)\n const sin = Math.sin((rotation * Math.PI) / 180)\n rowVec = { x: -sin * rowSpacing, y: cos * rowSpacing }\n colVec = { x: cos * columnSpacing, y: sin * columnSpacing }\n } else {\n rowVec = { x: 0, y: 0 }\n colVec = { x: 0, y: 0 }\n }\n\n // For rectangular arrays, add the block entities for each location in the array\n for (let r = 0; r < rowCount; r++) {\n for (let c = 0; c < columnCount; c++) {\n // Adjust insert transform by row and column for rectangular arrays\n const t: Transform = {\n x: insert.x + rowVec.x * r + colVec.x * c,\n y: insert.y + rowVec.y * r + colVec.y * c,\n scaleX: insert.scaleX,\n scaleY: insert.scaleY,\n scaleZ: insert.scaleZ,\n extrusionX: insert.extrusionX,\n extrusionY: insert.extrusionY,\n extrusionZ: insert.extrusionZ,\n rotation: insert.rotation,\n }\n // Add the insert transform and recursively add entities\n const transforms2 = transforms.slice(0)\n transforms2.push(t)\n\n // Use the insert layer\n const blockEntities = block.entities.map((be: Entity) => {\n const be2 = cloneDeep(be)\n be2.layer = insert.layer\n // https://github.com/bjnortier/dxf/issues/52\n // See Issue 52. If we don't modify the\n // entity coordinates here it creates an issue with the\n // transformation matrices (which are only applied AFTER\n // block insertion modifications has been applied).\n switch (be2.type) {\n case 'LINE': {\n const line = be2 as LineEntity\n line.start.x -= block.x\n line.start.y -= block.y\n line.end.x -= block.x\n line.end.y -= block.y\n break\n }\n case 'LWPOLYLINE':\n case 'POLYLINE': {\n const poly = be2 as PolylineEntity\n for (const v of poly.vertices) {\n if (v.x !== undefined) v.x -= block.x\n if (v.y !== undefined) v.y -= block.y\n }\n break\n }\n case 'CIRCLE': {\n const circle = be2 as CircleEntity\n circle.x -= block.x\n circle.y -= block.y\n break\n }\n case 'ELLIPSE': {\n const ellipse = be2 as EllipseEntity\n ellipse.x -= block.x\n ellipse.y -= block.y\n break\n }\n case 'ARC': {\n const arc = be2 as ArcEntity\n arc.x -= block.x\n arc.y -= block.y\n break\n }\n case 'SPLINE': {\n const spline = be2 as SplineEntity\n for (const cp of spline.controlPoints) {\n cp.x -= block.x\n cp.y -= block.y\n }\n break\n }\n }\n return be2\n })\n current = current.concat(gatherEntities(blockEntities, transforms2))\n }\n }\n } else {\n // Top-level entity. Clone and add the transforms\n // The transforms are reversed so they occur in\n // order of application - i.e. the transform of the\n // top-level insert is applied last\n const e2 = cloneDeep(e)\n e2.transforms = transforms.slice().reverse()\n current.push(e2)\n }\n }\n return current\n }\n\n return gatherEntities(parseResult.entities, [])\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,eAAe;AAEtB,OAAO,YAAY;AAgBJ,SAAR,YAA6B,aAAkC;AACpE,QAAM,eAAe,YAAY,OAAO;AAAA,IACtC,CAAC,KAAgC,MAAa;AAC5C,UAAI,EAAE,IAAI,IAAI;AACd,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,iBAAiB,CACrB,UACA,eACa;AACb,QAAI,UAAoB,CAAC;AACzB,eAAW,KAAK,UAAU;AACxB,UAAI,EAAE,SAAS,UAAU;AACvB,cAAM,SAAS;AACf,cAAM,QAAQ,aAAa,OAAO,KAAK;AACvC,YAAI,CAAC,OAAO;AACV,iBAAO,MAAM,qCAAqC,OAAO,KAAK;AAC9D;AAAA,QACF;AAEA,cAAM,WAAW,OAAO,YAAY;AACpC,cAAM,cAAc,OAAO,eAAe;AAC1C,cAAM,aAAa,OAAO,cAAc;AACxC,cAAM,gBAAgB,OAAO,iBAAiB;AAC9C,cAAM,WAAW,OAAO,YAAY;AAGpC,YAAI;AACJ,YAAI;AACJ,YAAI,WAAW,KAAK,cAAc,GAAG;AACnC,gBAAM,MAAM,KAAK,IAAK,WAAW,KAAK,KAAM,GAAG;AAC/C,gBAAM,MAAM,KAAK,IAAK,WAAW,KAAK,KAAM,GAAG;AAC/C,mBAAS,EAAE,GAAG,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