@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,86 @@
|
|
|
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
|
+
import { editOwnershipRefusal } from '@ifc-lite/export';
|
|
5
|
+
import { addSlabToStore } from './slab.js';
|
|
6
|
+
import { addRoofToStore } from './roof.js';
|
|
7
|
+
import { addPlateToStore } from './plate.js';
|
|
8
|
+
import { addSpaceToStore } from './space.js';
|
|
9
|
+
import { reassignHostedOpeningsInStore } from './hosted-placement-edit.js';
|
|
10
|
+
import { resolveSpatialAnchor } from './resolve-anchor.js';
|
|
11
|
+
import { toNativeLength } from './anchor.js';
|
|
12
|
+
import { computeSlabSplitGeometry } from './edit/slab-edit.js';
|
|
13
|
+
import { keepsFirstPiece } from './edit/split-guid.js';
|
|
14
|
+
import { pointInPolygon } from './edit/polygon-clip.js';
|
|
15
|
+
import { cloneElementMetadata } from './edit/metadata-clone.js';
|
|
16
|
+
import { planSlabOpeningCarry } from './edit/slab-opening-carry.js';
|
|
17
|
+
function polygonArea(points) {
|
|
18
|
+
let a = 0;
|
|
19
|
+
points.forEach(([x1, y1], i) => {
|
|
20
|
+
const [x2, y2] = points[(i + 1) % points.length];
|
|
21
|
+
a += x1 * y2 - x2 * y1;
|
|
22
|
+
});
|
|
23
|
+
return Math.abs(a / 2);
|
|
24
|
+
}
|
|
25
|
+
/** Whether `polygon` holds `p` — on a vertex / edge counts, as a clipped half keeps the source's corners. */
|
|
26
|
+
function holds(polygon, p) {
|
|
27
|
+
return polygon.some(([x, y]) => Math.abs(x - p[0]) < 1e-9 && Math.abs(y - p[1]) < 1e-9) || pointInPolygon(polygon, p);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A closed polyline profile at `outline` minus `origin` (the source placement's
|
|
31
|
+
* origin), in native units, on an unrotated solid position `rise` above the
|
|
32
|
+
* placement, extruded straight up: the rewrite places the clipped footprint
|
|
33
|
+
* exactly where the chain reader measured it, at the height the source's
|
|
34
|
+
* extrusion started (`baseElevation`: the split predicate only accepts
|
|
35
|
+
* vertical extrusions, which may start below their placement, #6233).
|
|
36
|
+
*/
|
|
37
|
+
export function emitClippedProfile(editor, outline, origin, rise, k) {
|
|
38
|
+
const n = (v) => toNativeLength({ lengthUnitScale: k }, v);
|
|
39
|
+
const ids = [...outline, outline[0]].map(([x, y]) => editor.addEntity('IfcCartesianPoint', [[n(x - origin[0]), n(y - origin[1])]]).expressId);
|
|
40
|
+
const polyline = editor.addEntity('IfcPolyline', [ids.map((id) => `#${id}`)]).expressId;
|
|
41
|
+
const profile = editor.addEntity('IfcArbitraryClosedProfileDef', ['.AREA.', null, `#${polyline}`]).expressId;
|
|
42
|
+
const solidOrigin = editor.addEntity('IfcCartesianPoint', [[0, 0, n(rise)]]).expressId;
|
|
43
|
+
const solidPosition = editor.addEntity('IfcAxis2Placement3D', [`#${solidOrigin}`, null, null]).expressId;
|
|
44
|
+
const up = editor.addEntity('IfcDirection', [[0, 0, 1]]).expressId;
|
|
45
|
+
return { profile, solidPosition, up };
|
|
46
|
+
}
|
|
47
|
+
function buildPiece(editor, anchor, env, type, outline, thickness, baseElevation) {
|
|
48
|
+
const base = { Profile: 'polygon', Position: [0, 0, baseElevation], OuterCurve: outline, Name: env.name, GlobalId: env.newGlobalId };
|
|
49
|
+
const params = { ...base, Thickness: thickness };
|
|
50
|
+
switch (type) {
|
|
51
|
+
case 'IfcSlab': return { expressId: addSlabToStore(editor, anchor, params).slabId, element: { kind: 'slab', params } };
|
|
52
|
+
case 'IfcRoof': return { expressId: addRoofToStore(editor, anchor, params).roofId, element: { kind: 'roof', params } };
|
|
53
|
+
case 'IfcPlate': return { expressId: addPlateToStore(editor, anchor, params).plateId, element: { kind: 'plate', params } };
|
|
54
|
+
default: {
|
|
55
|
+
const params = { ...base, Height: thickness };
|
|
56
|
+
return { expressId: addSpaceToStore(editor, anchor, params).spaceId, element: { kind: 'space', params } };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function splitSlabDraft(env, expressId, chain, cutA, cutB) {
|
|
61
|
+
const ownership = editOwnershipRefusal(env.dataStore, env.view, [chain.extrudedSolidId], new Set([expressId]));
|
|
62
|
+
if (ownership)
|
|
63
|
+
throw new Error(ownership);
|
|
64
|
+
const geo = computeSlabSplitGeometry(chain, cutA, cutB);
|
|
65
|
+
if (!geo.ok)
|
|
66
|
+
throw new Error(geo.reason);
|
|
67
|
+
const leftIsFirst = holds(geo.leftFootprint, chain.footprint[0]);
|
|
68
|
+
const [first, second] = leftIsFirst ? [geo.leftFootprint, geo.rightFootprint] : [geo.rightFootprint, geo.leftFootprint];
|
|
69
|
+
const keepFirst = keepsFirstPiece(polygonArea(first), polygonArea(second));
|
|
70
|
+
const kept = keepFirst ? first : second, cut = keepFirst ? second : first;
|
|
71
|
+
const moves = planSlabOpeningCarry(env, expressId, chain, cut, cutA, cutB, chain.baseElevation);
|
|
72
|
+
const { editor, dataStore, view } = env;
|
|
73
|
+
const anchor = resolveSpatialAnchor(dataStore, env.storeyExpressId, view);
|
|
74
|
+
const added = buildPiece(editor, anchor, env, chain.elementType, cut, geo.thickness, chain.baseElevation);
|
|
75
|
+
const origin = chain.placementOrigin;
|
|
76
|
+
const emitted = emitClippedProfile(editor, kept, origin, chain.baseElevation - origin[2], env.lengthUnitScale);
|
|
77
|
+
editor.setPositionalAttribute(chain.extrudedSolidId, 0, `#${emitted.profile}`);
|
|
78
|
+
editor.setPositionalAttribute(chain.extrudedSolidId, 1, `#${emitted.solidPosition}`);
|
|
79
|
+
editor.setPositionalAttribute(chain.extrudedSolidId, 2, `#${emitted.up}`);
|
|
80
|
+
reassignHostedOpeningsInStore(dataStore, editor, expressId, moves.map(move => ({ ...move, hostId: added.expressId })));
|
|
81
|
+
cloneElementMetadata(dataStore, view, editor, expressId, [added.expressId]);
|
|
82
|
+
const [leftId, rightId] = keepFirst === leftIsFirst ? [expressId, added.expressId] : [added.expressId, expressId];
|
|
83
|
+
return { sourceId: expressId, addedId: added.expressId, leftId, rightId, storeyId: env.storeyExpressId, element: added.element,
|
|
84
|
+
openings: { toLeft: 0, toRight: 0, skipped: 0 } };
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=element-split-slab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-split-slab.js","sourceRoot":"","sources":["../../src/in-store/element-split-slab.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAsB,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAgB,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAIpE,SAAS,WAAW,CAAC,MAA0B;IAC7C,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7B,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,G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yView, StoreEditor } from '@ifc-lite/mutations';
|
|
2
|
+
import type { IfcDataStore } from '@ifc-lite/parser';
|
|
3
|
+
import type { OrdinaryInStoreElement } from './ordinary-element.js';
|
|
4
|
+
import { type GlobalIdScope } from './edit/split-guid.js';
|
|
5
|
+
export type ElementSplitCut = {
|
|
6
|
+
readonly kind: 'wall' | 'linear';
|
|
7
|
+
readonly distance: number;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'slab';
|
|
10
|
+
readonly a: [number, number];
|
|
11
|
+
readonly b: [number, number];
|
|
12
|
+
};
|
|
13
|
+
export interface SplitEnvironment {
|
|
14
|
+
dataStore: IfcDataStore;
|
|
15
|
+
view: MutablePropertyView;
|
|
16
|
+
editor: StoreEditor;
|
|
17
|
+
storeyExpressId: number;
|
|
18
|
+
lengthUnitScale: number;
|
|
19
|
+
newGlobalId: string;
|
|
20
|
+
name: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface ElementSplitResult {
|
|
23
|
+
readonly sourceId: number;
|
|
24
|
+
readonly addedId: number;
|
|
25
|
+
readonly leftId: number;
|
|
26
|
+
readonly rightId: number;
|
|
27
|
+
readonly storeyId: number;
|
|
28
|
+
readonly element: OrdinaryInStoreElement;
|
|
29
|
+
readonly openings: {
|
|
30
|
+
toLeft: number;
|
|
31
|
+
toRight: number;
|
|
32
|
+
skipped: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface ElementSplitRequest {
|
|
36
|
+
readonly expressId: number;
|
|
37
|
+
readonly cut: ElementSplitCut;
|
|
38
|
+
}
|
|
39
|
+
export interface ElementSplitOptions {
|
|
40
|
+
/** Include peer source and live overlay views to avoid federation GUID collisions. */
|
|
41
|
+
readonly globalIdScopes?: readonly GlobalIdScope[];
|
|
42
|
+
}
|
|
43
|
+
/** #6232 D5: the live split predicate and complete writer shared by viewer,
|
|
44
|
+
* SDK and MCP. The larger piece retains identity; a refusal rolls back all
|
|
45
|
+
* helpers, relationship changes, journal entries and allocator state. */
|
|
46
|
+
export declare function splitElementInStore(store: IfcDataStore, editor: StoreEditor, expressId: number, cut: ElementSplitCut, options?: ElementSplitOptions): ElementSplitResult;
|
|
47
|
+
/** A selected set is one atomic operation, including late refusal. */
|
|
48
|
+
export declare function splitElementsInStore(store: IfcDataStore, editor: StoreEditor, requests: readonly ElementSplitRequest[], options?: ElementSplitOptions): ElementSplitResult[];
|
|
49
|
+
//# sourceMappingURL=element-split.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-split.d.ts","sourceRoot":"","sources":["../../src/in-store/element-split.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAKpE,OAAO,EAAwC,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIhG,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC/D;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC;AAC1F,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,YAAY,CAAC;IACxB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AACD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACzE;AACD,MAAM,WAAW,mBAAmB;IAAG,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAA;CAAE;AAClG,MAAM,WAAW,mBAAmB;IAClC,sFAAsF;IACtF,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CACpD;AAED;;yEAEyE;AACzE,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,EACjF,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,CAEpB;AAED,sEAAsE;AACtE,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,mBAAmB,EAAE,EAClF,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,EAAE,CAoBtB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
import { resolveSplitTarget } from './edit/split-target.js';
|
|
5
|
+
import { getModelLengthUnitScale } from './edit/length-unit-scale.js';
|
|
6
|
+
import { effectiveStoreyId } from './edit/effective-storey.js';
|
|
7
|
+
import { readAttributes } from './edit/placement-core.js';
|
|
8
|
+
import { deriveSplitGlobalId, globalIdTakenIn } from './edit/split-guid.js';
|
|
9
|
+
import { splitWallDraft, splitLinearDraft } from './element-split-axis.js';
|
|
10
|
+
import { splitSlabDraft } from './element-split-slab.js';
|
|
11
|
+
/** #6232 D5: the live split predicate and complete writer shared by viewer,
|
|
12
|
+
* SDK and MCP. The larger piece retains identity; a refusal rolls back all
|
|
13
|
+
* helpers, relationship changes, journal entries and allocator state. */
|
|
14
|
+
export function splitElementInStore(store, editor, expressId, cut, options = {}) {
|
|
15
|
+
return splitElementsInStore(store, editor, [{ expressId, cut }], options)[0];
|
|
16
|
+
}
|
|
17
|
+
/** A selected set is one atomic operation, including late refusal. */
|
|
18
|
+
export function splitElementsInStore(store, editor, requests, options = {}) {
|
|
19
|
+
if (requests.length === 0 || requests.length > 10000)
|
|
20
|
+
throw new Error('Split requires between 1 and 10000 elements');
|
|
21
|
+
if (new Set(requests.map(request => request.expressId)).size !== requests.length)
|
|
22
|
+
throw new Error('Split targets must be unique');
|
|
23
|
+
return editor.runAtomic(draft => requests.map(({ expressId, cut }) => {
|
|
24
|
+
const view = draft.getMutationView();
|
|
25
|
+
const scale = getModelLengthUnitScale(store);
|
|
26
|
+
const target = resolveSplitTarget(store, view, draft, expressId, scale);
|
|
27
|
+
if (!target.ok)
|
|
28
|
+
throw new Error(`Split unavailable: ${target.code}`);
|
|
29
|
+
if (target.kind !== cut.kind)
|
|
30
|
+
throw new Error('Split unavailable: kind');
|
|
31
|
+
const storeyId = effectiveStoreyId(store, view, expressId);
|
|
32
|
+
if (storeyId === undefined)
|
|
33
|
+
throw new Error('Split unavailable: storey');
|
|
34
|
+
const attrs = readAttributes(store, view, draft, expressId);
|
|
35
|
+
const env = {
|
|
36
|
+
dataStore: store, view, editor: draft, storeyExpressId: storeyId, lengthUnitScale: scale,
|
|
37
|
+
newGlobalId: deriveSplitGlobalId(typeof attrs?.[0] === 'string' ? attrs[0] : String(expressId), globalIdTakenIn([{ dataStore: store, view }, ...(options.globalIdScopes ?? [])])),
|
|
38
|
+
name: typeof attrs?.[2] === 'string' ? attrs[2] : undefined,
|
|
39
|
+
};
|
|
40
|
+
return splitDraft(env, expressId, target, cut);
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
function splitDraft(env, id, target, cut) {
|
|
44
|
+
if (target.kind === 'wall' && cut.kind === 'wall')
|
|
45
|
+
return splitWallDraft(env, id, target.chain, cut.distance);
|
|
46
|
+
if (target.kind === 'linear' && cut.kind === 'linear')
|
|
47
|
+
return splitLinearDraft(env, id, target.chain, cut.distance);
|
|
48
|
+
if (target.kind === 'slab' && cut.kind === 'slab')
|
|
49
|
+
return splitSlabDraft(env, id, target.chain, cut.a, cut.b);
|
|
50
|
+
throw new Error('Split unavailable: kind');
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=element-split.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-split.js","sourceRoot":"","sources":["../../src/in-store/element-split.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAK/D,OAAO,EAAE,kBAAkB,EAAoB,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAsB,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AA6BzD;;yEAEyE;AACzE,MAAM,UAAU,mBAAmB,CACjC,KAAmB,EAAE,M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CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,gBAAgB,CAAC,GAAG,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpH,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,cAAc,CAAC,GAAG,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9G,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type TransformPlan, type TransformRefusal } from './element-transform-plan.js';
|
|
2
|
+
import type { EditTarget } from './edit/target.js';
|
|
3
|
+
type Vec2 = [number, number];
|
|
4
|
+
export type StoreyTransformOp = {
|
|
5
|
+
readonly kind: 'move';
|
|
6
|
+
readonly delta: Vec2;
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'rotate';
|
|
9
|
+
readonly pivot: Vec2;
|
|
10
|
+
readonly angle: number;
|
|
11
|
+
};
|
|
12
|
+
/** Storey-local IFC XY metres. Caller owns the atomic transaction. */
|
|
13
|
+
export interface ElementTransformInput extends EditTarget {
|
|
14
|
+
readonly selected: readonly number[];
|
|
15
|
+
readonly op: StoreyTransformOp;
|
|
16
|
+
/** Viewer folds a render-space gesture through each owning storey's workplane. */
|
|
17
|
+
operationForStorey?(storeyId: number): StoreyTransformOp;
|
|
18
|
+
/** Different Align targets translate by different storey-local metre deltas. */
|
|
19
|
+
translationForElement?(expressId: number, storeyId: number, delta: Vec2): Vec2;
|
|
20
|
+
storeyOf?(expressId: number): number | null;
|
|
21
|
+
/** Host hooks preserve its live mesh preview and undo bookkeeping. Deltas are parent-local metres. */
|
|
22
|
+
translate?(expressId: number, delta: [number, number, number]): void;
|
|
23
|
+
rotate?(expressId: number, angle: number): void;
|
|
24
|
+
carryJoins?(plan: TransformPlan): readonly number[];
|
|
25
|
+
}
|
|
26
|
+
export declare function describeTransformRefusal(refusal: TransformRefusal): string;
|
|
27
|
+
export interface ElementTransformResult {
|
|
28
|
+
readonly remesh: number[];
|
|
29
|
+
readonly hostsChanged: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function transformElementsInStore(input: ElementTransformInput): ElementTransformResult;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=element-transform-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-transform-edit.d.ts","sourceRoot":"","sources":["../../src/in-store/element-transform-edit.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwB,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAO9G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7B,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAC/C;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,sEAAsE;AACtE,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAC;IAC/B,kFAAkF;IAClF,kBAAkB,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAAC;IACzD,gFAAgF;IAChF,qBAAqB,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/E,QAAQ,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5C,sGAAsG;IACtG,SAAS,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACrE,MAAM,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAChD,UAAU,CAAC,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,MAAM,EAAE,CAAC;CACrD;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAM1E;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,qBAAqB,GAAG,sBAAsB,CA+D7F"}
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
import { editOwnershipRefusal } from '@ifc-lite/export';
|
|
5
|
+
import { planElementTransform } from './element-transform-plan.js';
|
|
6
|
+
import { rotateBy, unrotateBy } from './element-transform-frames.js';
|
|
7
|
+
import { translateProduct, rotateProductYaw, resolvePlacementChain, resolveRotationState, translatedCoordinates } from './edit/placement-core.js';
|
|
8
|
+
import { getModelLengthUnitScale } from './edit/length-unit-scale.js';
|
|
9
|
+
import { toNativeLength } from './anchor.js';
|
|
10
|
+
import { effectiveStoreyId } from './edit/effective-storey.js';
|
|
11
|
+
import { carryWallJoinsInStore } from './element-transform-joins.js';
|
|
12
|
+
export function describeTransformRefusal(refusal) {
|
|
13
|
+
switch (refusal.reason) {
|
|
14
|
+
case 'noStorey': return `#${refusal.expressId} is on no storey`;
|
|
15
|
+
case 'noPlacement': return `#${refusal.expressId} has no placement`;
|
|
16
|
+
default: return `#${refusal.expressId}'s placement does not hang from its storey`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function transformElementsInStore(input) {
|
|
20
|
+
const opFor = (storeyId) => input.operationForStorey?.(storeyId) ?? input.op;
|
|
21
|
+
const plan = planElementTransform({ ...input, storeyOf: input.storeyOf ?? (id => effectiveStoreyId(input.dataStore, input.view, id) ?? null) });
|
|
22
|
+
if (plan.refused.length > 0)
|
|
23
|
+
throw new Error(`Can't move ${plan.refused.map(describeTransformRefusal).join(', ')}.`);
|
|
24
|
+
const steps = plan.roots.map(root => {
|
|
25
|
+
const op = opFor(root.storeyId);
|
|
26
|
+
if (op.kind === 'move') {
|
|
27
|
+
const delta = input.translationForElement?.(root.expressId, root.storeyId, op.delta) ?? op.delta;
|
|
28
|
+
if (!delta.every(Number.isFinite))
|
|
29
|
+
throw new Error('Move delta must be finite');
|
|
30
|
+
return { root, delta, turn: 0 };
|
|
31
|
+
}
|
|
32
|
+
if (!op.pivot.every(Number.isFinite) || !Number.isFinite(op.angle))
|
|
33
|
+
throw new Error('Rotation pivot and angle must be finite');
|
|
34
|
+
if (!root.upright)
|
|
35
|
+
throw new Error(`#${root.expressId} is tilted; only upright elements turn about the vertical.`);
|
|
36
|
+
const offset = [root.origin[0] - op.pivot[0], root.origin[1] - op.pivot[1]];
|
|
37
|
+
const swung = rotateBy([Math.cos(op.angle), Math.sin(op.angle)], offset);
|
|
38
|
+
const delta = [op.pivot[0] + swung[0] - root.origin[0], op.pivot[1] + swung[1] - root.origin[1]];
|
|
39
|
+
if (!delta.every(Number.isFinite))
|
|
40
|
+
throw new Error('Rotation overflow: derived displacement must be finite');
|
|
41
|
+
return { root, delta, turn: op.angle };
|
|
42
|
+
});
|
|
43
|
+
const unit = { lengthUnitScale: getModelLengthUnitScale(input.dataStore) };
|
|
44
|
+
const prepared = steps.map(step => {
|
|
45
|
+
const parentDelta = unrotateBy(step.root.parent.axis, step.delta);
|
|
46
|
+
const nativeDelta = [toNativeLength(unit, parentDelta[0]), toNativeLength(unit, parentDelta[1]), 0];
|
|
47
|
+
return { ...step, parentDelta, nativeDelta };
|
|
48
|
+
});
|
|
49
|
+
const writtenIds = [];
|
|
50
|
+
for (const { root, delta, turn, nativeDelta } of prepared) {
|
|
51
|
+
if (Math.hypot(...delta) > 1e-9) {
|
|
52
|
+
const placement = resolvePlacementChain(input.dataStore, input.view, input.editor, root.expressId);
|
|
53
|
+
if (!placement)
|
|
54
|
+
throw new Error(`#${root.expressId} has no writable local placement`);
|
|
55
|
+
if (!translatedCoordinates(placement.coordinates, nativeDelta))
|
|
56
|
+
throw new Error('Placement translation overflow: derived coordinates must be finite');
|
|
57
|
+
writtenIds.push(placement.cartesianPointId);
|
|
58
|
+
}
|
|
59
|
+
if (turn !== 0) {
|
|
60
|
+
const rotation = resolveRotationState(input.dataStore, input.view, input.editor, root.expressId);
|
|
61
|
+
if (!rotation || rotation.refDirectionId === null)
|
|
62
|
+
throw new Error(`#${root.expressId} has no explicit writable reference direction`);
|
|
63
|
+
writtenIds.push(rotation.refDirectionId);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (new Set(writtenIds).size !== writtenIds.length)
|
|
67
|
+
throw new Error('The selection shares writable placement leaves; shared occurrences cannot be transformed in place');
|
|
68
|
+
const ownership = editOwnershipRefusal(input.dataStore, input.view, writtenIds, new Set([...plan.roots.map(root => root.expressId), ...plan.carried]));
|
|
69
|
+
if (ownership)
|
|
70
|
+
throw new Error(ownership);
|
|
71
|
+
for (const { root, turn, parentDelta: [dx, dy], nativeDelta } of prepared) {
|
|
72
|
+
if (Math.hypot(dx, dy) > 1e-9) {
|
|
73
|
+
if (input.translate)
|
|
74
|
+
input.translate(root.expressId, [dx, dy, 0]);
|
|
75
|
+
else {
|
|
76
|
+
const result = translateProduct(input.dataStore, input.view, input.editor, root.expressId, nativeDelta);
|
|
77
|
+
if (!result.ok)
|
|
78
|
+
throw new Error(result.reason);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (turn !== 0) {
|
|
82
|
+
if (input.rotate)
|
|
83
|
+
input.rotate(root.expressId, turn);
|
|
84
|
+
else {
|
|
85
|
+
const result = rotateProductYaw(input.dataStore, input.view, input.editor, root.expressId, turn);
|
|
86
|
+
if (!result.ok)
|
|
87
|
+
throw new Error(result.reason);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const joined = input.carryJoins ? input.carryJoins(plan) : carryWallJoinsInStore(input, plan, input.op.kind === 'rotate' ? input.op.angle : 0);
|
|
92
|
+
return {
|
|
93
|
+
remesh: [...new Set([...plan.roots.map(root => root.expressId), ...plan.carried, ...joined])],
|
|
94
|
+
hostsChanged: joined.length > 0,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=element-transform-edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-transform-edit.js","sourceRoot":"","sources":["../../src/in-store/element-transform-edit.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAA6C,MAAM,6BAA6B,CAAC;AAC9G,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAClJ,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC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,MAAM,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;QAC7F,YAAY,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC;KAChC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { IfcDataStore } from '@ifc-lite/parser';
|
|
2
|
+
import type { MutablePropertyView } from '@ifc-lite/mutations';
|
|
3
|
+
type Vec2 = [number, number];
|
|
4
|
+
/** A planar rigid frame in the storey frame: `p ↦ R·p + origin`, `R`'s first column `axis`. Metres. */
|
|
5
|
+
export interface PlanFrame {
|
|
6
|
+
origin: Vec2;
|
|
7
|
+
/** Unit x axis. */
|
|
8
|
+
axis: Vec2;
|
|
9
|
+
}
|
|
10
|
+
export declare const IDENTITY_FRAME: PlanFrame;
|
|
11
|
+
export interface PlacementReader {
|
|
12
|
+
readonly dataStore: IfcDataStore;
|
|
13
|
+
readonly view: MutablePropertyView;
|
|
14
|
+
}
|
|
15
|
+
/** A product's `ObjectPlacement` (an `IfcLocalPlacement` id), or null. */
|
|
16
|
+
export declare function objectPlacementOf(r: PlacementReader, productId: number): number | null;
|
|
17
|
+
/** An `IfcLocalPlacement`'s `PlacementRelTo`, or null for a root placement. */
|
|
18
|
+
export declare function parentPlacementOf(r: PlacementReader, placementId: number): number | null;
|
|
19
|
+
/** A placement's origin in its parent's frame, metres (x, y). */
|
|
20
|
+
export declare function placementOrigin(r: PlacementReader, placementId: number): Vec2 | null;
|
|
21
|
+
/**
|
|
22
|
+
* A placement's own plan frame in its parent's frame; null when a link is
|
|
23
|
+
* unreadable or its Z axis is not up — a tilted placement has no planar
|
|
24
|
+
* frame, and turning it about Z would tip it: refuse, never guess.
|
|
25
|
+
*/
|
|
26
|
+
export declare function uprightFrame(r: PlacementReader, placementId: number): PlanFrame | null;
|
|
27
|
+
/** `inner` (in `outer`'s frame) re-expressed in `outer`'s parent frame. */
|
|
28
|
+
export declare function composeFrames(outer: PlanFrame, inner: PlanFrame): PlanFrame;
|
|
29
|
+
/** Rotate `v` by the rotation whose x axis is `axis`. */
|
|
30
|
+
export declare function rotateBy(axis: Vec2, v: readonly [number, number]): Vec2;
|
|
31
|
+
/** The inverse rotation of {@link rotateBy}. */
|
|
32
|
+
export declare function unrotateBy(axis: Vec2, v: readonly [number, number]): Vec2;
|
|
33
|
+
export declare function applyFrame(frame: PlanFrame, p: readonly [number, number]): Vec2;
|
|
34
|
+
/**
|
|
35
|
+
* The frame of `placementId` in the frame of `storeyPlacementId`: its own
|
|
36
|
+
* frame composed with every `PlacementRelTo` hop up to (not including) the
|
|
37
|
+
* storey's placement. `placementId === storeyPlacementId` is the identity.
|
|
38
|
+
* Null when the chain never reaches the storey's placement (a root or a
|
|
39
|
+
* cycle) or a link cannot be read.
|
|
40
|
+
*/
|
|
41
|
+
export declare function frameInStorey(r: PlacementReader, placementId: number, storeyPlacementId: number): PlanFrame | null;
|
|
42
|
+
/** Every placement above `placementId` (its parent first), stopping at a root or a cycle. */
|
|
43
|
+
export declare function placementAncestors(r: PlacementReader, placementId: number): number[];
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=element-transform-frames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-transform-frames.d.ts","sourceRoot":"","sources":["../../src/in-store/element-transform-frames.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAI/D,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE7B,uGAAuG;AACvG,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,IAAI,CAAC;I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E,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAclH;AAED,6FAA6F;AAC7F,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpF"}
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
* Plan frames of product placements, expressed in their storey's frame
|
|
6
|
+
* (charter #6232, C2 move / rotate).
|
|
7
|
+
*
|
|
8
|
+
* `translateEntity` adds a delta in the placement's PARENT frame and
|
|
9
|
+
* `rotateEntity` turns its RefDirection there. A move or turn is picked in the
|
|
10
|
+
* storey's frame (the workplane), so each moved element needs its parent
|
|
11
|
+
* placement's frame in the storey frame — the identity for the common
|
|
12
|
+
* element-under-storey shape, the host's frame for an opening, a composed
|
|
13
|
+
* chain for an assembly part — and its own origin there, to turn it about a
|
|
14
|
+
* pivot. Reads honour the session's overlay (created entities, positional
|
|
15
|
+
* edits), through the canonical current `readPlacementAttributes`.
|
|
16
|
+
*/
|
|
17
|
+
import { walkPlacementChain } from '@ifc-lite/data';
|
|
18
|
+
import { asCoordinateTriple, asDirectionRatios, asExpressIdRef, readPlacementAttributes } from './edit/placement-core.js';
|
|
19
|
+
import { getModelLengthUnitScale } from './edit/length-unit-scale.js';
|
|
20
|
+
export const IDENTITY_FRAME = { origin: [0, 0], axis: [1, 0] };
|
|
21
|
+
function attrs(r, id) {
|
|
22
|
+
return readPlacementAttributes(r.dataStore, r.view, r.view, id);
|
|
23
|
+
}
|
|
24
|
+
/** A product's `ObjectPlacement` (an `IfcLocalPlacement` id), or null. */
|
|
25
|
+
export function objectPlacementOf(r, productId) {
|
|
26
|
+
const product = attrs(r, productId);
|
|
27
|
+
return product ? asExpressIdRef(product[5]) : null;
|
|
28
|
+
}
|
|
29
|
+
/** An `IfcLocalPlacement`'s `PlacementRelTo`, or null for a root placement. */
|
|
30
|
+
export function parentPlacementOf(r, placementId) {
|
|
31
|
+
const placement = attrs(r, placementId);
|
|
32
|
+
return placement ? asExpressIdRef(placement[0]) : null;
|
|
33
|
+
}
|
|
34
|
+
/** The `IfcAxis2Placement3D` attributes of an `IfcLocalPlacement`, or null. */
|
|
35
|
+
function axisPlacement(r, placementId) {
|
|
36
|
+
const placement = attrs(r, placementId);
|
|
37
|
+
const axisId = placement ? asExpressIdRef(placement[1]) : null;
|
|
38
|
+
return axisId === null ? null : attrs(r, axisId);
|
|
39
|
+
}
|
|
40
|
+
/** A placement's origin in its parent's frame, metres (x, y). */
|
|
41
|
+
export function placementOrigin(r, placementId) {
|
|
42
|
+
const axisAttrs = axisPlacement(r, placementId);
|
|
43
|
+
const locationId = axisAttrs ? asExpressIdRef(axisAttrs[0]) : null;
|
|
44
|
+
const location = locationId === null ? null : asCoordinateTriple(attrs(r, locationId)?.[0]);
|
|
45
|
+
if (!location)
|
|
46
|
+
return null;
|
|
47
|
+
const scale = getModelLengthUnitScale(r.dataStore);
|
|
48
|
+
return [location[0] * scale, location[1] * scale];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A placement's own plan frame in its parent's frame; null when a link is
|
|
52
|
+
* unreadable or its Z axis is not up — a tilted placement has no planar
|
|
53
|
+
* frame, and turning it about Z would tip it: refuse, never guess.
|
|
54
|
+
*/
|
|
55
|
+
export function uprightFrame(r, placementId) {
|
|
56
|
+
const axisAttrs = axisPlacement(r, placementId);
|
|
57
|
+
const origin = placementOrigin(r, placementId);
|
|
58
|
+
if (!axisAttrs || !origin)
|
|
59
|
+
return null;
|
|
60
|
+
const zId = asExpressIdRef(axisAttrs[1]);
|
|
61
|
+
if (zId !== null) {
|
|
62
|
+
const z = asDirectionRatios(attrs(r, zId)?.[0]);
|
|
63
|
+
if (!z || Math.hypot(z[0], z[1]) > 1e-6 || z[2] <= 0)
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
let axis = [1, 0];
|
|
67
|
+
const refId = asExpressIdRef(axisAttrs[2]);
|
|
68
|
+
if (refId !== null) {
|
|
69
|
+
const ref = asDirectionRatios(attrs(r, refId)?.[0]);
|
|
70
|
+
const length = ref ? Math.hypot(ref[0], ref[1]) : 0;
|
|
71
|
+
if (!ref || !(length > 1e-9))
|
|
72
|
+
return null;
|
|
73
|
+
axis = [ref[0] / length, ref[1] / length];
|
|
74
|
+
}
|
|
75
|
+
return { origin, axis };
|
|
76
|
+
}
|
|
77
|
+
/** `inner` (in `outer`'s frame) re-expressed in `outer`'s parent frame. */
|
|
78
|
+
export function composeFrames(outer, inner) {
|
|
79
|
+
return { origin: applyFrame(outer, inner.origin), axis: rotateBy(outer.axis, inner.axis) };
|
|
80
|
+
}
|
|
81
|
+
/** Rotate `v` by the rotation whose x axis is `axis`. */
|
|
82
|
+
export function rotateBy(axis, v) {
|
|
83
|
+
return [axis[0] * v[0] - axis[1] * v[1], axis[1] * v[0] + axis[0] * v[1]];
|
|
84
|
+
}
|
|
85
|
+
/** The inverse rotation of {@link rotateBy}. */
|
|
86
|
+
export function unrotateBy(axis, v) {
|
|
87
|
+
return [axis[0] * v[0] + axis[1] * v[1], -axis[1] * v[0] + axis[0] * v[1]];
|
|
88
|
+
}
|
|
89
|
+
export function applyFrame(frame, p) {
|
|
90
|
+
const [x, y] = rotateBy(frame.axis, p);
|
|
91
|
+
return [frame.origin[0] + x, frame.origin[1] + y];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The frame of `placementId` in the frame of `storeyPlacementId`: its own
|
|
95
|
+
* frame composed with every `PlacementRelTo` hop up to (not including) the
|
|
96
|
+
* storey's placement. `placementId === storeyPlacementId` is the identity.
|
|
97
|
+
* Null when the chain never reaches the storey's placement (a root or a
|
|
98
|
+
* cycle) or a link cannot be read.
|
|
99
|
+
*/
|
|
100
|
+
export function frameInStorey(r, placementId, storeyPlacementId) {
|
|
101
|
+
const walked = walkPlacementChain(placementId, (id) => parentPlacementOf(r, id), {
|
|
102
|
+
stopAt: (id) => id === storeyPlacementId,
|
|
103
|
+
});
|
|
104
|
+
// A root or a cycle before the storey's placement: no frame in the storey.
|
|
105
|
+
if (walked.end !== 'stopped')
|
|
106
|
+
return null;
|
|
107
|
+
let frame = IDENTITY_FRAME;
|
|
108
|
+
// Every hop strictly below the storey's own placement, which is the last id.
|
|
109
|
+
for (const id of walked.ids.slice(0, -1)) {
|
|
110
|
+
const own = uprightFrame(r, id);
|
|
111
|
+
if (!own)
|
|
112
|
+
return null;
|
|
113
|
+
frame = composeFrames(own, frame);
|
|
114
|
+
}
|
|
115
|
+
return frame;
|
|
116
|
+
}
|
|
117
|
+
/** Every placement above `placementId` (its parent first), stopping at a root or a cycle. */
|
|
118
|
+
export function placementAncestors(r, placementId) {
|
|
119
|
+
return walkPlacementChain(placementId, (id) => parentPlacementOf(r, id)).ids.slice(1);
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=element-transform-frames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-transform-frames.js","sourceRoot":"","sources":["../../src/in-store/element-transform-frames.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC1H,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAWtE,MAAM,CAAC,MAAM,cAAc,GAAc,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAO1E,SAAS,KAAK,CAAC,CAAkB,EAAE,EAAU;IAC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AAC;QAChC,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;QACtB,KAAK,GAAG,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,kBAAkB,CAAC,CAAkB,EAAE,WAAmB;IACxE,OAAO,kBAAkB,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditTarget } from './edit/target.js';
|
|
2
|
+
import type { TransformPlan } from './element-transform-plan.js';
|
|
3
|
+
export declare function carryWallJoinsInStore(target: EditTarget, plan: TransformPlan, turn: number): readonly number[];
|
|
4
|
+
//# sourceMappingURL=element-transform-joins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-transform-joins.d.ts","sourceRoot":"","sources":["../../src/in-store/element-transform-joins.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAQjE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CA4C9G"}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
import { readWallJoinRels, readWallJoinTarget } from './wall-join-read.js';
|
|
5
|
+
import { reshapeWallsInStore, resolveWallJoinAnchor } from './wall-join-edit.js';
|
|
6
|
+
import { getModelLengthUnitScale } from './edit/length-unit-scale.js';
|
|
7
|
+
/** The parent placement is the storey's own: wall coordinates are storey-local. */
|
|
8
|
+
const underStorey = (parent) => parent.origin[0] === 0 && parent.origin[1] === 0 && parent.axis[0] === 1 && parent.axis[1] === 0;
|
|
9
|
+
export function carryWallJoinsInStore(target, plan, turn) {
|
|
10
|
+
if (String(target.dataStore.schemaVersion).toUpperCase() === 'IFC5' || !target.dataStore.source?.byteLength)
|
|
11
|
+
return [];
|
|
12
|
+
const { dataStore, view } = target;
|
|
13
|
+
const scale = getModelLengthUnitScale(dataStore);
|
|
14
|
+
const rigid = new Set([...plan.roots.map((r) => r.expressId), ...plan.carried]);
|
|
15
|
+
const [cos, sin] = [Math.cos(turn), Math.sin(turn)];
|
|
16
|
+
const edits = new Map();
|
|
17
|
+
const refresh = [];
|
|
18
|
+
for (const root of plan.roots) {
|
|
19
|
+
if (!underStorey(root.parent))
|
|
20
|
+
continue;
|
|
21
|
+
const moved = readWallJoinTarget(dataStore, view, root.expressId, scale);
|
|
22
|
+
if (!moved)
|
|
23
|
+
continue;
|
|
24
|
+
// Where a point of the wall went: the wall's placement turned by `turn` about its own origin, then moved.
|
|
25
|
+
const carried = (p) => {
|
|
26
|
+
const dx = p[0] - root.origin[0];
|
|
27
|
+
const dy = p[1] - root.origin[1];
|
|
28
|
+
return [moved.origin[0] + cos * dx - sin * dy, moved.origin[1] + sin * dx + cos * dy];
|
|
29
|
+
};
|
|
30
|
+
const rels = readWallJoinRels(dataStore, view, new Set([root.expressId]));
|
|
31
|
+
let checked = false;
|
|
32
|
+
for (const rel of rels) {
|
|
33
|
+
const own = rel.relatingId === root.expressId;
|
|
34
|
+
const otherId = own ? rel.relatedId : rel.relatingId;
|
|
35
|
+
const [ownConnection, otherConnection] = own
|
|
36
|
+
? [rel.relatingConnection, rel.relatedConnection]
|
|
37
|
+
: [rel.relatedConnection, rel.relatingConnection];
|
|
38
|
+
if (rigid.has(otherId))
|
|
39
|
+
continue;
|
|
40
|
+
// A join with a wall that stays is checked against the new place, whichever wall ends on which.
|
|
41
|
+
checked = true;
|
|
42
|
+
if (otherConnection === 'ATPATH')
|
|
43
|
+
continue;
|
|
44
|
+
const other = readWallJoinTarget(dataStore, view, otherId, scale);
|
|
45
|
+
if (!other)
|
|
46
|
+
continue;
|
|
47
|
+
const end = otherConnection === 'ATSTART' ? 'start' : 'end';
|
|
48
|
+
const joint = ownConnection === 'ATPATH'
|
|
49
|
+
? carried(other.wall[end])
|
|
50
|
+
: ownConnection === 'ATSTART' ? moved.wall.start : moved.wall.end;
|
|
51
|
+
edits.set(otherId, { ...edits.get(otherId), wallId: otherId, [end]: joint });
|
|
52
|
+
}
|
|
53
|
+
if (checked)
|
|
54
|
+
refresh.push(root.expressId);
|
|
55
|
+
}
|
|
56
|
+
if (refresh.length === 0)
|
|
57
|
+
return [];
|
|
58
|
+
const outcome = reshapeWallsInStore(target.editor, dataStore, resolveWallJoinAnchor(dataStore, view), [...edits.values()], { refresh });
|
|
59
|
+
return outcome.walls.filter((id) => !rigid.has(id));
|
|
60
|
+
}
|
|
61
|
+
;
|
|
62
|
+
//# sourceMappingURL=element-transform-joins.js.map
|