@bitbybit-dev/ifc 1.5.0-rc.0 → 1.6.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/lib/api/dto-registry.js +3 -1
- package/lib/api/ifc-service.d.ts +10 -5
- package/lib/api/ifc-service.js +7 -5
- package/lib/api/inputs/ifc-inputs.d.ts +121 -5
- package/lib/api/inputs/ifc-inputs.js +162 -5
- package/lib/api/resolved-inputs/index.d.ts +6 -3
- package/lib/api/services/doors.js +4 -1
- package/lib/api/services/elements.d.ts +28 -0
- package/lib/api/services/elements.js +60 -0
- package/lib/api/services/geometry.js +3 -3
- package/lib/api/services/index.d.ts +1 -0
- package/lib/api/services/index.js +1 -0
- package/lib/api/services/member-support.js +2 -2
- package/lib/api/services/model.js +3 -3
- package/lib/api/services/openings.js +16 -11
- package/lib/api/services/properties.js +4 -3
- package/lib/api/services/site.js +3 -1
- package/lib/api/services/spaces.js +1 -0
- package/lib/api/services/walls.d.ts +7 -5
- package/lib/api/services/walls.js +15 -7
- package/lib/api/services/windows.js +5 -2
- package/lib/build/assemblies.js +1 -1
- package/lib/build/bodied-elements.d.ts +5 -0
- package/lib/build/bodied-elements.js +35 -0
- package/lib/build/build-types.d.ts +29 -2
- package/lib/build/checks.d.ts +2 -0
- package/lib/build/checks.js +14 -0
- package/lib/build/clipping-registry.d.ts +3 -0
- package/lib/build/clipping-registry.js +39 -0
- package/lib/build/constants.d.ts +0 -1
- package/lib/build/constants.js +0 -1
- package/lib/build/entity-writer.js +4 -6
- package/lib/build/exact-bodies.d.ts +4 -0
- package/lib/build/exact-bodies.js +273 -0
- package/lib/build/fillings.js +1 -1
- package/lib/build/math.d.ts +3 -2
- package/lib/build/math.js +24 -16
- package/lib/build/measure.js +11 -11
- package/lib/build/moving.js +12 -11
- package/lib/build/openings.js +1 -1
- package/lib/build/outlines.d.ts +2 -0
- package/lib/build/outlines.js +14 -2
- package/lib/build/placement.js +4 -3
- package/lib/build/project.js +1 -1
- package/lib/build/quantities.js +13 -11
- package/lib/build/roof-clipping.js +5 -5
- package/lib/build/roofs.js +17 -16
- package/lib/build/site.js +9 -13
- package/lib/build/slab-openings.js +4 -4
- package/lib/build/slabs-columns-beams.js +16 -19
- package/lib/build/solids.js +3 -2
- package/lib/build/spaces.js +8 -6
- package/lib/build/spatial.js +1 -1
- package/lib/build/wall-edits.js +21 -15
- package/lib/build/wall-geometry.d.ts +2 -1
- package/lib/build/wall-geometry.js +48 -18
- package/lib/build/wall-parameters.js +7 -3
- package/lib/build/walls.js +15 -8
- package/lib/geometry/advanced.js +12 -13
- package/lib/geometry/curves.d.ts +2 -1
- package/lib/geometry/curves.js +27 -10
- package/lib/geometry/edges.js +6 -9
- package/lib/geometry/elements.d.ts +1 -1
- package/lib/geometry/elements.js +22 -5
- package/lib/geometry/exact-brep.constants.d.ts +1 -0
- package/lib/geometry/exact-brep.constants.js +1 -0
- package/lib/geometry/exact-brep.d.ts +11 -0
- package/lib/geometry/exact-brep.js +371 -0
- package/lib/geometry/faceted.d.ts +1 -0
- package/lib/geometry/faceted.js +20 -8
- package/lib/geometry/geometry-types.d.ts +9 -1
- package/lib/geometry/groups.js +2 -1
- package/lib/geometry/items.d.ts +2 -0
- package/lib/geometry/items.js +34 -5
- package/lib/geometry/operators.js +1 -1
- package/lib/geometry/profiles.js +9 -5
- package/lib/geometry/surfaces.constants.d.ts +1 -0
- package/lib/geometry/surfaces.constants.js +1 -0
- package/lib/geometry/surfaces.d.ts +1 -1
- package/lib/geometry/surfaces.js +8 -6
- package/lib/geometry/swept-solids.constants.d.ts +1 -0
- package/lib/geometry/swept-solids.constants.js +1 -0
- package/lib/geometry/swept-solids.js +22 -12
- package/lib/model/io.js +1 -1
- package/lib/model/owner-history.d.ts +2 -0
- package/lib/model/owner-history.js +101 -0
- package/lib/model/snapshot.d.ts +1 -0
- package/lib/model/snapshot.js +4 -0
- package/lib/model/transaction.js +19 -10
- package/lib/model/upgrade-rows.d.ts +26 -0
- package/lib/model/upgrade-rows.js +240 -0
- package/lib/model/upgrade-types.d.ts +9 -0
- package/lib/model/upgrade-types.js +1 -0
- package/lib/model/upgrade.js +20 -7
- package/lib/schema/registry.js +1 -1
- package/package.json +2 -3
package/lib/build/roofs.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { WORLD_AXES } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
2
|
-
import { add2, cross2, length2, scale2, subtract2 } from "@bitbybit-dev/base/lib/api/services/helpers/vectors";
|
|
3
|
-
import { wound2 } from "@bitbybit-dev/base/lib/api/services/helpers/polygons";
|
|
1
|
+
import { WORLD_AXES } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
|
+
import { add2, cross2, dot2, length2, scale2, subtract2 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/vectors";
|
|
3
|
+
import { wound2 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/polygons";
|
|
4
4
|
import * as Inputs from "../api/inputs";
|
|
5
5
|
import { enumValue, ref } from "../step/values";
|
|
6
|
-
import { AGGREGATION
|
|
6
|
+
import { AGGREGATION } from "./constants";
|
|
7
7
|
import { bodyContext } from "./contexts";
|
|
8
8
|
import { associateNewMaterial, layerSetThickness, layerSetUsage } from "./materials";
|
|
9
|
-
import {
|
|
9
|
+
import { direction2Of } from "./math";
|
|
10
10
|
import { cleanOutline } from "./outlines";
|
|
11
11
|
import { objectPlacementOf } from "./placement";
|
|
12
12
|
import { relate } from "./relationships";
|
|
13
13
|
import { containIn } from "./spatial";
|
|
14
|
+
import { radiansOf } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/scalars";
|
|
14
15
|
const RECTANGLE_CORNERS = 4;
|
|
15
16
|
const RIGHT_ANGLE_COSINE = 1e-6;
|
|
16
17
|
const MAX_PITCH_DEGREES = 89;
|
|
@@ -26,24 +27,24 @@ function rectangle(points, tolerance) {
|
|
|
26
27
|
throw new Error(`A roof's outline is a rectangle of ${RECTANGLE_CORNERS} corners, got ${corners.length}`);
|
|
27
28
|
}
|
|
28
29
|
corners.forEach((corner, index) => {
|
|
29
|
-
const before =
|
|
30
|
-
const after =
|
|
31
|
-
if (Math.abs(before
|
|
30
|
+
const before = direction2Of(subtract2(corner, corners[(index + RECTANGLE_CORNERS - 1) % RECTANGLE_CORNERS]));
|
|
31
|
+
const after = direction2Of(subtract2(corners[(index + 1) % RECTANGLE_CORNERS], corner));
|
|
32
|
+
if (Math.abs(dot2(before, after)) > RIGHT_ANGLE_COSINE) {
|
|
32
33
|
throw new Error(`A roof's outline is a rectangle, and its corner ${index} is not a right angle`);
|
|
33
34
|
}
|
|
34
35
|
});
|
|
35
36
|
return corners;
|
|
36
37
|
}
|
|
37
38
|
function expanded(corners, overhang) {
|
|
38
|
-
const along =
|
|
39
|
-
const across =
|
|
39
|
+
const along = direction2Of(subtract2(corners[1], corners[0]));
|
|
40
|
+
const across = direction2Of(subtract2(corners[3], corners[0]));
|
|
40
41
|
const out = (point, alongSign, acrossSign) => add2(point, add2(scale2(along, alongSign * overhang), scale2(across, acrossSign * overhang)));
|
|
41
42
|
return [out(corners[0], -1, -1), out(corners[1], 1, -1), out(corners[2], 1, 1), out(corners[3], -1, 1)];
|
|
42
43
|
}
|
|
43
44
|
function eavesPlane(corners, from, outline) {
|
|
44
45
|
const start = corners[from];
|
|
45
|
-
const along =
|
|
46
|
-
const across =
|
|
46
|
+
const along = direction2Of(subtract2(corners[(from + 1) % RECTANGLE_CORNERS], start));
|
|
47
|
+
const across = direction2Of(subtract2(corners[(from + RECTANGLE_CORNERS - 1) % RECTANGLE_CORNERS], start));
|
|
47
48
|
return { origin: start, along, inward: across, outline };
|
|
48
49
|
}
|
|
49
50
|
function gablePlanes(q) {
|
|
@@ -54,8 +55,8 @@ function gablePlanes(q) {
|
|
|
54
55
|
}
|
|
55
56
|
function hipPlanes(q, tolerance) {
|
|
56
57
|
const corners = length2(subtract2(q[1], q[0])) >= length2(subtract2(q[2], q[1])) ? q : [q[1], q[2], q[3], q[0]];
|
|
57
|
-
const along =
|
|
58
|
-
const across =
|
|
58
|
+
const along = direction2Of(subtract2(corners[1], corners[0]));
|
|
59
|
+
const across = direction2Of(subtract2(corners[3], corners[0]));
|
|
59
60
|
const half = length2(subtract2(corners[3], corners[0])) / 2;
|
|
60
61
|
const ridgeStart = add2(corners[0], add2(scale2(along, half), scale2(across, half)));
|
|
61
62
|
const ridgeEnd = add2(corners[1], add2(scale2(along, -half), scale2(across, half)));
|
|
@@ -85,7 +86,7 @@ function planeFrame(plane, height, slope) {
|
|
|
85
86
|
}
|
|
86
87
|
function inPlane(plane, frame, slope, point) {
|
|
87
88
|
const offset = subtract2(point, plane.origin);
|
|
88
|
-
return [offset[
|
|
89
|
+
return [dot2(offset, [frame.x[0], frame.x[1]]), dot2(offset, [plane.inward[0], plane.inward[1]]) / Math.cos(slope)];
|
|
89
90
|
}
|
|
90
91
|
export function createRoof(tx, writer, spec, tolerance) {
|
|
91
92
|
var _a;
|
|
@@ -100,7 +101,7 @@ export function createRoof(tx, writer, spec, tolerance) {
|
|
|
100
101
|
if (!(spec.overhang >= 0)) {
|
|
101
102
|
throw new Error(`A roof's overhang is zero or more, got ${spec.overhang}`);
|
|
102
103
|
}
|
|
103
|
-
const slope = flat ? 0 : spec.pitch
|
|
104
|
+
const slope = flat ? 0 : radiansOf(spec.pitch);
|
|
104
105
|
const outer = expanded(rectangle(spec.outline, tolerance), spec.overhang);
|
|
105
106
|
const eaves = spec.baseOffset - spec.overhang * Math.tan(slope);
|
|
106
107
|
const placement = writer.localPlacement(objectPlacementOf(tx, spec.storey), WORLD_AXES);
|
package/lib/build/site.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { WORLD_AXES } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
2
|
-
import { frustum, icosphere } from "@bitbybit-dev/base/lib/api/services/helpers/mesh-primitives";
|
|
3
|
-
import {
|
|
1
|
+
import { WORLD_AXES } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
|
+
import { frustum, icosphere } from "@bitbybit-dev/base/lib/api/services/helpers/mesh/mesh-primitives";
|
|
3
|
+
import { wound2 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/polygons";
|
|
4
4
|
import { enumValue, ref } from "../step/values";
|
|
5
5
|
import { POINT3_SIZE, TRIANGLE_CORNERS } from "./constants";
|
|
6
6
|
import { bodyContext } from "./contexts";
|
|
7
7
|
import { associateNewMaterial, dressParts, materialsOfParts, requireMaterial } from "./materials";
|
|
8
|
-
import { cleanOutline } from "./outlines";
|
|
8
|
+
import { cleanHoles, cleanOutline, measuredFrom } from "./outlines";
|
|
9
9
|
import { objectPlacementOf } from "./placement";
|
|
10
10
|
import { containIn } from "./spatial";
|
|
11
11
|
const GEOGRAPHIC_ELEMENT = "IfcGeographicElement";
|
|
@@ -56,15 +56,11 @@ export function createTerrain(tx, writer, spec, tolerance) {
|
|
|
56
56
|
const site = onlySite(tx);
|
|
57
57
|
const material = spec.material === undefined ? undefined : requireMaterial(tx, spec.material);
|
|
58
58
|
const outer = wound2(cleanOutline(spec.outline, tolerance, "outline"), true);
|
|
59
|
-
const holes = spec.holes
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return wound2(cleaned, false);
|
|
65
|
-
});
|
|
66
|
-
const placement = writer.localPlacement(objectPlacementOf(tx, site), Object.assign(Object.assign({}, WORLD_AXES), { origin: [0, 0, spec.elevation] }));
|
|
67
|
-
const solid = writer.extrusion(writer.profile({ outer, holes }), WORLD_AXES, spec.depth, [0, 0, -1]);
|
|
59
|
+
const holes = cleanHoles(outer, spec.holes, tolerance, "terrain");
|
|
60
|
+
const anchor = outer[0];
|
|
61
|
+
const placement = writer.localPlacement(objectPlacementOf(tx, site), Object.assign(Object.assign({}, WORLD_AXES), { origin: [anchor[0], anchor[1], spec.elevation] }));
|
|
62
|
+
const profile = writer.profile({ outer: measuredFrom(outer, anchor), holes: holes.map((hole) => measuredFrom(hole, anchor)) });
|
|
63
|
+
const solid = writer.extrusion(profile, WORLD_AXES, spec.depth, [0, 0, -1]);
|
|
68
64
|
const body = writer.shapeRepresentation(bodyContext(tx, writer), "Body", "SweptSolid", [solid]);
|
|
69
65
|
const terrain = writer.create(GEOGRAPHIC_ELEMENT, {
|
|
70
66
|
GlobalId: tx.globalId(spec.id),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { WORLD_AXES, vectorToWorld } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
2
|
-
import { wound2 } from "@bitbybit-dev/base/lib/api/services/helpers/polygons";
|
|
1
|
+
import { WORLD_AXES, vectorToWorld } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
|
+
import { wound2 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/polygons";
|
|
3
3
|
import { enumValue, isReference, ref } from "../step/values";
|
|
4
4
|
import { VERTICAL_COSINE, VOIDING } from "./constants";
|
|
5
5
|
import { bodyContext } from "./contexts";
|
|
6
6
|
import { polylinePoints } from "./curves";
|
|
7
|
-
import {
|
|
7
|
+
import { direction3Of, placedOnPlan } from "./math";
|
|
8
8
|
import { openingMargin } from "./openings";
|
|
9
9
|
import { cleanOutline, edgesCross, isInsideOrOn } from "./outlines";
|
|
10
10
|
import { absoluteFrame, directionOf, objectPlacementOf } from "./placement";
|
|
@@ -24,7 +24,7 @@ function extrudedSolidOf(reader, slab) {
|
|
|
24
24
|
return solid;
|
|
25
25
|
}
|
|
26
26
|
function verticalSpan(reader, slab, solid, frame) {
|
|
27
|
-
const direction = vectorToWorld(frame,
|
|
27
|
+
const direction = vectorToWorld(frame, direction3Of(directionOf(reader, reader.attribute(solid, "ExtrudedDirection"), [0, 0, 1])));
|
|
28
28
|
const depth = reader.attribute(solid, "Depth");
|
|
29
29
|
if (typeof depth !== "number" || Math.abs(frame.z[2]) < VERTICAL_COSINE || Math.abs(direction[2]) < VERTICAL_COSINE) {
|
|
30
30
|
throw new Error(`${describeObject(reader, slab)} is not extruded straight up or down, so this library does not cut it`);
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { WORLD_AXES } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
2
|
-
import { cross3, length3, subtract3 } from "@bitbybit-dev/base/lib/api/services/helpers/vectors";
|
|
3
|
-
import {
|
|
1
|
+
import { WORLD_AXES } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
|
+
import { add3, cross3, length3, scale3, subtract3 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/vectors";
|
|
3
|
+
import { wound2 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/polygons";
|
|
4
4
|
import { enumValue, ref } from "../step/values";
|
|
5
|
-
import {
|
|
5
|
+
import { VERTICAL_COSINE } from "./constants";
|
|
6
6
|
import { bodyContext } from "./contexts";
|
|
7
7
|
import { associateMaterial, associateNewMaterial, layerSetThickness, layerSetUsage } from "./materials";
|
|
8
|
-
import { frameFrom,
|
|
8
|
+
import { frameFrom, direction3Of } from "./math";
|
|
9
9
|
import { objectPlacementOf } from "./placement";
|
|
10
10
|
import { writeProfile } from "./profiles";
|
|
11
11
|
import { containIn } from "./spatial";
|
|
12
|
-
import { cleanOutline } from "./outlines";
|
|
12
|
+
import { cleanHoles, cleanOutline, measuredFrom } from "./outlines";
|
|
13
|
+
import { radiansOf } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/scalars";
|
|
13
14
|
export function createSlab(tx, writer, spec, tolerance) {
|
|
14
15
|
var _a;
|
|
15
16
|
const thickness = layerSetThickness(tx, spec.layerSet);
|
|
@@ -17,15 +18,11 @@ export function createSlab(tx, writer, spec, tolerance) {
|
|
|
17
18
|
throw new Error("A slab's layers must add up to more than zero thickness");
|
|
18
19
|
}
|
|
19
20
|
const outer = wound2(cleanOutline(spec.outline, tolerance, "outline"), true);
|
|
20
|
-
const holes = spec.holes
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return wound2(cleaned, false);
|
|
26
|
-
});
|
|
27
|
-
const placement = writer.localPlacement(objectPlacementOf(tx, spec.storey), Object.assign(Object.assign({}, WORLD_AXES), { origin: [0, 0, spec.topOffset] }));
|
|
28
|
-
const solid = writer.extrusion(writer.profile({ outer, holes }), WORLD_AXES, thickness, [0, 0, -1]);
|
|
21
|
+
const holes = cleanHoles(outer, spec.holes, tolerance, "slab");
|
|
22
|
+
const anchor = outer[0];
|
|
23
|
+
const placement = writer.localPlacement(objectPlacementOf(tx, spec.storey), Object.assign(Object.assign({}, WORLD_AXES), { origin: [anchor[0], anchor[1], spec.topOffset] }));
|
|
24
|
+
const profile = writer.profile({ outer: measuredFrom(outer, anchor), holes: holes.map((hole) => measuredFrom(hole, anchor)) });
|
|
25
|
+
const solid = writer.extrusion(profile, WORLD_AXES, thickness, [0, 0, -1]);
|
|
29
26
|
const body = writer.shapeRepresentation(bodyContext(tx, writer), "Body", "SweptSolid", [solid]);
|
|
30
27
|
const slab = writer.create("IfcSlab", {
|
|
31
28
|
GlobalId: tx.globalId(spec.id),
|
|
@@ -43,13 +40,13 @@ export function memberFrame(start, end, rotationDegrees) {
|
|
|
43
40
|
if (!(length3(along) > 0)) {
|
|
44
41
|
throw new Error("A member's start and end must be apart");
|
|
45
42
|
}
|
|
46
|
-
const z =
|
|
47
|
-
const horizontal = Math.abs(z[2]) >= VERTICAL_COSINE ? [1, 0, 0] :
|
|
43
|
+
const z = direction3Of(along);
|
|
44
|
+
const horizontal = Math.abs(z[2]) >= VERTICAL_COSINE ? [1, 0, 0] : direction3Of(cross3([0, 0, 1], z));
|
|
48
45
|
const base = frameFrom(start, z, horizontal);
|
|
49
|
-
const angle = rotationDegrees
|
|
46
|
+
const angle = radiansOf(rotationDegrees);
|
|
50
47
|
const cos = Math.cos(angle);
|
|
51
48
|
const sin = Math.sin(angle);
|
|
52
|
-
const x =
|
|
49
|
+
const x = add3(scale3(base.x, cos), scale3(base.y, sin));
|
|
53
50
|
return frameFrom(start, z, x);
|
|
54
51
|
}
|
|
55
52
|
export function createMember(tx, writer, kind, spec) {
|
package/lib/build/solids.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { WORLD_AXES, pointToWorld } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
1
|
+
import { WORLD_AXES, pointToWorld } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
2
|
import { isReference } from "../step/values";
|
|
3
3
|
import { axisPlacementFrame, directionOf } from "./placement";
|
|
4
|
+
import { length3 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/vectors";
|
|
4
5
|
export function frameOf(reader, placement) {
|
|
5
6
|
return isReference(placement) ? axisPlacementFrame(reader, placement.ref) : WORLD_AXES;
|
|
6
7
|
}
|
|
@@ -21,7 +22,7 @@ export function extrusionCorners(reader, item) {
|
|
|
21
22
|
const profileFrame = frameOf(reader, reader.attribute(profile.ref, "Position"));
|
|
22
23
|
const solidFrame = frameOf(reader, reader.attribute(item, "Position"));
|
|
23
24
|
const direction = directionOf(reader, reader.attribute(item, "ExtrudedDirection"), [0, 0, 1]);
|
|
24
|
-
const scale = depth /
|
|
25
|
+
const scale = depth / length3(direction);
|
|
25
26
|
const corners = [];
|
|
26
27
|
for (const x of [-xDim / 2, xDim / 2]) {
|
|
27
28
|
for (const y of [-yDim / 2, yDim / 2]) {
|
package/lib/build/spaces.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { WORLD_AXES, composeAxes } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
2
|
-
import { wound2 } from "@bitbybit-dev/base/lib/api/services/helpers/polygons";
|
|
1
|
+
import { WORLD_AXES, composeAxes } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
|
+
import { wound2 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/polygons";
|
|
3
3
|
import { enumValue, ref, textValue } from "../step/values";
|
|
4
4
|
import { AGGREGATION, VERTICAL_COSINE } from "./constants";
|
|
5
5
|
import { bodyContext } from "./contexts";
|
|
6
6
|
import { extrudedBodyOf } from "./measure";
|
|
7
|
-
import { cleanOutline } from "./outlines";
|
|
7
|
+
import { cleanOutline, measuredFrom } from "./outlines";
|
|
8
8
|
import { absoluteFrame, directionOf, objectPlacementOf } from "./placement";
|
|
9
9
|
import { appendToRelationship, relatingOf } from "./relationships";
|
|
10
|
+
import { length3 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/vectors";
|
|
10
11
|
const SPACE = "IfcSpace";
|
|
11
12
|
export function createSpace(tx, writer, spec, tolerance) {
|
|
12
13
|
var _a, _b;
|
|
@@ -14,8 +15,9 @@ export function createSpace(tx, writer, spec, tolerance) {
|
|
|
14
15
|
throw new Error(`A space's height must be more than zero, got ${spec.height}`);
|
|
15
16
|
}
|
|
16
17
|
const outline = wound2(cleanOutline(spec.outline, tolerance, "outline"), true);
|
|
17
|
-
const
|
|
18
|
-
const
|
|
18
|
+
const anchor = outline[0];
|
|
19
|
+
const placement = writer.localPlacement(objectPlacementOf(tx, spec.storey), Object.assign(Object.assign({}, WORLD_AXES), { origin: [anchor[0], anchor[1], spec.baseOffset] }));
|
|
20
|
+
const solid = writer.extrusion(writer.profile({ outer: measuredFrom(outline, anchor), holes: [] }), WORLD_AXES, spec.height);
|
|
19
21
|
const body = writer.shapeRepresentation(bodyContext(tx, writer), "Body", "SweptSolid", [solid]);
|
|
20
22
|
const space = writer.create(SPACE, {
|
|
21
23
|
GlobalId: tx.globalId(spec.id),
|
|
@@ -33,7 +35,7 @@ function extentOf(reader, space) {
|
|
|
33
35
|
const extruded = extrudedBodyOf(reader, space);
|
|
34
36
|
const frame = extruded === undefined ? undefined : composeAxes(absoluteFrame(reader, objectPlacementOf(reader, space)), extruded.frame);
|
|
35
37
|
const direction = extruded === undefined ? undefined : directionOf(reader, reader.attribute(extruded.solid, "ExtrudedDirection"), [0, 0, 1]);
|
|
36
|
-
const upright = frame !== undefined && direction !== undefined && frame.z[2] >= VERTICAL_COSINE && direction[2] /
|
|
38
|
+
const upright = frame !== undefined && direction !== undefined && frame.z[2] >= VERTICAL_COSINE && direction[2] / length3(direction) >= VERTICAL_COSINE;
|
|
37
39
|
return extruded && upright ? [extruded.shape.area, extruded.depth] : [0, 0];
|
|
38
40
|
}
|
|
39
41
|
export function spacesOf(reader, storey) {
|
package/lib/build/spatial.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WORLD_AXES } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
1
|
+
import { WORLD_AXES } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
2
|
import { keyGlobalId } from "../model/guid";
|
|
3
3
|
import { enumValue, ref, textValue } from "../step/values";
|
|
4
4
|
import { AGGREGATION, CONTAINMENT } from "./constants";
|
package/lib/build/wall-edits.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { WORLD_AXES, composeAxes, pointToWorld, relativeAxes } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
2
|
-
import { length2, length3, subtract2, subtract3 } from "@bitbybit-dev/base/lib/api/services/helpers/vectors";
|
|
1
|
+
import { WORLD_AXES, composeAxes, pointToWorld, relativeAxes } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
|
+
import { length2, length3, subtract2, subtract3 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/vectors";
|
|
3
3
|
import { isReference, ref } from "../step/values";
|
|
4
4
|
import { MATERIAL_ASSOCIATION, TYPE_DEFINITION } from "./constants";
|
|
5
5
|
import { axisContext } from "./contexts";
|
|
6
|
-
import { requiredReference } from "./checks";
|
|
7
|
-
import { associateNewMaterial, layerSetThickness, layerSetUsage, materialOf } from "./materials";
|
|
8
|
-
import {
|
|
6
|
+
import { requiredReference, requireWithinRecipes } from "./checks";
|
|
7
|
+
import { associateNewMaterial, layerSetFor, layerSetThickness, layerSetUsage, materialOf } from "./materials";
|
|
8
|
+
import { direction2Of } from "./math";
|
|
9
9
|
import { carriedWith, carryOpening, openingsOf, readWallOpening } from "./openings";
|
|
10
10
|
import { absoluteFrame, axisPlacementFrame, movePlacement, objectPlacementOf } from "./placement";
|
|
11
11
|
import { detach, relatingOf } from "./relationships";
|
|
@@ -17,7 +17,7 @@ function movesAny(from, to, points, tolerance) {
|
|
|
17
17
|
return points.some((point) => length3(subtract3(pointToWorld(to, point), pointToWorld(from, point))) > tolerance);
|
|
18
18
|
}
|
|
19
19
|
function wallFrame(start, end, bottom) {
|
|
20
|
-
const direction =
|
|
20
|
+
const direction = direction2Of(subtract2(end, start));
|
|
21
21
|
return {
|
|
22
22
|
origin: [start[0], start[1], bottom],
|
|
23
23
|
x: [direction[0], direction[1], 0],
|
|
@@ -64,7 +64,7 @@ function placeOpenings(tx, before, after, moves, tolerance) {
|
|
|
64
64
|
return places;
|
|
65
65
|
}
|
|
66
66
|
export function editWall(tx, writer, wall, change, tolerance, parallelTolerance) {
|
|
67
|
-
var _a, _b, _c, _d, _e, _f;
|
|
67
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
68
68
|
const before = readWall(tx, wall);
|
|
69
69
|
if (before.body === undefined) {
|
|
70
70
|
throw new Error(`${describeObject(tx, wall)} has no Body representation, so this library cannot rebuild it`);
|
|
@@ -76,26 +76,32 @@ export function editWall(tx, writer, wall, change, tolerance, parallelTolerance)
|
|
|
76
76
|
if (!(length > tolerance)) {
|
|
77
77
|
throw new Error("A wall's start and end must be apart");
|
|
78
78
|
}
|
|
79
|
+
requireWithinRecipes(length, "wall's length", "end");
|
|
79
80
|
if (!(height > 0)) {
|
|
80
81
|
throw new Error(`A wall's height must be more than zero, got ${height}`);
|
|
81
82
|
}
|
|
82
|
-
const
|
|
83
|
-
const
|
|
83
|
+
const current = layerSetOf(tx, before);
|
|
84
|
+
const layerSet = (_d = change.layerSet) !== null && _d !== void 0 ? _d : (change.thickness !== undefined && current !== undefined ? layerSetFor(tx, writer, undefined, change.thickness, "Wall") : current);
|
|
85
|
+
const layersChange = layerSet !== current;
|
|
84
86
|
if (layersChange) {
|
|
85
87
|
refuseTypedLayers(tx, wall);
|
|
86
88
|
}
|
|
87
|
-
const thickness = layerSetThickness(tx, layerSet);
|
|
89
|
+
const thickness = layerSet === undefined ? (_e = change.thickness) !== null && _e !== void 0 ? _e : before.high - before.low : layerSetThickness(tx, layerSet);
|
|
88
90
|
if (!(thickness > 0)) {
|
|
89
91
|
throw new Error("A wall's layers must add up to more than zero thickness");
|
|
90
92
|
}
|
|
91
|
-
const alignment = (
|
|
93
|
+
const alignment = (_f = change.alignment) !== null && _f !== void 0 ? _f : alignmentOf(before, tolerance);
|
|
92
94
|
const low = alignment === undefined ? before.low : offsetFor(alignment, thickness);
|
|
93
95
|
const axis = axisFrame(before);
|
|
94
|
-
const target = wallFrame(start, end, (
|
|
96
|
+
const target = wallFrame(start, end, (_g = change.bottom) !== null && _g !== void 0 ? _g : pointToWorld(before.frame, axis.origin)[2]);
|
|
95
97
|
const frame = composeAxes(target, relativeAxes(axis, WORLD_AXES));
|
|
96
98
|
const after = Object.assign(Object.assign({}, before), { frame, start, end, direction: [target.x[0], target.x[1]], length, low, high: low + thickness, height });
|
|
97
99
|
for (const join of joinsOf(tx, wall)) {
|
|
98
|
-
|
|
100
|
+
const other = readWall(tx, join.other);
|
|
101
|
+
if (!stillMeet(before, join.mine, other, join.theirs, tolerance, parallelTolerance)) {
|
|
102
|
+
throw new Error(`${describeObject(tx, wall)} is joined to ${describeObject(tx, join.other)} where this library does not see them meet, so it cannot keep the join through a change; disconnect them first with walls.disconnect`);
|
|
103
|
+
}
|
|
104
|
+
if (!stillMeet(after, join.mine, other, join.theirs, tolerance, parallelTolerance)) {
|
|
99
105
|
throw new Error(`The change takes ${describeObject(tx, wall)} away from ${describeObject(tx, join.other)}, which it is joined to; disconnect them first with walls.disconnect`);
|
|
100
106
|
}
|
|
101
107
|
}
|
|
@@ -111,12 +117,12 @@ export function editWall(tx, writer, wall, change, tolerance, parallelTolerance)
|
|
|
111
117
|
const axisEnd = pointToWorld(axis, [length, 0, 0]);
|
|
112
118
|
const axisCurve = writer.polyCurve2([[axis.origin[0], axis.origin[1]], [axisEnd[0], axisEnd[1]]], false);
|
|
113
119
|
replaceRepresentation(tx, wall, representationOf(tx, wall, "Axis"), writer.shapeRepresentation(axisContext(tx, writer), "Axis", "Curve2D", [axisCurve]));
|
|
114
|
-
if (layersChange || Math.abs(low - before.low) > tolerance) {
|
|
120
|
+
if (layerSet !== undefined && (layersChange || Math.abs(low - before.low) > tolerance)) {
|
|
115
121
|
tx.dropIfUnused(detach(tx, MATERIAL_ASSOCIATION, wall));
|
|
116
122
|
associateNewMaterial(tx, writer, [wall], layerSetUsage(writer, layerSet, "AXIS2", "POSITIVE", low));
|
|
117
123
|
}
|
|
118
124
|
places.forEach((place) => carryOpening(tx, writer, place, place, before, after));
|
|
119
|
-
regenerateWall(tx, writer, wall, tolerance, parallelTolerance, { height, base: before.base, halfSpaces });
|
|
125
|
+
regenerateWall(tx, writer, wall, tolerance, parallelTolerance, { height, base: before.base, low, high: low + thickness, halfSpaces });
|
|
120
126
|
for (const join of joinsOf(tx, wall)) {
|
|
121
127
|
if (join.theirs !== "ATPATH") {
|
|
122
128
|
regenerateWall(tx, writer, join.other, tolerance, parallelTolerance);
|
|
@@ -5,7 +5,7 @@ import type { Frame3, Line2 } from "./build-types";
|
|
|
5
5
|
export declare function readWall(reader: ModelReader, wall: number): WallGeometry;
|
|
6
6
|
export declare function axisFrame(geometry: WallGeometry): Frame3;
|
|
7
7
|
export declare function alignmentOf(geometry: WallGeometry, tolerance: number): Inputs.IFC.wallAlignmentEnum | undefined;
|
|
8
|
-
export declare function layerSetOf(reader: ModelReader, geometry: WallGeometry): number;
|
|
8
|
+
export declare function layerSetOf(reader: ModelReader, geometry: WallGeometry): number | undefined;
|
|
9
9
|
export declare function sideLine(geometry: WallGeometry, across: number): Line2;
|
|
10
10
|
export declare function axisLine(geometry: WallGeometry): Line2;
|
|
11
11
|
export declare function endPoint(geometry: WallGeometry, end: WallEnd): Base.Point2;
|
|
@@ -13,3 +13,4 @@ export declare function mitreCut(wall: WallGeometry, wallEnd: WallEnd, other: Wa
|
|
|
13
13
|
export declare function buttCut(stem: WallGeometry, stemEnd: WallEnd, through: WallGeometry): Line2;
|
|
14
14
|
export declare function footprintOf(geometry: WallGeometry, cuts: WallCuts, tolerance: number, parallelTolerance: number): Base.Point2[];
|
|
15
15
|
export declare function readableWall(reader: ModelReader, wall: number): WallGeometry | undefined;
|
|
16
|
+
export declare function inOwnFrame(reader: ModelReader, geometry: WallGeometry): WallGeometry;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { pointToLocal, vectorToLocal } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
2
|
-
import { signedArea2 } from "@bitbybit-dev/base/lib/api/services/helpers/polygons";
|
|
3
|
-
import { add2, leftOf2, length2, scale2, subtract2 } from "@bitbybit-dev/base/lib/api/services/helpers/vectors";
|
|
1
|
+
import { WORLD_AXES, pointToLocal, pointToWorld, vectorToLocal } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
|
+
import { signedArea2 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/polygons";
|
|
3
|
+
import { add2, leftOf2, length2, length3, scale2, subtract2 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/vectors";
|
|
4
4
|
import * as Inputs from "../api/inputs";
|
|
5
5
|
import { isEnumeration, isReference } from "../step/values";
|
|
6
6
|
import { requiredReference } from "./checks";
|
|
7
7
|
import { PARALLEL_TOLERANCE, VERTICAL_COSINE } from "./constants";
|
|
8
8
|
import { layerSetThickness, materialOf } from "./materials";
|
|
9
|
-
import { distanceToLine, intersectLines,
|
|
9
|
+
import { distanceToLine, intersectLines, direction2Of, parameterOnLine, placedOnPlan } from "./math";
|
|
10
10
|
import { absoluteFrame, axisPlacementFrame, directionOf, objectPlacementOf } from "./placement";
|
|
11
11
|
import { describeObject } from "./spatial";
|
|
12
12
|
import { firstItem, representationOf, unwrapClippings } from "./representations";
|
|
13
13
|
import { polylinePoints } from "./curves";
|
|
14
|
+
import { profileShape } from "./measure";
|
|
15
|
+
const LAYER_SET_USAGE = "IfcMaterialLayerSetUsage";
|
|
16
|
+
const VOIDED_PROFILE = "IfcArbitraryProfileDefWithVoids";
|
|
17
|
+
const STRIP_CORNERS = 4;
|
|
18
|
+
const SIDE_SLACK = 1e-6;
|
|
14
19
|
function axisPoints(reader, wall) {
|
|
15
20
|
const axis = representationOf(reader, wall, "Axis");
|
|
16
21
|
if (axis === undefined) {
|
|
@@ -32,17 +37,36 @@ function axisPoints(reader, wall) {
|
|
|
32
37
|
}
|
|
33
38
|
return [start, end];
|
|
34
39
|
}
|
|
35
|
-
function layerBounds(reader,
|
|
36
|
-
const usage = materialOf(reader, wall);
|
|
37
|
-
if (usage === undefined || reader.entity(usage).type !== "IfcMaterialLayerSetUsage") {
|
|
38
|
-
throw new Error(`${describeObject(reader, wall)} has no material layer set usage, so its thickness is unknown`);
|
|
39
|
-
}
|
|
40
|
+
function layerBounds(reader, usage) {
|
|
40
41
|
const layerSet = reader.attribute(usage, "ForLayerSet");
|
|
41
42
|
const offset = reader.attribute(usage, "OffsetFromReferenceLine");
|
|
42
43
|
const sense = reader.attribute(usage, "DirectionSense");
|
|
43
44
|
const thickness = isReference(layerSet) ? layerSetThickness(reader, layerSet.ref) : 0;
|
|
44
45
|
const start = typeof offset === "number" ? offset : 0;
|
|
45
|
-
return isEnumeration(sense) && sense.enum === "NEGATIVE" ? [start - thickness, start
|
|
46
|
+
return isEnumeration(sense) && sense.enum === "NEGATIVE" ? [start - thickness, start] : [start, start + thickness];
|
|
47
|
+
}
|
|
48
|
+
function bodySides(reader, wall, body, axisAcross) {
|
|
49
|
+
var _a;
|
|
50
|
+
const refusal = `${describeObject(reader, wall)} has no material layer set usage, so its thickness is read from its body, and `;
|
|
51
|
+
if (body === undefined) {
|
|
52
|
+
throw new Error(`${refusal}it has none`);
|
|
53
|
+
}
|
|
54
|
+
const [solid] = unwrapClippings(reader, firstItem(reader, body));
|
|
55
|
+
const profile = reader.entity(solid).type === "IfcExtrudedAreaSolid" ? reader.attribute(solid, "SweptArea") : null;
|
|
56
|
+
const outline = isReference(profile) && reader.entity(profile.ref).type !== VOIDED_PROFILE ? (_a = profileShape(reader, profile.ref)) === null || _a === void 0 ? void 0 : _a.outline : undefined;
|
|
57
|
+
if (outline === undefined || outline.length < STRIP_CORNERS) {
|
|
58
|
+
throw new Error(`${refusal}it is not a plan outline without holes extruded upwards`);
|
|
59
|
+
}
|
|
60
|
+
const position = reader.attribute(solid, "Position");
|
|
61
|
+
const frame = isReference(position) ? axisPlacementFrame(reader, position.ref) : undefined;
|
|
62
|
+
const across = outline.map((point) => (frame === undefined ? point[1] : pointToWorld(frame, [point[0], point[1], 0])[1]) - axisAcross);
|
|
63
|
+
const low = Math.min(...across);
|
|
64
|
+
const high = Math.max(...across);
|
|
65
|
+
const slack = (high - low) * SIDE_SLACK;
|
|
66
|
+
if (!(high - low > 0) || across.some((value) => Math.abs(value - low) > slack && Math.abs(value - high) > slack)) {
|
|
67
|
+
throw new Error(`${refusal}its outline is not a strip between two sides along its axis`);
|
|
68
|
+
}
|
|
69
|
+
return [low, high];
|
|
46
70
|
}
|
|
47
71
|
function verticalExtrusion(reader, wall, body) {
|
|
48
72
|
var _a;
|
|
@@ -55,7 +79,7 @@ function verticalExtrusion(reader, wall, body) {
|
|
|
55
79
|
const position = reader.attribute(solid, "Position");
|
|
56
80
|
const frame = isReference(position) ? axisPlacementFrame(reader, position.ref) : undefined;
|
|
57
81
|
const direction = directionOf(reader, reader.attribute(solid, "ExtrudedDirection"), [0, 0, 1]);
|
|
58
|
-
const upwards =
|
|
82
|
+
const upwards = length3(direction);
|
|
59
83
|
if (typeof depth !== "number" || !(depth > 0) || (frame !== undefined && frame.z[2] < VERTICAL_COSINE) || !(direction[2] / upwards >= VERTICAL_COSINE)) {
|
|
60
84
|
throw new Error(`${refusal}its extrusion does not rise straight up from a plan outline`);
|
|
61
85
|
}
|
|
@@ -69,15 +93,17 @@ export function readWall(reader, wall) {
|
|
|
69
93
|
const [localStart, localEnd] = axisPoints(reader, wall);
|
|
70
94
|
const start = placedOnPlan(frame, localStart);
|
|
71
95
|
const end = placedOnPlan(frame, localEnd);
|
|
72
|
-
const
|
|
96
|
+
const material = materialOf(reader, wall);
|
|
97
|
+
const usage = material !== undefined && reader.entity(material).type === LAYER_SET_USAGE ? material : undefined;
|
|
73
98
|
const body = representationOf(reader, wall, "Body");
|
|
74
99
|
const [height, base] = body === undefined ? [0, 0] : verticalExtrusion(reader, wall, body);
|
|
75
|
-
|
|
100
|
+
const [low, high] = usage === undefined ? bodySides(reader, wall, body, localStart[1]) : layerBounds(reader, usage);
|
|
101
|
+
return { wall, frame, start, end, direction: direction2Of(subtract2(end, start)), length: length2(subtract2(end, start)), low, high, height, base, body, usage };
|
|
76
102
|
}
|
|
77
103
|
export function axisFrame(geometry) {
|
|
78
104
|
const start = pointToLocal(geometry.frame, [geometry.start[0], geometry.start[1], 0]);
|
|
79
105
|
const end = pointToLocal(geometry.frame, [geometry.end[0], geometry.end[1], 0]);
|
|
80
|
-
const direction =
|
|
106
|
+
const direction = direction2Of(subtract2([end[0], end[1]], [start[0], start[1]]));
|
|
81
107
|
return { origin: [start[0], start[1], geometry.base], x: [direction[0], direction[1], 0], y: [-direction[1], direction[0], 0], z: [0, 0, 1] };
|
|
82
108
|
}
|
|
83
109
|
export function alignmentOf(geometry, tolerance) {
|
|
@@ -90,7 +116,7 @@ export function alignmentOf(geometry, tolerance) {
|
|
|
90
116
|
return Math.abs(geometry.low + geometry.high) <= tolerance ? Inputs.IFC.wallAlignmentEnum.center : undefined;
|
|
91
117
|
}
|
|
92
118
|
export function layerSetOf(reader, geometry) {
|
|
93
|
-
return requiredReference(reader, geometry.usage, "ForLayerSet");
|
|
119
|
+
return geometry.usage === undefined ? undefined : requiredReference(reader, geometry.usage, "ForLayerSet");
|
|
94
120
|
}
|
|
95
121
|
export function sideLine(geometry, across) {
|
|
96
122
|
return { point: add2(geometry.start, scale2(leftOf2(geometry.direction), across)), direction: geometry.direction };
|
|
@@ -113,7 +139,7 @@ export function mitreCut(wall, wallEnd, other, otherEnd, tolerance, parallelTole
|
|
|
113
139
|
if (length2(along) <= tolerance) {
|
|
114
140
|
return undefined;
|
|
115
141
|
}
|
|
116
|
-
return { point: first, direction:
|
|
142
|
+
return { point: first, direction: direction2Of(along) };
|
|
117
143
|
}
|
|
118
144
|
export function buttCut(stem, stemEnd, through) {
|
|
119
145
|
const far = stemEnd === "ATSTART" ? stem.end : stem.start;
|
|
@@ -123,11 +149,11 @@ export function footprintOf(geometry, cuts, tolerance, parallelTolerance) {
|
|
|
123
149
|
const toLocalLine = (line) => {
|
|
124
150
|
const point = pointToLocal(geometry.frame, [line.point[0], line.point[1], 0]);
|
|
125
151
|
const direction = vectorToLocal(geometry.frame, [line.direction[0], line.direction[1], 0]);
|
|
126
|
-
return { point: [point[0], point[1]], direction:
|
|
152
|
+
return { point: [point[0], point[1]], direction: direction2Of([direction[0], direction[1]]) };
|
|
127
153
|
};
|
|
128
154
|
const startLocal = pointToLocal(geometry.frame, [geometry.start[0], geometry.start[1], 0]);
|
|
129
155
|
const endLocal = pointToLocal(geometry.frame, [geometry.end[0], geometry.end[1], 0]);
|
|
130
|
-
const axisDirection =
|
|
156
|
+
const axisDirection = direction2Of(subtract2([endLocal[0], endLocal[1]], [startLocal[0], startLocal[1]]));
|
|
131
157
|
const across = leftOf2(axisDirection);
|
|
132
158
|
const squareAt = (point) => ({ point: [point[0], point[1]], direction: across });
|
|
133
159
|
const startCut = cuts.start ? toLocalLine(cuts.start) : squareAt(startLocal);
|
|
@@ -157,3 +183,7 @@ export function readableWall(reader, wall) {
|
|
|
157
183
|
return undefined;
|
|
158
184
|
}
|
|
159
185
|
}
|
|
186
|
+
export function inOwnFrame(reader, geometry) {
|
|
187
|
+
const [start, end] = axisPoints(reader, geometry.wall);
|
|
188
|
+
return Object.assign(Object.assign({}, geometry), { frame: WORLD_AXES, start, end, direction: direction2Of(subtract2(end, start)), length: length2(subtract2(end, start)) });
|
|
189
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WORLD_AXES, pointToLocal, pointToWorld } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
1
|
+
import { WORLD_AXES, pointToLocal, pointToWorld } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
2
|
import * as Inputs from "../api/inputs";
|
|
3
3
|
import { textValue } from "../step/values";
|
|
4
4
|
import { TYPE_DEFINITION } from "./constants";
|
|
@@ -13,12 +13,16 @@ const END_OF = {
|
|
|
13
13
|
ATEND: Inputs.IFC.wallEndEnum.end,
|
|
14
14
|
ATPATH: Inputs.IFC.wallEndEnum.along,
|
|
15
15
|
};
|
|
16
|
+
function layerSetName(reader, layerSet) {
|
|
17
|
+
var _a;
|
|
18
|
+
return layerSet === undefined ? "" : (_a = textValue(reader.attribute(layerSet, "LayerSetName"))) !== null && _a !== void 0 ? _a : "";
|
|
19
|
+
}
|
|
16
20
|
function globalIdOf(reader, id) {
|
|
17
21
|
var _a;
|
|
18
22
|
return (_a = textValue(reader.attribute(id, "GlobalId"))) !== null && _a !== void 0 ? _a : "";
|
|
19
23
|
}
|
|
20
24
|
export function wallParametersOf(reader, wall, tolerance) {
|
|
21
|
-
var _a, _b
|
|
25
|
+
var _a, _b;
|
|
22
26
|
const geometry = readWall(reader, wall);
|
|
23
27
|
const storey = containerOf(reader, wall);
|
|
24
28
|
const plan = storey === undefined ? WORLD_AXES : storeyFrame(reader, storey);
|
|
@@ -38,7 +42,7 @@ export function wallParametersOf(reader, wall, tolerance) {
|
|
|
38
42
|
thickness: geometry.high - geometry.low,
|
|
39
43
|
offset: geometry.low,
|
|
40
44
|
alignment: (_b = alignmentOf(geometry, tolerance)) !== null && _b !== void 0 ? _b : "",
|
|
41
|
-
layerSet: (
|
|
45
|
+
layerSet: layerSetName(reader, layerSetOf(reader, geometry)),
|
|
42
46
|
wallType: type === undefined ? "" : globalIdOf(reader, type),
|
|
43
47
|
joins: joinsOf(reader, wall).map((join) => ({ other: globalIdOf(reader, join.other), at: END_OF[join.mine], otherAt: END_OF[join.theirs] })),
|
|
44
48
|
openings: openingsOf(reader, wall).map((opening) => globalIdOf(reader, opening)),
|
package/lib/build/walls.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { WORLD_AXES, pointToLocal, vectorToLocal } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
|
|
2
|
-
import { cross2, length2, subtract2 } from "@bitbybit-dev/base/lib/api/services/helpers/vectors";
|
|
1
|
+
import { WORLD_AXES, pointToLocal, vectorToLocal } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/frame-axes";
|
|
2
|
+
import { cross2, length2, length3, subtract2 } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/vectors";
|
|
3
3
|
import * as Inputs from "../api/inputs";
|
|
4
4
|
import { enumValue, isEnumeration, isReference, ref } from "../step/values";
|
|
5
5
|
import { WALL_CONNECTION, WALL_ENDS } from "./constants";
|
|
6
6
|
import { axisContext, bodyContext } from "./contexts";
|
|
7
|
+
import { requireWithinRecipes } from "./checks";
|
|
7
8
|
import { associateNewMaterial, layerSetThickness, layerSetUsage } from "./materials";
|
|
8
|
-
import { distanceToLine,
|
|
9
|
+
import { distanceToLine, direction2Of, parameterOnLine } from "./math";
|
|
9
10
|
import { objectPlacementOf } from "./placement";
|
|
10
11
|
import { containIn, describeObject } from "./spatial";
|
|
11
12
|
import { defineByType } from "./type-objects";
|
|
12
13
|
import { axisLine, buttCut, endPoint, footprintOf, mitreCut, readWall } from "./wall-geometry";
|
|
13
14
|
import { firstItem, replaceRepresentation, unwrapClippings } from "./representations";
|
|
15
|
+
import { registerClippings } from "./clipping-registry";
|
|
14
16
|
const END_NAMES = { ATSTART: "start", ATEND: "end", ATPATH: "length" };
|
|
15
17
|
export function offsetFor(alignment, thickness) {
|
|
16
18
|
if (alignment === Inputs.IFC.wallAlignmentEnum.left) {
|
|
@@ -46,7 +48,8 @@ export function createWall(tx, writer, spec, tolerance) {
|
|
|
46
48
|
if (!(thickness > 0)) {
|
|
47
49
|
throw new Error("A wall's layers must add up to more than zero thickness");
|
|
48
50
|
}
|
|
49
|
-
const direction =
|
|
51
|
+
const direction = direction2Of(along);
|
|
52
|
+
requireWithinRecipes(length, "wall's length", "end");
|
|
50
53
|
const offset = offsetFor(spec.alignment, thickness);
|
|
51
54
|
const placement = writer.localPlacement(objectPlacementOf(tx, spec.storey), {
|
|
52
55
|
origin: [spec.start[0], spec.start[1], spec.baseOffset],
|
|
@@ -113,10 +116,12 @@ function cutsOf(reader, geometry, tolerance, parallelTolerance) {
|
|
|
113
116
|
export function regenerateWall(tx, writer, wall, tolerance, parallelTolerance, body) {
|
|
114
117
|
var _a;
|
|
115
118
|
const read = readWall(tx, wall);
|
|
116
|
-
const geometry = body === undefined ? read : Object.assign(Object.assign({}, read), { height: body.height, base: body.base });
|
|
119
|
+
const geometry = body === undefined ? read : Object.assign(Object.assign({}, read), { height: body.height, base: body.base, low: body.low, high: body.high });
|
|
117
120
|
const footprint = footprintOf(geometry, cutsOf(tx, geometry, tolerance, parallelTolerance), tolerance, parallelTolerance);
|
|
118
121
|
const halfSpaces = (_a = body === null || body === void 0 ? void 0 : body.halfSpaces) !== null && _a !== void 0 ? _a : (read.body === undefined ? [] : unwrapClippings(tx, firstItem(tx, read.body))[1]);
|
|
119
|
-
|
|
122
|
+
const rebuilt = extrudedBody(writer, footprint, geometry.base, geometry.height, halfSpaces);
|
|
123
|
+
registerClippings(tx, writer, wall, read.body, rebuilt);
|
|
124
|
+
replaceRepresentation(tx, wall, read.body, rebuilt);
|
|
120
125
|
}
|
|
121
126
|
function overlapHeights(a, b, tolerance) {
|
|
122
127
|
const bottom = (wall) => wall.frame.origin[2] + wall.base;
|
|
@@ -229,10 +234,12 @@ export function clipWall(tx, writer, wall, origin, normal) {
|
|
|
229
234
|
if (geometry.body === undefined) {
|
|
230
235
|
throw new Error(`${describeObject(tx, wall)} has no body to clip`);
|
|
231
236
|
}
|
|
232
|
-
if (!(
|
|
237
|
+
if (!(length3(normal) > 0)) {
|
|
233
238
|
throw new Error("A clipping plane needs a normal of some length");
|
|
234
239
|
}
|
|
235
240
|
const halfSpace = writer.halfSpace(pointToLocal(geometry.frame, origin), vectorToLocal(geometry.frame, normal), [1, 0, 0]);
|
|
236
241
|
const [solid, halfSpaces] = unwrapClippings(tx, firstItem(tx, geometry.body));
|
|
237
|
-
|
|
242
|
+
const clipped = clippedBody(writer, solid, [...halfSpaces, halfSpace]);
|
|
243
|
+
registerClippings(tx, writer, wall, geometry.body, clipped);
|
|
244
|
+
replaceRepresentation(tx, wall, geometry.body, clipped);
|
|
238
245
|
}
|