Curtain Wall

A curtain wall on a facade that turns a corner, as a BIM model. Each facet is a stack of IfcCurtainWall grids of glass panes between mullions and transoms, on its own wall line, and placedSolids() applies the two levels of the placement. The planning module, the storey height, the mullion and the glass unit are published figures, and the kernel measures the area of the vision glass. The slabs, the brackets, the back pans and the corner post are a display model.
Code
This is the full program. The playground runs it in your browser without a change.
ts
import { BimModel, placedSolids, toIfc } from 'brepjs-bim';
import { box, clone, compound, cylinder, extrude, fuseAll, getSolids, measureVolume, polygon, rotate, translate, unwrap } from 'brepjs/quick';
import { color, present } from 'brepjs/playground';
// Curtain wall on a facade that turns a corner: each facet is a stack of IfcCurtainWall grids, with glass panes
// between mullions and transoms, on its own wall line. The planning module, the storey height, the mullion and
// the glass unit are published figures. The slabs, the brackets, the back pans and the corner are a display
// model. Units are millimetres. The facade looks to +X and the corner is at the origin.
interface FacadeParams {
skew?: number; // degrees between the two facets. 0 makes a flat facade
storeys?: number; // storeys of glass
cutaway?: number; // modules at each end that show no glass. The IFC file keeps all the glass
}
// ---- published figures
const MODULE = 1500; // office planning grid
const STOREY = 3900; // floor to floor, in the usual range of 3.6 to 4.2 m
const MULLION = { face: 65, depth: 160 }; // a unitised system
const GLASS = { unit: 28, kgM2: 30.57 }; // double glazing 6-16-6, and its mass for each m2
const SLAB = 150; // composite slab
const HE240B = { h: 240, b: 240, tw: 10, tf: 17 };
// ---- display model
const SPANDREL = 1100, VISION = STOREY - SPANDREL; // the spandrel hides the slab edge and the ceiling zone
const MODULES = 3; // glass modules in each facet
const EDGE = { gap: 60, depth: 1500, column: 600 }; // from the mullions to the slab edge, and the slab strip
const COLORS = { glass: '#9fc3d4', spandrel: '#e4e7ea', frame: '#c3c9d1', slab: '#cfcabb', steel: '#8a99ad', bracket: '#12b5b0', pan: '#d3a956', fire: '#ff5a1f' };
type Tone = keyof typeof COLORS;
type P3 = [number, number, number];
type Body = ReturnType<typeof box>;
type Id = Extract<ReturnType<BimModel['addCurtainWall']>, { ok: true }>['value']; // the id of an element in the model
const Z: P3 = [0, 0, 1];
function facade({ skew = 30, storeys = 2, cutaway = 1 }: FacadeParams = {}) {
const model = new BimModel(), owned: { delete(): void }[] = [];
const own = <T extends { delete(): void }>(s: T): T => { owned.push(s); return s; };
try {
model.init({ name: 'Curtain wall' });
// The spatial structure makes this a BIM model: project, site, building, storey.
const project = model.getProject();
const site = unwrap(model.addSite({ name: 'Site' }));
const building = unwrap(model.addBuilding({ name: 'Building' }));
const storey = unwrap(model.addStorey({ name: 'Level 1', elevation: 0 }));
if (project) model.aggregate(project.localId, site);
model.aggregate(site, building);
model.aggregate(building, storey);
const tones = new Map<Id, Tone>(), hidden = new Map<Id, number[]>();
const put = (tone: Tone, made: ReturnType<BimModel['addCurtainWall']>): Id => {
const id = unwrap(made);
model.placeIn(id, storey);
tones.set(id, tone);
return id;
};
// Two wall lines meet at the origin. Each turns half of the skew away from the Y axis. A line has its own
// frame: axisX along the wall, and the inside of the building to the left of it.
const half = skew * Math.PI / 360, modules = MODULES, width = modules * MODULE, levels = Math.max(1, Math.round(storeys));
const reach = MULLION.depth * Math.tan(half) + MULLION.face / 2; // from the corner to the last grid line
const lines = [-1, 1].map((side) => {
const axisX: P3 = [-side * Math.sin(half), Math.cos(half), 0], inward: P3 = [-Math.cos(half), -side * Math.sin(half), 0];
const start = side < 0 ? -(width + reach) : reach;
return { side, axisX, inward, origin: [start * axisX[0], start * axisX[1], 0] as P3, turn: Math.atan2(axisX[1], axisX[0]) * 180 / Math.PI };
});
// The curtain walls. One call makes a grid of columns x rows panes with a mullion on each grid line. The
// placement has two levels: a pane has its place in the grid, and the grid is on the frame of its wall line.
// Each facet is a stack of grids: a spandrel band at each slab and a vision band between. A grid stops half a
// transom short of its band, so the transoms of two bands meet.
const bands = Array.from({ length: 2 * levels + 1 }, (_, i) => (i % 2 === 0
? { z: i / 2 * STOREY + SLAB - SPANDREL, height: SPANDREL, tone: 'spandrel' as const }
: { z: (i - 1) / 2 * STOREY + SLAB, height: VISION, tone: 'glass' as const }));
for (const line of lines) for (const band of bands) {
const id = put(band.tone, model.addCurtainWall({
width, height: band.height - MULLION.face, columns: modules, rows: 1,
panelThickness: GLASS.unit, mullionWidth: MULLION.face, mullionDepth: MULLION.depth,
origin: [line.origin[0], line.origin[1], band.z + MULLION.face / 2], axisX: line.axisX, axisZ: Z,
materialName: 'Aluminium', panelMaterialName: band.tone === 'glass' ? 'Double glazing 6-16-6' : 'Spandrel glass',
}));
// The panes of the end modules stay out of the view.
const open = Math.min(Math.max(Math.round(cutaway), 0), modules);
hidden.set(id, Array.from({ length: open }, (_, i) => (line.side < 0 ? i : modules - 1 - i)));
}
const sizes = { width, reach, half, modules, levels };
structure(model, put, own, lines, sizes);
dress(model, put, own, lines, sizes);
// The view. placedSolids() applies both levels of the placement. It gives the panes first, then the mullions
// and the transoms. The kernel measures the panes of the vision band.
const groups: Record<Tone, Body[]> = { glass: [], spandrel: [], frame: [], slab: [], steel: [], bracket: [], pan: [], fire: [] };
let visionM2 = 0;
for (const el of model.getAllElements()) {
const tone = tones.get(el.localId);
if (!tone) continue;
const placed = unwrap(placedSolids(el)).map((body) => own(body));
const skip = hidden.get(el.localId);
if (!skip) { groups[tone].push(...placed); continue; }
const panes = placed.slice(0, modules);
if (tone === 'glass') visionM2 += panes.reduce((sum, pane) => sum + unwrap(measureVolume(pane)), 0) / GLASS.unit / 1e6;
groups[tone].push(...panes.filter((_, i) => !skip.includes(i)));
groups.frame.push(...placed.slice(modules));
}
const shown = (Object.keys(COLORS) as Tone[]).filter((tone) => groups[tone].length > 0).map((tone) => color(compound(groups[tone]), COLORS[tone]));
const byHand = 2 * levels * modules * (MODULE - MULLION.face) * (VISION - 2 * MULLION.face) / 1e6;
return { model, shown, visionM2, byHand, glassKg: visionM2 * GLASS.kgM2 };
} catch (error) {
model[Symbol.dispose]();
throw error;
} finally {
owned.splice(0).forEach((body) => body.delete());
}
}
type Line = { side: number; axisX: P3; inward: P3; origin: P3; turn: number };
type Sizes = { width: number; reach: number; half: number; modules: number; levels: number };
type Put = (tone: Tone, made: ReturnType<BimModel['addCurtainWall']>) => Id;
type Own = <T extends { delete(): void }>(s: T) => T;
// A point of a wall line: u along the wall from the corner, t into the building.
const point = (line: Line, u: number, t: number, z: number): P3 => [u * line.axisX[0] + t * line.inward[0], u * line.axisX[1] + t * line.inward[1], z];
// A strip of each floor slab behind the facade, and a steel column behind the end module of each facet.
function structure(model: BimModel, put: Put, own: Own, lines: Line[], { width, reach, half, levels }: Sizes): void {
const edge = MULLION.depth + EDGE.gap, far = width + reach + MULLION.face / 2, near = (edge + EDGE.depth) * Math.tan(half);
const tops = Array.from({ length: levels + 1 }, (_, i) => i * STOREY);
for (const top of tops) {
for (const line of lines) {
const from = line.side < 0 ? -far : near;
put('slab', model.addSlab({ length: far - near, width: EDGE.depth, thickness: SLAB, origin: point(line, from, edge, top - SLAB), axisX: line.axisX, axisZ: Z, predefinedType: 'FLOOR', materialName: 'Concrete' }));
}
// The slabs stop at the corner. A piece with four sides fills the place between them.
if (near > 1) {
const [a, b] = [lines[0]!, lines[1]!];
const kite = own(unwrap(polygon([point(a, -near, edge, top - SLAB), point(a, -edge * Math.tan(half), edge, top - SLAB), point(b, near, edge, top - SLAB), point(a, -near, edge + EDGE.depth, top - SLAB)])));
put('slab', model.addProxy({ name: 'Slab corner', solid: unwrap(extrude(kite, [0, 0, SLAB])) as Body, materialName: 'Concrete' }));
}
}
const column = { kind: 'I_BEAM', overallWidth: HE240B.b, overallDepth: HE240B.h, flangeThickness: HE240B.tf, webThickness: HE240B.tw } as const;
for (const line of lines) for (const top of tops.slice(0, -1))
put('steel', model.addColumn({ height: STOREY - SLAB, profile: column, origin: point(line, line.side * (reach + width - MODULE / 2), edge + EDGE.column, top), axisX: line.axisX, axisZ: Z, materialName: 'Steel S355' }));
}
// The parts that hold and close the wall: a bracket at each mullion, a back pan behind each spandrel pane, a fire
// stop at each slab edge and a post at the corner. Each part is a proxy in the storey.
function dress(model: BimModel, put: Put, own: Own, lines: Line[], { width, reach, half, modules, levels }: Sizes): void {
const one = (shape: Parameters<typeof getSolids>[0]): Body => unwrap(clone(getSolids(own(shape))[0]!)) as Body;
const block = (u0: number, u1: number, t0: number, t1: number, z0: number, z1: number): Body => box(u1 - u0, t1 - t0, z1 - z0, { at: [(u0 + u1) / 2, (t0 + t1) / 2, (z0 + z1) / 2] });
// A body made at the corner, with x along the wall and y into the building, goes on a wall line.
const onLine = (line: Line, body: Body): Body => rotate(own(body), line.turn, { axis: Z });
const edge = MULLION.depth + EDGE.gap, far = width + reach + MULLION.face / 2, g = reach - MULLION.face / 2;
// The bracket is on top of the slab and holds the back of the mullion. Two anchors fix it to the slab.
const bracket = own(one(unwrap(fuseAll([
own(block(-70, 70, edge + 10, edge + 230, 0, 12)), own(block(-30, 30, MULLION.depth, edge + 90, 12, 90)),
own(cylinder(11, 14, { at: [-40, edge + 180, 12] })), own(cylinder(11, 14, { at: [40, edge + 180, 12] })),
]))));
for (const line of lines) {
const first = line.side < 0 ? -(width + reach) : reach, corner = line.side < 0 ? modules : 0; // no bracket at the corner
for (let level = 0; level <= levels; level++) {
const top = level * STOREY;
for (let k = 0; k <= modules; k++) if (k !== corner) put('bracket', model.addProxy({ name: 'Bracket', solid: onLine(line, translate(bracket, [first + k * MODULE, 0, top])), materialName: 'Steel, galvanised' }));
const from = line.side < 0 ? -far : edge * Math.tan(half), to = line.side < 0 ? -edge * Math.tan(half) : far;
put('fire', model.addProxy({ name: 'Fire stop', solid: onLine(line, block(from, to, MULLION.depth, edge, top - SLAB, top)), materialName: 'Mineral wool' }));
}
for (let level = 0; level <= levels; level++) for (let k = 0; k < modules; k++) {
const z = level * STOREY + SLAB - SPANDREL;
const u = first + k * MODULE + MULLION.face / 2;
put('pan', model.addProxy({ name: 'Back pan', solid: onLine(line, block(u, u + MODULE - MULLION.face, 60, MULLION.depth, z + MULLION.face, z + SPANDREL - MULLION.face)), materialName: 'Insulated steel pan' }));
}
}
// The corner post closes the wall between the end mullions of the two facets.
if (g > 1) {
const [a, b] = [lines[0]!, lines[1]!], z0 = SLAB - SPANDREL;
const kite = own(unwrap(polygon([point(a, -g, 0, z0), [0, 0, z0], point(b, g, 0, z0), point(a, -g, MULLION.depth, z0)])));
put('frame', model.addProxy({ name: 'Corner post', solid: unwrap(extrude(kite, [0, 0, levels * STOREY + SPANDREL])) as Body, materialName: 'Aluminium' }));
}
}
// Try facade({ skew: 0 }), facade({ skew: 60, storeys: 3 }) or facade({ cutaway: 0 }).
const scene = facade();
console.log('Vision glass: the kernel measures ' + scene.visionM2.toFixed(2) + ' m2 in the panes, the grid gives ' + scene.byHand.toFixed(2) + ' m2. That is ' + scene.glassKg.toFixed(0) + ' kg of double glazing.');
// The tree panel shows the IFC structure. The IFC button saves the model as a file.
export default present(scene.shown, {
bimTree: scene.model.toTreeSummary(),
ifc: async () => unwrap(await toIfc(scene.model, { applicationName: 'brepjs playground', applicationVersion: '1.0' })),
});Functions used
placedSolids toIfc box clone compound cylinder extrude fuseAll getSolids measureVolume polygon rotate translate unwrap color present