@ifc-lite/create 4.0.0 → 5.1.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/README.md +34 -0
- package/dist/in-store/align-boxes.d.ts +38 -0
- package/dist/in-store/align-boxes.d.ts.map +1 -0
- package/dist/in-store/align-boxes.js +97 -0
- package/dist/in-store/align-boxes.js.map +1 -0
- package/dist/in-store/anchor.d.ts.map +1 -1
- package/dist/in-store/anchor.js +13 -2
- package/dist/in-store/anchor.js.map +1 -1
- package/dist/in-store/beam.d.ts.map +1 -1
- package/dist/in-store/beam.js +3 -10
- package/dist/in-store/beam.js.map +1 -1
- package/dist/in-store/copy-array.d.ts +17 -0
- package/dist/in-store/copy-array.d.ts.map +1 -0
- package/dist/in-store/copy-array.js +47 -0
- package/dist/in-store/copy-array.js.map +1 -0
- package/dist/in-store/copy-batch.d.ts +27 -0
- package/dist/in-store/copy-batch.d.ts.map +1 -0
- package/dist/in-store/copy-batch.js +101 -0
- package/dist/in-store/copy-batch.js.map +1 -0
- package/dist/in-store/copy-dependent-walk.d.ts +27 -0
- package/dist/in-store/copy-dependent-walk.d.ts.map +1 -0
- package/dist/in-store/copy-dependent-walk.js +61 -0
- package/dist/in-store/copy-dependent-walk.js.map +1 -0
- package/dist/in-store/copy-frame.d.ts +4 -3
- package/dist/in-store/copy-frame.d.ts.map +1 -1
- package/dist/in-store/copy-frame.js +14 -1
- package/dist/in-store/copy-frame.js.map +1 -1
- package/dist/in-store/copy-product.d.ts +0 -20
- package/dist/in-store/copy-product.d.ts.map +1 -1
- package/dist/in-store/copy-product.js +35 -35
- package/dist/in-store/copy-product.js.map +1 -1
- package/dist/in-store/duplicate.d.ts +8 -0
- package/dist/in-store/duplicate.d.ts.map +1 -1
- package/dist/in-store/duplicate.js +8 -1
- package/dist/in-store/duplicate.js.map +1 -1
- package/dist/in-store/edit/effective-mutation-view.d.ts +6 -0
- package/dist/in-store/edit/effective-mutation-view.d.ts.map +1 -0
- package/dist/in-store/edit/effective-mutation-view.js +45 -0
- package/dist/in-store/edit/effective-mutation-view.js.map +1 -0
- package/dist/in-store/edit/effective-storey.d.ts +13 -0
- package/dist/in-store/edit/effective-storey.d.ts.map +1 -0
- package/dist/in-store/edit/effective-storey.js +36 -0
- package/dist/in-store/edit/effective-storey.js.map +1 -0
- package/dist/in-store/edit/effective-storeys.d.ts +9 -0
- package/dist/in-store/edit/effective-storeys.d.ts.map +1 -0
- package/dist/in-store/edit/effective-storeys.js +16 -0
- package/dist/in-store/edit/effective-storeys.js.map +1 -0
- package/dist/in-store/edit/hosted-opening-refit.d.ts +29 -0
- package/dist/in-store/edit/hosted-opening-refit.d.ts.map +1 -0
- package/dist/in-store/edit/hosted-opening-refit.js +168 -0
- package/dist/in-store/edit/hosted-opening-refit.js.map +1 -0
- package/dist/in-store/edit/length-unit-scale.d.ts +24 -0
- package/dist/in-store/edit/length-unit-scale.d.ts.map +1 -0
- package/dist/in-store/edit/length-unit-scale.js +37 -0
- package/dist/in-store/edit/length-unit-scale.js.map +1 -0
- package/dist/in-store/edit/linear-element-edit.d.ts +131 -0
- package/dist/in-store/edit/linear-element-edit.d.ts.map +1 -0
- package/dist/in-store/edit/linear-element-edit.js +259 -0
- package/dist/in-store/edit/linear-element-edit.js.map +1 -0
- package/dist/in-store/edit/metadata-clone-effective.d.ts +5 -0
- package/dist/in-store/edit/metadata-clone-effective.d.ts.map +1 -0
- package/dist/in-store/edit/metadata-clone-effective.js +47 -0
- package/dist/in-store/edit/metadata-clone-effective.js.map +1 -0
- package/dist/in-store/edit/metadata-clone.d.ts +40 -0
- package/dist/in-store/edit/metadata-clone.d.ts.map +1 -0
- package/dist/in-store/edit/metadata-clone.js +142 -0
- package/dist/in-store/edit/metadata-clone.js.map +1 -0
- package/dist/in-store/edit/placement-core.d.ts +140 -0
- package/dist/in-store/edit/placement-core.d.ts.map +1 -0
- package/dist/in-store/edit/placement-core.js +317 -0
- package/dist/in-store/edit/placement-core.js.map +1 -0
- package/dist/in-store/edit/polygon-clip.d.ts +58 -0
- package/dist/in-store/edit/polygon-clip.d.ts.map +1 -0
- package/dist/in-store/edit/polygon-clip.js +153 -0
- package/dist/in-store/edit/polygon-clip.js.map +1 -0
- package/dist/in-store/edit/read-profile.d.ts +6 -0
- package/dist/in-store/edit/read-profile.d.ts.map +1 -0
- package/dist/in-store/edit/read-profile.js +95 -0
- package/dist/in-store/edit/read-profile.js.map +1 -0
- package/dist/in-store/edit/slab-edit-frame.d.ts +40 -0
- package/dist/in-store/edit/slab-edit-frame.d.ts.map +1 -0
- package/dist/in-store/edit/slab-edit-frame.js +146 -0
- package/dist/in-store/edit/slab-edit-frame.js.map +1 -0
- package/dist/in-store/edit/slab-edit.d.ts +112 -0
- package/dist/in-store/edit/slab-edit.d.ts.map +1 -0
- package/dist/in-store/edit/slab-edit.js +275 -0
- package/dist/in-store/edit/slab-edit.js.map +1 -0
- package/dist/in-store/edit/slab-opening-carry.d.ts +10 -0
- package/dist/in-store/edit/slab-opening-carry.d.ts.map +1 -0
- package/dist/in-store/edit/slab-opening-carry.js +65 -0
- package/dist/in-store/edit/slab-opening-carry.js.map +1 -0
- package/dist/in-store/edit/split-guid.d.ts +29 -0
- package/dist/in-store/edit/split-guid.d.ts.map +1 -0
- package/dist/in-store/edit/split-guid.js +64 -0
- package/dist/in-store/edit/split-guid.js.map +1 -0
- package/dist/in-store/edit/split-target.d.ts +90 -0
- package/dist/in-store/edit/split-target.d.ts.map +1 -0
- package/dist/in-store/edit/split-target.js +116 -0
- package/dist/in-store/edit/split-target.js.map +1 -0
- package/dist/in-store/edit/target.d.ts +8 -0
- package/dist/in-store/edit/target.d.ts.map +1 -0
- package/dist/in-store/edit/target.js +5 -0
- package/dist/in-store/edit/target.js.map +1 -0
- package/dist/in-store/edit/trim-extend-geometry.d.ts +99 -0
- package/dist/in-store/edit/trim-extend-geometry.d.ts.map +1 -0
- package/dist/in-store/edit/trim-extend-geometry.js +105 -0
- package/dist/in-store/edit/trim-extend-geometry.js.map +1 -0
- package/dist/in-store/edit/wall-axis-edit.d.ts +16 -0
- package/dist/in-store/edit/wall-axis-edit.d.ts.map +1 -0
- package/dist/in-store/edit/wall-axis-edit.js +40 -0
- package/dist/in-store/edit/wall-axis-edit.js.map +1 -0
- package/dist/in-store/edit/wall-edit.d.ts +157 -0
- package/dist/in-store/edit/wall-edit.d.ts.map +1 -0
- package/dist/in-store/edit/wall-edit.js +276 -0
- package/dist/in-store/edit/wall-edit.js.map +1 -0
- package/dist/in-store/edit/wall-hosted-cuts.d.ts +35 -0
- package/dist/in-store/edit/wall-hosted-cuts.d.ts.map +1 -0
- package/dist/in-store/edit/wall-hosted-cuts.js +27 -0
- package/dist/in-store/edit/wall-hosted-cuts.js.map +1 -0
- package/dist/in-store/edit/wall-opening-reassign.d.ts +18 -0
- package/dist/in-store/edit/wall-opening-reassign.d.ts.map +1 -0
- package/dist/in-store/edit/wall-opening-reassign.js +50 -0
- package/dist/in-store/edit/wall-opening-reassign.js.map +1 -0
- package/dist/in-store/element-align.d.ts +13 -0
- package/dist/in-store/element-align.d.ts.map +1 -0
- package/dist/in-store/element-align.js +90 -0
- package/dist/in-store/element-align.js.map +1 -0
- package/dist/in-store/element-replacement.d.ts +26 -0
- package/dist/in-store/element-replacement.d.ts.map +1 -0
- package/dist/in-store/element-replacement.js +68 -0
- package/dist/in-store/element-replacement.js.map +1 -0
- package/dist/in-store/element-size-edit.d.ts +40 -0
- package/dist/in-store/element-size-edit.d.ts.map +1 -0
- package/dist/in-store/element-size-edit.js +103 -0
- package/dist/in-store/element-size-edit.js.map +1 -0
- package/dist/in-store/element-split-axis.d.ts +6 -0
- package/dist/in-store/element-split-axis.d.ts.map +1 -0
- package/dist/in-store/element-split-axis.js +87 -0
- package/dist/in-store/element-split-axis.js.map +1 -0
- package/dist/in-store/element-split-joined.d.ts +13 -0
- package/dist/in-store/element-split-joined.d.ts.map +1 -0
- package/dist/in-store/element-split-joined.js +74 -0
- package/dist/in-store/element-split-joined.js.map +1 -0
- package/dist/in-store/element-split-placement.d.ts +19 -0
- package/dist/in-store/element-split-placement.d.ts.map +1 -0
- package/dist/in-store/element-split-placement.js +48 -0
- package/dist/in-store/element-split-placement.js.map +1 -0
- package/dist/in-store/element-split-slab.d.ts +19 -0
- package/dist/in-store/element-split-slab.d.ts.map +1 -0
- package/dist/in-store/element-split-slab.js +86 -0
- package/dist/in-store/element-split-slab.js.map +1 -0
- package/dist/in-store/element-split.d.ts +49 -0
- package/dist/in-store/element-split.d.ts.map +1 -0
- package/dist/in-store/element-split.js +52 -0
- package/dist/in-store/element-split.js.map +1 -0
- package/dist/in-store/element-transform-edit.d.ts +33 -0
- package/dist/in-store/element-transform-edit.d.ts.map +1 -0
- package/dist/in-store/element-transform-edit.js +97 -0
- package/dist/in-store/element-transform-edit.js.map +1 -0
- package/dist/in-store/element-transform-frames.d.ts +45 -0
- package/dist/in-store/element-transform-frames.d.ts.map +1 -0
- package/dist/in-store/element-transform-frames.js +121 -0
- package/dist/in-store/element-transform-frames.js.map +1 -0
- package/dist/in-store/element-transform-joins.d.ts +4 -0
- package/dist/in-store/element-transform-joins.d.ts.map +1 -0
- package/dist/in-store/element-transform-joins.js +62 -0
- package/dist/in-store/element-transform-joins.js.map +1 -0
- package/dist/in-store/element-transform-plan.d.ts +38 -0
- package/dist/in-store/element-transform-plan.d.ts.map +1 -0
- package/dist/in-store/element-transform-plan.js +115 -0
- package/dist/in-store/element-transform-plan.js.map +1 -0
- package/dist/in-store/element-trim-extend.d.ts +25 -0
- package/dist/in-store/element-trim-extend.d.ts.map +1 -0
- package/dist/in-store/element-trim-extend.js +97 -0
- package/dist/in-store/element-trim-extend.js.map +1 -0
- package/dist/in-store/extract-grids.d.ts +7 -17
- package/dist/in-store/extract-grids.d.ts.map +1 -1
- package/dist/in-store/extract-grids.js +11 -2
- package/dist/in-store/extract-grids.js.map +1 -1
- package/dist/in-store/grid-column.d.ts +23 -0
- package/dist/in-store/grid-column.d.ts.map +1 -0
- package/dist/in-store/grid-column.js +73 -0
- package/dist/in-store/grid-column.js.map +1 -0
- package/dist/in-store/grid-intersection-read.d.ts +10 -0
- package/dist/in-store/grid-intersection-read.d.ts.map +1 -0
- package/dist/in-store/grid-intersection-read.js +45 -0
- package/dist/in-store/grid-intersection-read.js.map +1 -0
- package/dist/in-store/grid.d.ts +7 -1
- package/dist/in-store/grid.d.ts.map +1 -1
- package/dist/in-store/grid.js +12 -2
- package/dist/in-store/grid.js.map +1 -1
- package/dist/in-store/group-evidence.d.ts +49 -0
- package/dist/in-store/group-evidence.d.ts.map +1 -0
- package/dist/in-store/group-evidence.js +111 -0
- package/dist/in-store/group-evidence.js.map +1 -0
- package/dist/in-store/group-graph.d.ts +51 -0
- package/dist/in-store/group-graph.d.ts.map +1 -0
- package/dist/in-store/group-graph.js +207 -0
- package/dist/in-store/group-graph.js.map +1 -0
- package/dist/in-store/group.d.ts +34 -0
- package/dist/in-store/group.d.ts.map +1 -0
- package/dist/in-store/group.js +181 -0
- package/dist/in-store/group.js.map +1 -0
- package/dist/in-store/host-geometry-frame.d.ts +5 -1
- package/dist/in-store/host-geometry-frame.d.ts.map +1 -1
- package/dist/in-store/host-geometry-frame.js +58 -10
- package/dist/in-store/host-geometry-frame.js.map +1 -1
- package/dist/in-store/index.d.ts +7 -0
- package/dist/in-store/index.d.ts.map +1 -1
- package/dist/in-store/index.js +7 -0
- package/dist/in-store/index.js.map +1 -1
- package/dist/in-store/linear-profile-frame.d.ts +10 -0
- package/dist/in-store/linear-profile-frame.d.ts.map +1 -0
- package/dist/in-store/linear-profile-frame.js +17 -0
- package/dist/in-store/linear-profile-frame.js.map +1 -0
- package/dist/in-store/material.d.ts.map +1 -1
- package/dist/in-store/material.js +17 -6
- package/dist/in-store/material.js.map +1 -1
- package/dist/in-store/member.d.ts.map +1 -1
- package/dist/in-store/member.js +3 -7
- package/dist/in-store/member.js.map +1 -1
- package/dist/in-store/ordinary-element.d.ts +47 -0
- package/dist/in-store/ordinary-element.d.ts.map +1 -0
- package/dist/in-store/ordinary-element.js +38 -0
- package/dist/in-store/ordinary-element.js.map +1 -0
- package/dist/in-store/placement-frame.d.ts +5 -17
- package/dist/in-store/placement-frame.d.ts.map +1 -1
- package/dist/in-store/placement-frame.js +59 -43
- package/dist/in-store/placement-frame.js.map +1 -1
- package/dist/in-store/resolve-anchor.d.ts +3 -2
- package/dist/in-store/resolve-anchor.d.ts.map +1 -1
- package/dist/in-store/resolve-anchor.js +7 -5
- package/dist/in-store/resolve-anchor.js.map +1 -1
- package/dist/in-store/resolve-relations.d.ts +3 -1
- package/dist/in-store/resolve-relations.d.ts.map +1 -1
- package/dist/in-store/resolve-relations.js +8 -3
- package/dist/in-store/resolve-relations.js.map +1 -1
- package/dist/in-store/resolve-source.d.ts.map +1 -1
- package/dist/in-store/resolve-source.js +10 -3
- package/dist/in-store/resolve-source.js.map +1 -1
- package/dist/in-store/room-candidates.d.ts +58 -0
- package/dist/in-store/room-candidates.d.ts.map +1 -0
- package/dist/in-store/room-candidates.js +135 -0
- package/dist/in-store/room-candidates.js.map +1 -0
- package/dist/in-store/room-creation-plan.d.ts +16 -0
- package/dist/in-store/room-creation-plan.d.ts.map +1 -0
- package/dist/in-store/room-creation-plan.js +28 -0
- package/dist/in-store/room-creation-plan.js.map +1 -0
- package/dist/in-store/room-floor-height.d.ts +24 -0
- package/dist/in-store/room-floor-height.d.ts.map +1 -0
- package/dist/in-store/room-floor-height.js +32 -0
- package/dist/in-store/room-floor-height.js.map +1 -0
- package/dist/in-store/room-footprint-native.d.ts +19 -0
- package/dist/in-store/room-footprint-native.d.ts.map +1 -0
- package/dist/in-store/room-footprint-native.js +117 -0
- package/dist/in-store/room-footprint-native.js.map +1 -0
- package/dist/in-store/room-layout-cache.d.ts +23 -0
- package/dist/in-store/room-layout-cache.d.ts.map +1 -0
- package/dist/in-store/room-layout-cache.js +84 -0
- package/dist/in-store/room-layout-cache.js.map +1 -0
- package/dist/in-store/room-layout-core.d.ts +68 -0
- package/dist/in-store/room-layout-core.d.ts.map +1 -0
- package/dist/in-store/room-layout-core.js +153 -0
- package/dist/in-store/room-layout-core.js.map +1 -0
- package/dist/in-store/room-population.d.ts +5 -0
- package/dist/in-store/room-population.d.ts.map +1 -0
- package/dist/in-store/room-population.js +28 -0
- package/dist/in-store/room-population.js.map +1 -0
- package/dist/in-store/room-space-meshes.d.ts +15 -0
- package/dist/in-store/room-space-meshes.d.ts.map +1 -0
- package/dist/in-store/room-space-meshes.js +38 -0
- package/dist/in-store/room-space-meshes.js.map +1 -0
- package/dist/in-store/room-store.d.ts +55 -0
- package/dist/in-store/room-store.d.ts.map +1 -0
- package/dist/in-store/room-store.js +173 -0
- package/dist/in-store/room-store.js.map +1 -0
- package/dist/in-store/room-storey-elevation.d.ts +5 -0
- package/dist/in-store/room-storey-elevation.d.ts.map +1 -0
- package/dist/in-store/room-storey-elevation.js +42 -0
- package/dist/in-store/room-storey-elevation.js.map +1 -0
- package/dist/in-store/room-storey-frame.d.ts +47 -0
- package/dist/in-store/room-storey-frame.d.ts.map +1 -0
- package/dist/in-store/room-storey-frame.js +48 -0
- package/dist/in-store/room-storey-frame.js.map +1 -0
- package/dist/in-store/room-wall-rects.d.ts +117 -0
- package/dist/in-store/room-wall-rects.d.ts.map +1 -0
- package/dist/in-store/room-wall-rects.js +157 -0
- package/dist/in-store/room-wall-rects.js.map +1 -0
- package/dist/in-store/schema-attributes.d.ts +3 -3
- package/dist/in-store/schema-attributes.d.ts.map +1 -1
- package/dist/in-store/schema-attributes.js +9 -7
- package/dist/in-store/schema-attributes.js.map +1 -1
- package/dist/in-store/slab.d.ts.map +1 -1
- package/dist/in-store/slab.js +1 -4
- package/dist/in-store/slab.js.map +1 -1
- package/dist/in-store/stair-removal.d.ts +17 -0
- package/dist/in-store/stair-removal.d.ts.map +1 -0
- package/dist/in-store/stair-removal.js +134 -0
- package/dist/in-store/stair-removal.js.map +1 -0
- package/dist/in-store/storey-plan-frame.d.ts +2 -1
- package/dist/in-store/storey-plan-frame.d.ts.map +1 -1
- package/dist/in-store/storey-plan-frame.js +20 -11
- package/dist/in-store/storey-plan-frame.js.map +1 -1
- package/dist/in-store/storey-reassignment-plan.d.ts +53 -0
- package/dist/in-store/storey-reassignment-plan.d.ts.map +1 -0
- package/dist/in-store/storey-reassignment-plan.js +237 -0
- package/dist/in-store/storey-reassignment-plan.js.map +1 -0
- package/dist/in-store/storey-reassignment.d.ts +8 -0
- package/dist/in-store/storey-reassignment.d.ts.map +1 -0
- package/dist/in-store/storey-reassignment.js +52 -0
- package/dist/in-store/storey-reassignment.js.map +1 -0
- package/dist/in-store/trim-extend-plan.d.ts +27 -0
- package/dist/in-store/trim-extend-plan.d.ts.map +1 -0
- package/dist/in-store/trim-extend-plan.js +49 -0
- package/dist/in-store/trim-extend-plan.js.map +1 -0
- package/dist/in-store/wall-join-edit.d.ts +0 -17
- package/dist/in-store/wall-join-edit.d.ts.map +1 -1
- package/dist/in-store/wall-join-edit.js +41 -7
- package/dist/in-store/wall-join-edit.js.map +1 -1
- package/dist/in-store/wall-section-edit.d.ts +16 -0
- package/dist/in-store/wall-section-edit.d.ts.map +1 -0
- package/dist/in-store/wall-section-edit.js +75 -0
- package/dist/in-store/wall-section-edit.js.map +1 -0
- package/dist/in-store/wall-size-edit.d.ts +29 -0
- package/dist/in-store/wall-size-edit.d.ts.map +1 -0
- package/dist/in-store/wall-size-edit.js +65 -0
- package/dist/in-store/wall-size-edit.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/landxml/profile-geometry.d.ts +10 -0
- package/dist/landxml/profile-geometry.d.ts.map +1 -1
- package/dist/landxml/profile-geometry.js +16 -1
- package/dist/landxml/profile-geometry.js.map +1 -1
- package/package.json +9 -8
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core placement-chain reader + generic IfcProduct edits.
|
|
3
|
+
*
|
|
4
|
+
* Walks the standard product placement chain
|
|
5
|
+
*
|
|
6
|
+
* IfcProduct → ObjectPlacement → IfcLocalPlacement
|
|
7
|
+
* → RelativePlacement → IfcAxis2Placement3D
|
|
8
|
+
* → Location → IfcCartesianPoint → Coordinates [x, y, z]
|
|
9
|
+
*
|
|
10
|
+
* Reads honour the `StoreEditor` overlay (overlay-only entities,
|
|
11
|
+
* named/positional mutations and current retypes on top of source-buffer entities for placement owners).
|
|
12
|
+
* Writes go through `setPositionalAttribute` so they stack with
|
|
13
|
+
* other overlay edits and participate in the standard undo path.
|
|
14
|
+
*
|
|
15
|
+
* Wall-specific edits live in `wall-edit.ts`; this module stays
|
|
16
|
+
* generic so file size + cognitive scope stay manageable.
|
|
17
|
+
*/
|
|
18
|
+
import { type IfcDataStore } from '@ifc-lite/parser';
|
|
19
|
+
import type { MutablePropertyView, StoreEditor } from '@ifc-lite/mutations';
|
|
20
|
+
/** Synchronous source decoding for headless edits. The viewer may override
|
|
21
|
+
* this reader at boot; overlay reads never require a source buffer. */
|
|
22
|
+
export type SourceAttrsReader = (dataStore: IfcDataStore, expressId: number) => unknown[] | null;
|
|
23
|
+
/**
|
|
24
|
+
* Override the parser-backed source reader at app boot.
|
|
25
|
+
* Pass `null` to disable source reads (used by tests).
|
|
26
|
+
*/
|
|
27
|
+
export declare function setSourceAttrsReader(reader: SourceAttrsReader | null): void;
|
|
28
|
+
type EntityAttrs = unknown[];
|
|
29
|
+
/** #7315: only native placement owners use current named/retyped fields.
|
|
30
|
+
* The general body/profile reader retains its existing positional contract. */
|
|
31
|
+
export declare function readPlacementAttributes(dataStore: IfcDataStore, view: MutablePropertyView, editor: Pick<StoreEditor, 'getNewEntity'> & Partial<Pick<StoreEditor, 'getEntityType'>>, expressId: number): EntityAttrs | null;
|
|
32
|
+
/**
|
|
33
|
+
* Read the effective attribute list for an express id. Overlay-only
|
|
34
|
+
* entities come from the StoreEditor; source entities come from the
|
|
35
|
+
* original buffer. Positional-mutation overrides are layered on top so
|
|
36
|
+
* a previously-translated point reads back its mutated coords.
|
|
37
|
+
*/
|
|
38
|
+
export declare function readAttributes(dataStore: IfcDataStore, view: MutablePropertyView,
|
|
39
|
+
/** Only its overlay lookup is read, so the view itself will do. */
|
|
40
|
+
editor: Pick<StoreEditor, 'getNewEntity'>, expressId: number): EntityAttrs | null;
|
|
41
|
+
/**
|
|
42
|
+
* References take two forms in our attribute graph:
|
|
43
|
+
* - number (the parser normalises `#123` → 123 when reading source)
|
|
44
|
+
* - string `#123` (overlay entities created via `editor.addEntity`
|
|
45
|
+
* carry the raw `#X` form straight through)
|
|
46
|
+
* Treat both as valid so the chain walker works for source-buffer
|
|
47
|
+
* AND overlay-only entities — it's the same conceptual reference.
|
|
48
|
+
*/
|
|
49
|
+
export declare function asExpressIdRef(value: unknown): number | null;
|
|
50
|
+
export declare function asCoordinateTriple(value: unknown): [number, number, number] | null;
|
|
51
|
+
export declare function asDirectionRatios(value: unknown): [number, number, number] | null;
|
|
52
|
+
export interface PlacementChain {
|
|
53
|
+
/** IfcProduct.ObjectPlacement target (IfcLocalPlacement express id). */
|
|
54
|
+
localPlacementId: number;
|
|
55
|
+
/** IfcLocalPlacement.RelativePlacement target (IfcAxis2Placement3D express id). */
|
|
56
|
+
axisPlacementId: number;
|
|
57
|
+
/** IfcAxis2Placement3D.Location target (IfcCartesianPoint express id). */
|
|
58
|
+
cartesianPointId: number;
|
|
59
|
+
/** Current coordinates on the IfcCartesianPoint (storey-local, IFC Z-up). */
|
|
60
|
+
coordinates: [number, number, number];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Resolve the full placement chain for an IfcProduct. Returns `null`
|
|
64
|
+
* if any link is missing or has the wrong shape — callers should treat
|
|
65
|
+
* this as "this entity's placement isn't directly translatable" and
|
|
66
|
+
* surface a clear message rather than crashing.
|
|
67
|
+
*
|
|
68
|
+
* Indices follow the IfcProduct attribute order:
|
|
69
|
+
* [0] GlobalId · [1] OwnerHistory · [2] Name · [3] Description
|
|
70
|
+
* [4] ObjectType · [5] ObjectPlacement · [6] Representation · ...
|
|
71
|
+
*
|
|
72
|
+
* For non-product entities (e.g. profiles, points themselves) attrs[5]
|
|
73
|
+
* either doesn't exist or isn't a placement reference, so we bail.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolvePlacementChain(dataStore: IfcDataStore, view: MutablePropertyView, editor: StoreEditor, expressId: number): PlacementChain | null;
|
|
76
|
+
/** Pure preview shared by atomic preflight and the placement writer. */
|
|
77
|
+
export declare function translatedCoordinates(coordinates: readonly number[], delta: readonly number[]): [number, number, number] | null;
|
|
78
|
+
export type TranslateResult = {
|
|
79
|
+
ok: true;
|
|
80
|
+
oldCoordinates: [number, number, number];
|
|
81
|
+
newCoordinates: [number, number, number];
|
|
82
|
+
} | {
|
|
83
|
+
ok: false;
|
|
84
|
+
reason: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Translate an IfcProduct by `delta` (storey-local IFC Z-up). Reads
|
|
88
|
+
* the current coordinates from the chain, adds the delta, writes back
|
|
89
|
+
* via `setPositionalAttribute`. Caller is responsible for batching
|
|
90
|
+
* undo (the upstream `setPositionalAttribute` action already pushes a
|
|
91
|
+
* single mutation onto the model's undo stack).
|
|
92
|
+
*/
|
|
93
|
+
export declare function translateProduct(dataStore: IfcDataStore, view: MutablePropertyView, editor: StoreEditor, expressId: number, delta: [number, number, number]): TranslateResult;
|
|
94
|
+
/**
|
|
95
|
+
* Set the entity's position to an absolute storey-local coordinate.
|
|
96
|
+
* Convenience over `translateProduct` when the caller has a target
|
|
97
|
+
* (e.g. a numeric form bound to current coordinates).
|
|
98
|
+
*/
|
|
99
|
+
export declare function setProductPosition(dataStore: IfcDataStore, view: MutablePropertyView, editor: StoreEditor, expressId: number, position: [number, number, number]): TranslateResult;
|
|
100
|
+
/**
|
|
101
|
+
* Snapshot of the placement's IfcAxis2Placement3D rotation.
|
|
102
|
+
* `refDirectionId === null` means the slot is implicit (STEP `$`) —
|
|
103
|
+
* the default direction `[1, 0, 0]` is reported, but callers that
|
|
104
|
+
* want to rotate must refuse this case (no IfcDirection to write to
|
|
105
|
+
* without orphaning one on undo).
|
|
106
|
+
*/
|
|
107
|
+
export interface RotationState {
|
|
108
|
+
axisPlacementId: number;
|
|
109
|
+
refDirectionId: number | null;
|
|
110
|
+
refDirection: [number, number, number];
|
|
111
|
+
/** Current yaw about Z (rad). */
|
|
112
|
+
yawZ: number;
|
|
113
|
+
}
|
|
114
|
+
export declare function resolveRotationState(dataStore: IfcDataStore, view: MutablePropertyView, editor: StoreEditor, expressId: number): RotationState | null;
|
|
115
|
+
export type RotateResult = {
|
|
116
|
+
ok: true;
|
|
117
|
+
oldYawZ: number;
|
|
118
|
+
newYawZ: number;
|
|
119
|
+
newRefDirection: [number, number, number];
|
|
120
|
+
} | {
|
|
121
|
+
ok: false;
|
|
122
|
+
reason: string;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Rotate an IfcProduct about the storey-up Z axis by `deltaYaw`
|
|
126
|
+
* radians. Updates RefDirection on the IfcAxis2Placement3D in place
|
|
127
|
+
* when one already exists.
|
|
128
|
+
*
|
|
129
|
+
* Refuses to operate when the placement has no explicit RefDirection
|
|
130
|
+
* (the implicit `[1, 0, 0]` STEP default). Materialising a fresh
|
|
131
|
+
* IfcDirection there would require a multi-mutation atomic undo
|
|
132
|
+
* entry to avoid orphans on undo, which the store doesn't have yet.
|
|
133
|
+
* Every entity emitted by `@ifc-lite/create`'s in-store builders
|
|
134
|
+
* carries an explicit RefDirection, so the implicit branch only
|
|
135
|
+
* trips on hand-rolled source-buffer entities — surfacing a clear
|
|
136
|
+
* refusal beats silently leaking entities.
|
|
137
|
+
*/
|
|
138
|
+
export declare function rotateProductYaw(dataStore: IfcDataStore, view: MutablePropertyView, editor: StoreEditor, expressId: number, deltaYaw: number): RotateResult;
|
|
139
|
+
export {};
|
|
140
|
+
//# sourceMappingURL=placement-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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BAAmB,EACzB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GACjC,eAAe,CAYjB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,YAAY,EACvB,IAAI,EAAE,mBAAmB,EACzB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,GAChB,aAAa,GAAG,IAAI,CAyBtB;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACzF;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,YAAY,EACvB,IAAI,EAAE,mBAAmB,EACzB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,YAAY,CAyBd"}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* Core placement-chain reader + generic IfcProduct edits.
|
|
6
|
+
*
|
|
7
|
+
* Walks the standard product placement chain
|
|
8
|
+
*
|
|
9
|
+
* IfcProduct → ObjectPlacement → IfcLocalPlacement
|
|
10
|
+
* → RelativePlacement → IfcAxis2Placement3D
|
|
11
|
+
* → Location → IfcCartesianPoint → Coordinates [x, y, z]
|
|
12
|
+
*
|
|
13
|
+
* Reads honour the `StoreEditor` overlay (overlay-only entities,
|
|
14
|
+
* named/positional mutations and current retypes on top of source-buffer entities for placement owners).
|
|
15
|
+
* Writes go through `setPositionalAttribute` so they stack with
|
|
16
|
+
* other overlay edits and participate in the standard undo path.
|
|
17
|
+
*
|
|
18
|
+
* Wall-specific edits live in `wall-edit.ts`; this module stays
|
|
19
|
+
* generic so file size + cognitive scope stay manageable.
|
|
20
|
+
*/
|
|
21
|
+
import { EntityExtractor, resolveEffectiveEntityRecord } from '@ifc-lite/parser';
|
|
22
|
+
let configuredSourceReader = (store, id) => {
|
|
23
|
+
// @raw-entity-enumeration-ok source baseline; readAttributes applies positional overlay edits
|
|
24
|
+
const byId = store.entityIndex?.byId;
|
|
25
|
+
if (!store.source?.length || !byId)
|
|
26
|
+
return null;
|
|
27
|
+
const ref = byId.get(id);
|
|
28
|
+
return ref ? new EntityExtractor(store.source).extractEntity(ref)?.attributes ?? null : null;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Override the parser-backed source reader at app boot.
|
|
32
|
+
* Pass `null` to disable source reads (used by tests).
|
|
33
|
+
*/
|
|
34
|
+
export function setSourceAttrsReader(reader) {
|
|
35
|
+
configuredSourceReader = reader;
|
|
36
|
+
}
|
|
37
|
+
/** Shared source callback baseline; effective placement reads add no decoder. */
|
|
38
|
+
function baseAttributes(dataStore, editor, expressId) {
|
|
39
|
+
const overlay = editor.getNewEntity(expressId);
|
|
40
|
+
let attrs = null;
|
|
41
|
+
if (overlay) {
|
|
42
|
+
attrs = overlay.attributes.slice();
|
|
43
|
+
}
|
|
44
|
+
else if (configuredSourceReader) {
|
|
45
|
+
attrs = configuredSourceReader(dataStore, expressId);
|
|
46
|
+
if (!attrs)
|
|
47
|
+
return null;
|
|
48
|
+
attrs = attrs.slice();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// No source reader configured and no overlay entry — typical in
|
|
52
|
+
// unit tests that don't wire `setSourceAttrsReader`. Treat as
|
|
53
|
+
// "unknown entity" so callers fall back gracefully.
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return attrs;
|
|
57
|
+
}
|
|
58
|
+
/** #7315: only native placement owners use current named/retyped fields.
|
|
59
|
+
* The general body/profile reader retains its existing positional contract. */
|
|
60
|
+
export function readPlacementAttributes(dataStore, view, editor, expressId) {
|
|
61
|
+
if (view.isDeleted(expressId))
|
|
62
|
+
return null;
|
|
63
|
+
const attributes = baseAttributes(dataStore, editor, expressId);
|
|
64
|
+
if (!attributes)
|
|
65
|
+
return null;
|
|
66
|
+
const type = editor.getNewEntity(expressId)?.type ?? dataStore.getEntity(expressId)?.type ?? editor.getEntityType?.(expressId);
|
|
67
|
+
if (!type)
|
|
68
|
+
return null;
|
|
69
|
+
return resolveEffectiveEntityRecord({ type, attributes }, {
|
|
70
|
+
retype: view.getEntityTypeMutation(expressId)?.newType,
|
|
71
|
+
named: view.getAttributeMutationsForEntity(expressId).map(({ name, value }) => [name, value]),
|
|
72
|
+
positional: view.getPositionalMutationsForEntity(expressId) ?? [],
|
|
73
|
+
}, dataStore.schemaVersion).attributes;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Read the effective attribute list for an express id. Overlay-only
|
|
77
|
+
* entities come from the StoreEditor; source entities come from the
|
|
78
|
+
* original buffer. Positional-mutation overrides are layered on top so
|
|
79
|
+
* a previously-translated point reads back its mutated coords.
|
|
80
|
+
*/
|
|
81
|
+
export function readAttributes(dataStore, view,
|
|
82
|
+
/** Only its overlay lookup is read, so the view itself will do. */
|
|
83
|
+
editor, expressId) {
|
|
84
|
+
let attrs = baseAttributes(dataStore, editor, expressId);
|
|
85
|
+
if (!attrs)
|
|
86
|
+
return null;
|
|
87
|
+
// Apply positional mutations so a partially-edited entity reflects
|
|
88
|
+
// its current state (relevant when the user translates the same
|
|
89
|
+
// entity twice — the second read must see the first delta).
|
|
90
|
+
const mutated = view.getPositionalMutationsForEntity(expressId);
|
|
91
|
+
if (mutated) {
|
|
92
|
+
for (const [index, value] of mutated.entries()) {
|
|
93
|
+
attrs[index] = value;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return attrs;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* References take two forms in our attribute graph:
|
|
100
|
+
* - number (the parser normalises `#123` → 123 when reading source)
|
|
101
|
+
* - string `#123` (overlay entities created via `editor.addEntity`
|
|
102
|
+
* carry the raw `#X` form straight through)
|
|
103
|
+
* Treat both as valid so the chain walker works for source-buffer
|
|
104
|
+
* AND overlay-only entities — it's the same conceptual reference.
|
|
105
|
+
*/
|
|
106
|
+
export function asExpressIdRef(value) {
|
|
107
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
108
|
+
return value;
|
|
109
|
+
if (typeof value === 'string' && value.startsWith('#')) {
|
|
110
|
+
const id = parseInt(value.slice(1), 10);
|
|
111
|
+
return Number.isFinite(id) ? id : null;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
export function asCoordinateTriple(value) {
|
|
116
|
+
if (!Array.isArray(value))
|
|
117
|
+
return null;
|
|
118
|
+
if (value.length < 2)
|
|
119
|
+
return null;
|
|
120
|
+
const x = typeof value[0] === 'number' ? value[0] : NaN;
|
|
121
|
+
const y = typeof value[1] === 'number' ? value[1] : NaN;
|
|
122
|
+
// Coordinates may be 2D ([x, y]) — treat the missing Z as 0.
|
|
123
|
+
const z = value.length >= 3 && typeof value[2] === 'number' ? value[2] : 0;
|
|
124
|
+
if (Number.isNaN(x) || Number.isNaN(y))
|
|
125
|
+
return null;
|
|
126
|
+
return [x, y, z];
|
|
127
|
+
}
|
|
128
|
+
export function asDirectionRatios(value) {
|
|
129
|
+
if (!Array.isArray(value))
|
|
130
|
+
return null;
|
|
131
|
+
if (value.length < 2)
|
|
132
|
+
return null;
|
|
133
|
+
const x = typeof value[0] === 'number' ? value[0] : NaN;
|
|
134
|
+
const y = typeof value[1] === 'number' ? value[1] : NaN;
|
|
135
|
+
const z = value.length >= 3 && typeof value[2] === 'number' ? value[2] : 0;
|
|
136
|
+
if (Number.isNaN(x) || Number.isNaN(y))
|
|
137
|
+
return null;
|
|
138
|
+
return [x, y, z];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Resolve the full placement chain for an IfcProduct. Returns `null`
|
|
142
|
+
* if any link is missing or has the wrong shape — callers should treat
|
|
143
|
+
* this as "this entity's placement isn't directly translatable" and
|
|
144
|
+
* surface a clear message rather than crashing.
|
|
145
|
+
*
|
|
146
|
+
* Indices follow the IfcProduct attribute order:
|
|
147
|
+
* [0] GlobalId · [1] OwnerHistory · [2] Name · [3] Description
|
|
148
|
+
* [4] ObjectType · [5] ObjectPlacement · [6] Representation · ...
|
|
149
|
+
*
|
|
150
|
+
* For non-product entities (e.g. profiles, points themselves) attrs[5]
|
|
151
|
+
* either doesn't exist or isn't a placement reference, so we bail.
|
|
152
|
+
*/
|
|
153
|
+
export function resolvePlacementChain(dataStore, view, editor, expressId) {
|
|
154
|
+
const productAttrs = readPlacementAttributes(dataStore, view, editor, expressId);
|
|
155
|
+
if (!productAttrs)
|
|
156
|
+
return null;
|
|
157
|
+
const localPlacementId = asExpressIdRef(productAttrs[5]);
|
|
158
|
+
if (localPlacementId === null || editor.getEntityType(localPlacementId)?.toUpperCase() !== 'IFCLOCALPLACEMENT')
|
|
159
|
+
return null;
|
|
160
|
+
// This API exposes the same point to both numeric edits and the move gizmo.
|
|
161
|
+
// A child-local point below IfcGridPlacement is not a storey-local writable
|
|
162
|
+
// position: returning zero would offer a misleading edit origin (#6232).
|
|
163
|
+
// Inspect the complete parent chain so an intermediate local placement
|
|
164
|
+
// cannot hide the grid frame. File references are iterative and bounded.
|
|
165
|
+
const visited = new Set();
|
|
166
|
+
let ancestor = localPlacementId;
|
|
167
|
+
while (ancestor !== null) {
|
|
168
|
+
if (visited.size >= 10_000 || visited.has(ancestor))
|
|
169
|
+
return null;
|
|
170
|
+
visited.add(ancestor);
|
|
171
|
+
if (editor.getEntityType(ancestor)?.toUpperCase() !== 'IFCLOCALPLACEMENT')
|
|
172
|
+
return null;
|
|
173
|
+
const attrs = readPlacementAttributes(dataStore, view, editor, ancestor);
|
|
174
|
+
if (!attrs)
|
|
175
|
+
return null;
|
|
176
|
+
const parent = attrs[0];
|
|
177
|
+
ancestor = parent === null || parent === undefined ? null : asExpressIdRef(parent);
|
|
178
|
+
if (parent !== null && parent !== undefined && ancestor === null)
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const localPlacementAttrs = readPlacementAttributes(dataStore, view, editor, localPlacementId);
|
|
182
|
+
if (!localPlacementAttrs)
|
|
183
|
+
return null;
|
|
184
|
+
// IfcLocalPlacement.RelativePlacement is at index 1
|
|
185
|
+
// ([0] = PlacementRelTo (parent placement)).
|
|
186
|
+
const axisPlacementId = asExpressIdRef(localPlacementAttrs[1]);
|
|
187
|
+
if (axisPlacementId === null)
|
|
188
|
+
return null;
|
|
189
|
+
const axisAttrs = readPlacementAttributes(dataStore, view, editor, axisPlacementId);
|
|
190
|
+
if (!axisAttrs)
|
|
191
|
+
return null;
|
|
192
|
+
// IfcAxis2Placement3D.Location at index 0.
|
|
193
|
+
const cartesianPointId = asExpressIdRef(axisAttrs[0]);
|
|
194
|
+
if (cartesianPointId === null)
|
|
195
|
+
return null;
|
|
196
|
+
const pointAttrs = readPlacementAttributes(dataStore, view, editor, cartesianPointId);
|
|
197
|
+
if (!pointAttrs)
|
|
198
|
+
return null;
|
|
199
|
+
const coordinates = asCoordinateTriple(pointAttrs[0]);
|
|
200
|
+
if (!coordinates)
|
|
201
|
+
return null;
|
|
202
|
+
return { localPlacementId, axisPlacementId, cartesianPointId, coordinates };
|
|
203
|
+
}
|
|
204
|
+
/** Pure preview shared by atomic preflight and the placement writer. */
|
|
205
|
+
export function translatedCoordinates(coordinates, delta) {
|
|
206
|
+
const next = [coordinates[0] + delta[0], coordinates[1] + delta[1], coordinates[2] + delta[2]];
|
|
207
|
+
return delta.every(Number.isFinite) && next.every(Number.isFinite) ? next : null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Translate an IfcProduct by `delta` (storey-local IFC Z-up). Reads
|
|
211
|
+
* the current coordinates from the chain, adds the delta, writes back
|
|
212
|
+
* via `setPositionalAttribute`. Caller is responsible for batching
|
|
213
|
+
* undo (the upstream `setPositionalAttribute` action already pushes a
|
|
214
|
+
* single mutation onto the model's undo stack).
|
|
215
|
+
*/
|
|
216
|
+
export function translateProduct(dataStore, view, editor, expressId, delta) {
|
|
217
|
+
const chain = resolvePlacementChain(dataStore, view, editor, expressId);
|
|
218
|
+
if (!chain) {
|
|
219
|
+
return {
|
|
220
|
+
ok: false,
|
|
221
|
+
reason: 'Entity placement is not a simple IfcLocalPlacement → IfcAxis2Placement3D → IfcCartesianPoint chain',
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const next = translatedCoordinates(chain.coordinates, delta);
|
|
225
|
+
if (!next)
|
|
226
|
+
return { ok: false, reason: 'Placement translation overflow: derived coordinates must be finite' };
|
|
227
|
+
editor.setPositionalAttribute(chain.cartesianPointId, 0, next);
|
|
228
|
+
return { ok: true, oldCoordinates: chain.coordinates, newCoordinates: next };
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Set the entity's position to an absolute storey-local coordinate.
|
|
232
|
+
* Convenience over `translateProduct` when the caller has a target
|
|
233
|
+
* (e.g. a numeric form bound to current coordinates).
|
|
234
|
+
*/
|
|
235
|
+
export function setProductPosition(dataStore, view, editor, expressId, position) {
|
|
236
|
+
const chain = resolvePlacementChain(dataStore, view, editor, expressId);
|
|
237
|
+
if (!chain) {
|
|
238
|
+
return {
|
|
239
|
+
ok: false,
|
|
240
|
+
reason: 'Entity placement is not a simple IfcLocalPlacement → IfcAxis2Placement3D → IfcCartesianPoint chain',
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if (!position.every(Number.isFinite))
|
|
244
|
+
return { ok: false, reason: 'Placement coordinates must be finite' };
|
|
245
|
+
editor.setPositionalAttribute(chain.cartesianPointId, 0, position);
|
|
246
|
+
return { ok: true, oldCoordinates: chain.coordinates, newCoordinates: position };
|
|
247
|
+
}
|
|
248
|
+
export function resolveRotationState(dataStore, view, editor, expressId) {
|
|
249
|
+
const chain = resolvePlacementChain(dataStore, view, editor, expressId);
|
|
250
|
+
if (!chain)
|
|
251
|
+
return null;
|
|
252
|
+
const axisAttrs = readPlacementAttributes(dataStore, view, editor, chain.axisPlacementId);
|
|
253
|
+
if (!axisAttrs)
|
|
254
|
+
return null;
|
|
255
|
+
// IfcAxis2Placement3D index 2 = RefDirection (an optional IfcDirection ref).
|
|
256
|
+
const refDirectionId = asExpressIdRef(axisAttrs[2]);
|
|
257
|
+
if (refDirectionId === null) {
|
|
258
|
+
return {
|
|
259
|
+
axisPlacementId: chain.axisPlacementId,
|
|
260
|
+
refDirectionId: null,
|
|
261
|
+
refDirection: [1, 0, 0],
|
|
262
|
+
yawZ: 0,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
const dirAttrs = readPlacementAttributes(dataStore, view, editor, refDirectionId);
|
|
266
|
+
if (!dirAttrs)
|
|
267
|
+
return null;
|
|
268
|
+
// IfcDirection index 0 = DirectionRatios (list of doubles).
|
|
269
|
+
const ratios = asDirectionRatios(dirAttrs[0]);
|
|
270
|
+
if (!ratios)
|
|
271
|
+
return null;
|
|
272
|
+
// Yaw about Z derived from the in-plane direction. Numerically
|
|
273
|
+
// stable for any unit-length input; for non-unit inputs we still
|
|
274
|
+
// recover the angle from atan2.
|
|
275
|
+
const yawZ = Math.atan2(ratios[1], ratios[0]);
|
|
276
|
+
return { axisPlacementId: chain.axisPlacementId, refDirectionId, refDirection: ratios, yawZ };
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Rotate an IfcProduct about the storey-up Z axis by `deltaYaw`
|
|
280
|
+
* radians. Updates RefDirection on the IfcAxis2Placement3D in place
|
|
281
|
+
* when one already exists.
|
|
282
|
+
*
|
|
283
|
+
* Refuses to operate when the placement has no explicit RefDirection
|
|
284
|
+
* (the implicit `[1, 0, 0]` STEP default). Materialising a fresh
|
|
285
|
+
* IfcDirection there would require a multi-mutation atomic undo
|
|
286
|
+
* entry to avoid orphans on undo, which the store doesn't have yet.
|
|
287
|
+
* Every entity emitted by `@ifc-lite/create`'s in-store builders
|
|
288
|
+
* carries an explicit RefDirection, so the implicit branch only
|
|
289
|
+
* trips on hand-rolled source-buffer entities — surfacing a clear
|
|
290
|
+
* refusal beats silently leaking entities.
|
|
291
|
+
*/
|
|
292
|
+
export function rotateProductYaw(dataStore, view, editor, expressId, deltaYaw) {
|
|
293
|
+
const state = resolveRotationState(dataStore, view, editor, expressId);
|
|
294
|
+
if (!state) {
|
|
295
|
+
return {
|
|
296
|
+
ok: false,
|
|
297
|
+
reason: 'Entity placement is not a simple IfcLocalPlacement → IfcAxis2Placement3D chain',
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
if (state.refDirectionId === null) {
|
|
301
|
+
return {
|
|
302
|
+
ok: false,
|
|
303
|
+
reason: 'Entity has an implicit reference direction; rotation requires an explicit IfcDirection on its axis placement.',
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const newYaw = state.yawZ + deltaYaw;
|
|
307
|
+
const newRatios = [
|
|
308
|
+
Math.cos(newYaw),
|
|
309
|
+
Math.sin(newYaw),
|
|
310
|
+
state.refDirection[2],
|
|
311
|
+
];
|
|
312
|
+
if (!Number.isFinite(newYaw) || !newRatios.every(Number.isFinite))
|
|
313
|
+
return { ok: false, reason: 'Placement rotation overflow: derived direction must be finite' };
|
|
314
|
+
editor.setPositionalAttribute(state.refDirectionId, 0, newRatios);
|
|
315
|
+
return { ok: true, oldYawZ: state.yawZ, newYawZ: newYaw, newRefDirection: newRatios };
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=placement-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement-core.js","sourceRoot":"","sources":["../../../src/in-store/edit/placement-core.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,eAAe,EAAE,4BAA4B,EAAqB,MAAM,kBAAkB,CAAC;AAUpG,IAAI,sBAAsB,GAA6B,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;IACnE,8FAA8F;IAC9F,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC;IACrC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAChD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACzB,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/F,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAgC;IACnE,sBAAsB,GAAG,MAAM,CAAC;AAClC,CAAC;AAID,iFAAiF;AACjF,SAAS,cAAc,CAAC,SAAuB,EAAE,MAAyC,EAAE,SAAiB;IAC3G,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC/C,IAAI,KAAK,GAAuB,IAAI,CAAC;IACrC,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACrC,CAAC;SAAM,IAAI,sBAAsB,EAAE,CAAC;Q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,EACJ,+GAA+G;SAClH,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,GAAG,QAAQ,CAAC;IACrC,MAAM,SAAS,GAA6B;QAC1C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;QAChB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;QAChB,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;KACtB,CAAC;IACF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,+DAA+D,EAAE,CAAC;IACjK,MAAM,CAAC,sBAAsB,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;IAClE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 2D polygon half-plane clipping. Used by slab / roof / plate /
|
|
3
|
+
* space split to divide a footprint polygon into two halves by a
|
|
4
|
+
* cut line.
|
|
5
|
+
*
|
|
6
|
+
* The cut line is defined by two points in the polygon's local
|
|
7
|
+
* plane. We derive the line's normal (rotated 90° CCW from the
|
|
8
|
+
* direction) and use it to assign each polygon vertex to one of
|
|
9
|
+
* the two half-planes. Sutherland-Hodgman-style edge walk
|
|
10
|
+
* produces the clipped polygon for each side; the union of the
|
|
11
|
+
* two output polygons reconstructs the input (minus any sliver
|
|
12
|
+
* vertices that landed exactly on the cut line, which both halves
|
|
13
|
+
* include as boundary).
|
|
14
|
+
*
|
|
15
|
+
* Returns:
|
|
16
|
+
*
|
|
17
|
+
* - `{ ok: true, left, right }` when the cut intersects the
|
|
18
|
+
* polygon and both halves have ≥ 3 vertices (a valid polygon).
|
|
19
|
+
* - `{ ok: false, reason }` when the cut misses the polygon, is
|
|
20
|
+
* tangent to a single vertex, or produces a degenerate sliver
|
|
21
|
+
* (< 3 vertices on either side).
|
|
22
|
+
*
|
|
23
|
+
* "Left" / "right" naming follows the cut-line direction: walking
|
|
24
|
+
* from A to B, "left" is the half-plane on the user's left
|
|
25
|
+
* (positive cross product of (B-A) with (vertex-A)).
|
|
26
|
+
*/
|
|
27
|
+
export type Point2D = [number, number];
|
|
28
|
+
export type PolygonClipResult = {
|
|
29
|
+
ok: true;
|
|
30
|
+
left: Point2D[];
|
|
31
|
+
right: Point2D[];
|
|
32
|
+
} | {
|
|
33
|
+
ok: false;
|
|
34
|
+
reason: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Split a polygon into two halves by a cut line.
|
|
38
|
+
*
|
|
39
|
+
* Inputs:
|
|
40
|
+
* - `polygon` — outer curve as an ordered list of 2D vertices
|
|
41
|
+
* (CW or CCW; the algorithm is orientation-independent).
|
|
42
|
+
* First vertex should NOT repeat at the end.
|
|
43
|
+
* - `a`, `b` — two points defining the cut line. The line
|
|
44
|
+
* extends infinitely in both directions through these points,
|
|
45
|
+
* so the user-clicked endpoints don't need to lie on the
|
|
46
|
+
* polygon edge.
|
|
47
|
+
*
|
|
48
|
+
* Returns `{ ok: true, left, right }` when both halves are valid
|
|
49
|
+
* polygons (≥ 3 vertices). Otherwise returns `{ ok: false, reason }`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function clipPolygonByLine(polygon: Point2D[], a: Point2D, b: Point2D): PolygonClipResult;
|
|
52
|
+
/**
|
|
53
|
+
* Test helper: is `p` strictly inside `polygon` (ray-cast). Used by
|
|
54
|
+
* the slab-split tool to figure out which half the user clicked on
|
|
55
|
+
* after committing the cut, so we can move selection to that half.
|
|
56
|
+
*/
|
|
57
|
+
export declare function pointInPolygon(polygon: Point2D[], p: Point2D): boolean;
|
|
58
|
+
//# sourceMappingURL=polygon-clip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polygon-clip.d.ts","sourceRoot":"","sources":["../../../src/in-store/edit/polygon-clip.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvC,MAAM,MAAM,iBAAiB,GACzB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,EAAE,CAAA;CAAE,GAC/C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AA4FlC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAAE,EAClB,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,GACT,iBAAiB,CA+BnB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CActE"}
|