1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
//! Window operation geometry: where each panel is, which side it hangs on,
//! and what it sweeps when it opens (#170). The window counterpart of
//! [`door_operation`](crate::door_operation).
//!
//! # Why this lives in the facade
//!
//! The answer joins the window's placement (`ifc-geometry`) with its
//! partitioning and `IfcWindowPanelProperties`/`IfcWindowLiningProperties`
//! (`ifc-properties`). ADR 0003 forbids those sibling crates from depending
//! on each other, so the join is an orchestration item, compiled only with
//! both `geometry-select` and `properties`.
//!
//! # The convention, from the IFC4 ADD2 TC1 documentation
//!
//! - The window's local placement fixes the frame. `OverallWidth` "reflects
//! the X Dimension" and `OverallHeight` "the Z Dimension" of the window
//! opening; IfcWindow Figure 296 draws them as "the extent of the window in
//! the positive Z and X axis of the local placement". Panels lie in the
//! placement's XZ plane.
//! - "The IfcWindow only defines the local placement which determines the
//! opening direction of the window", and "all window panels are assumed to
//! open into the same direction" (IfcWindow, "Window opening operation by
//! window type"). "The window panel (for side hung windows) opens always
//! into the direction of the positive Y axis of the local placement"
//! (Figure 298), and "the positive y-axis determines the direction"
//! (IfcWindowPanelOperationEnum, Figure 321).
//! - `SIDEHUNGLEFTHAND` is a "panel that opens to the left when viewed from
//! the outside", `SIDEHUNGRIGHTHAND` "to the right"; the figures "are shown
//! as viewed from the outside (in direction of the positive y-axis)"
//! (IfcWindowPanelOperationEnum). Looking along +y with +z up, +x is on the
//! right, so left is local low x. The plan drawings of Figure 298 agree:
//! the `SideHungLeftHand` panel is hinged at the placement origin, the
//! `SideHungRightHand` panel at the far jamb, both opening towards +y.
//! - `TILTANDTURNLEFTHAND` is a "panel that opens to the left and is bottom
//! hung", `TILTANDTURNRIGHTHAND` "to the right"; `TOPHUNG` "panel is top
//! hung" and `BOTTOMHUNG` "bottom hung".
//! - `PanelPosition` places each panel in the partitioning, drawn "as
//! elevations in the XZ plane of the local placement of the window,
//! looking into the direction of the positive Y axis"
//! (IfcWindowPanelPositionEnum, Figure 321), which lists the positions per
//! partitioning, e.g. `DOUBLE_PANEL_VERTICAL` "first ... LEFT, second ...
//! RIGHT". Panels are returned in that listed order.
//! - Where the panels meet is `IfcWindowLiningProperties`: `FirstMullionOffset`
//! and `SecondMullionOffset` are the mullion centrelines "measured along the
//! x-axis of the window placement co-ordinate system", `FirstTransomOffset`
//! the transom centreline "measured along the z-axis", each a ratio of the
//! window ("0.5 indicates that the mullion is positioned in the middle").
//! `SecondTransomOffset`'s text says "measured along the x-axis", but
//! Figure 326 draws it from the window's bottom along z, above
//! `FirstTransomOffset`, and a transom is the "horizontal separator"; the
//! figure is followed. Which offsets apply to which partitioning is
//! Figure 326's list.
//!
//! Panels therefore tile `[0, OverallWidth] × [0, OverallHeight]` of the
//! placement's XZ plane at y = 0, split at the mullion and transom
//! centrelines. Lining, mullion and transom thicknesses and the IFC4 lining
//! offsets are **not** applied, as `door_operation` does not apply the door
//! lining; a caller that needs the panel inside the lining reads those
//! attributes itself. `FrameDepth` and `FrameThickness` are reported, not
//! applied.
//!
//! A hinged panel's sector is the quarter turn from closed to perpendicular
//! to the window plane, towards +y, as the door sectors are. IFC records no
//! opening angle, and Figure 298 draws the panel only ajar: the sector is
//! the symbolic bound, not a hardware stop.
//!
//! IFC2X3 has no `IfcWindow.PartitioningType`; its `IfcWindowStyle` states
//! the partitioning as `OperationType : IfcWindowStyleOperationEnum`, whose
//! members IFC4 kept as `IfcWindowTypePartitioningEnum` (the EXPRESS of both
//! releases lists them alike). The panel and lining sets hang off the
//! style's `HasPropertySets`, as they hang off an `IfcWindowType`'s.
//!
//! # What is refused
//!
//! Never defaulted: the `NOTDEFINED` and `USERDEFINED` partitionings
//! ("windows which are subdivided into more than three panels have to be
//! defined by the geometry only"); the `PIVOTHORIZONTAL` and `PIVOTVERTICAL`
//! panel operations ("hinges are in the middle", but which half turns
//! towards +y is not stated), `OTHEROPERATION` and `NOTDEFINED`; a window
//! without panel properties, `OverallWidth` or `OverallHeight`; panels that
//! contradict the partitioning; and a split whose lining offset is missing
//! or does not fall inside the window. See [`WindowOperationError`].
use Transform;
use ;
use ExactSource;
use crate;
pub use WindowOperationError;
/// How one window operates, panel by panel, in world coordinates (metres).
///
/// Returned by [`window_operation`].
/// `IfcWindowTypePartitioningEnum` (IFC4, IFC4X3) and
/// `IfcWindowStyleOperationEnum` (IFC2X3): the panel layouts derived here.
/// `IfcWindowPanelOperationEnum`: the panel operations derived here.
/// `IfcWindowPanelPositionEnum`: where a panel sits in the window, as
/// written.
/// How a window panel moves.
/// One window panel.
/// Why a partitioning or panel operation is refused rather than derived.
/// The operation geometry of one window: each panel's frame, size, hinge
/// side and swept sectors, in world metres.
///
/// Binds to the release the header declares (IFC2X3, IFC4 or IFC4X3), as
/// the exact property resolver does, and reads:
///
/// - the partitioning: `IfcWindow.PartitioningType` (IFC4, IFC4X3) and the
/// type object's (`IfcWindowType.PartitioningType`; IFC2X3
/// `IfcWindowStyle.OperationType`). Either alone governs; when both are
/// stated they must agree;
/// - `IfcWindow.OverallWidth` and `OverallHeight`, in the project length
/// unit resolved by [`ifc_properties::exact_unit`];
/// - the `IfcWindowPanelProperties` from
/// [`ifc_properties::exact_predefined_sets`]: the occurrence's own sets
/// when it has any, else its type's, never a mix; and, for a partitioning
/// with more than one panel, the one `IfcWindowLiningProperties` chosen
/// the same way;
/// - the placement from [`ifc_geometry::product_world_transform`], scaled by
/// the same exact length unit.
///
/// See the module documentation for the convention and its citations.
///
/// # Errors
///
/// A [`WindowOperationError`] whenever any input is missing, contradictory
/// or outside what the specification defines precisely; nothing is
/// defaulted.