@bitbybit-dev/ifc 0.0.0-stage → 1.5.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.
Files changed (242) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +42 -0
  3. package/README.md +92 -2
  4. package/index.d.ts +1 -0
  5. package/index.js +1 -0
  6. package/lib/api/dto-registry.d.ts +8 -0
  7. package/lib/api/dto-registry.js +109 -0
  8. package/lib/api/ifc-service.d.ts +109 -0
  9. package/lib/api/ifc-service.js +55 -0
  10. package/lib/api/inputs/base-inputs.d.ts +5 -0
  11. package/lib/api/inputs/base-inputs.js +5 -0
  12. package/lib/api/inputs/ifc-inputs.d.ts +2727 -0
  13. package/lib/api/inputs/ifc-inputs.js +2498 -0
  14. package/lib/api/inputs/index.d.ts +3 -0
  15. package/lib/api/inputs/index.js +3 -0
  16. package/lib/api/resolved-inputs/index.d.ts +70 -0
  17. package/lib/api/resolved-inputs/index.js +1 -0
  18. package/lib/api/services/assemblies.d.ts +28 -0
  19. package/lib/api/services/assemblies.js +49 -0
  20. package/lib/api/services/beams.d.ts +33 -0
  21. package/lib/api/services/beams.js +59 -0
  22. package/lib/api/services/columns.d.ts +26 -0
  23. package/lib/api/services/columns.js +56 -0
  24. package/lib/api/services/defaults.constants.d.ts +44 -0
  25. package/lib/api/services/defaults.constants.js +44 -0
  26. package/lib/api/services/doors.d.ts +45 -0
  27. package/lib/api/services/doors.js +94 -0
  28. package/lib/api/services/geometry.d.ts +51 -0
  29. package/lib/api/services/geometry.js +87 -0
  30. package/lib/api/services/index.d.ts +17 -0
  31. package/lib/api/services/index.js +17 -0
  32. package/lib/api/services/materials.d.ts +46 -0
  33. package/lib/api/services/materials.js +86 -0
  34. package/lib/api/services/member-support.d.ts +7 -0
  35. package/lib/api/services/member-support.js +29 -0
  36. package/lib/api/services/members.d.ts +24 -0
  37. package/lib/api/services/members.js +51 -0
  38. package/lib/api/services/model.d.ts +244 -0
  39. package/lib/api/services/model.js +409 -0
  40. package/lib/api/services/openings.d.ts +57 -0
  41. package/lib/api/services/openings.js +102 -0
  42. package/lib/api/services/properties.d.ts +89 -0
  43. package/lib/api/services/properties.js +142 -0
  44. package/lib/api/services/quantities.d.ts +38 -0
  45. package/lib/api/services/quantities.js +51 -0
  46. package/lib/api/services/roofs.d.ts +24 -0
  47. package/lib/api/services/roofs.js +52 -0
  48. package/lib/api/services/service-support.d.ts +8 -0
  49. package/lib/api/services/service-support.js +37 -0
  50. package/lib/api/services/service-types.d.ts +3 -0
  51. package/lib/api/services/service-types.js +1 -0
  52. package/lib/api/services/site.d.ts +37 -0
  53. package/lib/api/services/site.js +80 -0
  54. package/lib/api/services/slabs.d.ts +31 -0
  55. package/lib/api/services/slabs.js +59 -0
  56. package/lib/api/services/spaces.d.ts +36 -0
  57. package/lib/api/services/spaces.js +64 -0
  58. package/lib/api/services/spatial.d.ts +54 -0
  59. package/lib/api/services/spatial.js +75 -0
  60. package/lib/api/services/walls.d.ts +140 -0
  61. package/lib/api/services/walls.js +268 -0
  62. package/lib/api/services/windows.d.ts +46 -0
  63. package/lib/api/services/windows.js +76 -0
  64. package/lib/build/assemblies.d.ts +4 -0
  65. package/lib/build/assemblies.js +45 -0
  66. package/lib/build/build-types.d.ts +345 -0
  67. package/lib/build/build-types.js +1 -0
  68. package/lib/build/checks.d.ts +6 -0
  69. package/lib/build/checks.js +32 -0
  70. package/lib/build/constants.d.ts +27 -0
  71. package/lib/build/constants.js +43 -0
  72. package/lib/build/contexts.d.ts +9 -0
  73. package/lib/build/contexts.js +52 -0
  74. package/lib/build/curves.d.ts +3 -0
  75. package/lib/build/curves.js +23 -0
  76. package/lib/build/entity-writer.d.ts +23 -0
  77. package/lib/build/entity-writer.js +97 -0
  78. package/lib/build/fillings.d.ts +7 -0
  79. package/lib/build/fillings.js +182 -0
  80. package/lib/build/georeference.d.ts +5 -0
  81. package/lib/build/georeference.js +44 -0
  82. package/lib/build/materials.d.ts +18 -0
  83. package/lib/build/materials.js +166 -0
  84. package/lib/build/math.d.ts +10 -0
  85. package/lib/build/math.js +47 -0
  86. package/lib/build/measure.d.ts +9 -0
  87. package/lib/build/measure.js +195 -0
  88. package/lib/build/moving.d.ts +4 -0
  89. package/lib/build/moving.js +61 -0
  90. package/lib/build/openings.d.ts +12 -0
  91. package/lib/build/openings.js +156 -0
  92. package/lib/build/outlines.d.ts +4 -0
  93. package/lib/build/outlines.js +40 -0
  94. package/lib/build/placement.d.ts +16 -0
  95. package/lib/build/placement.js +106 -0
  96. package/lib/build/profiles.d.ts +4 -0
  97. package/lib/build/profiles.js +35 -0
  98. package/lib/build/project.d.ts +11 -0
  99. package/lib/build/project.js +134 -0
  100. package/lib/build/properties.d.ts +10 -0
  101. package/lib/build/properties.js +182 -0
  102. package/lib/build/quantities.d.ts +7 -0
  103. package/lib/build/quantities.js +262 -0
  104. package/lib/build/relationships.d.ts +9 -0
  105. package/lib/build/relationships.js +67 -0
  106. package/lib/build/removal.d.ts +3 -0
  107. package/lib/build/removal.js +106 -0
  108. package/lib/build/representations.d.ts +6 -0
  109. package/lib/build/representations.js +46 -0
  110. package/lib/build/roof-clipping.d.ts +5 -0
  111. package/lib/build/roof-clipping.js +79 -0
  112. package/lib/build/roofs.d.ts +4 -0
  113. package/lib/build/roofs.js +131 -0
  114. package/lib/build/site.d.ts +7 -0
  115. package/lib/build/site.js +112 -0
  116. package/lib/build/slab-openings.d.ts +4 -0
  117. package/lib/build/slab-openings.js +71 -0
  118. package/lib/build/slabs-columns-beams.d.ts +8 -0
  119. package/lib/build/slabs-columns-beams.js +73 -0
  120. package/lib/build/solids.d.ts +5 -0
  121. package/lib/build/solids.js +33 -0
  122. package/lib/build/spaces.d.ts +6 -0
  123. package/lib/build/spaces.js +55 -0
  124. package/lib/build/spatial.d.ts +17 -0
  125. package/lib/build/spatial.js +111 -0
  126. package/lib/build/type-objects.d.ts +4 -0
  127. package/lib/build/type-objects.js +9 -0
  128. package/lib/build/wall-edits.d.ts +5 -0
  129. package/lib/build/wall-edits.js +138 -0
  130. package/lib/build/wall-geometry.d.ts +15 -0
  131. package/lib/build/wall-geometry.js +159 -0
  132. package/lib/build/wall-parameters.d.ts +3 -0
  133. package/lib/build/wall-parameters.js +47 -0
  134. package/lib/build/walls.d.ts +12 -0
  135. package/lib/build/walls.js +238 -0
  136. package/lib/geometry/advanced.d.ts +27 -0
  137. package/lib/geometry/advanced.js +292 -0
  138. package/lib/geometry/colours.d.ts +3 -0
  139. package/lib/geometry/colours.js +109 -0
  140. package/lib/geometry/curves.d.ts +32 -0
  141. package/lib/geometry/curves.js +370 -0
  142. package/lib/geometry/edges.constants.d.ts +5 -0
  143. package/lib/geometry/edges.constants.js +5 -0
  144. package/lib/geometry/edges.d.ts +21 -0
  145. package/lib/geometry/edges.js +164 -0
  146. package/lib/geometry/elements.d.ts +3 -0
  147. package/lib/geometry/elements.js +152 -0
  148. package/lib/geometry/errors.d.ts +3 -0
  149. package/lib/geometry/errors.js +6 -0
  150. package/lib/geometry/faceted.d.ts +31 -0
  151. package/lib/geometry/faceted.js +214 -0
  152. package/lib/geometry/geometry-types.d.ts +103 -0
  153. package/lib/geometry/geometry-types.js +1 -0
  154. package/lib/geometry/groups.d.ts +21 -0
  155. package/lib/geometry/groups.js +106 -0
  156. package/lib/geometry/items.d.ts +34 -0
  157. package/lib/geometry/items.js +313 -0
  158. package/lib/geometry/operators.d.ts +3 -0
  159. package/lib/geometry/operators.js +65 -0
  160. package/lib/geometry/profiles.d.ts +4 -0
  161. package/lib/geometry/profiles.js +277 -0
  162. package/lib/geometry/recipe-builder.d.ts +14 -0
  163. package/lib/geometry/recipe-builder.js +48 -0
  164. package/lib/geometry/references.d.ts +4 -0
  165. package/lib/geometry/references.js +17 -0
  166. package/lib/geometry/regions.d.ts +4 -0
  167. package/lib/geometry/regions.js +26 -0
  168. package/lib/geometry/surfaces.constants.d.ts +17 -0
  169. package/lib/geometry/surfaces.constants.js +17 -0
  170. package/lib/geometry/surfaces.d.ts +6 -0
  171. package/lib/geometry/surfaces.js +306 -0
  172. package/lib/geometry/swept-solids.constants.d.ts +7 -0
  173. package/lib/geometry/swept-solids.constants.js +6 -0
  174. package/lib/geometry/swept-solids.d.ts +25 -0
  175. package/lib/geometry/swept-solids.js +243 -0
  176. package/lib/index.d.ts +6 -0
  177. package/lib/index.js +6 -0
  178. package/lib/model/constants.d.ts +30 -0
  179. package/lib/model/constants.js +30 -0
  180. package/lib/model/entity-lookup.d.ts +9 -0
  181. package/lib/model/entity-lookup.js +20 -0
  182. package/lib/model/guid.d.ts +7 -0
  183. package/lib/model/guid.js +60 -0
  184. package/lib/model/id-map.d.ts +10 -0
  185. package/lib/model/id-map.js +80 -0
  186. package/lib/model/index.d.ts +4 -0
  187. package/lib/model/index.js +2 -0
  188. package/lib/model/io.d.ts +6 -0
  189. package/lib/model/io.js +136 -0
  190. package/lib/model/is-model.d.ts +9 -0
  191. package/lib/model/is-model.js +11 -0
  192. package/lib/model/model-types.d.ts +111 -0
  193. package/lib/model/model-types.js +1 -0
  194. package/lib/model/overlay-indexes.d.ts +17 -0
  195. package/lib/model/overlay-indexes.js +69 -0
  196. package/lib/model/references.d.ts +2 -0
  197. package/lib/model/references.js +51 -0
  198. package/lib/model/rows-by-id.d.ts +8 -0
  199. package/lib/model/rows-by-id.js +39 -0
  200. package/lib/model/snapshot.d.ts +36 -0
  201. package/lib/model/snapshot.js +144 -0
  202. package/lib/model/source.d.ts +29 -0
  203. package/lib/model/source.js +172 -0
  204. package/lib/model/transaction.d.ts +39 -0
  205. package/lib/model/transaction.js +250 -0
  206. package/lib/model/upgrade.d.ts +2 -0
  207. package/lib/model/upgrade.js +78 -0
  208. package/lib/schema/constants.d.ts +3 -0
  209. package/lib/schema/constants.js +3 -0
  210. package/lib/schema/generated/ifc4.d.ts +2 -0
  211. package/lib/schema/generated/ifc4.js +1204 -0
  212. package/lib/schema/generated/ifc4x3.d.ts +2 -0
  213. package/lib/schema/generated/ifc4x3.js +1325 -0
  214. package/lib/schema/registry.d.ts +7 -0
  215. package/lib/schema/registry.js +37 -0
  216. package/lib/schema/schema-types.d.ts +45 -0
  217. package/lib/schema/schema-types.js +1 -0
  218. package/lib/schema/schema.d.ts +23 -0
  219. package/lib/schema/schema.js +136 -0
  220. package/lib/step/constants.d.ts +48 -0
  221. package/lib/step/constants.js +48 -0
  222. package/lib/step/encoder.d.ts +21 -0
  223. package/lib/step/encoder.js +321 -0
  224. package/lib/step/errors.d.ts +39 -0
  225. package/lib/step/errors.js +45 -0
  226. package/lib/step/file-index.d.ts +2 -0
  227. package/lib/step/file-index.js +221 -0
  228. package/lib/step/header.d.ts +4 -0
  229. package/lib/step/header.js +52 -0
  230. package/lib/step/numbers.d.ts +3 -0
  231. package/lib/step/numbers.js +73 -0
  232. package/lib/step/reader.d.ts +2 -0
  233. package/lib/step/reader.js +160 -0
  234. package/lib/step/scanner.d.ts +13 -0
  235. package/lib/step/scanner.js +203 -0
  236. package/lib/step/step-types.d.ts +170 -0
  237. package/lib/step/step-types.js +1 -0
  238. package/lib/step/strings.d.ts +2 -0
  239. package/lib/step/strings.js +150 -0
  240. package/lib/step/values.d.ts +13 -0
  241. package/lib/step/values.js +51 -0
  242. package/package.json +51 -5
@@ -0,0 +1,64 @@
1
+ import { resolveDto } from "@bitbybit-dev/base";
2
+ import { requireFinite, requireOutline } from "../../build/checks";
3
+ import { createSpace, spacesOf } from "../../build/spaces";
4
+ import * as Inputs from "../inputs";
5
+ import { DEFAULT_MILLIMETRES } from "./defaults.constants";
6
+ import { editModel, lengthIn, lengthTolerance, modelOf, oneOf, resolveId } from "./service-support";
7
+ /**
8
+ * Spaces: the rooms and areas of a storey, each an outline in the storey's plan extruded up to its
9
+ * height, with a number and a name. Tools schedule rooms and their areas from them.
10
+ * @beta
11
+ */
12
+ export class IFCSpaces {
13
+ /**
14
+ * Adds a space to a storey: a room or an area, from an outline in the storey's plan, `height`
15
+ * high. A space is part of its storey, as IFC aggregates spaces, rather than an element on it.
16
+ * @param inputs - The model, the storey, the outline, the height, and the space's number and name
17
+ * @returns A new model with the space
18
+ * @group create
19
+ * @shortname add space
20
+ * @drawable false
21
+ * @example
22
+ * ```typescript
23
+ * model = await bitbybit.ifc.spaces.add({ model, storey: "ground", id: "kitchen", name: "0.01", longName: "Kitchen", outline: [[0, 0], [4000, 0], [4000, 3000], [0, 3000]], height: 2700 });
24
+ * ```
25
+ */
26
+ add(inputs) {
27
+ const resolved = resolveDto(Inputs.IFC.AddSpaceDto, inputs);
28
+ const model = modelOf(resolved.model);
29
+ requireOutline(resolved.outline, "outline");
30
+ requireFinite(resolved.baseOffset, "base offset");
31
+ const storey = resolveId(model, resolved.storey, "IfcBuildingStorey", "storey");
32
+ const predefinedType = oneOf(resolved.predefinedType, Inputs.IFC.spacePredefinedTypeEnum, "predefined type");
33
+ const height = lengthIn(model, resolved.height, DEFAULT_MILLIMETRES.spaceHeight);
34
+ return editModel(model, (tx, writer) => {
35
+ createSpace(tx, writer, {
36
+ storey,
37
+ id: resolved.id,
38
+ name: resolved.name,
39
+ longName: resolved.longName,
40
+ outline: resolved.outline,
41
+ height,
42
+ baseOffset: resolved.baseOffset,
43
+ predefinedType,
44
+ }, lengthTolerance(model));
45
+ });
46
+ }
47
+ /**
48
+ * Lists the spaces of the model, or of one storey, with their numbers, names, areas and heights.
49
+ * @param inputs - The model and, optionally, the storey
50
+ * @returns The spaces
51
+ * @group query
52
+ * @shortname list spaces
53
+ * @drawable false
54
+ * @example
55
+ * ```typescript
56
+ * const rooms = await bitbybit.ifc.spaces.list({ model, storey: "ground" });
57
+ * ```
58
+ */
59
+ list(inputs) {
60
+ const model = modelOf(inputs.model);
61
+ const storey = inputs.storey === undefined ? undefined : resolveId(model, inputs.storey, "IfcBuildingStorey", "storey");
62
+ return spacesOf(model, storey);
63
+ }
64
+ }
@@ -0,0 +1,54 @@
1
+ import type { IfcModel } from "../../model/model-types";
2
+ import * as Inputs from "../inputs";
3
+ /**
4
+ * The spatial structure of a model: the storeys of its building, which every wall, slab, column and
5
+ * beam is added to. A storey has an elevation; what stands on it is placed in its plan, with Z up
6
+ * from its floor.
7
+ * @beta
8
+ */
9
+ export declare class IFCSpatial {
10
+ /**
11
+ * Adds a storey to the model's building at an elevation above the building's origin.
12
+ *
13
+ * Give it an `id` such as `ground` to refer to it when adding walls and slabs. The model must
14
+ * have exactly one building, as `model.create` makes.
15
+ * @param inputs - The model, the storey's id, name and elevation
16
+ * @returns A new model with the storey
17
+ * @group storeys
18
+ * @shortname add storey
19
+ * @drawable false
20
+ * @example
21
+ * ```typescript
22
+ * model = await bitbybit.ifc.spatial.addStorey({ model, id: "first", name: "First floor", elevation: 3000 });
23
+ * ```
24
+ */
25
+ addStorey(inputs: Inputs.IFC.AddStoreyDto<IfcModel>): IfcModel;
26
+ /**
27
+ * Raises or lowers a storey to a new elevation. Everything placed on the storey moves with it;
28
+ * the other storeys stay where they are.
29
+ * @param inputs - The model, the storey and its new elevation
30
+ * @returns A new model with the storey moved
31
+ * @group storeys
32
+ * @shortname set storey elevation
33
+ * @drawable false
34
+ * @example
35
+ * ```typescript
36
+ * model = await bitbybit.ifc.spatial.setElevation({ model, storey: "first", elevation: 3200 });
37
+ * ```
38
+ */
39
+ setElevation(inputs: Inputs.IFC.SetStoreyElevationDto<IfcModel>): IfcModel;
40
+ /**
41
+ * Lists the storeys of the model's buildings, lowest first, with their GlobalIds, names and
42
+ * elevations.
43
+ * @param inputs - The model
44
+ * @returns The storeys, lowest first
45
+ * @group storeys
46
+ * @shortname storeys
47
+ * @drawable false
48
+ * @example
49
+ * ```typescript
50
+ * const storeys = await bitbybit.ifc.spatial.storeys({ model });
51
+ * ```
52
+ */
53
+ storeys(inputs: Inputs.IFC.ModelDto<IfcModel>): Inputs.IFC.StoreyInfoDto[];
54
+ }
@@ -0,0 +1,75 @@
1
+ import { resolveDto } from "@bitbybit-dev/base";
2
+ import { requireFinite } from "../../build/checks";
3
+ import { addStorey, onlyBuilding, setStoreyElevation, storeysOf } from "../../build/spatial";
4
+ import * as Inputs from "../inputs";
5
+ import { editModel, modelOf, resolveId } from "./service-support";
6
+ /**
7
+ * The spatial structure of a model: the storeys of its building, which every wall, slab, column and
8
+ * beam is added to. A storey has an elevation; what stands on it is placed in its plan, with Z up
9
+ * from its floor.
10
+ * @beta
11
+ */
12
+ export class IFCSpatial {
13
+ /**
14
+ * Adds a storey to the model's building at an elevation above the building's origin.
15
+ *
16
+ * Give it an `id` such as `ground` to refer to it when adding walls and slabs. The model must
17
+ * have exactly one building, as `model.create` makes.
18
+ * @param inputs - The model, the storey's id, name and elevation
19
+ * @returns A new model with the storey
20
+ * @group storeys
21
+ * @shortname add storey
22
+ * @drawable false
23
+ * @example
24
+ * ```typescript
25
+ * model = await bitbybit.ifc.spatial.addStorey({ model, id: "first", name: "First floor", elevation: 3000 });
26
+ * ```
27
+ */
28
+ addStorey(inputs) {
29
+ const resolved = resolveDto(Inputs.IFC.AddStoreyDto, inputs);
30
+ const model = modelOf(resolved.model);
31
+ requireFinite(resolved.elevation, "storey's elevation");
32
+ const building = onlyBuilding(model);
33
+ return editModel(model, (tx, writer) => {
34
+ addStorey(tx, writer, building, resolved.id, resolved.name, resolved.elevation);
35
+ });
36
+ }
37
+ /**
38
+ * Raises or lowers a storey to a new elevation. Everything placed on the storey moves with it;
39
+ * the other storeys stay where they are.
40
+ * @param inputs - The model, the storey and its new elevation
41
+ * @returns A new model with the storey moved
42
+ * @group storeys
43
+ * @shortname set storey elevation
44
+ * @drawable false
45
+ * @example
46
+ * ```typescript
47
+ * model = await bitbybit.ifc.spatial.setElevation({ model, storey: "first", elevation: 3200 });
48
+ * ```
49
+ */
50
+ setElevation(inputs) {
51
+ const resolved = resolveDto(Inputs.IFC.SetStoreyElevationDto, inputs);
52
+ const model = modelOf(resolved.model);
53
+ requireFinite(resolved.elevation, "storey's elevation");
54
+ const storey = resolveId(model, resolved.storey, "IfcBuildingStorey", "storey");
55
+ return editModel(model, (tx, writer) => {
56
+ setStoreyElevation(tx, writer, storey, resolved.elevation);
57
+ });
58
+ }
59
+ /**
60
+ * Lists the storeys of the model's buildings, lowest first, with their GlobalIds, names and
61
+ * elevations.
62
+ * @param inputs - The model
63
+ * @returns The storeys, lowest first
64
+ * @group storeys
65
+ * @shortname storeys
66
+ * @drawable false
67
+ * @example
68
+ * ```typescript
69
+ * const storeys = await bitbybit.ifc.spatial.storeys({ model });
70
+ * ```
71
+ */
72
+ storeys(inputs) {
73
+ return storeysOf(modelOf(inputs.model));
74
+ }
75
+ }
@@ -0,0 +1,140 @@
1
+ import type { IfcModel } from "../../model/model-types";
2
+ import * as Inputs from "../inputs";
3
+ /**
4
+ * Walls: straight walls on a storey, from an axis, a height and a thickness or a layer set, joined
5
+ * at their corners and clipped under roofs. A wall keeps its axis, layers and height, so joins and
6
+ * clippings are worked out again from them whenever a wall changes, and tools that edit IFC walls
7
+ * edit these as walls.
8
+ *
9
+ * Doors, windows and openings go into walls through `doors`, `windows` and `openings`.
10
+ * @beta
11
+ */
12
+ export declare class IFCWalls {
13
+ /**
14
+ * Adds a straight wall on a storey, from `start` to `end` in the storey's plan, `height` high.
15
+ *
16
+ * The wall is made of its type's layer set, the named `layerSet`, or one layer `thickness` thick,
17
+ * in that order of preference. `alignment` says which side of the axis the layers lie on; join
18
+ * walls at their corners afterwards with `walls.connect`.
19
+ * @param inputs - The model, the storey, the axis, the height, the thickness or layer set, and the alignment
20
+ * @returns A new model with the wall
21
+ * @group create
22
+ * @shortname add wall
23
+ * @drawable false
24
+ * @example
25
+ * ```typescript
26
+ * model = await bitbybit.ifc.walls.add({ model, storey: "ground", id: "south", start: [0, 0], end: [10000, 0], height: 2700, thickness: 250 });
27
+ * model = await bitbybit.ifc.walls.add({ model, storey: "ground", id: "east", start: [10000, 0], end: [10000, 8000], height: 2700, thickness: 250 });
28
+ * model = await bitbybit.ifc.walls.connect({ model, wall: "south", other: "east" });
29
+ * ```
30
+ */
31
+ add(inputs: Inputs.IFC.AddWallDto<IfcModel>): IfcModel;
32
+ /**
33
+ * Joins two walls where they meet, trimming both: two walls meeting at their ends are mitred
34
+ * into a corner, and a wall ending against another's side is cut back to that side.
35
+ *
36
+ * The join is recorded in the model, and joining the two walls again replaces it. Walls that do
37
+ * not meet cannot be joined.
38
+ * @param inputs - The model and the two walls
39
+ * @returns A new model with the walls joined
40
+ * @group edit
41
+ * @shortname connect walls
42
+ * @drawable false
43
+ * @example
44
+ * ```typescript
45
+ * model = await bitbybit.ifc.walls.connect({ model, wall: "south", other: "east" });
46
+ * ```
47
+ */
48
+ connect(inputs: Inputs.IFC.ConnectWallsDto<IfcModel>): IfcModel;
49
+ /**
50
+ * Takes away the join between two walls, so the ends it trimmed are square again.
51
+ * @param inputs - The model and the two walls
52
+ * @returns A new model with the walls no longer joined
53
+ * @group edit
54
+ * @shortname disconnect walls
55
+ * @drawable false
56
+ * @example
57
+ * ```typescript
58
+ * model = await bitbybit.ifc.walls.disconnect({ model, wall: "south", other: "east" });
59
+ * ```
60
+ */
61
+ disconnect(inputs: Inputs.IFC.ConnectWallsDto<IfcModel>): IfcModel;
62
+ /**
63
+ * Changes a wall's axis, height, base, layers or alignment. Joined walls are trimmed again,
64
+ * clippings stay put, and openings, doors and windows move with it, keeping their offset and sill. A
65
+ * change is refused when it parts the wall from a joined wall, puts an opening off its end, or leaves
66
+ * behind an opening, door or window placed elsewhere.
67
+ * @param inputs - The model, the wall and what to change
68
+ * @returns A new model with the wall changed
69
+ * @group edit
70
+ * @shortname edit wall
71
+ * @drawable false
72
+ * @example
73
+ * ```typescript
74
+ * model = await bitbybit.ifc.walls.edit({ model, wall: "south", height: 3200, thickness: 300 });
75
+ * ```
76
+ */
77
+ edit(inputs: Inputs.IFC.EditWallDto<IfcModel>): IfcModel;
78
+ /**
79
+ * Reads a wall's parameters back from the model: its axis, height, base, thickness, layers and
80
+ * alignment, the walls it is joined to, its openings and its clippings. It reads walls other tools
81
+ * wrote too, when they keep an axis and a layer set usage as IFC's standard walls do.
82
+ * @param inputs - The model and the wall
83
+ * @returns The wall's parameters, in the plan of its storey
84
+ * @group query
85
+ * @shortname wall parameters
86
+ * @drawable false
87
+ * @example
88
+ * ```typescript
89
+ * const wall = await bitbybit.ifc.walls.parameters({ model, wall: "south" });
90
+ * ```
91
+ */
92
+ parameters(inputs: Inputs.IFC.WallDto<IfcModel>): Inputs.IFC.WallParametersDto;
93
+ /**
94
+ * Clips a wall with a plane, removing the part on the side the plane's normal points to, as a
95
+ * wall is cut under a sloping roof.
96
+ *
97
+ * The plane is given in the wall's storey, and a wall can be clipped by several planes. Clipping
98
+ * keeps the wall's full height in its data, so joins stay right.
99
+ * @param inputs - The model, the wall, a point on the plane and its normal
100
+ * @returns A new model with the wall clipped
101
+ * @group edit
102
+ * @shortname clip wall by plane
103
+ * @drawable false
104
+ * @example
105
+ * ```typescript
106
+ * model = await bitbybit.ifc.walls.clipByPlane({ model, wall: "south", origin: [0, 0, 2600], normal: [0, -0.5, 1] });
107
+ * ```
108
+ */
109
+ clipByPlane(inputs: Inputs.IFC.ClipWallDto<IfcModel>): IfcModel;
110
+ /**
111
+ * Clips a wall under a roof by each of the roof's planes that cuts it: under the eaves level or
112
+ * along the slope, under a gable to the gable's triangle. Planes above the wall leave it alone, and
113
+ * clipping again changes nothing. A plane below the wall's bottom everywhere is refused, as it would
114
+ * leave nothing of the wall.
115
+ * @param inputs - The model, the wall and the roof
116
+ * @returns A new model with the wall clipped
117
+ * @group edit
118
+ * @shortname clip wall by roof
119
+ * @drawable false
120
+ * @example
121
+ * ```typescript
122
+ * model = await bitbybit.ifc.walls.clipByRoof({ model, wall: "west", roof: "roof" });
123
+ * ```
124
+ */
125
+ clipByRoof(inputs: Inputs.IFC.ClipWallByRoofDto<IfcModel>): IfcModel;
126
+ /**
127
+ * Adds a wall type: a named kind of wall made of a layer set. Walls added with this type as their
128
+ * `wallType` are made of its layers.
129
+ * @param inputs - The model, the type's id and name, its layer set and its kind
130
+ * @returns A new model with the wall type
131
+ * @group types
132
+ * @shortname add wall type
133
+ * @drawable false
134
+ * @example
135
+ * ```typescript
136
+ * model = await bitbybit.ifc.walls.addType({ model, id: "exterior", name: "Exterior 230", layerSet: "Exterior wall" });
137
+ * ```
138
+ */
139
+ addType(inputs: Inputs.IFC.AddWallTypeDto<IfcModel>): IfcModel;
140
+ }
@@ -0,0 +1,268 @@
1
+ import { resolveDto } from "@bitbybit-dev/base";
2
+ import { WORLD_AXES, pointToWorld, vectorToWorld } from "@bitbybit-dev/base/lib/api/services/helpers/frame-axes";
3
+ import { requireFinite, requirePoint } from "../../build/checks";
4
+ import { PARALLEL_TOLERANCE, POINT2_SIZE, POINT3_SIZE } from "../../build/constants";
5
+ import { associateMaterial, layerSetFor, materialOf, requireLayerSet } from "../../build/materials";
6
+ import { containerOf, storeyFrame } from "../../build/spatial";
7
+ import { declareInProject } from "../../build/type-objects";
8
+ import { clipWallByRoof } from "../../build/roof-clipping";
9
+ import { disconnectWalls, editWall } from "../../build/wall-edits";
10
+ import { wallParametersOf } from "../../build/wall-parameters";
11
+ import { clipWall, connectWalls, createWall } from "../../build/walls";
12
+ import { enumValue } from "../../step/values";
13
+ import * as Inputs from "../inputs";
14
+ import { DEFAULT_MILLIMETRES } from "./defaults.constants";
15
+ import { editModel, lengthIn, lengthTolerance, modelOf, oneOf, resolveId } from "./service-support";
16
+ function typeLayerSet(tx, wallType, name) {
17
+ const material = materialOf(tx, wallType);
18
+ if (material === undefined || tx.entity(material).type !== "IfcMaterialLayerSet") {
19
+ throw new Error(`The wall type '${name}' has no layer set`);
20
+ }
21
+ return material;
22
+ }
23
+ /**
24
+ * Walls: straight walls on a storey, from an axis, a height and a thickness or a layer set, joined
25
+ * at their corners and clipped under roofs. A wall keeps its axis, layers and height, so joins and
26
+ * clippings are worked out again from them whenever a wall changes, and tools that edit IFC walls
27
+ * edit these as walls.
28
+ *
29
+ * Doors, windows and openings go into walls through `doors`, `windows` and `openings`.
30
+ * @beta
31
+ */
32
+ export class IFCWalls {
33
+ /**
34
+ * Adds a straight wall on a storey, from `start` to `end` in the storey's plan, `height` high.
35
+ *
36
+ * The wall is made of its type's layer set, the named `layerSet`, or one layer `thickness` thick,
37
+ * in that order of preference. `alignment` says which side of the axis the layers lie on; join
38
+ * walls at their corners afterwards with `walls.connect`.
39
+ * @param inputs - The model, the storey, the axis, the height, the thickness or layer set, and the alignment
40
+ * @returns A new model with the wall
41
+ * @group create
42
+ * @shortname add wall
43
+ * @drawable false
44
+ * @example
45
+ * ```typescript
46
+ * model = await bitbybit.ifc.walls.add({ model, storey: "ground", id: "south", start: [0, 0], end: [10000, 0], height: 2700, thickness: 250 });
47
+ * model = await bitbybit.ifc.walls.add({ model, storey: "ground", id: "east", start: [10000, 0], end: [10000, 8000], height: 2700, thickness: 250 });
48
+ * model = await bitbybit.ifc.walls.connect({ model, wall: "south", other: "east" });
49
+ * ```
50
+ */
51
+ add(inputs) {
52
+ const resolved = resolveDto(Inputs.IFC.AddWallDto, inputs);
53
+ const model = modelOf(resolved.model);
54
+ requirePoint(resolved.start, POINT2_SIZE, "start");
55
+ requirePoint(resolved.end, POINT2_SIZE, "end");
56
+ const storey = resolveId(model, resolved.storey, "IfcBuildingStorey", "storey");
57
+ const typeName = resolved.wallType;
58
+ const wallType = typeName === undefined ? undefined : resolveId(model, typeName, "IfcWallType", "wall type");
59
+ const alignment = oneOf(resolved.alignment, Inputs.IFC.wallAlignmentEnum, "wall alignment");
60
+ const predefinedType = oneOf(resolved.predefinedType, Inputs.IFC.wallPredefinedTypeEnum, "predefined type");
61
+ const height = lengthIn(model, resolved.height, DEFAULT_MILLIMETRES.wallHeight);
62
+ const thickness = lengthIn(model, resolved.thickness, DEFAULT_MILLIMETRES.wallThickness);
63
+ return editModel(model, (tx, writer) => {
64
+ createWall(tx, writer, {
65
+ storey,
66
+ id: resolved.id,
67
+ name: resolved.name,
68
+ start: resolved.start,
69
+ end: resolved.end,
70
+ height,
71
+ baseOffset: resolved.baseOffset,
72
+ layerSet: wallType === undefined || typeName === undefined ? layerSetFor(tx, writer, resolved.layerSet, thickness, "Wall") : typeLayerSet(tx, wallType, typeName),
73
+ alignment,
74
+ wallType,
75
+ predefinedType: wallType === undefined ? predefinedType : undefined,
76
+ }, lengthTolerance(model));
77
+ });
78
+ }
79
+ /**
80
+ * Joins two walls where they meet, trimming both: two walls meeting at their ends are mitred
81
+ * into a corner, and a wall ending against another's side is cut back to that side.
82
+ *
83
+ * The join is recorded in the model, and joining the two walls again replaces it. Walls that do
84
+ * not meet cannot be joined.
85
+ * @param inputs - The model and the two walls
86
+ * @returns A new model with the walls joined
87
+ * @group edit
88
+ * @shortname connect walls
89
+ * @drawable false
90
+ * @example
91
+ * ```typescript
92
+ * model = await bitbybit.ifc.walls.connect({ model, wall: "south", other: "east" });
93
+ * ```
94
+ */
95
+ connect(inputs) {
96
+ const model = modelOf(inputs.model);
97
+ const wall = resolveId(model, inputs.wall, "IfcWall", "wall");
98
+ const other = resolveId(model, inputs.other, "IfcWall", "wall");
99
+ return editModel(model, (tx, writer) => {
100
+ connectWalls(tx, writer, wall, other, lengthTolerance(model), PARALLEL_TOLERANCE);
101
+ });
102
+ }
103
+ /**
104
+ * Takes away the join between two walls, so the ends it trimmed are square again.
105
+ * @param inputs - The model and the two walls
106
+ * @returns A new model with the walls no longer joined
107
+ * @group edit
108
+ * @shortname disconnect walls
109
+ * @drawable false
110
+ * @example
111
+ * ```typescript
112
+ * model = await bitbybit.ifc.walls.disconnect({ model, wall: "south", other: "east" });
113
+ * ```
114
+ */
115
+ disconnect(inputs) {
116
+ const model = modelOf(inputs.model);
117
+ const wall = resolveId(model, inputs.wall, "IfcWall", "wall");
118
+ const other = resolveId(model, inputs.other, "IfcWall", "wall");
119
+ return editModel(model, (tx, writer) => {
120
+ disconnectWalls(tx, writer, wall, other, lengthTolerance(model), PARALLEL_TOLERANCE);
121
+ });
122
+ }
123
+ /**
124
+ * Changes a wall's axis, height, base, layers or alignment. Joined walls are trimmed again,
125
+ * clippings stay put, and openings, doors and windows move with it, keeping their offset and sill. A
126
+ * change is refused when it parts the wall from a joined wall, puts an opening off its end, or leaves
127
+ * behind an opening, door or window placed elsewhere.
128
+ * @param inputs - The model, the wall and what to change
129
+ * @returns A new model with the wall changed
130
+ * @group edit
131
+ * @shortname edit wall
132
+ * @drawable false
133
+ * @example
134
+ * ```typescript
135
+ * model = await bitbybit.ifc.walls.edit({ model, wall: "south", height: 3200, thickness: 300 });
136
+ * ```
137
+ */
138
+ edit(inputs) {
139
+ const resolved = resolveDto(Inputs.IFC.EditWallDto, inputs);
140
+ const model = modelOf(resolved.model);
141
+ const wall = resolveId(model, resolved.wall, "IfcWall", "wall");
142
+ if (resolved.start !== undefined) {
143
+ requirePoint(resolved.start, POINT2_SIZE, "start");
144
+ }
145
+ if (resolved.end !== undefined) {
146
+ requirePoint(resolved.end, POINT2_SIZE, "end");
147
+ }
148
+ if (resolved.baseOffset !== undefined) {
149
+ requireFinite(resolved.baseOffset, "base offset");
150
+ }
151
+ const alignment = resolved.alignment === undefined ? undefined : oneOf(resolved.alignment, Inputs.IFC.wallAlignmentEnum, "wall alignment");
152
+ const tolerance = lengthTolerance(model);
153
+ const storey = containerOf(model, wall);
154
+ const plan = storey === undefined ? WORLD_AXES : storeyFrame(model, storey);
155
+ const inWorld = (point) => {
156
+ const world = pointToWorld(plan, [point[0], point[1], 0]);
157
+ return [world[0], world[1]];
158
+ };
159
+ return editModel(model, (tx, writer) => {
160
+ editWall(tx, writer, wall, {
161
+ start: resolved.start === undefined ? undefined : inWorld(resolved.start),
162
+ end: resolved.end === undefined ? undefined : inWorld(resolved.end),
163
+ bottom: resolved.baseOffset === undefined ? undefined : pointToWorld(plan, [0, 0, resolved.baseOffset])[2],
164
+ height: resolved.height,
165
+ layerSet: resolved.layerSet !== undefined ? requireLayerSet(tx, resolved.layerSet) : resolved.thickness !== undefined ? layerSetFor(tx, writer, undefined, resolved.thickness, "Wall") : undefined,
166
+ alignment,
167
+ }, tolerance, PARALLEL_TOLERANCE);
168
+ });
169
+ }
170
+ /**
171
+ * Reads a wall's parameters back from the model: its axis, height, base, thickness, layers and
172
+ * alignment, the walls it is joined to, its openings and its clippings. It reads walls other tools
173
+ * wrote too, when they keep an axis and a layer set usage as IFC's standard walls do.
174
+ * @param inputs - The model and the wall
175
+ * @returns The wall's parameters, in the plan of its storey
176
+ * @group query
177
+ * @shortname wall parameters
178
+ * @drawable false
179
+ * @example
180
+ * ```typescript
181
+ * const wall = await bitbybit.ifc.walls.parameters({ model, wall: "south" });
182
+ * ```
183
+ */
184
+ parameters(inputs) {
185
+ const model = modelOf(inputs.model);
186
+ return wallParametersOf(model, resolveId(model, inputs.wall, "IfcWall", "wall"), lengthTolerance(model));
187
+ }
188
+ /**
189
+ * Clips a wall with a plane, removing the part on the side the plane's normal points to, as a
190
+ * wall is cut under a sloping roof.
191
+ *
192
+ * The plane is given in the wall's storey, and a wall can be clipped by several planes. Clipping
193
+ * keeps the wall's full height in its data, so joins stay right.
194
+ * @param inputs - The model, the wall, a point on the plane and its normal
195
+ * @returns A new model with the wall clipped
196
+ * @group edit
197
+ * @shortname clip wall by plane
198
+ * @drawable false
199
+ * @example
200
+ * ```typescript
201
+ * model = await bitbybit.ifc.walls.clipByPlane({ model, wall: "south", origin: [0, 0, 2600], normal: [0, -0.5, 1] });
202
+ * ```
203
+ */
204
+ clipByPlane(inputs) {
205
+ const resolved = resolveDto(Inputs.IFC.ClipWallDto, inputs);
206
+ const model = modelOf(resolved.model);
207
+ requirePoint(resolved.origin, POINT3_SIZE, "origin");
208
+ requirePoint(resolved.normal, POINT3_SIZE, "normal");
209
+ const wall = resolveId(model, resolved.wall, "IfcWall", "wall");
210
+ const storey = containerOf(model, wall);
211
+ const frame = storey === undefined ? undefined : storeyFrame(model, storey);
212
+ const origin = frame ? pointToWorld(frame, resolved.origin) : resolved.origin;
213
+ const normal = frame ? vectorToWorld(frame, resolved.normal) : resolved.normal;
214
+ return editModel(model, (tx, writer) => {
215
+ clipWall(tx, writer, wall, origin, normal);
216
+ });
217
+ }
218
+ /**
219
+ * Clips a wall under a roof by each of the roof's planes that cuts it: under the eaves level or
220
+ * along the slope, under a gable to the gable's triangle. Planes above the wall leave it alone, and
221
+ * clipping again changes nothing. A plane below the wall's bottom everywhere is refused, as it would
222
+ * leave nothing of the wall.
223
+ * @param inputs - The model, the wall and the roof
224
+ * @returns A new model with the wall clipped
225
+ * @group edit
226
+ * @shortname clip wall by roof
227
+ * @drawable false
228
+ * @example
229
+ * ```typescript
230
+ * model = await bitbybit.ifc.walls.clipByRoof({ model, wall: "west", roof: "roof" });
231
+ * ```
232
+ */
233
+ clipByRoof(inputs) {
234
+ const model = modelOf(inputs.model);
235
+ const wall = resolveId(model, inputs.wall, "IfcWall", "wall");
236
+ const roof = resolveId(model, inputs.roof, "IfcRoof", "roof");
237
+ return editModel(model, (tx, writer) => {
238
+ clipWallByRoof(tx, writer, wall, roof, lengthTolerance(model));
239
+ });
240
+ }
241
+ /**
242
+ * Adds a wall type: a named kind of wall made of a layer set. Walls added with this type as their
243
+ * `wallType` are made of its layers.
244
+ * @param inputs - The model, the type's id and name, its layer set and its kind
245
+ * @returns A new model with the wall type
246
+ * @group types
247
+ * @shortname add wall type
248
+ * @drawable false
249
+ * @example
250
+ * ```typescript
251
+ * model = await bitbybit.ifc.walls.addType({ model, id: "exterior", name: "Exterior 230", layerSet: "Exterior wall" });
252
+ * ```
253
+ */
254
+ addType(inputs) {
255
+ const resolved = resolveDto(Inputs.IFC.AddWallTypeDto, inputs);
256
+ const model = modelOf(resolved.model);
257
+ return editModel(model, (tx, writer) => {
258
+ const layerSet = requireLayerSet(tx, resolved.layerSet);
259
+ const type = writer.create("IfcWallType", {
260
+ GlobalId: tx.globalId(resolved.id),
261
+ Name: resolved.name,
262
+ PredefinedType: enumValue(oneOf(resolved.predefinedType, Inputs.IFC.wallPredefinedTypeEnum, "predefined type")),
263
+ });
264
+ associateMaterial(tx, writer, [type], layerSet);
265
+ declareInProject(tx, writer, type);
266
+ });
267
+ }
268
+ }
@@ -0,0 +1,46 @@
1
+ import type { IfcModel } from "../../model/model-types";
2
+ import * as Inputs from "../inputs";
3
+ /**
4
+ * Windows: window types, each a frame around one pane of glass, and windows of those types placed
5
+ * in walls. A window cuts its own opening and shares its type's geometry, so a type placed many
6
+ * times is written once.
7
+ * @beta
8
+ */
9
+ export declare class IFCWindows {
10
+ /**
11
+ * Adds a window type: a frame around one pane, `width` by `height`, which windows are then
12
+ * placed from.
13
+ *
14
+ * The frame's members are `frameThickness` wide and `frameDepth` deep; the glass sits in the
15
+ * middle of the depth. A `frameMaterial` and a `glassMaterial` give each part its material and
16
+ * colour.
17
+ * @param inputs - The model, the type's id and name, and its sizes
18
+ * @returns A new model with the window type
19
+ * @group types
20
+ * @shortname add window type
21
+ * @drawable false
22
+ * @example
23
+ * ```typescript
24
+ * model = await bitbybit.ifc.materials.add({ model, name: "Glass", color: "#a9c7d6", transparency: 0.7 });
25
+ * model = await bitbybit.ifc.windows.addType({ model, id: "window-120", name: "Window 1200", width: 1200, height: 1400, glassMaterial: "Glass" });
26
+ * ```
27
+ */
28
+ addType(inputs: Inputs.IFC.AddWindowTypeDto<IfcModel>): IfcModel;
29
+ /**
30
+ * Places a window of a window type in a wall, `offset` along the wall's axis from its start and
31
+ * `sill` above its base, cutting an opening as wide and high as the type.
32
+ *
33
+ * The window is centred in the wall's thickness and belongs to the wall's storey. It must fit
34
+ * along the wall.
35
+ * @param inputs - The model, the wall, the window type, and where the window goes
36
+ * @returns A new model with the window
37
+ * @group create
38
+ * @shortname add window
39
+ * @drawable false
40
+ * @example
41
+ * ```typescript
42
+ * model = await bitbybit.ifc.windows.add({ model, wall: "south", windowType: "window-120", offset: 6000, sill: 900 });
43
+ * ```
44
+ */
45
+ add(inputs: Inputs.IFC.AddWindowDto<IfcModel>): IfcModel;
46
+ }