@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,142 @@
1
+ import { resolveDto } from "@bitbybit-dev/base";
2
+ import { addPropertySet, propertySetsOf, removePropertySet, removePropertyValues, setPropertyValues } from "../../build/properties";
3
+ import * as Inputs from "../inputs";
4
+ import { editModel, modelOf, resolveId } from "./service-support";
5
+ function propertySpecs(properties) {
6
+ if (!Array.isArray(properties)) {
7
+ throw new TypeError("Expected the properties as a list");
8
+ }
9
+ return properties.map((property) => {
10
+ const full = resolveDto(Inputs.IFC.PropertyDto, property);
11
+ if (typeof full.value !== "string" && typeof full.value !== "boolean" && !(typeof full.value === "number" && Number.isFinite(full.value))) {
12
+ throw new TypeError(`The property '${full.name}' needs a text, a finite number, or true or false`);
13
+ }
14
+ return { name: full.name, value: full.value, type: full.type };
15
+ });
16
+ }
17
+ /**
18
+ * Properties: named sets of values attached to elements and types, such as `Pset_WallCommon` with
19
+ * `IsExternal` and `FireRating`, which other tools list, filter and schedule by.
20
+ * @beta
21
+ */
22
+ export class IFCProperties {
23
+ /**
24
+ * Attaches a property set to one or more objects: walls, doors, types or any object with a
25
+ * GlobalId.
26
+ *
27
+ * Each value is written as its `type`, or as a label, an integer, a real or a boolean by the
28
+ * kind of value. One set is shared by every object it is attached to.
29
+ * @param inputs - The model, the objects, the set's name and its properties
30
+ * @returns A new model with the property set
31
+ * @group properties
32
+ * @shortname add property set
33
+ * @drawable false
34
+ * @example
35
+ * ```typescript
36
+ * model = await bitbybit.ifc.properties.addSet({
37
+ * model,
38
+ * elements: ["south", "east"],
39
+ * name: "Pset_WallCommon",
40
+ * properties: [{ name: "IsExternal", value: true }, { name: "FireRating", value: "REI 60" }],
41
+ * });
42
+ * ```
43
+ */
44
+ addSet(inputs) {
45
+ const resolved = resolveDto(Inputs.IFC.AddPropertySetDto, inputs);
46
+ const model = modelOf(resolved.model);
47
+ if (!Array.isArray(resolved.elements) || !resolved.elements.length) {
48
+ throw new TypeError("A property set is attached to a list of at least one object");
49
+ }
50
+ const objects = resolved.elements.map((element) => resolveId(model, element, "IfcObjectDefinition", "object"));
51
+ const properties = propertySpecs(resolved.properties);
52
+ return editModel(model, (tx, writer) => {
53
+ addPropertySet(tx, writer, objects, resolved.name, properties);
54
+ });
55
+ }
56
+ /**
57
+ * Reads the property sets attached to an object, with each single value by name.
58
+ *
59
+ * Values of other kinds of property, such as lists and tables, and logical values that are
60
+ * unknown are left out.
61
+ * @param inputs - The model and the object
62
+ * @returns The object's property sets
63
+ * @group properties
64
+ * @shortname get property sets
65
+ * @drawable false
66
+ * @example
67
+ * ```typescript
68
+ * const sets = await bitbybit.ifc.properties.getSets({ model, element: "south" });
69
+ * ```
70
+ */
71
+ getSets(inputs) {
72
+ const model = modelOf(inputs.model);
73
+ return propertySetsOf(model, resolveId(model, inputs.element, "IfcObjectDefinition", "object"));
74
+ }
75
+ /**
76
+ * Sets property values of one object, in its property set of the given name, and makes the set
77
+ * when the object has none. A set the object shares with other objects is copied first, so only
78
+ * this object's values change.
79
+ * @param inputs - The model, the object, the set's name and the properties
80
+ * @returns A new model with the values set
81
+ * @group properties
82
+ * @shortname set property values
83
+ * @drawable false
84
+ * @example
85
+ * ```typescript
86
+ * model = await bitbybit.ifc.properties.setValues({ model, element: "south", name: "Pset_WallCommon", properties: [{ name: "FireRating", value: "REI 90" }] });
87
+ * ```
88
+ */
89
+ setValues(inputs) {
90
+ const resolved = resolveDto(Inputs.IFC.SetPropertyValuesDto, inputs);
91
+ const model = modelOf(resolved.model);
92
+ const object = resolveId(model, resolved.element, "IfcObjectDefinition", "object");
93
+ const properties = propertySpecs(resolved.properties);
94
+ return editModel(model, (tx, writer) => {
95
+ setPropertyValues(tx, writer, object, resolved.name, properties);
96
+ });
97
+ }
98
+ /**
99
+ * Takes properties out of one object's property set; the set goes when none are left. A set the
100
+ * object shares with other objects is copied first, so the others keep their values.
101
+ * @param inputs - The model, the object, the set's name and the names of the properties
102
+ * @returns A new model without the properties
103
+ * @group properties
104
+ * @shortname remove property values
105
+ * @drawable false
106
+ * @example
107
+ * ```typescript
108
+ * model = await bitbybit.ifc.properties.removeValues({ model, element: "south", name: "Pset_WallCommon", names: ["FireRating"] });
109
+ * ```
110
+ */
111
+ removeValues(inputs) {
112
+ const resolved = resolveDto(Inputs.IFC.RemovePropertyValuesDto, inputs);
113
+ const model = modelOf(resolved.model);
114
+ if (!Array.isArray(resolved.names) || !resolved.names.length || !resolved.names.every((name) => typeof name === "string")) {
115
+ throw new TypeError("Expected the names of the properties as a list of at least one text");
116
+ }
117
+ const object = resolveId(model, resolved.element, "IfcObjectDefinition", "object");
118
+ return editModel(model, (tx, writer) => {
119
+ removePropertyValues(tx, writer, object, resolved.name, resolved.names);
120
+ });
121
+ }
122
+ /**
123
+ * Takes a property set away from one object. Other objects that share the set keep it.
124
+ * @param inputs - The model, the object and the set's name
125
+ * @returns A new model without the set on the object
126
+ * @group properties
127
+ * @shortname remove property set
128
+ * @drawable false
129
+ * @example
130
+ * ```typescript
131
+ * model = await bitbybit.ifc.properties.removeSet({ model, element: "south", name: "Pset_WallCommon" });
132
+ * ```
133
+ */
134
+ removeSet(inputs) {
135
+ const resolved = resolveDto(Inputs.IFC.RemovePropertySetDto, inputs);
136
+ const model = modelOf(resolved.model);
137
+ const object = resolveId(model, resolved.element, "IfcObjectDefinition", "object");
138
+ return editModel(model, (tx, writer) => {
139
+ removePropertySet(tx, writer, object, resolved.name);
140
+ });
141
+ }
142
+ }
@@ -0,0 +1,38 @@
1
+ import type { IfcModel } from "../../model/model-types";
2
+ import type * as Inputs from "../inputs";
3
+ /**
4
+ * Quantities: the base quantity sets IFC defines, such as `Qto_WallBaseQuantities` with a wall's
5
+ * length, side areas and volumes net of its openings, measured from the elements' own geometry, so
6
+ * other tools schedule and price them.
7
+ * @beta
8
+ */
9
+ export declare class IFCQuantities {
10
+ /**
11
+ * Measures elements and writes their base quantity sets, replacing any set of the same name: walls,
12
+ * slabs, columns, beams, members, doors, windows, wall openings, spaces and roofs. A wall's volume
13
+ * and side area follow its clippings and lose its openings. Measure again after changing elements.
14
+ * @param inputs - The model and, optionally, the elements to measure
15
+ * @returns A new model with the quantity sets
16
+ * @group quantities
17
+ * @shortname compute quantities
18
+ * @drawable false
19
+ * @example
20
+ * ```typescript
21
+ * model = await bitbybit.ifc.quantities.compute({ model });
22
+ * ```
23
+ */
24
+ compute(inputs: Inputs.IFC.ComputeQuantitiesDto<IfcModel>): IfcModel;
25
+ /**
26
+ * Reads the quantity sets of an element, with each quantity's value by name.
27
+ * @param inputs - The model and the element
28
+ * @returns The element's quantity sets
29
+ * @group quantities
30
+ * @shortname get quantities
31
+ * @drawable false
32
+ * @example
33
+ * ```typescript
34
+ * const sets = await bitbybit.ifc.quantities.get({ model, element: "south" });
35
+ * ```
36
+ */
37
+ get(inputs: Inputs.IFC.ElementDto<IfcModel>): Inputs.IFC.QuantitySetInfoDto[];
38
+ }
@@ -0,0 +1,51 @@
1
+ import { computeQuantities, quantitiesOf } from "../../build/quantities";
2
+ import { editModel, lengthTolerance, modelOf, resolveId } from "./service-support";
3
+ /**
4
+ * Quantities: the base quantity sets IFC defines, such as `Qto_WallBaseQuantities` with a wall's
5
+ * length, side areas and volumes net of its openings, measured from the elements' own geometry, so
6
+ * other tools schedule and price them.
7
+ * @beta
8
+ */
9
+ export class IFCQuantities {
10
+ /**
11
+ * Measures elements and writes their base quantity sets, replacing any set of the same name: walls,
12
+ * slabs, columns, beams, members, doors, windows, wall openings, spaces and roofs. A wall's volume
13
+ * and side area follow its clippings and lose its openings. Measure again after changing elements.
14
+ * @param inputs - The model and, optionally, the elements to measure
15
+ * @returns A new model with the quantity sets
16
+ * @group quantities
17
+ * @shortname compute quantities
18
+ * @drawable false
19
+ * @example
20
+ * ```typescript
21
+ * model = await bitbybit.ifc.quantities.compute({ model });
22
+ * ```
23
+ */
24
+ compute(inputs) {
25
+ var _a;
26
+ const model = modelOf(inputs.model);
27
+ if (inputs.elements !== undefined && !Array.isArray(inputs.elements)) {
28
+ throw new TypeError("Expected the elements as a list");
29
+ }
30
+ const elements = (_a = inputs.elements) === null || _a === void 0 ? void 0 : _a.map((element) => resolveId(model, element, "IfcProduct", "element"));
31
+ return editModel(model, (tx, writer) => {
32
+ computeQuantities(tx, writer, model, elements, lengthTolerance(model));
33
+ });
34
+ }
35
+ /**
36
+ * Reads the quantity sets of an element, with each quantity's value by name.
37
+ * @param inputs - The model and the element
38
+ * @returns The element's quantity sets
39
+ * @group quantities
40
+ * @shortname get quantities
41
+ * @drawable false
42
+ * @example
43
+ * ```typescript
44
+ * const sets = await bitbybit.ifc.quantities.get({ model, element: "south" });
45
+ * ```
46
+ */
47
+ get(inputs) {
48
+ const model = modelOf(inputs.model);
49
+ return quantitiesOf(model, resolveId(model, inputs.element, "IfcObjectDefinition", "object"));
50
+ }
51
+ }
@@ -0,0 +1,24 @@
1
+ import type { IfcModel } from "../../model/model-types";
2
+ import * as Inputs from "../inputs";
3
+ /**
4
+ * Roofs: flat, mono-pitch, gable and hip roofs over a rectangle, each an `IfcRoof` whose parts are the
5
+ * sloping slabs of its planes. Walls are clipped under a roof with `walls.clipByRoof`.
6
+ * @beta
7
+ */
8
+ export declare class IFCRoofs {
9
+ /**
10
+ * Adds a roof over a rectangle of a storey: flat, sloping one way, gabled, or hipped on all four
11
+ * sides. Every slope has the same `pitch`; its underside meets the outline at `baseOffset` above
12
+ * the storey's floor and reaches `overhang` past it on every side.
13
+ * @param inputs - The model, the storey, the rectangle, the roof's shape, pitch, thickness and overhang
14
+ * @returns A new model with the roof
15
+ * @group create
16
+ * @shortname add roof
17
+ * @drawable false
18
+ * @example
19
+ * ```typescript
20
+ * model = await bitbybit.ifc.roofs.add({ model, storey: "first", id: "roof", outline: [[0, 0], [10000, 0], [10000, 8000], [0, 8000]], kind: Bit.Inputs.IFC.roofKindEnum.gable, pitch: 35, baseOffset: 3000, overhang: 400 });
21
+ * ```
22
+ */
23
+ add(inputs: Inputs.IFC.AddRoofDto<IfcModel>): IfcModel;
24
+ }
@@ -0,0 +1,52 @@
1
+ import { resolveDto } from "@bitbybit-dev/base";
2
+ import { requireFinite, requireOutline } from "../../build/checks";
3
+ import { layerSetFor } from "../../build/materials";
4
+ import { createRoof } from "../../build/roofs";
5
+ import * as Inputs from "../inputs";
6
+ import { DEFAULT_MILLIMETRES } from "./defaults.constants";
7
+ import { editModel, lengthIn, lengthTolerance, modelOf, oneOf, resolveId } from "./service-support";
8
+ /**
9
+ * Roofs: flat, mono-pitch, gable and hip roofs over a rectangle, each an `IfcRoof` whose parts are the
10
+ * sloping slabs of its planes. Walls are clipped under a roof with `walls.clipByRoof`.
11
+ * @beta
12
+ */
13
+ export class IFCRoofs {
14
+ /**
15
+ * Adds a roof over a rectangle of a storey: flat, sloping one way, gabled, or hipped on all four
16
+ * sides. Every slope has the same `pitch`; its underside meets the outline at `baseOffset` above
17
+ * the storey's floor and reaches `overhang` past it on every side.
18
+ * @param inputs - The model, the storey, the rectangle, the roof's shape, pitch, thickness and overhang
19
+ * @returns A new model with the roof
20
+ * @group create
21
+ * @shortname add roof
22
+ * @drawable false
23
+ * @example
24
+ * ```typescript
25
+ * model = await bitbybit.ifc.roofs.add({ model, storey: "first", id: "roof", outline: [[0, 0], [10000, 0], [10000, 8000], [0, 8000]], kind: Bit.Inputs.IFC.roofKindEnum.gable, pitch: 35, baseOffset: 3000, overhang: 400 });
26
+ * ```
27
+ */
28
+ add(inputs) {
29
+ const resolved = resolveDto(Inputs.IFC.AddRoofDto, inputs);
30
+ const model = modelOf(resolved.model);
31
+ requireOutline(resolved.outline, "outline");
32
+ requireFinite(resolved.pitch, "pitch");
33
+ requireFinite(resolved.overhang, "overhang");
34
+ requireFinite(resolved.baseOffset, "base offset");
35
+ const storey = resolveId(model, resolved.storey, "IfcBuildingStorey", "storey");
36
+ const kind = oneOf(resolved.kind, Inputs.IFC.roofKindEnum, "roof kind");
37
+ const thickness = lengthIn(model, resolved.thickness, DEFAULT_MILLIMETRES.slabThickness);
38
+ return editModel(model, (tx, writer) => {
39
+ createRoof(tx, writer, {
40
+ storey,
41
+ id: resolved.id,
42
+ name: resolved.name,
43
+ outline: resolved.outline,
44
+ kind,
45
+ pitch: resolved.pitch,
46
+ layerSet: layerSetFor(tx, writer, resolved.layerSet, thickness, "Roof"),
47
+ overhang: resolved.overhang,
48
+ baseOffset: resolved.baseOffset,
49
+ }, lengthTolerance(model));
50
+ });
51
+ }
52
+ }
@@ -0,0 +1,8 @@
1
+ import { ModelSnapshot } from "../../model/snapshot";
2
+ import type { ModelChange } from "./service-types";
3
+ export declare function modelOf(value: unknown): ModelSnapshot;
4
+ export declare function editModel(model: unknown, change: ModelChange): ModelSnapshot;
5
+ export declare function lengthTolerance(model: ModelSnapshot): number;
6
+ export declare function lengthIn(model: ModelSnapshot, value: number | undefined, millimetres: number): number;
7
+ export declare function resolveId(model: ModelSnapshot, idOrGlobalId: string, type: string, what: string): number;
8
+ export declare function oneOf<T extends string>(value: unknown, allowed: Readonly<Record<string, T>>, what: string): T;
@@ -0,0 +1,37 @@
1
+ import { GEOMETRY_TOLERANCE_METRES, METRES_TO_MILLIMETRES } from "../../build/constants";
2
+ import { EntityWriter } from "../../build/entity-writer";
3
+ import { millimetresPerUnit } from "../../build/project";
4
+ import { resolveObject } from "../../build/spatial";
5
+ import { ModelSnapshot } from "../../model/snapshot";
6
+ import { IfcTransaction } from "../../model/transaction";
7
+ export function modelOf(value) {
8
+ if (!(value instanceof ModelSnapshot)) {
9
+ throw new TypeError("Expected an IFC model, as `model.create` or `model.read` return");
10
+ }
11
+ return value;
12
+ }
13
+ export function editModel(model, change) {
14
+ const base = modelOf(model);
15
+ const tx = new IfcTransaction(base);
16
+ change(tx, new EntityWriter(tx));
17
+ return tx.commit();
18
+ }
19
+ export function lengthTolerance(model) {
20
+ return GEOMETRY_TOLERANCE_METRES * METRES_TO_MILLIMETRES / millimetresPerUnit(model);
21
+ }
22
+ export function lengthIn(model, value, millimetres) {
23
+ return value !== null && value !== void 0 ? value : millimetres / millimetresPerUnit(model);
24
+ }
25
+ export function resolveId(model, idOrGlobalId, type, what) {
26
+ if (typeof idOrGlobalId !== "string" || idOrGlobalId.length === 0) {
27
+ throw new TypeError(`Expected the ${what}'s GlobalId or id as a text`);
28
+ }
29
+ return resolveObject(model, idOrGlobalId, type, what);
30
+ }
31
+ export function oneOf(value, allowed, what) {
32
+ const values = Object.values(allowed);
33
+ if (typeof value !== "string" || !values.includes(value)) {
34
+ throw new RangeError(`The ${what} '${String(value)}' is not one of ${values.join(", ")}`);
35
+ }
36
+ return value;
37
+ }
@@ -0,0 +1,3 @@
1
+ import type { EntityWriter } from "../../build/entity-writer";
2
+ import type { IfcTransaction } from "../../model/transaction";
3
+ export type ModelChange = (tx: IfcTransaction, writer: EntityWriter) => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { IfcModel } from "../../model/model-types";
2
+ import * as Inputs from "../inputs";
3
+ /**
4
+ * The site around the building: its terrain and its trees, written as geographic elements of the
5
+ * site, so the ground and planting travel with the building in the file.
6
+ * @beta
7
+ */
8
+ export declare class IFCSite {
9
+ /**
10
+ * Adds terrain to the site: the ground as an outline in the site's plan, with holes where the
11
+ * building or paving meets it, its top at `elevation` and `depth` deep.
12
+ * @param inputs - The model, the outline and its holes, the depth and elevation, and the ground's material
13
+ * @returns A new model with the terrain
14
+ * @group create
15
+ * @shortname add terrain
16
+ * @drawable false
17
+ * @example
18
+ * ```typescript
19
+ * model = await bitbybit.ifc.site.addTerrain({ model, outline: [[-30000, -30000], [30000, -30000], [30000, 30000], [-30000, 30000]], holes: [[[0, 0], [10000, 0], [10000, 8000], [0, 8000]]], material: "Lawn" });
20
+ * ```
21
+ */
22
+ addTerrain(inputs: Inputs.IFC.AddTerrainDto<IfcModel>): IfcModel;
23
+ /**
24
+ * Adds a tree to the site: a tapering trunk and a rounded crown at `position`, `height` tall,
25
+ * each part in its own material, with its species written as the element's object type.
26
+ * @param inputs - The model, where the tree stands, its sizes, its species and its materials
27
+ * @returns A new model with the tree
28
+ * @group create
29
+ * @shortname add tree
30
+ * @drawable false
31
+ * @example
32
+ * ```typescript
33
+ * model = await bitbybit.ifc.site.addTree({ model, species: "Silver birch", position: [-6000, -8000], height: 9000, crownRadius: 2200, crownMaterial: "Foliage", trunkMaterial: "Bark" });
34
+ * ```
35
+ */
36
+ addTree(inputs: Inputs.IFC.AddTreeDto<IfcModel>): IfcModel;
37
+ }
@@ -0,0 +1,80 @@
1
+ import { resolveDto } from "@bitbybit-dev/base";
2
+ import { requireFinite, requireOutline } from "../../build/checks";
3
+ import { createTerrain, createTree } from "../../build/site";
4
+ import * as Inputs from "../inputs";
5
+ import { DEFAULT_MILLIMETRES } from "./defaults.constants";
6
+ import { editModel, lengthIn, lengthTolerance, modelOf } from "./service-support";
7
+ /**
8
+ * The site around the building: its terrain and its trees, written as geographic elements of the
9
+ * site, so the ground and planting travel with the building in the file.
10
+ * @beta
11
+ */
12
+ export class IFCSite {
13
+ /**
14
+ * Adds terrain to the site: the ground as an outline in the site's plan, with holes where the
15
+ * building or paving meets it, its top at `elevation` and `depth` deep.
16
+ * @param inputs - The model, the outline and its holes, the depth and elevation, and the ground's material
17
+ * @returns A new model with the terrain
18
+ * @group create
19
+ * @shortname add terrain
20
+ * @drawable false
21
+ * @example
22
+ * ```typescript
23
+ * model = await bitbybit.ifc.site.addTerrain({ model, outline: [[-30000, -30000], [30000, -30000], [30000, 30000], [-30000, 30000]], holes: [[[0, 0], [10000, 0], [10000, 8000], [0, 8000]]], material: "Lawn" });
24
+ * ```
25
+ */
26
+ addTerrain(inputs) {
27
+ var _a;
28
+ const resolved = resolveDto(Inputs.IFC.AddTerrainDto, inputs);
29
+ const model = modelOf(resolved.model);
30
+ requireOutline(resolved.outline, "outline");
31
+ ((_a = resolved.holes) !== null && _a !== void 0 ? _a : []).forEach((hole, index) => requireOutline(hole, `hole ${index}`));
32
+ requireFinite(resolved.elevation, "elevation");
33
+ return editModel(model, (tx, writer) => {
34
+ var _a;
35
+ createTerrain(tx, writer, {
36
+ id: resolved.id,
37
+ name: resolved.name,
38
+ outline: resolved.outline,
39
+ holes: (_a = resolved.holes) !== null && _a !== void 0 ? _a : [],
40
+ depth: lengthIn(model, resolved.depth, DEFAULT_MILLIMETRES.terrainDepth),
41
+ elevation: resolved.elevation,
42
+ material: resolved.material,
43
+ }, lengthTolerance(model));
44
+ });
45
+ }
46
+ /**
47
+ * Adds a tree to the site: a tapering trunk and a rounded crown at `position`, `height` tall,
48
+ * each part in its own material, with its species written as the element's object type.
49
+ * @param inputs - The model, where the tree stands, its sizes, its species and its materials
50
+ * @returns A new model with the tree
51
+ * @group create
52
+ * @shortname add tree
53
+ * @drawable false
54
+ * @example
55
+ * ```typescript
56
+ * model = await bitbybit.ifc.site.addTree({ model, species: "Silver birch", position: [-6000, -8000], height: 9000, crownRadius: 2200, crownMaterial: "Foliage", trunkMaterial: "Bark" });
57
+ * ```
58
+ */
59
+ addTree(inputs) {
60
+ const resolved = resolveDto(Inputs.IFC.AddTreeDto, inputs);
61
+ const model = modelOf(resolved.model);
62
+ requireFinite(resolved.position[0], "position's x");
63
+ requireFinite(resolved.position[1], "position's y");
64
+ requireFinite(resolved.elevation, "elevation");
65
+ return editModel(model, (tx, writer) => {
66
+ createTree(tx, writer, {
67
+ id: resolved.id,
68
+ name: resolved.name,
69
+ species: resolved.species,
70
+ position: resolved.position,
71
+ elevation: resolved.elevation,
72
+ height: lengthIn(model, resolved.height, DEFAULT_MILLIMETRES.treeHeight),
73
+ crownRadius: lengthIn(model, resolved.crownRadius, DEFAULT_MILLIMETRES.crownRadius),
74
+ trunkRadius: lengthIn(model, resolved.trunkRadius, DEFAULT_MILLIMETRES.trunkRadius),
75
+ crownMaterial: resolved.crownMaterial,
76
+ trunkMaterial: resolved.trunkMaterial,
77
+ });
78
+ });
79
+ }
80
+ }
@@ -0,0 +1,31 @@
1
+ import type { IfcModel } from "../../model/model-types";
2
+ import * as Inputs from "../inputs";
3
+ /**
4
+ * Slabs: floors, roofs and landings, each an outline in a storey's plan with optional holes,
5
+ * extruded down from its top by its thickness or by the layer set it is made of.
6
+ * @beta
7
+ */
8
+ export declare class IFCSlabs {
9
+ /**
10
+ * Adds a slab: an outline in a storey's plan, with optional holes, its top `topOffset` above the
11
+ * storey's floor and its thickness below that.
12
+ *
13
+ * The slab is made of the named `layerSet`, first layer at the top, or of one layer `thickness`
14
+ * thick. Outlines may wind either way.
15
+ * @param inputs - The model, the storey, the outline and holes, the thickness or layer set, and the slab's kind
16
+ * @returns A new model with the slab
17
+ * @group create
18
+ * @shortname add slab
19
+ * @drawable false
20
+ * @example
21
+ * ```typescript
22
+ * model = await bitbybit.ifc.slabs.add({
23
+ * model,
24
+ * storey: "ground",
25
+ * outline: [[0, 0], [10000, 0], [10000, 8000], [0, 8000]],
26
+ * thickness: 250,
27
+ * });
28
+ * ```
29
+ */
30
+ add(inputs: Inputs.IFC.AddSlabDto<IfcModel>): IfcModel;
31
+ }
@@ -0,0 +1,59 @@
1
+ import { resolveDto } from "@bitbybit-dev/base";
2
+ import { requireFinite, requireOutline } from "../../build/checks";
3
+ import { layerSetFor } from "../../build/materials";
4
+ import { createSlab } from "../../build/slabs-columns-beams";
5
+ import * as Inputs from "../inputs";
6
+ import { DEFAULT_MILLIMETRES } from "./defaults.constants";
7
+ import { editModel, lengthIn, lengthTolerance, modelOf, oneOf, resolveId } from "./service-support";
8
+ /**
9
+ * Slabs: floors, roofs and landings, each an outline in a storey's plan with optional holes,
10
+ * extruded down from its top by its thickness or by the layer set it is made of.
11
+ * @beta
12
+ */
13
+ export class IFCSlabs {
14
+ /**
15
+ * Adds a slab: an outline in a storey's plan, with optional holes, its top `topOffset` above the
16
+ * storey's floor and its thickness below that.
17
+ *
18
+ * The slab is made of the named `layerSet`, first layer at the top, or of one layer `thickness`
19
+ * thick. Outlines may wind either way.
20
+ * @param inputs - The model, the storey, the outline and holes, the thickness or layer set, and the slab's kind
21
+ * @returns A new model with the slab
22
+ * @group create
23
+ * @shortname add slab
24
+ * @drawable false
25
+ * @example
26
+ * ```typescript
27
+ * model = await bitbybit.ifc.slabs.add({
28
+ * model,
29
+ * storey: "ground",
30
+ * outline: [[0, 0], [10000, 0], [10000, 8000], [0, 8000]],
31
+ * thickness: 250,
32
+ * });
33
+ * ```
34
+ */
35
+ add(inputs) {
36
+ var _a;
37
+ const resolved = resolveDto(Inputs.IFC.AddSlabDto, inputs);
38
+ const model = modelOf(resolved.model);
39
+ requireOutline(resolved.outline, "outline");
40
+ const holes = (_a = resolved.holes) !== null && _a !== void 0 ? _a : [];
41
+ holes.forEach((hole, index) => requireOutline(hole, `hole ${index}`));
42
+ requireFinite(resolved.topOffset, "slab's top offset");
43
+ const storey = resolveId(model, resolved.storey, "IfcBuildingStorey", "storey");
44
+ const predefinedType = oneOf(resolved.predefinedType, Inputs.IFC.slabPredefinedTypeEnum, "predefined type");
45
+ const thickness = lengthIn(model, resolved.thickness, DEFAULT_MILLIMETRES.slabThickness);
46
+ return editModel(model, (tx, writer) => {
47
+ createSlab(tx, writer, {
48
+ storey,
49
+ id: resolved.id,
50
+ name: resolved.name,
51
+ outline: resolved.outline,
52
+ holes,
53
+ layerSet: layerSetFor(tx, writer, resolved.layerSet, thickness, "Slab"),
54
+ topOffset: resolved.topOffset,
55
+ predefinedType,
56
+ }, lengthTolerance(model));
57
+ });
58
+ }
59
+ }
@@ -0,0 +1,36 @@
1
+ import type { IfcModel } from "../../model/model-types";
2
+ import * as Inputs from "../inputs";
3
+ /**
4
+ * Spaces: the rooms and areas of a storey, each an outline in the storey's plan extruded up to its
5
+ * height, with a number and a name. Tools schedule rooms and their areas from them.
6
+ * @beta
7
+ */
8
+ export declare class IFCSpaces {
9
+ /**
10
+ * Adds a space to a storey: a room or an area, from an outline in the storey's plan, `height`
11
+ * high. A space is part of its storey, as IFC aggregates spaces, rather than an element on it.
12
+ * @param inputs - The model, the storey, the outline, the height, and the space's number and name
13
+ * @returns A new model with the space
14
+ * @group create
15
+ * @shortname add space
16
+ * @drawable false
17
+ * @example
18
+ * ```typescript
19
+ * 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 });
20
+ * ```
21
+ */
22
+ add(inputs: Inputs.IFC.AddSpaceDto<IfcModel>): IfcModel;
23
+ /**
24
+ * Lists the spaces of the model, or of one storey, with their numbers, names, areas and heights.
25
+ * @param inputs - The model and, optionally, the storey
26
+ * @returns The spaces
27
+ * @group query
28
+ * @shortname list spaces
29
+ * @drawable false
30
+ * @example
31
+ * ```typescript
32
+ * const rooms = await bitbybit.ifc.spaces.list({ model, storey: "ground" });
33
+ * ```
34
+ */
35
+ list(inputs: Inputs.IFC.SpacesDto<IfcModel>): Inputs.IFC.SpaceInfoDto[];
36
+ }