@mark1russell7/room-view 0.2.2 → 0.2.3
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 +18 -1
- package/build/{anchors-J6mcUeJn.js → anchors-Ba3OUmhF.js} +57 -3
- package/build/anchors-Ba3OUmhF.js.map +1 -0
- package/build/index.d.ts +5 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -6
- package/build/index.js.map +1 -1
- package/build/layers-B5nL_lVW.js +247 -0
- package/build/layers-B5nL_lVW.js.map +1 -0
- package/build/layers-BO_MMtQJ.d.ts +294 -0
- package/build/layers-BO_MMtQJ.d.ts.map +1 -0
- package/build/{level-5Nb9rq5L.js → level-CXCIX08K.js} +125 -22
- package/build/level-CXCIX08K.js.map +1 -0
- package/build/{level-Bmz-H5iH.d.ts → level-Cjcf3u20.d.ts} +89 -6
- package/build/level-Cjcf3u20.d.ts.map +1 -0
- package/build/{loads-Bp8aH2HJ.d.ts → loads-Diy6-Ekz.d.ts} +2 -2
- package/build/{loads-Bp8aH2HJ.d.ts.map → loads-Diy6-Ekz.d.ts.map} +1 -1
- package/build/marks.d.ts +2 -3
- package/build/marks.d.ts.map +1 -1
- package/build/marks.js +2 -2
- package/build/sample.d.ts +2 -2
- package/build/schema.d.ts +3 -3
- package/build/schema.d.ts.map +1 -1
- package/build/schema.js +9 -6
- package/build/schema.js.map +1 -1
- package/build/solids-S_j17vFJ.d.ts +313 -0
- package/build/solids-S_j17vFJ.d.ts.map +1 -0
- package/build/three.d.ts +2 -3
- package/build/three.d.ts.map +1 -1
- package/build/three.js +1 -2
- package/build/three.js.map +1 -1
- package/package.json +1 -1
- package/build/anchors-BEnxNnSV.d.ts +0 -75
- package/build/anchors-BEnxNnSV.d.ts.map +0 -1
- package/build/anchors-J6mcUeJn.js.map +0 -1
- package/build/frames-BYMK5ZId.d.ts +0 -39
- package/build/frames-BYMK5ZId.d.ts.map +0 -1
- package/build/layers-CtgTEnmt.js +0 -90
- package/build/layers-CtgTEnmt.js.map +0 -1
- package/build/layers-D_HqUjYu.d.ts +0 -148
- package/build/layers-D_HqUjYu.d.ts.map +0 -1
- package/build/level-5Nb9rq5L.js.map +0 -1
- package/build/level-Bmz-H5iH.d.ts.map +0 -1
- package/build/room-DrXMmX_h.js +0 -29
- package/build/room-DrXMmX_h.js.map +0 -1
- package/build/room-NREa6vXr.d.ts +0 -163
- package/build/room-NREa6vXr.d.ts.map +0 -1
- package/build/solids-BHLnvDVu.d.ts +0 -120
- package/build/solids-BHLnvDVu.d.ts.map +0 -1
- package/build/units-BZmvVyu4.js +0 -30
- package/build/units-BZmvVyu4.js.map +0 -1
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { B as Scene, C as WallFrame, F as PlacedObject, I as PlanPoint, R as Room, W as WallFace, c as SolidKind, y as JoinOptions } from "./solids-S_j17vFJ.js";
|
|
2
|
+
import { Point3, Transform3 } from "@mark1russell7/layout-contract";
|
|
3
|
+
/** These are the surfaces that an anchor can be on. */
|
|
4
|
+
declare const ANCHOR_SURFACES: readonly ["wall", "floor", "ceiling", "object"];
|
|
5
|
+
/** A surface of an anchor. */
|
|
6
|
+
type AnchorSurface = (typeof ANCHOR_SURFACES)[number];
|
|
7
|
+
/** An anchor on a face of a wall. The lengths are in the unit of the room. */
|
|
8
|
+
interface WallAnchor {
|
|
9
|
+
readonly on: "wall";
|
|
10
|
+
/** The `id` of the wall. */
|
|
11
|
+
readonly wall: string;
|
|
12
|
+
readonly face: WallFace;
|
|
13
|
+
/** The distance along the line of the wall, from `from` to the anchor. */
|
|
14
|
+
readonly offset: number;
|
|
15
|
+
/** The height of the anchor above the floor. */
|
|
16
|
+
readonly height: number;
|
|
17
|
+
}
|
|
18
|
+
/** An anchor on the floor, at a point of the plan. */
|
|
19
|
+
interface FloorAnchor {
|
|
20
|
+
readonly on: "floor";
|
|
21
|
+
readonly at: PlanPoint;
|
|
22
|
+
/** The `id` of the floor that has the point. Without it, the point is on any floor of the room. */
|
|
23
|
+
readonly floor?: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
/** An anchor on the ceiling, above a point of the plan. The ceiling is at the height of the room. */
|
|
26
|
+
interface CeilingAnchor {
|
|
27
|
+
readonly on: "ceiling";
|
|
28
|
+
readonly at: PlanPoint;
|
|
29
|
+
/** The `id` of the floor below the point. Without it, the point is above any floor of the room. */
|
|
30
|
+
readonly floor?: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* An anchor on a placed object. The point and the direction are in the frame of the object, before its turn.
|
|
34
|
+
* The origin of that frame is the center of the bottom of the object.
|
|
35
|
+
*/
|
|
36
|
+
interface ObjectAnchor {
|
|
37
|
+
readonly on: "object";
|
|
38
|
+
/** The `id` of the placed object. */
|
|
39
|
+
readonly object: string;
|
|
40
|
+
/** The point in the frame of the object. The default is the center of its top. */
|
|
41
|
+
readonly at?: readonly [number, number, number] | undefined;
|
|
42
|
+
/** The direction out of the surface, in the frame of the object. The default is up: `[0, 0, 1]`. */
|
|
43
|
+
readonly out?: readonly [number, number, number] | undefined;
|
|
44
|
+
}
|
|
45
|
+
/** An anchor: a place in the space of the core, for a record of an add-on. */
|
|
46
|
+
type Anchor = WallAnchor | FloorAnchor | CeilingAnchor | ObjectAnchor;
|
|
47
|
+
/** The position of an anchor in the room, in meters. */
|
|
48
|
+
interface AnchorFrame {
|
|
49
|
+
/** The point of the anchor. */
|
|
50
|
+
readonly at: Point3;
|
|
51
|
+
/** The unit vector out of the surface, into the space of the room. */
|
|
52
|
+
readonly out: Point3;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The space of a scene, for the add-ons. It reads each wall, object and anchor of the scene.
|
|
56
|
+
* Make it once with `sceneSpace`, and give it to each add-on.
|
|
57
|
+
*/
|
|
58
|
+
interface SceneSpace {
|
|
59
|
+
readonly scene: Scene;
|
|
60
|
+
/** The length of the unit of the room, in meters. */
|
|
61
|
+
readonly scale: number;
|
|
62
|
+
/** This function gives the frame of a wall in meters, or `undefined` when the room does not have the wall. */
|
|
63
|
+
readonly wall: (id: string) => WallFrame | undefined;
|
|
64
|
+
/** This function gives a placed object of the scene, or `undefined` when the scene does not have it. */
|
|
65
|
+
readonly object: (id: string) => PlacedObject | undefined;
|
|
66
|
+
/** This function gives the transform of a placed object in meters, or `undefined` when the object has no place. */
|
|
67
|
+
readonly transform: (id: string) => Transform3 | undefined;
|
|
68
|
+
/** This function gives the position of an anchor, or `undefined` when the anchor has no position. `checkAnchor` tells the reason. */
|
|
69
|
+
readonly frame: (anchor: Anchor) => AnchorFrame | undefined;
|
|
70
|
+
}
|
|
71
|
+
/** This function gives the space of a scene. The transforms of the objects are calculated one time, at the first use. */
|
|
72
|
+
declare function sceneSpace(scene: Scene): SceneSpace;
|
|
73
|
+
/**
|
|
74
|
+
* This function gives an anchor with each length times a factor. A direction stays, because it has no unit.
|
|
75
|
+
* `convertSurvey` uses it to change the unit of the anchors of a layer.
|
|
76
|
+
*/
|
|
77
|
+
declare function scaleAnchor(anchor: Anchor, factor: number): Anchor;
|
|
78
|
+
/** These are the levels of a finding. An error is a fault that the model cannot show. A warning is a fault that the model can show. */
|
|
79
|
+
declare const FINDING_LEVELS: readonly ["error", "warning"];
|
|
80
|
+
/** A level of a finding. */
|
|
81
|
+
type FindingLevel = (typeof FINDING_LEVELS)[number];
|
|
82
|
+
/** These are the kinds of the records that a finding can name. */
|
|
83
|
+
declare const RECORD_KINDS: readonly ["room", "wall", "opening", "floor", "outlet", "circuit", "object", "load"];
|
|
84
|
+
/** A kind of record. */
|
|
85
|
+
type RecordKind = (typeof RECORD_KINDS)[number];
|
|
86
|
+
/**
|
|
87
|
+
* This function gives the name of a record: its kind, a colon and its `id`, for example `object:desk`.
|
|
88
|
+
* The kind of a record of a layer is the name of the layer, for example `electrical/1`. A finding, a mark and the selection use this name.
|
|
89
|
+
*/
|
|
90
|
+
declare function recordName(kind: string, id: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* This function gives the name of the record of a solid, as `recordName` gives it. `source` is the field `source` of the solid.
|
|
93
|
+
* The glass of a window is a solid of its opening, so its name has the kind `opening`.
|
|
94
|
+
*/
|
|
95
|
+
declare function solidRecord(kind: SolidKind, source: string): string;
|
|
96
|
+
/** This function gives the kind and the `id` of a record name, or `undefined` for a text with no kind. A kind has no colon, so the first colon ends it. */
|
|
97
|
+
declare function parseRecordName(name: string): {
|
|
98
|
+
readonly kind: string;
|
|
99
|
+
readonly id: string;
|
|
100
|
+
} | undefined;
|
|
101
|
+
/** These are the codes of the findings. */
|
|
102
|
+
declare const FINDING_CODES: readonly ["number-not-finite", "number-too-large", "id-duplicate", "size-not-positive", "wall-length", "wall-short", "wall-overlap", "opening-wall", "opening-range", "opening-height", "opening-overlap", "outlet-wall", "outlet-circuit", "outlet-range", "outlet-in-opening", "floor-ring", "circuit-limit", "object-parent", "object-cycle", "object-outlet", "object-outside", "object-overlap", "object-in-wall", "load-circuit", "load-watts"];
|
|
103
|
+
/** A code of a finding. */
|
|
104
|
+
type FindingCode = (typeof FINDING_CODES)[number];
|
|
105
|
+
/** A finding: one fault of a room record or a scene record. */
|
|
106
|
+
interface Finding {
|
|
107
|
+
readonly level: FindingLevel;
|
|
108
|
+
readonly code: FindingCode;
|
|
109
|
+
/** The kind of the record with the fault. */
|
|
110
|
+
readonly record: RecordKind;
|
|
111
|
+
/** The `id` of the record with the fault. For a load, it is the `id` of the circuit. For the room record, it is empty. */
|
|
112
|
+
readonly at: string;
|
|
113
|
+
/** The fault in plain words, with the values. */
|
|
114
|
+
readonly message: string;
|
|
115
|
+
/**
|
|
116
|
+
* The `id` of the second record of the fault. It is the other opening or the other object of an overlap, or the opening that an outlet is in.
|
|
117
|
+
* It is also the wall that an object overlaps, or the parent or the outlet that an object names. A fault of one record has none.
|
|
118
|
+
*/
|
|
119
|
+
readonly other?: string | undefined;
|
|
120
|
+
}
|
|
121
|
+
/** The options of the checks. Give the options that the model gets. */
|
|
122
|
+
interface CheckOptions {
|
|
123
|
+
/** The options of the corners of the walls. */
|
|
124
|
+
readonly joins?: JoinOptions | undefined;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* This function gives each fault of a room record. A room with no finding of the level `error` gives a full model.
|
|
128
|
+
*
|
|
129
|
+
* The function examines the meaning of the record: for example, an opening must be in its wall. The schema examines the form of the record.
|
|
130
|
+
*/
|
|
131
|
+
declare function checkRoom(room: Room, options?: CheckOptions): readonly Finding[];
|
|
132
|
+
/**
|
|
133
|
+
* This function gives each fault of a scene record: the faults of its room, then the faults of its placed objects and its loads.
|
|
134
|
+
* A scene with no finding of the level `error` gives a full model.
|
|
135
|
+
*/
|
|
136
|
+
declare function checkScene(scene: Scene, options?: CheckOptions): readonly Finding[];
|
|
137
|
+
/** These are the codes of the faults of an anchor. */
|
|
138
|
+
declare const ANCHOR_CODES: readonly ["anchor-not-finite", "anchor-wall", "anchor-object", "anchor-floor", "anchor-range", "anchor-direction", "anchor-in-opening", "anchor-outside"];
|
|
139
|
+
/** A code of a fault of an anchor. */
|
|
140
|
+
type AnchorCode = (typeof ANCHOR_CODES)[number];
|
|
141
|
+
/** A fault of an anchor. `checkLayers` gives it the layer and the key of the anchor. */
|
|
142
|
+
interface AnchorFault {
|
|
143
|
+
readonly level: FindingLevel;
|
|
144
|
+
readonly code: AnchorCode;
|
|
145
|
+
/** The fault in plain words, with the values. */
|
|
146
|
+
readonly message: string;
|
|
147
|
+
/** The `id` of the second record of the fault: the opening that the anchor is in. A different fault has none. */
|
|
148
|
+
readonly other?: string | undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* This function gives the faults of an anchor in the space of a scene. `name` starts each message.
|
|
152
|
+
* An error tells that the anchor has no position. A warning tells a fault that the model can show.
|
|
153
|
+
*/
|
|
154
|
+
declare function checkAnchor(anchor: Anchor, space: SceneSpace, name?: string): readonly AnchorFault[];
|
|
155
|
+
/** The result of the read of a layer: the layer, or the faults of its form. */
|
|
156
|
+
type LayerParse<Layer> = {
|
|
157
|
+
readonly ok: true;
|
|
158
|
+
readonly layer: Layer;
|
|
159
|
+
} | {
|
|
160
|
+
readonly ok: false;
|
|
161
|
+
readonly errors: readonly string[];
|
|
162
|
+
};
|
|
163
|
+
/** A fault that an add-on finds in its layer. */
|
|
164
|
+
interface AddOnFault {
|
|
165
|
+
readonly level: FindingLevel;
|
|
166
|
+
/** The code of the fault. The add-on gives its own codes. */
|
|
167
|
+
readonly code: string;
|
|
168
|
+
/** The `id` of the record with the fault. For the layer, it is empty. */
|
|
169
|
+
readonly at: string;
|
|
170
|
+
/** The fault in plain words, with the values. */
|
|
171
|
+
readonly message: string;
|
|
172
|
+
/** The `id` of the second record of the fault. A fault of one record has none. */
|
|
173
|
+
readonly other?: string | undefined;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* An add-on: one topic on the core, for example electrical, plumbing or light.
|
|
177
|
+
* A host gives a list of add-ons to `checkLayers`. The core knows only this type.
|
|
178
|
+
*/
|
|
179
|
+
interface AddOn<Layer> {
|
|
180
|
+
/** The name of the format of the layer, for example `electrical/1`. It is the key of the layer in `Scene.layers`. */
|
|
181
|
+
readonly schema: string;
|
|
182
|
+
/** This function reads the JSON of a layer. */
|
|
183
|
+
parse(value: unknown): LayerParse<Layer>;
|
|
184
|
+
/**
|
|
185
|
+
* This function gives the anchors of the records of a layer, by a key.
|
|
186
|
+
* The key is the `id` of a record, or the `id` and a position for a record with many anchors.
|
|
187
|
+
*/
|
|
188
|
+
anchors(layer: Layer): ReadonlyMap<string, Anchor>;
|
|
189
|
+
/** This function gives the layer with new anchors, by the keys of `anchors`. The core uses it when it moves the records of a room. */
|
|
190
|
+
withAnchors(layer: Layer, anchors: ReadonlyMap<string, Anchor>): Layer;
|
|
191
|
+
/** This function gives the faults of the meaning of a layer. The core examines the anchors, so this function does not. */
|
|
192
|
+
check(layer: Layer, space: SceneSpace): readonly AddOnFault[];
|
|
193
|
+
/**
|
|
194
|
+
* This function gives one layer from the parts of a level: the layer of the level record, then the layer of each room.
|
|
195
|
+
*
|
|
196
|
+
* - A record of a part gets the name `part.name(id)`. Each `id` of the layer that names such a record or a placed object gets it too.
|
|
197
|
+
* - A record that all the rooms share keeps its `id`, for example a circuit of an apartment. The first record of an `id` stays.
|
|
198
|
+
* - The core changes the anchors before this function, so the function does not change an anchor.
|
|
199
|
+
*
|
|
200
|
+
* `expandLevel` does not carry the layer of a room when its add-on has no such function.
|
|
201
|
+
*/
|
|
202
|
+
join?(parts: readonly LayerPart<Layer>[]): Layer;
|
|
203
|
+
}
|
|
204
|
+
/** One part of the layers of a level, for the function `join` of an add-on. `layerPart` makes it. */
|
|
205
|
+
interface LayerPart<Layer> {
|
|
206
|
+
/** The `id` of the room of the layer. The layer of the level record has no room. */
|
|
207
|
+
readonly room?: string | undefined;
|
|
208
|
+
readonly layer: Layer;
|
|
209
|
+
/**
|
|
210
|
+
* This function gives the name in the level of a record of the part, from its `id` in the part.
|
|
211
|
+
* A record of a room gets the name that `roomName` gives, and a record of the level record keeps its `id`.
|
|
212
|
+
* The function also gives the name of a record of the core that the part names, for example a placed object.
|
|
213
|
+
*/
|
|
214
|
+
readonly name: (id: string) => string;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* This function gives the name in a level of a record of a room. The name is the `id` of the room, a slash and the `id` in the survey.
|
|
218
|
+
* `expandLevel` gives each wall, each opening and each placed object such a name. The function `join` of an add-on gives it to the records of a room.
|
|
219
|
+
*/
|
|
220
|
+
declare function roomName(room: string, id: string): string;
|
|
221
|
+
/**
|
|
222
|
+
* This function makes one part of the layers of a level. With no room, the part is the layer of the level record.
|
|
223
|
+
* Its function `name` has the rule of `roomName`, so an add-on does not write that rule again.
|
|
224
|
+
*/
|
|
225
|
+
declare function layerPart<Layer>(layer: Layer, room?: string): LayerPart<Layer>;
|
|
226
|
+
/** These are the codes of the faults of a layer that the core finds. */
|
|
227
|
+
declare const LAYER_CODES: readonly ["layer-name", "layer-unknown", "layer-form"];
|
|
228
|
+
/** A finding of a layer: a fault of its form, of an anchor or of the meaning of its records. */
|
|
229
|
+
interface LayerFinding {
|
|
230
|
+
readonly level: FindingLevel;
|
|
231
|
+
/** A code of `LAYER_CODES` or `ANCHOR_CODES`, or a code of the add-on. */
|
|
232
|
+
readonly code: string;
|
|
233
|
+
/** The key of the layer in `Scene.layers`. */
|
|
234
|
+
readonly layer: string;
|
|
235
|
+
/** The key of the anchor, or the `id` of the record with the fault. For the layer, it is empty. */
|
|
236
|
+
readonly at: string;
|
|
237
|
+
/** The fault in plain words, with the values. */
|
|
238
|
+
readonly message: string;
|
|
239
|
+
/** The `id` of the second record of the fault. A fault of one record has none. */
|
|
240
|
+
readonly other?: string | undefined;
|
|
241
|
+
/** The `id` of the room of the layer. Only a finding of `expandLevel` about the layer of a room has it. */
|
|
242
|
+
readonly room?: string | undefined;
|
|
243
|
+
}
|
|
244
|
+
/** This function reads the layer of an add-on in a scene. It gives `undefined` when the scene has no layer of the add-on. */
|
|
245
|
+
declare function readLayer<Layer>(scene: Scene, addOn: AddOn<Layer>): LayerParse<Layer> | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* This function gives the findings of the layers of a scene, with a list of add-ons.
|
|
248
|
+
* Each layer gets the faults of its form, of each anchor and of the meaning of its records. A layer of no add-on of the list gets a warning.
|
|
249
|
+
* The findings are in the order of the layer keys, then of the record keys. Thus equal inputs give equal findings.
|
|
250
|
+
*
|
|
251
|
+
* The name of the record of a finding is `recordName(finding.layer, finding.at)`, so a finding selects its mark.
|
|
252
|
+
* `checkScene` examines the core, and this function examines the layers.
|
|
253
|
+
*/
|
|
254
|
+
declare function checkLayers(scene: Scene, addOns: readonly AddOn<unknown>[]): readonly LayerFinding[];
|
|
255
|
+
/** The result of a change of layers: the layers that the function carried, and a finding for each layer that it did not carry. */
|
|
256
|
+
interface LayersMove {
|
|
257
|
+
/** The layers of the result, in the order of their names. */
|
|
258
|
+
readonly layers: Readonly<Record<string, unknown>>;
|
|
259
|
+
/** One finding or more for each layer that is not in the result. Each finding has the level `error`. */
|
|
260
|
+
readonly findings: readonly LayerFinding[];
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* This function gives layers with each anchor changed by `move`. The add-on of each layer comes from the list.
|
|
264
|
+
* `expandSurvey` uses it to put the layers of a survey on the room record. A host uses it when it moves the records of a room.
|
|
265
|
+
*
|
|
266
|
+
* A layer that the function cannot read is not in the result, because its anchors are in the old space. A finding tells each such layer:
|
|
267
|
+
*
|
|
268
|
+
* - `layer-name`: the name is not a layer name.
|
|
269
|
+
* - `layer-unknown`: no add-on of the list has the name.
|
|
270
|
+
* - `layer-form`: the add-on found a fault in the form of the layer.
|
|
271
|
+
*
|
|
272
|
+
* `room` is the `id` of the room of the layers, in a level. Each finding gets it.
|
|
273
|
+
*/
|
|
274
|
+
declare function moveLayers(layers: Readonly<Record<string, unknown>> | undefined, addOns: readonly AddOn<unknown>[], move: (anchor: Anchor) => Anchor, room?: string): LayersMove;
|
|
275
|
+
/** The layers of one room of a level, for `joinLayers`. The anchors have the names of the level already. */
|
|
276
|
+
interface RoomLayers {
|
|
277
|
+
/** The `id` of the room. */
|
|
278
|
+
readonly room: string;
|
|
279
|
+
readonly layers: Readonly<Record<string, unknown>> | undefined;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* This function gives the layers of a level. Each name gets one layer, from the layer of the level record and the layers of the rooms.
|
|
283
|
+
* The function `join` of the add-on of each name makes that layer. `expandLevel` uses this function.
|
|
284
|
+
*
|
|
285
|
+
* - A layer that only the level record has stays as it is, because its anchors are on the room record of the level already.
|
|
286
|
+
* `checkLayers` examines it.
|
|
287
|
+
* - The layer of a room needs an add-on of its name with the function `join`. Without it, a finding tells the layer of each room,
|
|
288
|
+
* and the layer of the level record stays as it is. The codes are the codes of `moveLayers`.
|
|
289
|
+
* An add-on with no function `join` gives the code `layer-unknown`.
|
|
290
|
+
* - With such an add-on, a part with a fault in its form is not in the layer of the result. A finding tells the part.
|
|
291
|
+
*/
|
|
292
|
+
declare function joinLayers(own: Readonly<Record<string, unknown>> | undefined, rooms: readonly RoomLayers[], addOns: readonly AddOn<unknown>[]): LayersMove;
|
|
293
|
+
export { recordName as A, WallAnchor as B, FindingLevel as C, checkRoom as D, checkAnchor as E, AnchorSurface as F, sceneSpace as H, CeilingAnchor as I, FloorAnchor as L, ANCHOR_SURFACES as M, Anchor as N, checkScene as O, AnchorFrame as P, ObjectAnchor as R, FindingCode as S, RecordKind as T, scaleAnchor as V, AnchorFault as _, LayerParse as a, FINDING_LEVELS as b, RoomLayers as c, layerPart as d, moveLayers as f, AnchorCode as g, ANCHOR_CODES as h, LayerFinding as i, solidRecord as j, parseRecordName as k, checkLayers as l, roomName as m, AddOnFault as n, LayerPart as o, readLayer as p, LAYER_CODES as r, LayersMove as s, AddOn as t, joinLayers as u, CheckOptions as v, RECORD_KINDS as w, Finding as x, FINDING_CODES as y, SceneSpace as z };
|
|
294
|
+
//# sourceMappingURL=layers-BO_MMtQJ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layers-BO_MMtQJ.d.ts","names":[],"sources":["../src/anchors.ts","../src/check.ts","../src/layers.ts"],"mappings":";;;cAUa;;KAGD,wBAAwB;;UAGnB;WACN;;WAEA;WACA,MAAM;;WAEN;;WAEA;;;UAIM;WACN;WACA,IAAI;;WAEJ;;;UAIM;WACN;WACA,IAAI;;WAEJ;;;;;;UAOM;WACN;;WAEA;;WAEA;;WAEA;;;KAIC,SAAS,aAAa,cAAc,gBAAgB;;UAG/C;;WAEN,IAAI;;WAEJ,KAAK;;;;;;UAOC;WACN,OAAO;;WAEP;;WAEA,OAAO,eAAe;;WAEtB,SAAS,eAAe;;WAExB,YAAY,eAAe;;WAE3B,QAAQ,QAAQ,WAAW;;;iBAiBtB,WAAW,OAAO,QAAQ;;;;;iBA0C1B,YAAY,QAAQ,QAAQ,iBAAiB;;cCrIhD;;KAGD,uBAAuB;;cAGtB;;KAYD,qBAAqB;;;;;iBAMjB,WAAW,cAAc;;;;;iBAQzB,YAAY,MAAM,WAAW;;iBAK7B,gBAAgB;WAA0B;WAAuB;;;cAMpE;;KAuDD,sBAAsB;;UAGjB;WACN,OAAO;WACP,MAAM;;WAEN,QAAQ;;WAER;;WAEA;;;;;WAKA;;;UAIM;;WAEN,QAAQ;;;;;;;iBA2CH,UAAU,MAAM,MAAM,UAAS,wBAA6B;;;;;iBAwK5D,WAAW,OAAO,OAAO,UAAS,wBAA6B;;cAkFlE;;KAYD,qBAAqB;;UAGhB;WACN,OAAO;WACP,MAAM;;WAEN;;WAEA;;;;;;iBAOK,YAAY,QAAQ,QAAQ,OAAO,YAAY,yBAAuC;;KCxb1F,WAAW;WAAoB;WAAmB,OAAO;;WAAqB;WAAoB;;;UAG7F;WACN,OAAO;;WAEP;;WAEA;;WAEA;;WAEA;;;;;;UAOM,MAAM;;WAEZ;;EAET,MAAM,iBAAiB,WAAW;;;;;EAKlC,QAAQ,OAAO,QAAQ,oBAAoB;;EAE3C,YAAY,OAAO,OAAO,SAAS,oBAAoB,UAAU;;EAEjE,MAAM,OAAO,OAAO,OAAO,sBAAsB;;;;;;;;;;EAUjD,MAAM,gBAAgB,UAAU,WAAW;;;UAI5B,UAAU;;WAEhB;WACA,OAAO;;;;;;WAMP,OAAO;;;;;;iBAOF,SAAS,cAAc;;;;;iBAQvB,UAAU,OAAO,OAAO,OAAO,gBAAgB,UAAU;;cAK5D;;UAGI;WACN,OAAO;;WAEP;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;iBAWK,UAAU,OAAO,OAAO,OAAO,OAAO,MAAM,SAAS,WAAW;;;;;;;;;iBAahE,YAAY,OAAO,OAAO,iBAAiB,4BAA4B;;UAkCtE;;WAEN,QAAQ,SAAS;;WAEjB,mBAAmB;;;;;;;;;;;;;;iBAiCd,WACd,QAAQ,SAAS,sCACjB,iBAAiB,kBACjB,OAAO,QAAQ,WAAW,QAC1B,gBACC;;UAiBc;;WAEN;WACA,QAAQ,SAAS;;;;;;;;;;;;;iBAcZ,WAAW,KAAK,SAAS,sCAAsC,gBAAgB,cAAc,iBAAiB,mBAAmB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { a as
|
|
1
|
+
import { F as metersPer, I as unitsPer, n as scaleAnchor } from "./anchors-Ba3OUmhF.js";
|
|
2
|
+
import { a as moveLayers, d as SCENE_SCHEMA, r as joinLayers, s as roomName, u as ROOM_SCHEMA } from "./layers-B5nL_lVW.js";
|
|
3
3
|
/** This function gives the unit vector of a direction in degrees. A direction along an axis gives an exact vector. */
|
|
4
4
|
function directionOf(degrees) {
|
|
5
5
|
const turn = (degrees % 360 + 360) % 360;
|
|
@@ -33,8 +33,49 @@ function squared(degrees) {
|
|
|
33
33
|
const SURVEY_SCHEMA = "survey/1";
|
|
34
34
|
/** These are the names of the turns at a square corner. */
|
|
35
35
|
const SQUARE_TURNS = ["left", "right"];
|
|
36
|
+
/** The `id` of the floor of the room record of a closed survey. */
|
|
37
|
+
const SURVEY_FLOOR = "floor";
|
|
36
38
|
/** The default limit of the gap of a closed walk, as a part of the length of the walk. */
|
|
37
39
|
const CLOSURE_LIMIT = .01;
|
|
40
|
+
/**
|
|
41
|
+
* This function gives an anchor of a survey on the room record of the survey. `frame` comes from the result of `expandSurvey`.
|
|
42
|
+
*
|
|
43
|
+
* - An anchor on a wall names a side. Its `offset` starts at the first corner of the side and goes along the inner face.
|
|
44
|
+
* The result is on the face in the room, and its `offset` changes in the proportion of the side, as an opening does. Its `face` in the survey has no effect.
|
|
45
|
+
* - A point of an anchor on the floor or on the ceiling is in the frame of the walk. The first corner is the origin, and the first side goes along the x axis.
|
|
46
|
+
* The result is at its place in the plan. The correction of the gap does not move the point.
|
|
47
|
+
* - An anchor on an object stays, because a placed object keeps the `id` and the frame of its object in the survey.
|
|
48
|
+
*/
|
|
49
|
+
function surveyAnchor(anchor, frame) {
|
|
50
|
+
if (anchor.on === "object") return anchor;
|
|
51
|
+
if (anchor.on === "wall") {
|
|
52
|
+
const factor = Object.hasOwn(frame.factors, anchor.wall) ? frame.factors[anchor.wall] ?? 1 : 1;
|
|
53
|
+
return {
|
|
54
|
+
...anchor,
|
|
55
|
+
face: frame.face,
|
|
56
|
+
offset: anchor.offset * factor
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const [cos, sin] = directionOf(frame.heading);
|
|
60
|
+
const [x, y] = anchor.at;
|
|
61
|
+
return {
|
|
62
|
+
...anchor,
|
|
63
|
+
at: [frame.start[0] + (x * cos - y * sin), frame.start[1] + (x * sin + y * cos)]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* This function gives the scene record of the result of `expandSurvey` or of `expandLevel`: the room record, the placed objects and the layers.
|
|
68
|
+
* The scene has the name of the room record. `checkScene` and `checkLayers` examine it.
|
|
69
|
+
*/
|
|
70
|
+
function resultScene(result) {
|
|
71
|
+
return {
|
|
72
|
+
schema: SCENE_SCHEMA,
|
|
73
|
+
...result.room.name === void 0 ? {} : { name: result.room.name },
|
|
74
|
+
room: result.room,
|
|
75
|
+
objects: result.objects,
|
|
76
|
+
...result.layers === void 0 ? {} : { layers: result.layers }
|
|
77
|
+
};
|
|
78
|
+
}
|
|
38
79
|
/** This function tells if a turn is a measured angle: an angle from -360 degrees to 360 degrees. */
|
|
39
80
|
function isMeasured(turn) {
|
|
40
81
|
return typeof turn === "number" && Math.abs(turn) <= 360;
|
|
@@ -48,15 +89,21 @@ function degreesOf(turn) {
|
|
|
48
89
|
/**
|
|
49
90
|
* This function gives a survey in a different unit. Each length of the record changes, and each angle stays.
|
|
50
91
|
* A survey that has the unit already is the result.
|
|
92
|
+
*
|
|
93
|
+
* The anchors of a layer change through the add-on of the layer in `addOns`. An add-on keeps each different length of its layer in a fixed unit.
|
|
94
|
+
* The result has only the layers that an add-on of the list reads, because the anchors of a different layer stay in the old unit.
|
|
95
|
+
* `moveLayers` with `scaleAnchor` gives a finding for each layer that the result does not have.
|
|
51
96
|
*/
|
|
52
|
-
function convertSurvey(survey, unit) {
|
|
97
|
+
function convertSurvey(survey, unit, addOns = []) {
|
|
53
98
|
if (survey.unit === unit) return survey;
|
|
54
99
|
const factor = unitsPer(survey.unit, unit);
|
|
55
100
|
const to = (value) => value * factor;
|
|
56
101
|
const start = survey.start === void 0 ? void 0 : [to(survey.start[0]), to(survey.start[1])];
|
|
102
|
+
const layers = survey.layers === void 0 ? void 0 : moveLayers(survey.layers, addOns, (anchor) => scaleAnchor(anchor, factor)).layers;
|
|
57
103
|
return {
|
|
58
104
|
...survey,
|
|
59
105
|
unit,
|
|
106
|
+
...layers === void 0 ? {} : { layers },
|
|
60
107
|
height: to(survey.height),
|
|
61
108
|
wallThickness: to(survey.wallThickness),
|
|
62
109
|
sides: survey.sides.map((side) => ({
|
|
@@ -168,7 +215,8 @@ function expandSurvey(survey, options = {}) {
|
|
|
168
215
|
return [x - partX * gapX, y - partY * gapY];
|
|
169
216
|
});
|
|
170
217
|
const start = survey.start !== void 0 && inRange(survey.start[0]) && inRange(survey.start[1]) ? survey.start : [0, 0];
|
|
171
|
-
const
|
|
218
|
+
const heading = survey.heading !== void 0 && Number.isFinite(survey.heading) ? survey.heading : 0;
|
|
219
|
+
const [cos, sin] = directionOf(heading);
|
|
172
220
|
const place = ([x, y]) => [start[0] + (x * cos - y * sin), start[1] + (x * sin + y * cos)];
|
|
173
221
|
const walk = points.map(place);
|
|
174
222
|
const corners = adjusted.map(place);
|
|
@@ -223,7 +271,7 @@ function expandSurvey(survey, options = {}) {
|
|
|
223
271
|
walls,
|
|
224
272
|
...survey.openings === void 0 || openings === void 0 ? {} : { openings: shared ? openings : survey.openings },
|
|
225
273
|
...closed ? { floors: [{
|
|
226
|
-
id:
|
|
274
|
+
id: SURVEY_FLOOR,
|
|
227
275
|
...survey.name === void 0 ? {} : { name: survey.name },
|
|
228
276
|
ring: toLeft ? corners : [...corners].reverse()
|
|
229
277
|
}] } : {},
|
|
@@ -309,6 +357,13 @@ function expandSurvey(survey, options = {}) {
|
|
|
309
357
|
const made = placeOf(object);
|
|
310
358
|
return made === void 0 ? [] : [made];
|
|
311
359
|
});
|
|
360
|
+
const frame = {
|
|
361
|
+
face,
|
|
362
|
+
start,
|
|
363
|
+
heading,
|
|
364
|
+
factors: Object.fromEntries(factorOf)
|
|
365
|
+
};
|
|
366
|
+
const moved = survey.layers === void 0 ? void 0 : moveLayers(survey.layers, options.addOns ?? [], (anchor) => surveyAnchor(anchor, frame));
|
|
312
367
|
return {
|
|
313
368
|
room,
|
|
314
369
|
corners,
|
|
@@ -320,7 +375,10 @@ function expandSurvey(survey, options = {}) {
|
|
|
320
375
|
closed
|
|
321
376
|
},
|
|
322
377
|
checks,
|
|
323
|
-
objects
|
|
378
|
+
objects,
|
|
379
|
+
frame,
|
|
380
|
+
...moved === void 0 ? {} : { layers: moved.layers },
|
|
381
|
+
layerFindings: moved?.findings ?? []
|
|
324
382
|
};
|
|
325
383
|
}
|
|
326
384
|
// src/level.ts
|
|
@@ -362,6 +420,30 @@ const CONNECTION_FAULTS = [
|
|
|
362
420
|
"opening",
|
|
363
421
|
"one-room"
|
|
364
422
|
];
|
|
423
|
+
/** This function gives a survey with no layers. */
|
|
424
|
+
function withoutLayers(survey) {
|
|
425
|
+
const { layers, ...rest } = survey;
|
|
426
|
+
return layers === void 0 ? survey : rest;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* This function gives an anchor of a room with the names of the level. A wall and an object get the name that `roomName` gives.
|
|
430
|
+
* The floor of a room has the `id` of the room in a level.
|
|
431
|
+
*/
|
|
432
|
+
function inRoom(room, anchor) {
|
|
433
|
+
if (anchor.on === "wall") return {
|
|
434
|
+
...anchor,
|
|
435
|
+
wall: roomName(room, anchor.wall)
|
|
436
|
+
};
|
|
437
|
+
if (anchor.on === "object") return {
|
|
438
|
+
...anchor,
|
|
439
|
+
object: roomName(room, anchor.object)
|
|
440
|
+
};
|
|
441
|
+
if (anchor.floor === void 0) return anchor;
|
|
442
|
+
return {
|
|
443
|
+
...anchor,
|
|
444
|
+
floor: anchor.floor === "floor" ? room : roomName(room, anchor.floor)
|
|
445
|
+
};
|
|
446
|
+
}
|
|
365
447
|
/** The largest angle between the two walls of a connection that fits, in degrees. */
|
|
366
448
|
const CONNECTION_TURN_LIMIT = 2;
|
|
367
449
|
/** A length in meters at this value or less is 0 for the level. */
|
|
@@ -453,6 +535,9 @@ function placeFrom(known, knownHole, hole, depth) {
|
|
|
453
535
|
* This applies to the two walls of a connection, and to two walls that overlap.
|
|
454
536
|
* A wall that is in part an outer wall gets the same thickness along its full length.
|
|
455
537
|
*
|
|
538
|
+
* The layers of each room go to the room record of the level in one change. The change has the unit of the level, the place of the room, then the names of the level.
|
|
539
|
+
* Then the function `join` of each add-on gives one layer for the level. The layer of the level record comes first.
|
|
540
|
+
*
|
|
456
541
|
* `checkRoom` examines the room record. It tells when two rooms overlap.
|
|
457
542
|
*/
|
|
458
543
|
function expandLevel(level, options = {}) {
|
|
@@ -461,7 +546,7 @@ function expandLevel(level, options = {}) {
|
|
|
461
546
|
const inRange = (value) => Number.isFinite(value) && Math.abs(value) * scale <= 1e6;
|
|
462
547
|
const size = (value) => value !== void 0 && inRange(value) && value * scale > SMALL ? value : void 0;
|
|
463
548
|
const count = level.rooms.length;
|
|
464
|
-
const surveys = level.rooms.map((room) => convertSurvey(room.survey, unit));
|
|
549
|
+
const surveys = level.rooms.map((room) => convertSurvey(withoutLayers(room.survey), unit));
|
|
465
550
|
const owns = surveys.map((survey) => expandSurvey({
|
|
466
551
|
...survey,
|
|
467
552
|
start: void 0,
|
|
@@ -716,24 +801,42 @@ function expandLevel(level, options = {}) {
|
|
|
716
801
|
...object.outlet === void 0 ? {} : { outlet: `${id}/${object.outlet}` }
|
|
717
802
|
});
|
|
718
803
|
});
|
|
804
|
+
const room = {
|
|
805
|
+
schema: ROOM_SCHEMA,
|
|
806
|
+
...level.name === void 0 ? {} : { name: level.name },
|
|
807
|
+
unit,
|
|
808
|
+
height,
|
|
809
|
+
wallThickness,
|
|
810
|
+
walls,
|
|
811
|
+
...openings.length === 0 ? {} : { openings },
|
|
812
|
+
...floors.length === 0 ? {} : { floors },
|
|
813
|
+
...outlets.length === 0 ? {} : { outlets },
|
|
814
|
+
...circuits.size === 0 ? {} : { circuits: [...circuits.values()] }
|
|
815
|
+
};
|
|
816
|
+
const addOns = options.addOns ?? [];
|
|
817
|
+
const parts = [];
|
|
818
|
+
const findings = [];
|
|
819
|
+
rooms.forEach(({ id, result }, index) => {
|
|
820
|
+
const given = level.rooms[index]?.survey;
|
|
821
|
+
if (given?.layers === void 0) return;
|
|
822
|
+
const factor = unitsPer(given.unit, unit);
|
|
823
|
+
const moved = moveLayers(given.layers, addOns, (anchor) => inRoom(id, surveyAnchor(scaleAnchor(anchor, factor), result.frame)), id);
|
|
824
|
+
parts.push({
|
|
825
|
+
room: id,
|
|
826
|
+
layers: moved.layers
|
|
827
|
+
});
|
|
828
|
+
findings.push(...moved.findings);
|
|
829
|
+
});
|
|
830
|
+
const layers = level.layers === void 0 && parts.length === 0 ? void 0 : joinLayers(level.layers, parts, addOns);
|
|
719
831
|
return {
|
|
720
|
-
room
|
|
721
|
-
schema: ROOM_SCHEMA,
|
|
722
|
-
...level.name === void 0 ? {} : { name: level.name },
|
|
723
|
-
unit,
|
|
724
|
-
height,
|
|
725
|
-
wallThickness,
|
|
726
|
-
walls,
|
|
727
|
-
...openings.length === 0 ? {} : { openings },
|
|
728
|
-
...floors.length === 0 ? {} : { floors },
|
|
729
|
-
...outlets.length === 0 ? {} : { outlets },
|
|
730
|
-
...circuits.size === 0 ? {} : { circuits: [...circuits.values()] }
|
|
731
|
-
},
|
|
832
|
+
room,
|
|
732
833
|
rooms,
|
|
733
834
|
connections: results,
|
|
734
|
-
objects
|
|
835
|
+
objects,
|
|
836
|
+
...layers === void 0 ? {} : { layers: layers.layers },
|
|
837
|
+
layerFindings: layers === void 0 ? findings : [...findings, ...layers.findings]
|
|
735
838
|
};
|
|
736
839
|
}
|
|
737
|
-
export { ROOM_PLACES as a, SQUARE_TURNS as c,
|
|
840
|
+
export { ROOM_PLACES as a, SQUARE_TURNS as c, convertSurvey as d, expandSurvey as f, LEVEL_SCHEMA as i, SURVEY_FLOOR as l, surveyAnchor as m, CONNECTION_TURN_LIMIT as n, expandLevel as o, resultScene as p, CONNECTION_USES as r, CLOSURE_LIMIT as s, CONNECTION_FAULTS as t, SURVEY_SCHEMA as u };
|
|
738
841
|
|
|
739
|
-
//# sourceMappingURL=level-
|
|
842
|
+
//# sourceMappingURL=level-CXCIX08K.js.map
|