Works out a column's height from its levels and the length, cross-section area and volume written with it.
How the precision is kept
Height is a difference of two level elevations plus an offset; area and volume are one product each in 64-bit, with Math.PI for a round column. The sizes kept in the column's own property set are rounded to 6 decimals of the file's unit, and the shared model writer rounds the quantities to 6 decimals of a meter, square meter or cubic meter when it stores them.
Calculations under this policy
4 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.
The height a column is built with: up to its top level plus an offset, else its fixed height.
h = top elevation − own elevation + offset
One subtraction of level elevations and one addition. When the top level is not above the column's own level the fixed height is used, or 3000 mm when that is not greater than zero.
model-columns.js
lines 53 to 58
BimCraft 0.8.1
/** The height a column has: to its top level (+ offset), else its fixed height. */
function heightOf(levels, c) {
const me = levels.find((l) => l.id === c.storey), top = c.topLevel ? levels.find((l) => l.guid === c.topLevel) : null;
if (me && top && top.elevation > me.elevation) return top.elevation - me.elevation + (c.topOffset || 0);
return c.height > 0 ? c.height : COLUMN_DEFAULTS.height;
}
Cross-section area and volume
64-bit
The quantities written on a column.
area = π (w ÷ 2)² or w × d; volume = area × h
One product each in 64-bit, in mm² and mm³; π is Math.PI. The model writer then divides by 1e6 or 1e9 and rounds to 6 decimals of a square or cubic meter.
Rebuilds columns whose height no longer matches their levels.
rebuild when |stored − wanted| > 0.5 mm
The stored height is compared with the height the levels give and the column is rebuilt only when they differ by more than 0.5 mm, an absolute tolerance; a smaller level change leaves the column as it was.
model-columns.js
lines 132 to 143
BimCraft 0.8.1
/** Columns of a level (and those of the level below, whose top may follow it) whose height no longer matches: made again. */
export function syncColumns(w, storey) {
let n = 0;
let cols = [];
try { cols = readColumns(w); } catch (e) { return 0; }
for (const c of cols) {
const used = Number(w.readPset(c.id, COLUMN_PSET)?.UsedHeight) * w.unitMm;
if (Math.abs(used - c.h) > 0.5) { writeColumn(w, c); n++; }
}
void storey; void levelAbove;
return n;
}
In detail
Method
area = π (w ÷ 2)² for a round column, w × d for a rectangular one; volume = area × height.
Number types
64-bit numbers in millimeters.
Tolerances
A column is rebuilt when its stored height is more than 0.5 mm from the height its levels give. Sizes under 50 mm and heights under 300 mm are refused.
Checked by
tools/bimcraft-test/draw06-test.mjs and tools/bimcraft-test/modify-test.mjs call placeColumns and readColumns in Node.
Approach: 64-bit, direct
Every value is a 64-bit number from input to result. Formulas are closed form or a direct solve, and every comparison uses a stated tolerance.