> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ploterr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WallNetwork

> WallNetwork joins walls.

Add walls to one network and Floorkit resolves each corner, T-junction and crossing.

## Import

```typescript theme={null}
import { WallNetwork } from '@opengeometry/floorkit';
```

## Example

```typescript theme={null}
import { WallNetwork, WallMaterial, Floorkit } from '@opengeometry/floorkit';

async function example(wasmURL: string): Promise<void> {
  await new Floorkit().setupOpenGeometry(wasmURL);
  const network = new WallNetwork({ defaultJoin: 'miter' });
  try {
    const walls = network.addPolyline(
      [
        [0, 0, 0],
        [5, 0, 0],
        [5, 0, 4],
      ],
      {
        labelName: 'Perimeter',
        thickness: 0.2,
        height: 3,
        baseElevation: 0,
        locationLine: 'centre',
        locationOffset: 0,
        material: WallMaterial.CONCRETE,
        color: 0xcccccc,
        priority: 0,
        joins: { start: { allow: true }, end: { allow: true } },
      },
    );
    const report = network.resolve();
    console.log(report.junctions, report.diagnostics);
    console.log(walls.map((wall) => wall.toDrawing('top')));
  } finally {
    network.dispose();
  }
}
```

## Notes

* `add` registers one wall. Call `resolve()` after you add a group of walls. `addPolyline` makes one wall for each segment and resolves them.
* Read `ResolveReport.diagnostics` after `resolve()`. It lists openings that moved and joins that were not possible.
* After you change a live opening, call `commitOpeningCuts()` on its wall.
* The network is not a scene object. Add each wall to your scene.
* `dispose()` disposes the walls of the network. Dispose doors and windows separately.
* Start the geometry kernel before you create this object. See [`Floorkit`](/floorkit/api/runtime/floorkit).
* This object is live geometry. To save a building, write it in a [building model](/floorkit/concepts/building-model).

## Constructor

```typescript theme={null}
constructor(options?: Partial<WallNetworkOptions>);
```

<ParamField path="options.joinTolerance" type="number" />

<ParamField path="options.defaultJoin" type="JoinType" />

<ParamField path="options.miterLimit" type="number" />

<ParamField path="options.autoJoin" type="boolean" />

## Properties

<ResponseField name="walls" type="Map<string, Wall>">
  Read-only.
</ResponseField>

<ResponseField name="nodes" type="Map<string, WallNode>">
  Read-only.
</ResponseField>

<ResponseField name="constraints" type="WallConstraint[]">
  Read-only.
</ResponseField>

<ResponseField
  name="joinOverrides"
  type="Map<string, {
type?: JoinType;
order?: string[];
}>"
>
  Read-only.
</ResponseField>

<ResponseField name="onResolved" type="Event<ResolveReport>">
  Read-only.
</ResponseField>

<ResponseField name="options" type="WallNetworkOptions">
  Read-only.
</ResponseField>

<ResponseField name="openingDetachTolerance" type="number | undefined">
  Metres from every wall beyond which a dragged door or window leaves its wall; `undefined` keeps it
  on walls.
</ResponseField>

## Methods

### subscribeInvalidation

```typescript theme={null}
subscribeInvalidation(callback: (changed: readonly string[]) => void): () => void;
```

### syncArcConfigEndpoints

```typescript theme={null}
syncArcConfigEndpoints(wallId: string, axis: WallAxis): void;
```

Keep a property-edited arc's free endpoint nodes on the authored circle.

### beginEdit

```typescript theme={null}
beginEdit(): void;
```

### endEdit

```typescript theme={null}
endEdit(): {
    undo: () => void;
    redo: () => void;
} | undefined;
```

### atomicModelEdit

```typescript theme={null}
atomicModelEdit<T>(edit: () => T): T;
```

### invalidateWall

```typescript theme={null}
invalidateWall(id: string, diagnostics?: JunctionDiagnostic[], extraChanged?: string[]): void;
```

Tell listeners that a wall changed; without `diagnostics` they get its opening diagnostics.

### snapAxisPoint

```typescript theme={null}
snapAxisPoint(cursor: XZ, radius: number, origin?: XZ): {
    point: XZ;
    kind: "endpoint" | "midpoint" | "perpendicular";
} | undefined;
```

### snapEndPoint

```typescript theme={null}
snapEndPoint(wallOrId: Wall | string, end: WallEnd, cursor: XZ, radius: number): XZ;
```

### nearestWall

```typescript theme={null}
nearestWall(point: XZ, maxDistance: number): {
    wall: Wall;
    station: number;
    distance: number;
} | undefined;
```

### outlineNeighbors

```typescript theme={null}
outlineNeighbors(wall: Wall): Wall[];
```

### lastResolveReport

```typescript theme={null}
lastResolveReport(): ResolveReport;
```

The junctions and diagnostics of the last resolve, as they are now, without a new resolve.

### junctionsOfWall

```typescript theme={null}
junctionsOfWall(wallId: string): readonly Junction[];
```

The junctions of the last resolve that `wallId` is a member of.

### openingDiagnostics

```typescript theme={null}
openingDiagnostics(): Extract<JunctionDiagnostic, {
    openingId: string;
}>[];
```

The current opening diagnostics of the hosted openings: an opening that does not fit where it is has an entry with its `fit`; one over a T seam has `opening-over-junction`.

### isSplitCrossingWall

```typescript theme={null}
isSplitCrossingWall(wallId: string, junctions?: readonly Junction[]): boolean;
```

### tSeamStations

```typescript theme={null}
tSeamStations(host: Wall, junctions?: readonly Junction[]): {
    start: number;
    end: number;
}[];
```

The stations along `host` where the seam of a T stem lies on a face of `host`.

### openingJunctionDiagnostics

```typescript theme={null}
openingJunctionDiagnostics(host: Wall, openingId: string, bounds: {
    startAlongWall: number;
    endAlongWall: number;
}, junctions?: readonly Junction[]): JunctionDiagnostic[];
```

### registerOpening

```typescript theme={null}
registerOpening(opening: Door | Window | WallOpening, point: XZ, maxDistance: number): {
    undo: () => void;
    redo: () => void;
} | undefined;
```

### beginHostedOpeningEdit

```typescript theme={null}
beginHostedOpeningEdit(opening: HostedOpening): void;
```

### previewHostedOpeningEdit

```typescript theme={null}
previewHostedOpeningEdit(opening: HostedOpening, position: Vec3, snapRadius: number): void;
```

### commitHostedOpeningEdit

```typescript theme={null}
commitHostedOpeningEdit(opening: HostedOpening): {
    undo: () => void;
    redo: () => void;
} | undefined;
```

### rehostOpening

```typescript theme={null}
rehostOpening(opening: Door | Window | WallOpening, point: XZ, maxDistance: number): {
    undo: () => void;
    redo: () => void;
} | undefined;
```

### add

```typescript theme={null}
add(wall: Wall): Wall;
```

### addArc

```typescript theme={null}
addArc(axis: Extract<WallAxis, {
    kind: "circularArc";
}>, options: Omit<WallOptions, "axis" | "ogid">, id?: string): Wall;
```

### addPolyline

```typescript theme={null}
addPolyline(points: readonly Vec3[], options: Omit<WallOptions, "axis" | "ogid">, ids?: readonly string[], resolve?: boolean): Wall[];
```

### replaceSavedWalls

```typescript theme={null}
replaceSavedWalls(saved: {
    runs: readonly {
        points: readonly Vec3[];
        options: Omit<WallOptions, 'axis' | 'ogid'>;
        ids: readonly string[];
    }[];
    options: Partial<WallNetworkOptions> | undefined;
}, placed?: (walls: readonly Wall[]) => void): void;
```

Bring the walls and options to the saved runs; no joint, trim or order of before stays, and after a throw the network holds the walls of both states until the next call repairs it.

### setJoin

```typescript theme={null}
setJoin(junctionKey: string, type: JoinType, order?: string[]): ResolveReport;
```

### disallowJoin

```typescript theme={null}
disallowJoin(wallOrId: Wall | string, end: WallEnd, disallow?: boolean): void;
```

### remove

```typescript theme={null}
remove(wallOrId: Wall | string): void;
```

### moveEnd

```typescript theme={null}
moveEnd(wallOrId: Wall | string, end: WallEnd, point: XZ): ResolveReport;
```

### translateWall

```typescript theme={null}
translateWall(wallOrId: Wall | string, delta: XZ): ResolveReport;
```

### resolve

```typescript theme={null}
resolve(dirtyWallIds?: ReadonlySet<string>): ResolveReport;
```

### restoreDetachedFaceTrims

```typescript theme={null}
restoreDetachedFaceTrims(trims: readonly WallDetachedFaceTrim[]): void;
```

Replace auxiliary face trims atomically without resolving or replacing walls.

**Throws:** \{Error} If the trim payload is invalid or refers to a missing wall.

### toModel

```typescript theme={null}
toModel(): WallNetworkModel;
```

### fromModel

```typescript theme={null}
static fromModel(model: WallNetworkModel): WallNetwork;
```

### dispose

```typescript theme={null}
dispose(): void;
```

## Types

### WallNode

```typescript theme={null}
interface WallNode {
  id: string;
  point: [number, number];
  ends: WallEndRef[];
}
```

### WallConstraint

```typescript theme={null}
interface WallConstraint extends WallEndRef {
  hostWallId: string;
  station: number;
}
```

### Event

Simple event handler by [Jason Kleban](https://gist.github.com/JasonKleban/50cee44960c225ac1993c922563aa540).

The package does not export this type by name.

```typescript theme={null}
class Event<T> {
  add(
    handler: T extends void
      ? {
          (): void;
        }
      : {
          (data: T): void;
        },
  ): void;
  remove(
    handler: T extends void
      ? {
          (): void;
        }
      : {
          (data: T): void;
        },
  ): void;
  trigger: (data?: T) => void;
  reset(): void;
}
```

<ResponseField name="trigger" type="unknown" required>
  Triggers all the callbacks assigned to this event.
</ResponseField>

### ResolveReport

```typescript theme={null}
interface ResolveReport {
  changed: string[];
  junctions: Junction[];
  diagnostics: JunctionDiagnostic[];
}
```

### WallNetworkOptions

```typescript theme={null}
interface WallNetworkOptions {
  joinTolerance: number;
  defaultJoin: JoinType;
  miterLimit: number;
  autoJoin: boolean;
}
```

### WallAxis

```typescript theme={null}
type WallAxis =
  | {
      kind: 'line';
      start: Vec3;
      end: Vec3;
    }
  | {
      kind: 'circularArc';
      center: Vec3;
      radius: number;
      startAngle: number;
      sweepAngle: number;
    };
```

### XZ

```typescript theme={null}
type XZ = {
  x: number;
  z: number;
};
```

### WallEnd

```typescript theme={null}
type WallEnd = 'start' | 'end';
```

### HostedOpening

The package does not export this type by name.

```typescript theme={null}
type HostedOpening = Door | Window | WallOpening;
```

### JoinType

```typescript theme={null}
type JoinType = 'miter' | 'butt' | 'squareOff';
```

### WallDetachedFaceTrim

A detached wall-end face trim; source retains the native T/X reconstruction policy.

```typescript theme={null}
interface WallDetachedFaceTrim extends WallEndRef {
  hostWallId: string;
  source?: 'T' | 'X';
}
```

### WallNetworkModel

```typescript theme={null}
interface WallNetworkModel {
  walls: WallOptions[];
  nodes: WallNode[];
  constraints: WallConstraint[];
  detachedFaceTrims?: WallDetachedFaceTrim[];
  joinOverrides: WallJoinOverride[];
  options: WallNetworkOptions;
}
```

### WallEndRef

```typescript theme={null}
interface WallEndRef {
  wallId: string;
  end: WallEnd;
}
```

### WallJoinOverride

```typescript theme={null}
interface WallJoinOverride {
  junctionKey: string;
  type?: JoinType;
  order?: string[];
}
```

## Related

* [`Door`](/floorkit/api/architecture/door)
* [`Wall`](/floorkit/api/architecture/wall)
* [`WallOpening`](/floorkit/api/architecture/wall-opening)
* [`Window`](/floorkit/api/architecture/window)
* [`Junction`](/floorkit/api/architecture/wall#junction)
* [`JunctionDiagnostic`](/floorkit/api/architecture/wall#junctiondiagnostic)
* [`Vec3`](/floorkit/api/architecture/wall#vec3)
* [`WallOptions`](/floorkit/api/architecture/wall#walloptions)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.