@archilogic/floor-plan-sdk 5.1.13 → 5.1.14

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/dist/fpe.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { default as default_2 } from 'rbush';
2
+
1
3
  /**
2
4
  * This interface was referenced by `AuthJson`'s JSON-Schema
3
5
  * via the `definition` "actionScope".
@@ -1013,6 +1015,15 @@ declare interface HtmlMarkerState extends HtmlMarkerArgs {
1013
1015
  floorPlan: FloorPlanEngine;
1014
1016
  }
1015
1017
 
1018
+ declare type IndexedNodeReference = {
1019
+ id: string;
1020
+ type: LayoutBoundingBoxNode['type'];
1021
+ minX: number;
1022
+ minY: number;
1023
+ maxX: number;
1024
+ maxY: number;
1025
+ };
1026
+
1016
1027
  declare type IndexRange = {
1017
1028
  type: 'index:range';
1018
1029
  start: number;
@@ -1183,10 +1194,9 @@ declare class LayoutAsset extends LayoutTransformElementBase {
1183
1194
  get isComponentInstanceChild(): boolean;
1184
1195
  setParameters(parameters: RecursivePartial<LayoutAssetParameters>): void;
1185
1196
  setProduct(product: SpaceGraphProduct): void;
1186
- getBoundingBox(localTransform?: boolean): {
1197
+ calculateBoundingBox(): {
1187
1198
  min: Vector3;
1188
1199
  max: Vector3;
1189
- transform: Transform3d;
1190
1200
  };
1191
1201
  }
1192
1202
 
@@ -1246,10 +1256,9 @@ declare class LayoutBoundaryElementBase extends LayoutElementBase {
1246
1256
  parameters: LayoutBoundaryElementParameters;
1247
1257
  boundaries: LayoutBoundary[];
1248
1258
  constructor(id: string, type: LayoutBoundaryElementType, boundaries: LayoutBoundary[]);
1249
- getBoundingBox(): {
1259
+ calculateBoundingBox(): {
1250
1260
  min: Vector3;
1251
1261
  max: Vector3;
1252
- transform: Transform3d;
1253
1262
  };
1254
1263
  }
1255
1264
 
@@ -1336,6 +1345,32 @@ declare type LayoutBoundaryWallType = typeof LayoutBoundaryWallTypeValue;
1336
1345
 
1337
1346
  declare const LayoutBoundaryWallTypeValue = "element:boundaryWall";
1338
1347
 
1348
+ declare class LayoutBoundingBoxNode extends LayoutNodeBase {
1349
+ protected axisAlignedBoundingBox: BoundingBox3d | null;
1350
+ protected objectAlignedBoundingBox: BoundingBox3d | null;
1351
+ protected boundingBoxContour: Vector2_2[] | null;
1352
+ protected transform: Transform3d | null;
1353
+ protected worldTransform: Transform3d | null;
1354
+ calculateTransform(): Transform3d;
1355
+ getTransform(): Transform3d;
1356
+ calculateWorldTransform(): Transform3d;
1357
+ getWorldTransform(): Transform3d;
1358
+ resetTransform(resetIndex?: boolean): void;
1359
+ resetBoundingBox(resetIndex?: boolean): void;
1360
+ resetSpatialIndexing(): void;
1361
+ calculateBoundingBox(): BoundingBox3d;
1362
+ /**
1363
+ * returns the node's object aligned bounding box with transform
1364
+ */
1365
+ getBoundingBox(localTransform?: boolean): TransformBoundingBox3d;
1366
+ /**
1367
+ * returns the node's axis aligned bounding box with transform applied
1368
+ */
1369
+ getAxisAlignedBoundingBox(): BoundingBox3d;
1370
+ calculateBoundingBoxContour(localTransform?: boolean): Vector2_2[];
1371
+ getBoundingBoxContour(): Vector2_2[];
1372
+ }
1373
+
1339
1374
  declare class LayoutCasework extends LayoutTransformElementBase {
1340
1375
  type: LayoutCaseworkType;
1341
1376
  parameters: LayoutCaseworkParameters;
@@ -1425,10 +1460,9 @@ declare class LayoutDoor extends LayoutTransformElementBase {
1425
1460
  parameters: LayoutDoorParameters;
1426
1461
  constructor(id: string);
1427
1462
  setParameters(parameters: RecursivePartial<LayoutDoorParameters>): void;
1428
- getBoundingBox(localTransform?: boolean): {
1463
+ calculateBoundingBox(): {
1429
1464
  min: Vector3;
1430
1465
  max: Vector3;
1431
- transform: Transform3d;
1432
1466
  };
1433
1467
  }
1434
1468
 
@@ -1453,14 +1487,15 @@ declare const LayoutDoorTypeValue = "element:door";
1453
1487
  declare type LayoutEdgeElement = LayoutCurtainWall | LayoutSpaceDivider | LayoutWall;
1454
1488
 
1455
1489
  declare class LayoutEdgeElementBase extends LayoutElementBase {
1490
+ #private;
1456
1491
  type: LayoutEdgeElementType;
1457
1492
  parameters: LayoutEdgeElementParameters;
1458
1493
  private edges;
1459
1494
  private vertices;
1495
+ private boundingBoxTransform;
1460
1496
  edgesChanged: boolean;
1461
1497
  constructor(id: string, type: LayoutEdgeElementType, edges: SpatialGraphEdge[]);
1462
1498
  setEdges(edges: SpatialGraphEdge[]): void;
1463
- private verifyEdges;
1464
1499
  getEdges(): SpatialGraphEdge[];
1465
1500
  getVertices(): SpatialGraphVertex[];
1466
1501
  getStartVertex(): SpatialGraphVertex | undefined;
@@ -1469,6 +1504,9 @@ declare class LayoutEdgeElementBase extends LayoutElementBase {
1469
1504
  getAxisLength(): number;
1470
1505
  getEdgeAtLinearPosition(u: number): SpatialGraphEdge | undefined;
1471
1506
  getEdgesAtLinearSegment(u: number, v: number): SpatialGraphEdge[];
1507
+ resetTransform(): void;
1508
+ getBoundingBox(): TransformBoundingBox3d;
1509
+ calculateBoundingBoxTransform(): Transform3d;
1472
1510
  /**
1473
1511
  * @deprecated Use getEdges() instead of edge
1474
1512
  */
@@ -1496,22 +1534,16 @@ declare type LayoutEdgeElementType = LayoutCurtainWallType | LayoutSpaceDividerT
1496
1534
 
1497
1535
  declare type LayoutElement = LayoutBoundaryElement | LayoutEdgeElement | LayoutOpeningElement | LayoutTransformElement;
1498
1536
 
1499
- declare class LayoutElementBase extends LayoutNodeBase {
1537
+ declare class LayoutElementBase extends LayoutBoundingBoxNode {
1500
1538
  type: LayoutElementType;
1501
1539
  parameters: LayoutElementParameters;
1502
1540
  parent: LayoutElement | null;
1503
1541
  elements: LayoutElement[];
1504
1542
  geometries: GeometryOperationJson[];
1505
1543
  insertElement(element: LayoutElement): void;
1506
- getTransform(): Transform3d;
1507
- getWorldTransform(): Transform3d;
1508
- /**
1509
- * returns the element's object aligned bounding box with transform
1510
- */
1511
- getBoundingBox(localTransform?: boolean): TransformBoundingBox3d;
1512
- getAxisAlignedBoundingBox(localTransform?: boolean): BoundingBox3d;
1513
- getBoundingBoxContour(localTransform?: boolean): Vector2_2[];
1514
1544
  get isExternal(): boolean;
1545
+ resetTransform(resetIndex?: boolean): void;
1546
+ resetBoundingBox(resetIndex?: boolean): void;
1515
1547
  removeElement(element: LayoutElement): void;
1516
1548
  copyForClone(element: LayoutElement): void;
1517
1549
  setParameters(parameters: RecursivePartial<LayoutElementParameters>): void;
@@ -1825,7 +1857,8 @@ declare type LayoutSlabType = typeof LayoutSlabTypeValue;
1825
1857
 
1826
1858
  declare const LayoutSlabTypeValue = "element:slab";
1827
1859
 
1828
- declare class LayoutSpace extends LayoutNodeBase {
1860
+ declare class LayoutSpace extends LayoutBoundingBoxNode {
1861
+ #private;
1829
1862
  type: LayoutSpaceType;
1830
1863
  attributes: LayoutSpaceAttributes;
1831
1864
  boundaries: LayoutBoundary[];
@@ -1836,6 +1869,7 @@ declare class LayoutSpace extends LayoutNodeBase {
1836
1869
  setId(id: string): void;
1837
1870
  setAttributes(attributes: LayoutSpaceAttributesJson): void;
1838
1871
  get isExternal(): boolean;
1872
+ calculateArea(): number;
1839
1873
  getArea(): number;
1840
1874
  getAdjacentSpaces(graph: Graph, { connectivity }?: {
1841
1875
  connectivity?: number;
@@ -1849,9 +1883,10 @@ declare class LayoutSpace extends LayoutNodeBase {
1849
1883
  boundary: LayoutBoundary | undefined;
1850
1884
  edgeIndex: number;
1851
1885
  };
1852
- getBoundingBox(): TransformBoundingBox3d;
1886
+ calculateBoundingBox(): BoundingBox3d;
1853
1887
  getAxisAlignedBoundingBox(): BoundingBox3d;
1854
- getBoundingBoxContour(): Vector2_2[];
1888
+ resetBoundingBox(resetIndex?: boolean): void;
1889
+ resetSpatialIndexing(): void;
1855
1890
  attachSlab(slab: LayoutBoundarySlab): void;
1856
1891
  detachSlab(slab: LayoutBoundarySlab): void;
1857
1892
  toJSON(): LayoutSpaceJson;
@@ -1872,7 +1907,7 @@ declare class LayoutSpaceDivider extends LayoutEdgeElementBase {
1872
1907
  parameters: LayoutSpaceDividerParameters;
1873
1908
  constructor(id: string, edges: SpatialGraphEdge[]);
1874
1909
  setParameters(parameters: RecursivePartial<LayoutSpaceDividerParameters>): void;
1875
- getBoundingBox(): TransformBoundingBox3d;
1910
+ calculateBoundingBox(): BoundingBox3d;
1876
1911
  }
1877
1912
 
1878
1913
  declare interface LayoutSpaceDividerJson extends LayoutEdgeElementBaseJson {
@@ -1969,10 +2004,9 @@ declare class LayoutStairs extends LayoutTransformElementBase {
1969
2004
  parameters: LayoutStairsParameters;
1970
2005
  constructor(id: string);
1971
2006
  setParameters(parameters: RecursivePartial<LayoutStairsParameters>, skipElementCreation?: boolean): void;
1972
- getBoundingBox(localTransform?: boolean): {
2007
+ calculateBoundingBox(): {
1973
2008
  min: Vector3;
1974
2009
  max: Vector3;
1975
- transform: Transform3d;
1976
2010
  };
1977
2011
  }
1978
2012
 
@@ -2009,12 +2043,11 @@ declare class LayoutTransformElementBase extends LayoutElementBase {
2009
2043
  setRotation(rotation: number, rotationAxis?: Vector3): void;
2010
2044
  setTransform(position: Vector3, rotation: number, rotationAxis?: Vector3): void;
2011
2045
  getSpaces(): LayoutSpace[];
2012
- getTransform(): Transform3d;
2013
- getWorldTransform(): Transform3d;
2014
- getBoundingBox(localTransform?: boolean): {
2046
+ calculateTransform(): Transform3d;
2047
+ calculateWorldTransform(): Transform3d;
2048
+ calculateBoundingBox(): {
2015
2049
  min: Vector3;
2016
2050
  max: Vector3;
2017
- transform: Transform3d;
2018
2051
  };
2019
2052
  setParameters(parameters: RecursivePartial<LayoutTransformElementParameters>): void;
2020
2053
  }
@@ -2069,7 +2102,7 @@ declare class LayoutWall extends LayoutEdgeElementBase {
2069
2102
  constructor(id: string, edges: SpatialGraphEdge[]);
2070
2103
  copyForClone(wall: LayoutWall): void;
2071
2104
  setParameters(parameters: RecursivePartial<LayoutWallParameters>): void;
2072
- getBoundingBox(): TransformBoundingBox3d;
2105
+ calculateBoundingBox(): BoundingBox3d;
2073
2106
  }
2074
2107
 
2075
2108
  declare interface LayoutWallGeometryProfile {
@@ -2518,9 +2551,9 @@ declare class SpaceGraph {
2518
2551
  nodes: SpaceGraphNode[];
2519
2552
  nodesById: Record<string, SpaceGraphNode>;
2520
2553
  nodesByType: NodesByType<{
2521
- readonly 'spatialStructure:building': typeof SpaceGraphBuilding;
2522
- readonly 'spatialStructure:floor': typeof SpaceGraphFloor;
2523
- readonly 'spatialStructure:layout': typeof SpaceGraphLayout;
2554
+ readonly 'spatialStructure:building': SpaceGraphBuilding;
2555
+ readonly 'spatialStructure:floor': SpaceGraphFloor;
2556
+ readonly 'spatialStructure:layout': SpaceGraphLayout;
2524
2557
  readonly 'relation:group': typeof GroupRelation;
2525
2558
  readonly 'product:static': typeof SpaceGraphProductStatic;
2526
2559
  readonly 'product:component': typeof SpaceGraphProductComponent;
@@ -2575,10 +2608,6 @@ declare class SpaceGraph {
2575
2608
  unregisterNode(node: SpaceGraphNode): void;
2576
2609
  insertSpatialStructure(spatialStructure: SpaceGraphSpatialStructure): void;
2577
2610
  removeSpatialStructure(): SpaceGraphSpatialStructure | undefined;
2578
- createSpatialStructure(type: SpaceGraphBuildingType, id: string): SpaceGraphBuilding;
2579
- createSpatialStructure(type: SpaceGraphFloorType, id: string): SpaceGraphFloor;
2580
- createSpatialStructure(type: LayoutType, id: string): SpaceGraphLayout;
2581
- createSpatialStructure(type: SpaceGraphSpatialStructureType, id: string): SpaceGraphSpatialStructure;
2582
2611
  insertProduct(product: SpaceGraphProduct): void;
2583
2612
  removeProduct(product: SpaceGraphProduct): void;
2584
2613
  createProduct(id: string, type: SpaceGraphProductType): SpaceGraphProduct;
@@ -2601,6 +2630,7 @@ declare class SpaceGraph {
2601
2630
  once<EventType extends keyof SpaceGraphEventMap>(event: EventType, handler: (...args: SpaceGraphEventMap[EventType]) => void, context?: any): void;
2602
2631
  off<EventType extends keyof SpaceGraphEventMap>(event: EventType, handler?: (...args: SpaceGraphEventMap[EventType]) => void): void;
2603
2632
  toJSON(): SpaceGraphJson;
2633
+ static fromJSON(spaceGraphJson: SpaceGraphJson): SpaceGraph;
2604
2634
  }
2605
2635
 
2606
2636
  declare class SpaceGraphBasicMaterial extends SpaceGraphNodeBase {
@@ -2636,6 +2666,10 @@ declare class SpaceGraphBuilding extends SpaceGraphSpatialStructureBase {
2636
2666
  removeFloor(floor: SpaceGraphFloor): void;
2637
2667
  createFloor(id: string): SpaceGraphFloor;
2638
2668
  toJSON(): SpaceGraphBuildingJson;
2669
+ static fromJSON(buildingJson: SpaceGraphBuildingJson, options: {
2670
+ spaceGraph: SpaceGraph;
2671
+ skipInsert?: boolean;
2672
+ }): SpaceGraphBuilding;
2639
2673
  }
2640
2674
 
2641
2675
  declare interface SpaceGraphBuildingJson extends SpaceGraphSpatialStructureBaseJson {
@@ -2778,6 +2812,10 @@ declare class SpaceGraphFloor extends SpaceGraphSpatialStructureBase {
2778
2812
  removeLayout(layout: SpaceGraphLayout): void;
2779
2813
  createLayout(id: string): SpaceGraphLayout;
2780
2814
  toJSON(): SpaceGraphFloorJson;
2815
+ static fromJSON(floorJson: SpaceGraphFloorJson, options?: {
2816
+ spaceGraph: SpaceGraph;
2817
+ skipInsert?: boolean;
2818
+ }): SpaceGraphFloor;
2781
2819
  }
2782
2820
 
2783
2821
  declare interface SpaceGraphFloorJson extends SpaceGraphSpatialStructureBaseJson {
@@ -2846,6 +2884,7 @@ declare class SpaceGraphLayout extends SpaceGraphSpatialStructureBase {
2846
2884
  readonly 'view:2d': Layout2dView;
2847
2885
  readonly 'view:3d': Layout3dView;
2848
2886
  }>;
2887
+ spatialIndex: SpatialIndex;
2849
2888
  debugIds: boolean;
2850
2889
  suggestedIds: Record<string, boolean>;
2851
2890
  constructor(id: string);
@@ -2882,6 +2921,10 @@ declare class SpaceGraphLayout extends SpaceGraphSpatialStructureBase {
2882
2921
  getElementId(element: LayoutElement, prefix?: string): string;
2883
2922
  getBoundingBox(): TransformBoundingBox3d;
2884
2923
  toJSON(): SpaceGraphLayoutJson;
2924
+ static fromJSON(layoutJson: SpaceGraphLayoutJson, options?: {
2925
+ spaceGraph?: SpaceGraph;
2926
+ skipInsert?: boolean;
2927
+ }): SpaceGraphLayout;
2885
2928
  }
2886
2929
 
2887
2930
  declare interface SpaceGraphLayoutJson extends SpaceGraphSpatialStructureBaseJson {
@@ -3117,6 +3160,8 @@ declare class SpatialGraphEdge extends SpatialGraphNodeBase {
3117
3160
  getLength(): number;
3118
3161
  get isExternal(): boolean;
3119
3162
  setVertices(vertex1: SpatialGraphVertex, vertex2: SpatialGraphVertex): void;
3163
+ resetSpatialIndexing(): void;
3164
+ calculateBoundingBox(): BoundingBox3d;
3120
3165
  setVerticesByIds(vertexId1: string, vertexId2: string): void;
3121
3166
  canSplit(u: number, options?: EdgeCanSplitOptions): boolean;
3122
3167
  split(u: number, options?: EdgeSplitOptions, updateSpaceBoundaries?: boolean): EdgeSplitReturnValue;
@@ -3137,7 +3182,7 @@ declare const SpatialGraphEdgeTypeValue = "spatialGraph:edge";
3137
3182
 
3138
3183
  declare type SpatialGraphNode_2 = SpatialGraphVertex | SpatialGraphEdge;
3139
3184
 
3140
- declare class SpatialGraphNodeBase extends LayoutNodeBase {
3185
+ declare class SpatialGraphNodeBase extends LayoutBoundingBoxNode {
3141
3186
  }
3142
3187
 
3143
3188
  declare interface SpatialGraphNodeBaseJson extends LayoutNodeBaseJson {
@@ -3151,9 +3196,11 @@ declare class SpatialGraphVertex extends SpatialGraphNodeBase {
3151
3196
  edges: SpatialGraphEdge[];
3152
3197
  constructor(id: string, x: number, y: number);
3153
3198
  sortVertexEdges(): void;
3199
+ calculateTransform(): Transform3d;
3154
3200
  addEdge(edge: SpatialGraphEdge): void;
3155
3201
  removeEdge(edge: SpatialGraphEdge): void;
3156
3202
  setPosition(x: number, y: number): void;
3203
+ resetSpatialIndexing(): void;
3157
3204
  toJSON(): SpatialGraphVertexJson;
3158
3205
  }
3159
3206
 
@@ -3167,6 +3214,43 @@ declare type SpatialGraphVertexType = typeof SpatialGraphVertexTypeValue;
3167
3214
 
3168
3215
  declare const SpatialGraphVertexTypeValue = "spatialGraph:vertex";
3169
3216
 
3217
+ /**
3218
+ * A spatial index for efficiently querying nodes within a 2D bounding box.
3219
+ *
3220
+ * @example
3221
+ * ```typescript
3222
+ * const spatialIndex = new SpatialIndex(layout);
3223
+ * spatialIndex.addNode(node);
3224
+ * const foundNodes = spatialIndex.find({
3225
+ * min: [-10, -10],
3226
+ * max: [10, 10],
3227
+ * margin: 0.1,
3228
+ * types: ['element:wall', 'element:door']
3229
+ * });
3230
+ * ```
3231
+ */
3232
+ declare class SpatialIndex extends default_2<IndexedNodeReference> {
3233
+ nodeIds: Set<string>;
3234
+ layout: SpaceGraphLayout;
3235
+ constructor(layout: SpaceGraphLayout);
3236
+ /**
3237
+ * Find nodes by 2d bounding, margin and types selection
3238
+ *
3239
+ * `max` will fallback to `min` if not provided
3240
+ */
3241
+ find<T = LayoutBoundingBoxNode>({ min, max, margin, types }: SpatialIndexFind): T[];
3242
+ addNode(node: LayoutBoundingBoxNode): void;
3243
+ removeNode(node: LayoutBoundingBoxNode): void;
3244
+ remove(node: IndexedNodeReference): this;
3245
+ }
3246
+
3247
+ declare type SpatialIndexFind = {
3248
+ min: Vector2_2;
3249
+ max?: Vector2_2;
3250
+ margin?: number;
3251
+ types?: LayoutNodeType[];
3252
+ };
3253
+
3170
3254
  declare class SphereGeometry extends ParametricGeometryBase {
3171
3255
  type: SphereGeometryType;
3172
3256
  radius: number;