Update the kernel logic to implement explicit end-plate connections and gusset plates…
- User
Update the kernel logic to implement explicit end-plate connections and gusset plates for the rafter-to-column joint, ensuring no overlapping geometry. use this as ur knowledge and use ur max capabiliies Starting with the foundation — pure domain types. No rendering, no UI, just engineering data structures.
Wrote types.ts/tas-steel/src/domain 330 lines 13.5 KB /**
- TAS Steel — Domain Types
- Pure engineering types. No rendering, no UI, no framework dependencies.
- These types define the complete data model for industrial steel portal-frame buildings.
- All coordinates in meters. All angles in degrees. All weights in kg. */
// ─── Geometry Primitives ───────────────────────────────────────────────
export interface Vec3 { readonly x: number; readonly y: number; readonly z: number; }
// ─── Materials ─────────────────────────────────────────────────────────
export type MaterialGrade = 'S235' | 'S275' | 'S355' | 'S450';
export interface Material { readonly grade: MaterialGrade; /** Yield strength in MPa / readonly fy: number; /* Ultimate strength in MPa / readonly fu: number; /* Density in kg/m³ / readonly density: number; /* Young's modulus in MPa */ readonly E: number; }
export const MATERIAL_CATALOGUE: Record<MaterialGrade, Material> = { S235: { grade: 'S235', fy: 235, fu: 360, density: 7850, E: 210000 }, S275: { grade: 'S275', fy: 275, fu: 430, density: 7850, E: 210000 }, S355: { grade: 'S355', fy: 355, fu: 510, density: 7850, E: 210000 }, S450: { grade: 'S450', fy: 450, fu: 550, density: 7850, E: 210000 }, };
// ─── Section Profiles ──────────────────────────────────────────────────
export type SectionShape = 'IPE' | 'HEA' | 'HEB' | 'UPN' | 'CHS' | 'RHS' | 'SHS' | 'L';
export interface SectionProfile { /** Unique section designation, e.g. "IPE300" / readonly designation: string; readonly shape: SectionShape; /* Depth in mm / readonly depth: number; /* Width in mm / readonly width: number; /* Web thickness in mm / readonly tw: number; /* Flange thickness in mm / readonly tf: number; /* Cross-sectional area in cm² / readonly area: number; /* Weight per meter in kg/m / readonly weightPerMeter: number; /* Strong-axis moment of inertia in cm⁴ / readonly Iy: number; /* Weak-axis moment of inertia in cm⁴ */ readonly Iz: number; }
// ─── Section Catalogue ─────────────────────────────────────────────────
export const SECTION_CATALOGUE: Record<string, SectionProfile> = { // IPE Sections (European I-beams) IPE200: { designation: 'IPE200', shape: 'IPE', depth: 200, width: 100, tw: 5.6, tf: 8.5, area: 28.5, weightPerMeter: 22.4, Iy: 1943, Iz: 142 }, IPE240: { designation: 'IPE240', shape: 'IPE', depth: 240, width: 120, tw: 6.2, tf: 9.8, area: 39.1, weightPerMeter: 30.7, Iy: 3892, Iz: 284 }, IPE270: { designation: 'IPE270', shape: 'IPE', depth: 270, width: 135, tw: 6.6, tf: 10.2, area: 45.9, weightPerMeter: 36.1, Iy: 5790, Iz: 420 }, IPE300: { designation: 'IPE300', shape: 'IPE', depth: 300, width: 150, tw: 7.1, tf: 10.7, area: 53.8, weightPerMeter: 42.2, Iy: 8356, Iz: 604 }, IPE330: { designation: 'IPE330', shape: 'IPE', depth: 330, width: 160, tw: 7.5, tf: 11.5, area: 62.6, weightPerMeter: 49.1, Iy: 11770, Iz: 788 }, IPE360: { designation: 'IPE360', shape: 'IPE', depth: 360, width: 170, tw: 8.0, tf: 12.7, area: 72.7, weightPerMeter: 57.1, Iy: 16270, Iz: 1043 }, IPE400: { designation: 'IPE400', shape: 'IPE', depth: 400, width: 180, tw: 8.6, tf: 13.5, area: 84.5, weightPerMeter: 66.3, Iy: 23130, Iz: 1318 }, IPE450: { designation: 'IPE450', shape: 'IPE', depth: 450, width: 190, tw: 9.4, tf: 14.6, area: 98.8, weightPerMeter: 77.6, Iy: 33740, Iz: 1676 }, IPE500: { designation: 'IPE500', shape: 'IPE', depth: 500, width: 200, tw: 10.2, tf: 16.0, area: 115.5, weightPerMeter: 90.7, Iy: 48200, Iz: 2142 }, IPE550: { designation: 'IPE550', shape: 'IPE', depth: 550, width: 210, tw: 11.1, tf: 17.2, area: 134.4, weightPerMeter: 105.5, Iy: 67120, Iz: 2668 }, IPE600: { designation: 'IPE600', shape: 'IPE', depth: 600, width: 220, tw: 12.0, tf: 19.0, area: 156.0, weightPerMeter: 122.4, Iy: 92080, Iz: 3387 },
// HEA Sections (wide-flange) HEA200: { designation: 'HEA200', shape: 'HEA', depth: 190, width: 200, tw: 6.5, tf: 10.0, area: 53.8, weightPerMeter: 42.3, Iy: 3692, Iz: 1336 }, HEA240: { designation: 'HEA240', shape: 'HEA', depth: 230, width: 240, tw: 7.5, tf: 12.0, area: 76.8, weightPerMeter: 60.3, Iy: 7763, Iz: 2769 }, HEA260: { designation: 'HEA260', shape: 'HEA', depth: 250, width: 260, tw: 7.5, tf: 12.5, area: 86.8, weightPerMeter: 68.2, Iy: 10450, Iz: 3668 }, HEA300: { designation: 'HEA300', shape: 'HEA', depth: 290, width: 300, tw: 8.5, tf: 14.0, area: 112.5, weightPerMeter: 88.3, Iy: 18260, Iz: 6310 }, HEA360: { designation: 'HEA360', shape: 'HEA', depth: 350, width: 300, tw: 10.0, tf: 17.5, area: 142.8, weightPerMeter: 112.1, Iy: 33090, Iz: 7887 }, HEA400: { designation: 'HEA400', shape: 'HEA', depth: 390, width: 300, tw: 11.0, tf: 19.0, area: 159.0, weightPerMeter: 124.8, Iy: 45070, Iz: 8564 },
// HEB Sections (wide-flange, heavier) HEB200: { designation: 'HEB200', shape: 'HEB', depth: 200, width: 200, tw: 9.0, tf: 15.0, area: 78.1, weightPerMeter: 61.3, Iy: 5696, Iz: 2003 }, HEB240: { designation: 'HEB240', shape: 'HEB', depth: 240, width: 240, tw: 10.0, tf: 17.0, area: 106.0, weightPerMeter: 83.2, Iy: 11260, Iz: 3923 }, HEB260: { designation: 'HEB260', shape: 'HEB', depth: 260, width: 260, tw: 10.0, tf: 17.5, area: 118.4, weightPerMeter: 93.0, Iy: 14920, Iz: 5135 }, HEB300: { designation: 'HEB300', shape: 'HEB', depth: 300, width: 300, tw: 11.0, tf: 19.0, area: 149.1, weightPerMeter: 117.0, Iy: 25170, Iz: 8563 }, HEB360: { designation: 'HEB360', shape: 'HEB', depth: 360, width: 300, tw: 12.5, tf: 22.5, area: 180.6, weightPerMeter: 141.8, Iy: 43190, Iz: 10140 }, HEB400: { designation: 'HEB400', shape: 'HEB', depth: 400, width: 300, tw: 13.5, tf: 24.0, area: 197.8, weightPerMeter: 155.3, Iy: 57680, Iz: 10820 },
// CHS (Circular Hollow Sections) — for bracing CHS114x4: { designation: 'CHS114x4', shape: 'CHS', depth: 114.3, width: 114.3, tw: 4.0, tf: 4.0, area: 13.9, weightPerMeter: 10.9, Iy: 209, Iz: 209 }, CHS139x5: { designation: 'CHS139x5', shape: 'CHS', depth: 139.7, width: 139.7, tw: 5.0, tf: 5.0, area: 21.2, weightPerMeter: 16.6, Iy: 489, Iz: 489 }, CHS168x6: { designation: 'CHS168x6', shape: 'CHS', depth: 168.3, width: 168.3, tw: 6.3, tf: 6.3, area: 32.1, weightPerMeter: 25.2, Iy: 1073, Iz: 1073 },
// L-Angles — for bracing L80x8: { designation: 'L80x8', shape: 'L', depth: 80, width: 80, tw: 8, tf: 8, area: 12.3, weightPerMeter: 9.63, Iy: 72.2, Iz: 72.2 }, L100x10: { designation: 'L100x10', shape: 'L', depth: 100, width: 100, tw: 10, tf: 10, area: 19.2, weightPerMeter: 15.0, Iy: 177, Iz: 177 }, L120x12: { designation: 'L120x12', shape: 'L', depth: 120, width: 120, tw: 12, tf: 12, area: 27.5, weightPerMeter: 21.6, Iy: 368, Iz: 368 },
// UPN (Channel sections) — for purlins/girts UPN120: { designation: 'UPN120', shape: 'UPN', depth: 120, width: 55, tw: 7.0, tf: 9.0, area: 17.0, weightPerMeter: 13.4, Iy: 364, Iz: 43.2 }, UPN140: { designation: 'UPN140', shape: 'UPN', depth: 140, width: 60, tw: 7.0, tf: 10.0, area: 20.4, weightPerMeter: 16.0, Iy: 605, Iz: 62.7 }, UPN160: { designation: 'UPN160', shape: 'UPN', depth: 160, width: 65, tw: 7.5, tf: 10.5, area: 24.0, weightPerMeter: 18.8, Iy: 925, Iz: 85.3 }, UPN200: { designation: 'UPN200', shape: 'UPN', depth: 200, width: 75, tw: 8.5, tf: 11.5, area: 32.2, weightPerMeter: 25.3, Iy: 1910, Iz: 148 }, };
// ─── Structural Nodes ──────────────────────────────────────────────────
export interface StructuralNode { /** Deterministic ID: e.g. "N-F02-L" (Node, Frame 02, Left) */ readonly id: string; readonly position: Vec3; }
// ─── Member Roles ──────────────────────────────────────────────────────
export type MemberRole = | 'column' | 'rafter' | 'purlin' | 'girt' | 'eave_strut' | 'bracing_wall' | 'bracing_roof' | 'base_plate' | 'fly_brace';
// ─── Members ───────────────────────────────────────────────────────────
export interface Member { /** Deterministic ID: e.g. "M-COL-F02-L" / readonly id: string; readonly role: MemberRole; readonly startNodeId: string; readonly endNodeId: string; readonly section: SectionProfile; readonly material: Material; /* Computed length in meters / readonly length: number; /* Weight in kg (length × weightPerMeter) / readonly weight: number; /* Rotation about longitudinal axis in degrees (0 = web vertical) */ readonly rotation: number; }
// ─── Bracing Configuration ─────────────────────────────────────────────
export type BracingPattern = 'X' | 'V' | 'single_diagonal' | 'K';
export interface BracingConfig { readonly wallBracingPattern: BracingPattern; readonly roofBracingPattern: BracingPattern; /** Which bays have wall bracing (0-indexed). Empty = auto (first + last) / readonly wallBracingBays: number[]; /* Which bays have roof bracing (0-indexed). Empty = auto (first + last) */ readonly roofBracingBays: number[]; readonly wallBracingSection: string; readonly roofBracingSection: string; }
// ─── Building Specification ────────────────────────────────────────────
export interface BuildingSpec { /** Human-readable project name / readonly name: string; /* Clear span width in meters (between column centres) / readonly span: number; /* Total building length in meters / readonly length: number; /* Number of bays (building length / bay spacing) / readonly bayCount: number; /* Eave height in meters (to underside of rafter at column junction) / readonly eaveHeight: number; /* Roof pitch in degrees / readonly roofPitch: number; /* Material grade / readonly materialGrade: MaterialGrade; /* Column section designation / readonly columnSection: string; /* Rafter section designation / readonly rafterSection: string; /* Purlin section designation / readonly purlinSection: string; /* Girt section designation / readonly girtSection: string; /* Eave strut section designation / readonly eaveStrutSection: string; /* Purlin spacing in meters (along rafter slope) / readonly purlinSpacing: number; /* Girt spacing in meters (vertical spacing on walls) / readonly girtSpacing: number; /* Bracing configuration */ readonly bracing: BracingConfig; }
// ─── Generated Structural Model ────────────────────────────────────────
export interface StructuralModel { /** The spec that produced this model / readonly spec: BuildingSpec; /* Generation timestamp (ISO string) / readonly generatedAt: string; /* Deterministic hash of the spec for cache/comparison / readonly specHash: string; /* All structural nodes / readonly nodes: ReadonlyMap<string, StructuralNode>; /* All members / readonly members: ReadonlyMap<string, Member>; /* Computed properties */ readonly summary: ModelSummary; }
export interface ModelSummary { readonly totalMembers: number; readonly totalNodes: number; readonly totalWeight: number; readonly memberCountByRole: Record<MemberRole, number>; readonly weightByRole: Record<MemberRole, number>; readonly frameCount: number; readonly baySpacing: number; readonly ridgeHeight: number; }
// ─── Validation ────────────────────────────────────────────────────────
export type ValidationSeverity = 'error' | 'warning' | 'info';
export interface ValidationIssue { readonly severity: ValidationSeverity; readonly code: string; readonly message: string; /** Related member or node IDs */ readonly relatedIds: string[]; }
export interface ValidationResult { readonly passed: boolean; readonly issues: ValidationIssue[]; readonly checkedAt: string; }
// ─── Bill of Materials ─────────────────────────────────────────────────
export interface BOMLineItem { readonly role: MemberRole; readonly section: string; readonly material: MaterialGrade; readonly count: number; readonly unitLength: number; readonly totalLength: number; readonly unitWeight: number; readonly totalWeight: number; }
export interface BillOfMaterials { readonly projectName: string; readonly items: BOMLineItem[]; readonly totalWeight: number; readonly totalMemberCount: number; readonly generatedAt: string; }
// ─── IFC Export Mapping ────────────────────────────────────────────────
export type IfcEntityType = 'IfcColumn' | 'IfcBeam' | 'IfcMember' | 'IfcPlate';
export const ROLE_TO_IFC_ENTITY: Record<MemberRole, IfcEntityType> = { column: 'IfcColumn', rafter: 'IfcBeam', purlin: 'IfcBeam', girt: 'IfcBeam', eave_strut: 'IfcBeam', bracing_wall: 'IfcMember', bracing_roof: 'IfcMember', base_plate: 'IfcPlate', fly_brace: 'IfcMember', };
// ─── Utility: Deterministic hash ───────────────────────────────────────
export function hashSpec(spec: BuildingSpec): string { // Simple deterministic hash from spec values const str = JSON.stringify(spec, Object.keys(spec).sort()); let hash = 0; for (let i = 0; i < str.length; i++) { const char = str.charCodeAt(i); hash = ((hash << 5) - hash) + char; hash = hash & hash; // Convert to 32bit integer } return 'SPEC-' + Math.abs(hash).toString(16).toUpperCase().padStart(8, '0'); }
// ─── Utility: Vec3 operations ──────────────────────────────────────────
export function vec3(x: number, y: number, z: number): Vec3 { return { x, y, z }; }
export function vec3Distance(a: Vec3, b: Vec3): number { const dx = b.x - a.x; const dy = b.y - a.y; const dz = b.z - a.z; return Math.sqrt(dx * dx + dy * dy + dz * dz); }
export function vec3Equals(a: Vec3, b: Vec3, tolerance = 1e-6): boolean { return ( Math.abs(a.x - b.x) < tolerance && Math.abs(a.y - b.y) < tolerance && Math.abs(a.z - b.z) < tolerance ); }
export function vec3Lerp(a: Vec3, b: Vec3, t: number): Vec3 { return { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t, z: a.z + (b.z - a.z) * t, }; } Now the project setup — TypeScript config and dependencies:
Wrote package.json/tas-steel 28 lines 578 B { "name": "tas-steel", "version": "0.1.0", "private": true, "type": "module", "scripts": { "test": "vitest run", "test:watch": "vitest", "build": "vite build", "dev": "vite", "typecheck": "tsc --noEmit" }, "dependencies": { "three": "^0.170.0", "react": "^18.3.1", "react-dom": "^18.3.1" }, "devDependencies": { "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@types/three": "^0.170.0", "@vitejs/plugin-react": "^4.3.4", "typescript": "^5.6.3", "vite": "^6.0.0", "vitest": "^2.1.0" } } Wrote tsconfig.json/tas-steel 33 lines 865 B { "compilerOptions": { "target": "ES2022", "module": "ESNext", "moduleResolution": "bundler", "lib": ["ES2022", "DOM", "DOM.Iterable"], "jsx": "react-jsx", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "declaration": true, "sourceMap": true, "outDir": "./dist", "baseUrl": ".", "paths": { "@domain/": ["src/domain/"], "@generators/": ["src/generators/"], "@validation/": ["src/validation/"], "@takeoff/": ["src/takeoff/"], "@ifc/": ["src/ifc/"], "@viewer/": ["src/viewer/"], "@ui/": ["src/ui/"], "@presets/": ["src/presets/"] } }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"] }
Ran 2 tools Now the core — the HangarGenerator. This is the heart of TAS Steel. It takes a BuildingSpec and deterministically generates a complete structural model.
Wrote HangarGenerator.ts/tas-steel/src/generators 431 lines 15.2 KB /**
- TAS Steel — Hangar Generator
- Deterministic generator: BuildingSpec → StructuralModel
- Generates a portal-frame steel building with:
-
- Portal frames (columns + rafters) at each frame line
-
- Purlins along roof slope between frames
-
- Girts along walls between frames
-
- Eave struts at column-rafter junctions
-
- Wall bracing in designated bays
-
- Roof bracing in designated bays
- Coordinate system:
- X = across span (left to right)
- Y = vertical (up)
- Z = along building length (front to back)
- All geometry in meters. All IDs deterministic. */
import { BuildingSpec, StructuralModel, StructuralNode, Member, MemberRole, ModelSummary, SectionProfile, Material, Vec3, vec3, vec3Distance, hashSpec, SECTION_CATALOGUE, MATERIAL_CATALOGUE, } from '../domain/types.js';
// ─── ID Generation (deterministic) ────────────────────────────────────
function nodeId(prefix: string, frameIdx: number, side: string): string { return
N-${prefix}-F${String(frameIdx).padStart(2, '0')}-${side}; }function memberIdFn(role: string, frameIdx: number, side: string, idx?: number): string { const base =
M-${role}-F${String(frameIdx).padStart(2, '0')}-${side}; return idx !== undefined ?${base}-${String(idx).padStart(2, '0')}: base; }function bracingMemberId(type: 'WB' | 'RB', bayIdx: number, side: string, leg: number): string { return
M-${type}-B${String(bayIdx).padStart(2, '0')}-${side}-${leg}; }function purlinId(frameIdx: number, side: string, purlinIdx: number): string { return
M-PUR-F${String(frameIdx).padStart(2, '0')}-${side}-${String(purlinIdx).padStart(2, '0')}; }function girtId(frameIdx: number, side: string, girtIdx: number): string { return
M-GRT-F${String(frameIdx).padStart(2, '0')}-${side}-${String(girtIdx).padStart(2, '0')}; }function eaveStrutId(frameIdx: number, side: string): string { return
M-EVS-F${String(frameIdx).padStart(2, '0')}-${side}; }// ─── Generator ─────────────────────────────────────────────────────────
export function generateBuilding(spec: BuildingSpec): StructuralModel { const nodes = new Map<string, StructuralNode>(); const members = new Map<string, Member>();
const material = MATERIAL_CATALOGUE[spec.materialGrade]; const columnSection = resolveSection(spec.columnSection); const rafterSection = resolveSection(spec.rafterSection); const purlinSection = resolveSection(spec.purlinSection); const girtSection = resolveSection(spec.girtSection); const eaveStrutSection = resolveSection(spec.eaveStrutSection); const wallBracingSection = resolveSection(spec.bracing.wallBracingSection); const roofBracingSection = resolveSection(spec.bracing.roofBracingSection);
const frameCount = spec.bayCount + 1; // N bays → N+1 frames const baySpacing = spec.length / spec.bayCount; const halfSpan = spec.span / 2; const pitchRad = (spec.roofPitch * Math.PI) / 180; const ridgeRise = halfSpan * Math.tan(pitchRad); const ridgeHeight = spec.eaveHeight + ridgeRise; const rafterLength = halfSpan / Math.cos(pitchRad);
// ── 1. Generate Portal Frame Nodes & Members ─────────────────────
for (let f = 0; f < frameCount; f++) { const z = f * baySpacing;
// Base nodes (ground level) const baseL = addNode(nodes, nodeId('BASE', f, 'L'), vec3(0, 0, z)); const baseR = addNode(nodes, nodeId('BASE', f, 'R'), vec3(spec.span, 0, z)); // Eave nodes (top of columns) const eaveL = addNode(nodes, nodeId('EAVE', f, 'L'), vec3(0, spec.eaveHeight, z)); const eaveR = addNode(nodes, nodeId('EAVE', f, 'R'), vec3(spec.span, spec.eaveHeight, z)); // Ridge node const ridge = addNode(nodes, nodeId('RIDGE', f, 'C'), vec3(halfSpan, ridgeHeight, z)); // Columns addMember(members, memberIdFn('COL', f, 'L'), 'column', baseL, eaveL, columnSection, material); addMember(members, memberIdFn('COL', f, 'R'), 'column', baseR, eaveR, columnSection, material); // Rafters addMember(members, memberIdFn('RAF', f, 'L'), 'rafter', eaveL, ridge, rafterSection, material); addMember(members, memberIdFn('RAF', f, 'R'), 'rafter', eaveR, ridge, rafterSection, material);}
// ── 2. Generate Purlins ──────────────────────────────────────────
// Purlins run along Z between consecutive frames, spaced along the rafter slope const purlinCountPerSide = Math.max(1, Math.floor(rafterLength / spec.purlinSpacing));
for (let f = 0; f < frameCount - 1; f++) { const z1 = f * baySpacing; const z2 = (f + 1) * baySpacing;
for (let p = 1; p <= purlinCountPerSide; p++) { const t = p / (purlinCountPerSide + 1); // normalized position along rafter const slopeX_L = t * halfSpan; // distance from left eave along X const slopeY = spec.eaveHeight + t * ridgeRise; // Left side purlin const pnL1 = addNode(nodes, `N-PUR-F${pad(f)}-L-${pad(p)}-S`, vec3(slopeX_L, slopeY, z1)); const pnL2 = addNode(nodes, `N-PUR-F${pad(f)}-L-${pad(p)}-E`, vec3(slopeX_L, slopeY, z2)); addMember(members, purlinId(f, 'L', p), 'purlin', pnL1, pnL2, purlinSection, material, 90); // Right side purlin (mirror) const slopeX_R = spec.span - slopeX_L; const pnR1 = addNode(nodes, `N-PUR-F${pad(f)}-R-${pad(p)}-S`, vec3(slopeX_R, slopeY, z1)); const pnR2 = addNode(nodes, `N-PUR-F${pad(f)}-R-${pad(p)}-E`, vec3(slopeX_R, slopeY, z2)); addMember(members, purlinId(f, 'R', p), 'purlin', pnR1, pnR2, purlinSection, material, 90); } // Ridge purlin const ridgePn1 = addNode(nodes, `N-PUR-F${pad(f)}-C-S`, vec3(halfSpan, ridgeHeight, z1)); const ridgePn2 = addNode(nodes, `N-PUR-F${pad(f)}-C-E`, vec3(halfSpan, ridgeHeight, z2)); addMember(members, `M-PUR-F${pad(f)}-C-00`, 'purlin', ridgePn1, ridgePn2, purlinSection, material, 90); // Eave purlins (at the eave line) const eavePnL1 = addNode(nodes, `N-PUR-F${pad(f)}-EL-S`, vec3(0, spec.eaveHeight, z1)); const eavePnL2 = addNode(nodes, `N-PUR-F${pad(f)}-EL-E`, vec3(0, spec.eaveHeight, z2)); addMember(members, `M-PUR-F${pad(f)}-EL-00`, 'purlin', eavePnL1, eavePnL2, purlinSection, material, 90); const eavePnR1 = addNode(nodes, `N-PUR-F${pad(f)}-ER-S`, vec3(spec.span, spec.eaveHeight, z1)); const eavePnR2 = addNode(nodes, `N-PUR-F${pad(f)}-ER-E`, vec3(spec.span, spec.eaveHeight, z2)); addMember(members, `M-PUR-F${pad(f)}-ER-00`, 'purlin', eavePnR1, eavePnR2, purlinSection, material, 90);}
// ── 3. Generate Girts ────────────────────────────────────────────
const girtCount = Math.max(1, Math.floor(spec.eaveHeight / spec.girtSpacing) - 1);
for (let f = 0; f < frameCount - 1; f++) { const z1 = f * baySpacing; const z2 = (f + 1) * baySpacing;
for (let g = 1; g <= girtCount; g++) { const girtY = g * (spec.eaveHeight / (girtCount + 1)); // Left wall girts const gnL1 = addNode(nodes, `N-GRT-F${pad(f)}-L-${pad(g)}-S`, vec3(0, girtY, z1)); const gnL2 = addNode(nodes, `N-GRT-F${pad(f)}-L-${pad(g)}-E`, vec3(0, girtY, z2)); addMember(members, girtId(f, 'L', g), 'girt', gnL1, gnL2, girtSection, material, 90); // Right wall girts const gnR1 = addNode(nodes, `N-GRT-F${pad(f)}-R-${pad(g)}-S`, vec3(spec.span, girtY, z1)); const gnR2 = addNode(nodes, `N-GRT-F${pad(f)}-R-${pad(g)}-E`, vec3(spec.span, girtY, z2)); addMember(members, girtId(f, 'R', g), 'girt', gnR1, gnR2, girtSection, material, 90); }}
// ── 4. Generate Eave Struts ──────────────────────────────────────
for (let f = 0; f < frameCount - 1; f++) { const z1 = f * baySpacing; const z2 = (f + 1) * baySpacing;
// Left eave strut const esL1 = addNode(nodes, `N-EVS-F${pad(f)}-L-S`, vec3(0, spec.eaveHeight, z1)); const esL2 = addNode(nodes, `N-EVS-F${pad(f)}-L-E`, vec3(0, spec.eaveHeight, z2)); addMember(members, eaveStrutId(f, 'L'), 'eave_strut', esL1, esL2, eaveStrutSection, material); // Right eave strut const esR1 = addNode(nodes, `N-EVS-F${pad(f)}-R-S`, vec3(spec.span, spec.eaveHeight, z1)); const esR2 = addNode(nodes, `N-EVS-F${pad(f)}-R-E`, vec3(spec.span, spec.eaveHeight, z2)); addMember(members, eaveStrutId(f, 'R'), 'eave_strut', esR1, esR2, eaveStrutSection, material);}
// ── 5. Generate Wall Bracing ─────────────────────────────────────
const wallBracingBays = spec.bracing.wallBracingBays.length > 0 ? spec.bracing.wallBracingBays : [0, spec.bayCount - 1]; // default: first + last bay
for (const bayIdx of wallBracingBays) { if (bayIdx < 0 || bayIdx >= spec.bayCount) continue; const z1 = bayIdx * baySpacing; const z2 = (bayIdx + 1) * baySpacing;
// Left wall bracing generateBracing( nodes, members, spec.bracing.wallBracingPattern, 'bracing_wall', 'WB', bayIdx, 'L', vec3(0, 0, z1), vec3(0, 0, z2), vec3(0, spec.eaveHeight, z1), vec3(0, spec.eaveHeight, z2), wallBracingSection, material ); // Right wall bracing generateBracing( nodes, members, spec.bracing.wallBracingPattern, 'bracing_wall', 'WB', bayIdx, 'R', vec3(spec.span, 0, z1), vec3(spec.span, 0, z2), vec3(spec.span, spec.eaveHeight, z1), vec3(spec.span, spec.eaveHeight, z2), wallBracingSection, material );}
// ── 6. Generate Roof Bracing ─────────────────────────────────────
const roofBracingBays = spec.bracing.roofBracingBays.length > 0 ? spec.bracing.roofBracingBays : [0, spec.bayCount - 1]; // default: first + last bay
for (const bayIdx of roofBracingBays) { if (bayIdx < 0 || bayIdx >= spec.bayCount) continue; const z1 = bayIdx * baySpacing; const z2 = (bayIdx + 1) * baySpacing;
// Left roof slope bracing generateBracing( nodes, members, spec.bracing.roofBracingPattern, 'bracing_roof', 'RB', bayIdx, 'L', vec3(0, spec.eaveHeight, z1), vec3(0, spec.eaveHeight, z2), vec3(halfSpan, ridgeHeight, z1), vec3(halfSpan, ridgeHeight, z2), roofBracingSection, material ); // Right roof slope bracing generateBracing( nodes, members, spec.bracing.roofBracingPattern, 'bracing_roof', 'RB', bayIdx, 'R', vec3(spec.span, spec.eaveHeight, z1), vec3(spec.span, spec.eaveHeight, z2), vec3(halfSpan, ridgeHeight, z1), vec3(halfSpan, ridgeHeight, z2), roofBracingSection, material );}
// ── 7. Compute Summary ───────────────────────────────────────────
const summary = computeSummary(spec, members, nodes, frameCount, baySpacing, ridgeHeight);
return { spec, generatedAt: new Date().toISOString(), specHash: hashSpec(spec), nodes, members, summary, }; }
// ─── Bracing Pattern Generator ─────────────────────────────────────────
function generateBracing( nodes: Map<string, StructuralNode>, members: Map<string, Member>, pattern: string, role: MemberRole, typePrefix: 'WB' | 'RB', bayIdx: number, side: string, bl: Vec3, br: Vec3, // bottom-left, bottom-right tl: Vec3, tr: Vec3, // top-left, top-right section: SectionProfile, material: Material, ): void { const nBL = addNode(nodes,
N-${typePrefix}-B${pad(bayIdx)}-${side}-BL, bl); const nBR = addNode(nodes,N-${typePrefix}-B${pad(bayIdx)}-${side}-BR, br); const nTL = addNode(nodes,N-${typePrefix}-B${pad(bayIdx)}-${side}-TL, tl); const nTR = addNode(nodes,N-${typePrefix}-B${pad(bayIdx)}-${side}-TR, tr);switch (pattern) { case 'X': // Two diagonals forming X addMember(members, bracingMemberId(typePrefix, bayIdx, side, 1), role, nBL, nTR, section, material); addMember(members, bracingMemberId(typePrefix, bayIdx, side, 2), role, nBR, nTL, section, material); break; case 'V': // V-brace: two members meeting at bottom center const midBottom = vec3( (bl.x + br.x) / 2, (bl.y + br.y) / 2, (bl.z + br.z) / 2, ); const nMB = addNode(nodes,
N-${typePrefix}-B${pad(bayIdx)}-${side}-MB, midBottom); addMember(members, bracingMemberId(typePrefix, bayIdx, side, 1), role, nTL, nMB, section, material); addMember(members, bracingMemberId(typePrefix, bayIdx, side, 2), role, nTR, nMB, section, material); break; case 'single_diagonal': addMember(members, bracingMemberId(typePrefix, bayIdx, side, 1), role, nBL, nTR, section, material); break; case 'K': // K-brace: two members meeting at mid-height of one side const midLeft = vec3( (bl.x + tl.x) / 2, (bl.y + tl.y) / 2, (bl.z + tl.z) / 2, ); const nML = addNode(nodes,N-${typePrefix}-B${pad(bayIdx)}-${side}-ML, midLeft); addMember(members, bracingMemberId(typePrefix, bayIdx, side, 1), role, nML, nBR, section, material); addMember(members, bracingMemberId(typePrefix, bayIdx, side, 2), role, nML, nTR, section, material); break; default: // Fallback: X pattern addMember(members, bracingMemberId(typePrefix, bayIdx, side, 1), role, nBL, nTR, section, material); addMember(members, bracingMemberId(typePrefix, bayIdx, side, 2), role, nBR, nTL, section, material); } }// ─── Helper Functions ──────────────────────────────────────────────────
function pad(n: number): string { return String(n).padStart(2, '0'); }
function resolveSection(designation: string): SectionProfile { const section = SECTION_CATALOGUE[designation]; if (!section) { throw new Error(
Section "${designation}" not found in catalogue. Available: ${Object.keys(SECTION_CATALOGUE).join(', ')}); } return section; }function addNode( nodes: Map<string, StructuralNode>, id: string, position: Vec3, ): StructuralNode { // If node with same ID exists and has same position, reuse it const existing = nodes.get(id); if (existing) { return existing; } const node: StructuralNode = { id, position }; nodes.set(id, node); return node; }
function addMember( members: Map<string, Member>, id: string, role: MemberRole, startNode: StructuralNode, endNode: StructuralNode, section: SectionProfile, material: Material, rotation = 0, ): Member { const length = vec3Distance(startNode.position, endNode.position); const weight = length * section.weightPerMeter;
const member: Member = { id, role, startNodeId: startNode.id, endNodeId: endNode.id, section, material, length, weight, rotation, }; members.set(id, member); return member; }
function computeSummary( spec: BuildingSpec, members: ReadonlyMap<string, Member>, nodes: ReadonlyMap<string, StructuralNode>, frameCount: number, baySpacing: number, ridgeHeight: number, ): ModelSummary { const roles: MemberRole[] = [ 'column', 'rafter', 'purlin', 'girt', 'eave_strut', 'bracing_wall', 'bracing_roof', 'base_plate', 'fly_brace', ];
const memberCountByRole = {} as Record<MemberRole, number>; const weightByRole = {} as Record<MemberRole, number>;
for (const role of roles) { memberCountByRole[role] = 0; weightByRole[role] = 0; }
let totalWeight = 0; for (const member of members.values()) { memberCountByRole[member.role]++; weightByRole[member.role] += member.weight; totalWeight += member.weight; }
return { totalMembers: members.size, totalNodes: nodes.size, totalWeight, memberCountByRole, weightByRole, frameCount, baySpacing, ridgeHeight, }; } todo write Now the validation layer — real engineering checks, not decorative:
Wrote validate.ts/tas-steel/src/validation 443 lines 16.3 KB … 10 earlier lines hidden
- 4. Bracing connectivity (bracing members connect to real nodes)
-
- Unit consistency
-
- Collision/overlap detection (members occupying same space)
-
- Section validity (all referenced sections exist)
-
- Node duplication detection */
import { BuildingSpec, StructuralModel, ValidationResult, ValidationIssue, ValidationSeverity, Member, StructuralNode, Vec3, vec3Distance, vec3Equals, SECTION_CATALOGUE, MATERIAL_CATALOGUE, } from '../domain/types.js';
type IssueCollector = ValidationIssue[];
// ─── Main Validation Entry Point ───────────────────────────────────────
export function validateModel(model: StructuralModel): ValidationResult { const issues: IssueCollector = [];
validateSpec(model.spec, issues); validateTopology(model, issues); validateMemberLengths(model, issues); validateBracingConnectivity(model, issues); validateNodeDuplication(model, issues); validateMemberCollisions(model, issues); validateSectionReferences(model.spec, issues); validateUnitConsistency(model, issues); validateFrameGeometry(model, issues);
const passed = !issues.some(i => i.severity === 'error');
return { passed, issues, checkedAt: new Date().toISOString(), }; }
// ─── 1. Spec Sanity ────────────────────────────────────────────────────
function validateSpec(spec: BuildingSpec, issues: IssueCollector): void { // Zero or negative dimensions if (spec.span <= 0) { issues.push(issue('error', 'SPEC_SPAN_INVALID',
Span must be positive, got ${spec.span}m, [])); } if (spec.length <= 0) { issues.push(issue('error', 'SPEC_LENGTH_INVALID',Length must be positive, got ${spec.length}m, [])); } if (spec.bayCount <= 0 || !Number.isInteger(spec.bayCount)) { issues.push(issue('error', 'SPEC_BAYS_INVALID',Bay count must be a positive integer, got ${spec.bayCount}, [])); } if (spec.eaveHeight <= 0) { issues.push(issue('error', 'SPEC_EAVE_INVALID',Eave height must be positive, got ${spec.eaveHeight}m, [])); } if (spec.roofPitch < 0 || spec.roofPitch >= 45) { issues.push(issue('error', 'SPEC_PITCH_INVALID',Roof pitch must be 0-45°, got ${spec.roofPitch}°, [])); } if (spec.purlinSpacing <= 0) { issues.push(issue('error', 'SPEC_PURLIN_SPACING_INVALID',Purlin spacing must be positive, got ${spec.purlinSpacing}m, [])); } if (spec.girtSpacing <= 0) { issues.push(issue('error', 'SPEC_GIRT_SPACING_INVALID',Girt spacing must be positive, got ${spec.girtSpacing}m, [])); }// Reasonable ranges if (spec.span > 100) { issues.push(issue('warning', 'SPEC_SPAN_LARGE',
Span ${spec.span}m exceeds typical portal frame range (max ~60m), [])); } if (spec.span < 6) { issues.push(issue('warning', 'SPEC_SPAN_SMALL',Span ${spec.span}m is unusually small for a portal frame, [])); } if (spec.eaveHeight > 30) { issues.push(issue('warning', 'SPEC_EAVE_HIGH',Eave height ${spec.eaveHeight}m is unusually high, [])); } if (spec.eaveHeight < 3) { issues.push(issue('warning', 'SPEC_EAVE_LOW',Eave height ${spec.eaveHeight}m is unusually low, [])); } if (spec.roofPitch < 3) { issues.push(issue('warning', 'SPEC_PITCH_LOW',Roof pitch ${spec.roofPitch}° is very low — drainage concerns, [])); }// Bay spacing check const baySpacing = spec.length / spec.bayCount; if (baySpacing > 12) { issues.push(issue('warning', 'SPEC_BAY_SPACING_LARGE',
Bay spacing ${baySpacing.toFixed(1)}m exceeds typical 6-8m range, [])); } if (baySpacing < 3) { issues.push(issue('warning', 'SPEC_BAY_SPACING_SMALL',Bay spacing ${baySpacing.toFixed(1)}m is unusually small, [])); }// Material check if (!MATERIAL_CATALOGUE[spec.materialGrade]) { issues.push(issue('error', 'SPEC_MATERIAL_INVALID',
Material grade "${spec.materialGrade}" not in catalogue, [])); } }// ─── 2. Topology Consistency ───────────────────────────────────────────
function validateTopology(model: StructuralModel, issues: IssueCollector): void { const referencedNodeIds = new Set();
for (const member of model.members.values()) { referencedNodeIds.add(member.startNodeId); referencedNodeIds.add(member.endNodeId);
// Check that referenced nodes exist if (!model.nodes.has(member.startNodeId)) { issues.push(issue('error', 'TOPO_MISSING_START_NODE', `Member ${member.id} references non-existent start node ${member.startNodeId}`, [member.id, member.startNodeId])); } if (!model.nodes.has(member.endNodeId)) { issues.push(issue('error', 'TOPO_MISSING_END_NODE', `Member ${member.id} references non-existent end node ${member.endNodeId}`, [member.id, member.endNodeId])); } // Self-referencing check if (member.startNodeId === member.endNodeId) { issues.push(issue('error', 'TOPO_SELF_REF', `Member ${member.id} starts and ends at the same node ${member.startNodeId}`, [member.id])); }}
// Orphan nodes (nodes not referenced by any member) for (const nodeId of model.nodes.keys()) { if (!referencedNodeIds.has(nodeId)) { issues.push(issue('warning', 'TOPO_ORPHAN_NODE',
Node ${nodeId} is not connected to any member, [nodeId])); } } }// ─── 3. Member Length Sanity ───────────────────────────────────────────
function validateMemberLengths(model: StructuralModel, issues: IssueCollector): void { for (const member of model.members.values()) { // Zero-length members if (member.length < 0.001) { issues.push(issue('error', 'LEN_ZERO',
Member ${member.id} has zero/near-zero length: ${member.length.toFixed(4)}m, [member.id])); continue; }// Verify computed length matches node positions const startNode = model.nodes.get(member.startNodeId); const endNode = model.nodes.get(member.endNodeId); if (startNode && endNode) { const computedLen = vec3Distance(startNode.position, endNode.position); const lenError = Math.abs(computedLen - member.length); if (lenError > 0.001) { issues.push(issue('error', 'LEN_MISMATCH', `Member ${member.id} stored length ${member.length.toFixed(3)}m ≠ computed ${computedLen.toFixed(3)}m (Δ=${lenError.toFixed(4)}m)`, [member.id])); } } // Unreasonable lengths by role const maxLengths: Record<string, number> = { column: 30, rafter: 40, purlin: 15, girt: 15, eave_strut: 15, bracing_wall: 30, bracing_roof: 40, }; const maxLen = maxLengths[member.role] || 50; if (member.length > maxLen) { issues.push(issue('warning', 'LEN_EXCESSIVE', `Member ${member.id} (${member.role}) length ${member.length.toFixed(2)}m exceeds typical max ${maxLen}m`, [member.id])); } // Negative weight if (member.weight < 0) { issues.push(issue('error', 'WEIGHT_NEGATIVE', `Member ${member.id} has negative weight: ${member.weight.toFixed(2)}kg`, [member.id])); } // Weight consistency: length × weightPerMeter const expectedWeight = member.length * member.section.weightPerMeter; const weightError = Math.abs(expectedWeight - member.weight); if (weightError > 0.1) { issues.push(issue('error', 'WEIGHT_MISMATCH', `Member ${member.id} stored weight ${member.weight.toFixed(2)}kg ≠ computed ${expectedWeight.toFixed(2)}kg`, [member.id])); }} }
// ─── 4. Bracing Connectivity ───────────────────────────────────────────
function validateBracingConnectivity(model: StructuralModel, issues: IssueCollector): void { const bracingMembers = [...model.members.values()].filter( m => m.role === 'bracing_wall' || m.role === 'bracing_roof' );
for (const brace of bracingMembers) { const startNode = model.nodes.get(brace.startNodeId); const endNode = model.nodes.get(brace.endNodeId);
if (!startNode || !endNode) continue; // Check that bracing endpoints are near frame nodes or other structural nodes let startConnected = false; let endConnected = false; for (const node of model.nodes.values()) { if (node.id === brace.startNodeId) continue; if (vec3Equals(node.position, startNode.position, 0.01)) { startConnected = true; } } for (const node of model.nodes.values()) { if (node.id === brace.endNodeId) continue; if (vec3Equals(node.position, endNode.position, 0.01)) { endConnected = true; } } // For V and K patterns, mid-point nodes may not coincide with frame nodes // Only warn, don't error if (!startConnected && !endConnected) { issues.push(issue('info', 'BRACE_ISOLATED', `Bracing member ${brace.id} endpoints are not at established structural nodes`, [brace.id])); }}
// Check that bracing bays specified in spec are actually generated if (bracingMembers.length === 0) { issues.push(issue('warning', 'BRACE_NONE',
No bracing members found in model — building may be laterally unstable, [])); } }// ─── 5. Node Duplication ───────────────────────────────────────────────
function validateNodeDuplication(model: StructuralModel, issues: IssueCollector): void { const nodeList = [...model.nodes.values()]; const duplicateGroups = new Map<string, string[]>();
for (let i = 0; i < nodeList.length; i++) { for (let j = i + 1; j < nodeList.length; j++) { if (vec3Equals(nodeList[i].position, nodeList[j].position, 0.001)) { const key =
${nodeList[i].position.x.toFixed(3)},${nodeList[i].position.y.toFixed(3)},${nodeList[i].position.z.toFixed(3)}; if (!duplicateGroups.has(key)) { duplicateGroups.set(key, [nodeList[i].id]); } const group = duplicateGroups.get(key)!; if (!group.includes(nodeList[j].id)) { group.push(nodeList[j].id); } } } }for (const [pos, nodeIds] of duplicateGroups) { if (nodeIds.length > 4) { // Only warn for excessive duplicates — some co-location is expected at frame junctions issues.push(issue('info', 'NODE_COLOCATED',
${nodeIds.length} nodes co-located at (${pos}): ${nodeIds.slice(0, 5).join(', ')}${nodeIds.length > 5 ? '...' : ''}, nodeIds)); } } }// ─── 6. Member Collision Detection ─────────────────────────────────────
function validateMemberCollisions(model: StructuralModel, issues: IssueCollector): void { const memberList = [...model.members.values()]; let collisionCount = 0; const maxCollisions = 20; // Don't spam
for (let i = 0; i < memberList.length && collisionCount < maxCollisions; i++) { for (let j = i + 1; j < memberList.length && collisionCount < maxCollisions; j++) { const a = memberList[i]; const b = memberList[j];
// Skip expected overlaps (same role at same location is normal for eave/purlin nodes) if (a.role === b.role && a.startNodeId === b.startNodeId && a.endNodeId === b.endNodeId) { issues.push(issue('error', 'MEMBER_DUPLICATE', `Duplicate members: ${a.id} and ${b.id} share identical start/end nodes`, [a.id, b.id])); collisionCount++; } }} }
// ─── 7. Section Reference Validation ───────────────────────────────────
function validateSectionReferences(spec: BuildingSpec, issues: IssueCollector): void { const sectionRefs = [ { name: 'columnSection', value: spec.columnSection }, { name: 'rafterSection', value: spec.rafterSection }, { name: 'purlinSection', value: spec.purlinSection }, { name: 'girtSection', value: spec.girtSection }, { name: 'eaveStrutSection', value: spec.eaveStrutSection }, { name: 'wallBracingSection', value: spec.bracing.wallBracingSection }, { name: 'roofBracingSection', value: spec.bracing.roofBracingSection }, ];
for (const ref of sectionRefs) { if (!SECTION_CATALOGUE[ref.value]) { issues.push(issue('error', 'SECTION_NOT_FOUND',
Spec references section "${ref.value}" for ${ref.name} — not found in catalogue, [])); } } }// ─── 8. Unit Consistency ───────────────────────────────────────────────
function validateUnitConsistency(model: StructuralModel, issues: IssueCollector): void { // All coordinates should be in reasonable meter ranges for (const node of model.nodes.values()) { const { x, y, z } = node.position; if (Math.abs(x) > 500 || Math.abs(y) > 500 || Math.abs(z) > 500) { issues.push(issue('warning', 'UNIT_COORD_RANGE',
Node ${node.id} position (${x.toFixed(2)}, ${y.toFixed(2)}, ${z.toFixed(2)}) may indicate wrong units (expected meters), [node.id])); } if (y < -0.01) { issues.push(issue('warning', 'UNIT_BELOW_GROUND',Node ${node.id} is below ground level: Y=${y.toFixed(3)}m, [node.id])); } }// Summary total weight sanity check (steel building ~15-40 kg/m² floor area typically) const floorArea = model.spec.span * model.spec.length; const kgPerSqm = model.summary.totalWeight / floorArea; if (kgPerSqm > 200) { issues.push(issue('warning', 'UNIT_WEIGHT_HIGH',
Total steel weight ${model.summary.totalWeight.toFixed(0)}kg / ${floorArea.toFixed(0)}m² = ${kgPerSqm.toFixed(1)} kg/m² — unusually heavy, [])); } if (kgPerSqm < 5) { issues.push(issue('warning', 'UNIT_WEIGHT_LOW',Total steel weight ${model.summary.totalWeight.toFixed(0)}kg / ${floorArea.toFixed(0)}m² = ${kgPerSqm.toFixed(1)} kg/m² — unusually light, [])); } }// ─── 9. Frame Geometry ─────────────────────────────────────────────────
function validateFrameGeometry(model: StructuralModel, issues: IssueCollector): void { const spec = model.spec; const frameCount = spec.bayCount + 1;
for (let f = 0; f < frameCount; f++) { const pad2 = String(f).padStart(2, '0'); const baseL = model.nodes.get(
N-BASE-F${pad2}-L); const baseR = model.nodes.get(N-BASE-F${pad2}-R); const eaveL = model.nodes.get(N-EAVE-F${pad2}-L); const eaveR = model.nodes.get(N-EAVE-F${pad2}-R); const ridge = model.nodes.get(N-RIDGE-F${pad2}-C);if (!baseL || !baseR || !eaveL || !eaveR || !ridge) { issues.push(issue('error', 'FRAME_INCOMPLETE', `Frame ${f} is missing one or more key nodes`, [`F${pad2}`])); continue; } // Columns should be vertical (same X, same Z) if (Math.abs(baseL.position.x - eaveL.position.x) > 0.001 || Math.abs(baseL.position.z - eaveL.position.z) > 0.001) { issues.push(issue('error', 'FRAME_COL_NOT_VERTICAL', `Frame ${f} left column is not vertical`, [`N-BASE-F${pad2}-L`, `N-EAVE-F${pad2}-L`])); } if (Math.abs(baseR.position.x - eaveR.position.x) > 0.001 || Math.abs(baseR.position.z - eaveR.position.z) > 0.001) { issues.push(issue('error', 'FRAME_COL_NOT_VERTICAL', `Frame ${f} right column is not vertical`, [`N-BASE-F${pad2}-R`, `N-EAVE-F${pad2}-R`])); } // Ridge should be at midspan const expectedRidgeX = (baseL.position.x + baseR.position.x) / 2; if (Math.abs(ridge.position.x - expectedRidgeX) > 0.01) { issues.push(issue('error', 'FRAME_RIDGE_OFF_CENTER', `Frame ${f} ridge X=${ridge.position.x.toFixed(3)} not at midspan ${expectedRidgeX.toFixed(3)}`, [`N-RIDGE-F${pad2}-C`])); } // Ridge should be above eaves if (ridge.position.y <= eaveL.position.y) { issues.push(issue('error', 'FRAME_RIDGE_BELOW_EAVE', `Frame ${f} ridge height ${ridge.position.y.toFixed(3)}m ≤ eave height ${eaveL.position.y.toFixed(3)}m`, [`N-RIDGE-F${pad2}-C`])); } // Eaves should be at same height if (Math.abs(eaveL.position.y - eaveR.position.y) > 0.001) { issues.push(issue('error', 'FRAME_EAVE_UNEVEN', `Frame ${f} eave heights differ: L=${eaveL.position.y.toFixed(3)} R=${eaveR.position.y.toFixed(3)}`, [`N-EAVE-F${pad2}-L`, `N-EAVE-F${pad2}-R`])); }} }
// ─── Issue Factory ─────────────────────────────────────────────────────
function issue( severity: ValidationSeverity, code: string, message: string, relatedIds: string[], ): ValidationIssue { return { severity, code, message, relatedIds }; } todo write Wrote bom.ts/tas-steel/src/takeoff 175 lines 5.7 KB /**
- TAS Steel — Bill of Materials / Takeoff
- Computes BOM from a StructuralModel.
- Groups members by role + section + material.
- Pure computation — no UI, no rendering. */
import { StructuralModel, BillOfMaterials, BOMLineItem, Member, MemberRole, MaterialGrade, } from '../domain/types.js';
// ─── BOM Generation ────────────────────────────────────────────────────
export function generateBOM(model: StructuralModel): BillOfMaterials { // Group by: role + section + material const groups = new Map<string, { role: MemberRole; section: string; material: MaterialGrade; members: Member[]; }>();
for (const member of model.members.values()) { const key =
${member.role}|${member.section.designation}|${member.material.grade}; if (!groups.has(key)) { groups.set(key, { role: member.role, section: member.section.designation, material: member.material.grade, members: [], }); } groups.get(key)!.members.push(member); }// Build line items const items: BOMLineItem[] = []; let totalWeight = 0; let totalMemberCount = 0;
// Sort groups by role priority, then by section const sortedGroups = [...groups.values()].sort((a, b) => { const rolePriority: Record<MemberRole, number> = { column: 1, rafter: 2, purlin: 3, girt: 4, eave_strut: 5, bracing_wall: 6, bracing_roof: 7, fly_brace: 8, base_plate: 9, }; const pa = rolePriority[a.role] || 99; const pb = rolePriority[b.role] || 99; if (pa !== pb) return pa - pb; return a.section.localeCompare(b.section); });
for (const group of sortedGroups) { const count = group.members.length;
// All members in a group should have very similar lengths if they're // repeating elements (purlins, girts). For columns/rafters they may vary. // We compute average unit length for the BOM line. const lengths = group.members.map(m => m.length); const totalLength = lengths.reduce((sum, l) => sum + l, 0); const avgLength = totalLength / count; const weights = group.members.map(m => m.weight); const groupTotalWeight = weights.reduce((sum, w) => sum + w, 0); const avgWeight = groupTotalWeight / count; items.push({ role: group.role, section: group.section, material: group.material, count, unitLength: round3(avgLength), totalLength: round3(totalLength), unitWeight: round2(avgWeight), totalWeight: round2(groupTotalWeight), }); totalWeight += groupTotalWeight; totalMemberCount += count;}
return { projectName: model.spec.name, items, totalWeight: round2(totalWeight), totalMemberCount, generatedAt: new Date().toISOString(), }; }
// ─── BOM Formatting ────────────────────────────────────────────────────
export function formatBOMAsText(bom: BillOfMaterials): string { const lines: string[] = [];
lines.push(
╔══════════════════════════════════════════════════════════════════════════════╗); lines.push(║ BILL OF MATERIALS — ${bom.projectName.padEnd(54)}║); lines.push(╠══════════════════════════════════════════════════════════════════════════════╣); lines.push(║ Generated: ${bom.generatedAt.padEnd(63)}║); lines.push(╠════════════════╦══════════╦═══════╦══════╦═══════════╦══════════╦═══════════╣); lines.push(║ Role ║ Section ║ Grade ║ Qty ║ Unit Len ║ Tot Len ║ Tot Wt ║); lines.push(║ ║ ║ ║ ║ (m) ║ (m) ║ (kg) ║); lines.push(╠════════════════╬══════════╬═══════╬══════╬═══════════╬══════════╬═══════════╣);for (const item of bom.items) { const role = item.role.padEnd(14); const section = item.section.padEnd(8); const grade = item.material.padEnd(5); const qty = String(item.count).padStart(4); const unitLen = item.unitLength.toFixed(2).padStart(9); const totLen = item.totalLength.toFixed(1).padStart(8); const totWt = item.totalWeight.toFixed(1).padStart(9); lines.push(
║ ${role} ║ ${section} ║ ${grade} ║ ${qty} ║ ${unitLen} ║ ${totLen} ║ ${totWt} ║); }lines.push(
╠════════════════╬══════════╬═══════╬══════╬═══════════╬══════════╬═══════════╣); const totalQty = String(bom.totalMemberCount).padStart(4); const totalWt = bom.totalWeight.toFixed(1).padStart(9); lines.push(║ TOTAL ║ ║ ║ ${totalQty} ║ ║ ║ ${totalWt} ║); lines.push(║ ║ ║ ║ ║ ║ ║ ${(bom.totalWeight / 1000).toFixed(2).padStart(6)} t ║); lines.push(╚════════════════╩══════════╩═══════╩══════╩═══════════╩══════════╩═══════════╝);return lines.join('\n'); }
// ─── BOM as CSV ────────────────────────────────────────────────────────
export function formatBOMAsCSV(bom: BillOfMaterials): string { const lines: string[] = []; lines.push('Role,Section,Material,Quantity,Unit Length (m),Total Length (m),Unit Weight (kg),Total Weight (kg)');
for (const item of bom.items) { lines.push([ item.role, item.section, item.material, item.count, item.unitLength.toFixed(3), item.totalLength.toFixed(3), item.unitWeight.toFixed(2), item.totalWeight.toFixed(2), ].join(',')); }
lines.push(''); lines.push(
Total Members,${bom.totalMemberCount}); lines.push(Total Weight (kg),${bom.totalWeight.toFixed(2)}); lines.push(Total Weight (t),${(bom.totalWeight / 1000).toFixed(3)});return lines.join('\n'); }
// ─── Utilities ─────────────────────────────────────────────────────────
function round2(n: number): number { return Math.round(n * 100) / 100; }
function round3(n: number): number { return Math.round(n * 1000) / 1000; } todo write Now the IFC export — this must produce valid IFC-SPF (STEP Physical File) that opens in BIMvision and other tools:
Wrote ifcExporter.ts/tas-steel/src/ifc 449 lines 16.8 KB … 36 earlier lines hidden next(): number { return ++this.counter; } }
// ─── GUID Generator (IFC-compatible 22-char base64) ───────────────────
function ifcGuid(seed: string): string { // Deterministic pseudo-GUID from seed string let hash = 0; for (let i = 0; i < seed.length; i++) { hash = ((hash << 5) - hash + seed.charCodeAt(i)) & 0xffffffff; } // Expand to 128 bits using multiple passes const bytes = new Uint8Array(16); for (let i = 0; i < 16; i++) { hash = ((hash * 1103515245) + 12345) & 0x7fffffff; bytes[i] = hash & 0xff; } // Set version 4 UUID bits bytes[6] = (bytes[6] & 0x0f) | 0x40; bytes[8] = (bytes[8] & 0x3f) | 0x80;
// Convert to IFC base64 (22 chars) return uuidToIfcGuid(bytes); }
function uuidToIfcGuid(bytes: Uint8Array): string { const base64chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$'; let result = '';
// Process 16 bytes → 22 base64 chars (IFC encoding: 3 bytes → 4 chars, last group padded) const groups = [ [bytes[0], bytes[1], bytes[2]], [bytes[3], bytes[4], bytes[5]], [bytes[6], bytes[7], bytes[8]], [bytes[9], bytes[10], bytes[11]], [bytes[12], bytes[13], bytes[14]], [bytes[15], 0, 0], ];
for (let g = 0; g < groups.length; g++) { const [a, b, c] = groups[g]; const val = (a << 16) | (b << 8) | c; const chars = g < 5 ? 4 : 2; // Last group only uses 2 chars for (let i = chars - 1; i >= 0; i--) { result += base64chars[(val >> (i * 6)) & 0x3f]; } }
return result; }
// ─── Coordinate conversion: meters → millimeters ──────────────────────
function toMm(v: number): string { return (v * 1000).toFixed(1); }
function vecToMm(v: Vec3): string { return
(${toMm(v.x)},${toMm(v.y)},${toMm(v.z)}); }// ─── Profile name to IFC profile type ─────────────────────────────────
function sectionToIfcProfile(designation: string): string { // For now, use IfcArbitraryClosedProfileDef as fallback // In production, map to IfcIShapeProfileDef, IfcCircleHollowProfileDef, etc. return designation; }
// ─── Main Export Function ──────────────────────────────────────────────
export function exportToIFC(model: StructuralModel): string { const id = new IfcIdAllocator(); const lines: string[] = [];
// ── Header ─────────────────────────────────────────────────────── lines.push("ISO-10303-21;"); lines.push("HEADER;"); lines.push(
FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');); lines.push(FILE_NAME('${model.spec.name}.ifc','${model.generatedAt}',('TAS Steel Generator'),('TAS Steel'),'TAS Steel v0.1','TAS Steel','');); lines.push(FILE_SCHEMA(('IFC2X3'));); lines.push("ENDSEC;"); lines.push("DATA;");// ── Project structure ──────────────────────────────────────────── const ownerHistoryId = id.next(); const personId = id.next(); const orgId = id.next(); const personOrgId = id.next(); const appId = id.next();
lines.push(
#${personId}=IFCPERSON($,$,'TAS Steel',$,$,$,$,$);); lines.push(#${orgId}=IFCORGANIZATION($,'TAS Steel','TAS Steel Generator',$,$);); lines.push(#${personOrgId}=IFCPERSONANDORGANIZATION(#${personId},#${orgId},$);); lines.push(#${appId}=IFCAPPLICATION(#${orgId},'0.1','TAS Steel','TAS-STEEL');); lines.push(#${ownerHistoryId}=IFCOWNERHISTORY(#${personOrgId},#${appId},$,.NOCHANGE.,$,#${personOrgId},#${appId},0););// Units — millimeters const dimExpId = id.next(); const siLengthId = id.next(); const mmUnitId = id.next(); const siAreaId = id.next(); const siVolumeId = id.next(); const siAngleId = id.next(); const unitAssignId = id.next();
lines.push(
#${dimExpId}=IFCDIMENSIONALEXPONENTS(1,0,0,0,0,0,0);); lines.push(#${siLengthId}=IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);); lines.push(#${mmUnitId}=IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);); lines.push(#${siAreaId}=IFCSIUNIT(*,.AREAUNIT.,$,.SQUARE_METRE.);); lines.push(#${siVolumeId}=IFCSIUNIT(*,.VOLUMEUNIT.,$,.CUBIC_METRE.);); lines.push(#${siAngleId}=IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);); lines.push(#${unitAssignId}=IFCUNITASSIGNMENT((#${mmUnitId},#${siAreaId},#${siVolumeId},#${siAngleId})););// Geometric context const originId = id.next(); const contextId = id.next();
lines.push(
#${originId}=IFCCARTESIANPOINT((0.,0.,0.));); lines.push(#${contextId}=IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.E-05,#${id.next()},$);); const axis2d3dId = id.next(); lines.push(#${axis2d3dId - 1}=IFCAXIS2PLACEMENT3D(#${originId},$,$);); // Rewrite the context with the correct axis reference lines[lines.length - 2] =#${contextId}=IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.E-05,#${axis2d3dId - 1},$);;// Sub-context for body representation const bodyContextId = id.next(); lines.push(
#${bodyContextId}=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Body','Model',*,*,*,*,#${contextId},$,.MODEL_VIEW.,$););// Project const projectId = id.next(); lines.push(
#${projectId}=IFCPROJECT('${ifcGuid('project-' + model.spec.name)}',#${ownerHistoryId},'${model.spec.name}',$,$,$,$,(#${contextId}),#${unitAssignId}););// Site const siteId = id.next(); const sitePlacementId = id.next(); const siteAxisId = id.next(); lines.push(
#${siteAxisId}=IFCAXIS2PLACEMENT3D(#${originId},$,$);); lines.push(#${sitePlacementId}=IFCLOCALPLACEMENT($,#${siteAxisId});); lines.push(#${siteId}=IFCSITE('${ifcGuid('site-' + model.spec.name)}',#${ownerHistoryId},'Site',$,$,#${sitePlacementId},$,$,.ELEMENT.,$,$,$,$,$););// Building const buildingId = id.next(); const buildingPlacementId = id.next(); const buildingAxisId = id.next(); lines.push(
#${buildingAxisId}=IFCAXIS2PLACEMENT3D(#${originId},$,$);); lines.push(#${buildingPlacementId}=IFCLOCALPLACEMENT(#${sitePlacementId},#${buildingAxisId});); lines.push(#${buildingId}=IFCBUILDING('${ifcGuid('building-' + model.spec.name)}',#${ownerHistoryId},'${model.spec.name}',$,$,#${buildingPlacementId},$,$,.ELEMENT.,$,$,$););// Building Storey const storeyId = id.next(); const storeyPlacementId = id.next(); const storeyAxisId = id.next(); lines.push(
#${storeyAxisId}=IFCAXIS2PLACEMENT3D(#${originId},$,$);); lines.push(#${storeyPlacementId}=IFCLOCALPLACEMENT(#${buildingPlacementId},#${storeyAxisId});); lines.push(#${storeyId}=IFCBUILDINGSTOREY('${ifcGuid('storey-' + model.spec.name)}',#${ownerHistoryId},'Ground Floor',$,$,#${storeyPlacementId},$,$,.ELEMENT.,0.););// ── Spatial hierarchy ──────────────────────────────────────────── const relAggSiteBldg = id.next(); lines.push(
#${relAggSiteBldg}=IFCRELAGGREGATES('${ifcGuid('agg-site-bldg')}',#${ownerHistoryId},$,$,#${siteId},(#${buildingId})););const relAggBldgStorey = id.next(); lines.push(
#${relAggBldgStorey}=IFCRELAGGREGATES('${ifcGuid('agg-bldg-storey')}',#${ownerHistoryId},$,$,#${buildingId},(#${storeyId})););const relAggProjectSite = id.next(); lines.push(
#${relAggProjectSite}=IFCRELAGGREGATES('${ifcGuid('agg-project-site')}',#${ownerHistoryId},$,$,#${projectId},(#${siteId})););// ── Members ────────────────────────────────────────────────────── const memberEntityIds: number[] = [];
for (const member of model.members.values()) { const startNode = model.nodes.get(member.startNodeId); const endNode = model.nodes.get(member.endNodeId); if (!startNode || !endNode) continue;
const entityType = ROLE_TO_IFC_ENTITY[member.role]; const membEntIds = writeMemberEntity( lines, id, ownerHistoryId, storeyPlacementId, bodyContextId, member, startNode.position, endNode.position, entityType, model.spec.name ); memberEntityIds.push(membEntIds.entityId); // Property set with TAS ID writeTASPropertySet( lines, id, ownerHistoryId, membEntIds.entityId, member );}
// Spatial containment if (memberEntityIds.length > 0) { const relContained = id.next(); const memberRefs = memberEntityIds.map(eid =>
#${eid}).join(','); lines.push(#${relContained}=IFCRELCONTAINEDINSPATIALSTRUCTURE('${ifcGuid('contain-storey')}',#${ownerHistoryId},$,$,(${memberRefs}),#${storeyId});); }// ── Footer ─────────────────────────────────────────────────────── lines.push("ENDSEC;"); lines.push("END-ISO-10303-21;");
return lines.join('\n'); }
// ─── Write a single member entity ──────────────────────────────────────
function writeMemberEntity( lines: string[], id: IfcIdAllocator, ownerHistoryId: number, parentPlacementId: number, bodyContextId: number, member: Member, startPos: Vec3, endPos: Vec3, entityType: IfcEntityType, projectName: string, ): { entityId: number } { // Compute direction vector const dx = endPos.x - startPos.x; const dy = endPos.y - startPos.y; const dz = endPos.z - startPos.z; const len = Math.sqrt(dx * dx + dy * dy + dz * dz); const dirX = dx / len; const dirY = dy / len; const dirZ = dz / len;
// Start point (in mm) const startPtId = id.next(); lines.push(
#${startPtId}=IFCCARTESIANPOINT((${toMm(startPos.x)},${toMm(startPos.y)},${toMm(startPos.z)})););// Direction const dirId = id.next(); lines.push(
#${dirId}=IFCDIRECTION((${dirX.toFixed(6)},${dirY.toFixed(6)},${dirZ.toFixed(6)})););// Ref direction (perpendicular to member axis) const refDir = computeRefDirection(dirX, dirY, dirZ); const refDirId = id.next(); lines.push(
#${refDirId}=IFCDIRECTION((${refDir[0].toFixed(6)},${refDir[1].toFixed(6)},${refDir[2].toFixed(6)})););// Axis placement const axisPlacementId = id.next(); lines.push(
#${axisPlacementId}=IFCAXIS2PLACEMENT3D(#${startPtId},#${dirId},#${refDirId}););// Local placement const localPlacementId = id.next(); lines.push(
#${localPlacementId}=IFCLOCALPLACEMENT(#${parentPlacementId},#${axisPlacementId}););// Profile definition — use I-shape for IPE/HEA/HEB, rectangle approximation for others const profileId = writeProfileDef(lines, id, member);
// Extruded area solid const extrusionDirId = id.next(); lines.push(
#${extrusionDirId}=IFCDIRECTION((0.,0.,1.)););const solidId = id.next(); const lengthMm = member.length * 1000; lines.push(
#${solidId}=IFCEXTRUDEDAREASOLID(#${profileId},#${id.next()},#${extrusionDirId},${lengthMm.toFixed(1)});); // Axis2Placement for the extrusion position const extOriginId = id.next(); lines.push(#${extOriginId}=IFCCARTESIANPOINT((0.,0.,0.));); const extAxisId = id.next(); lines.push(#${extAxisId}=IFCAXIS2PLACEMENT3D(#${extOriginId},$,$);); // Fix: rewrite solid with correct placement reference lines[lines.length - 4] =#${solidId}=IFCEXTRUDEDAREASOLID(#${profileId},#${extAxisId},#${extrusionDirId},${lengthMm.toFixed(1)});;// Shape representation const shapeRepId = id.next(); lines.push(
#${shapeRepId}=IFCSHAPEREPRESENTATION(#${bodyContextId},'Body','SweptSolid',(#${solidId})););// Product definition shape const prodDefShapeId = id.next(); lines.push(
#${prodDefShapeId}=IFCPRODUCTDEFINITIONSHAPE($,$,(#${shapeRepId})););// The actual IFC entity const entityId = id.next(); const guid = ifcGuid(
member-${projectName}-${member.id}); const name =${member.role}: ${member.id}; const desc =${member.section.designation} ${member.material.grade} L=${member.length.toFixed(3)}m;switch (entityType) { case 'IfcColumn': lines.push(
#${entityId}=IFCCOLUMN('${guid}',#${ownerHistoryId},'${name}','${desc}',$,#${localPlacementId},#${prodDefShapeId},$);); break; case 'IfcBeam': lines.push(#${entityId}=IFCBEAM('${guid}',#${ownerHistoryId},'${name}','${desc}',$,#${localPlacementId},#${prodDefShapeId},$);); break; case 'IfcMember': lines.push(#${entityId}=IFCMEMBER('${guid}',#${ownerHistoryId},'${name}','${desc}',$,#${localPlacementId},#${prodDefShapeId},$);); break; case 'IfcPlate': lines.push(#${entityId}=IFCPLATE('${guid}',#${ownerHistoryId},'${name}','${desc}',$,#${localPlacementId},#${prodDefShapeId},$);); break; }return { entityId }; }
// ─── Profile Definition ───────────────────────────────────────────────
function writeProfileDef(lines: string[], id: IfcIdAllocator, member: Member): number { const s = member.section; const profileId = id.next();
if (s.shape === 'IPE' || s.shape === 'HEA' || s.shape === 'HEB') { // IfcIShapeProfileDef lines.push(
#${profileId}=IFCISHAPEPROFILEDEF(.AREA.,'${s.designation}',$,${s.width.toFixed(1)},${s.depth.toFixed(1)},${s.tw.toFixed(1)},${s.tf.toFixed(1)},$);); } else if (s.shape === 'CHS') { // IfcCircleHollowProfileDef const radius = s.depth / 2; const wallThickness = s.tw; lines.push(#${profileId}=IFCCIRCLEHOLLOWPROFILEDEF(.AREA.,'${s.designation}',$,${radius.toFixed(1)},${wallThickness.toFixed(1)});); } else if (s.shape === 'UPN') { // IfcUShapeProfileDef lines.push(#${profileId}=IFCUSHAPEPROFILEDEF(.AREA.,'${s.designation}',$,${s.depth.toFixed(1)},${s.width.toFixed(1)},${s.tw.toFixed(1)},${s.tf.toFixed(1)},$,$,$);); } else { // Fallback: rectangle approximation lines.push(#${profileId}=IFCRECTANGLEPROFILEDEF(.AREA.,'${s.designation}',$,${s.width.toFixed(1)},${s.depth.toFixed(1)});); }return profileId; }
// ─── TAS Property Set ─────────────────────────────────────────────────
function writeTASPropertySet( lines: string[], id: IfcIdAllocator, ownerHistoryId: number, entityId: number, member: Member, ): void { // Property: TAS_MemberId const propMemberIdVal = id.next(); lines.push(
#${propMemberIdVal}=IFCPROPERTYSINGLEVALUE('TAS_MemberId',$,IFCTEXT('${member.id}'),$););// Property: TAS_Role const propRoleVal = id.next(); lines.push(
#${propRoleVal}=IFCPROPERTYSINGLEVALUE('TAS_Role',$,IFCTEXT('${member.role}'),$););// Property: TAS_Section const propSectionVal = id.next(); lines.push(
#${propSectionVal}=IFCPROPERTYSINGLEVALUE('TAS_Section',$,IFCTEXT('${member.section.designation}'),$););// Property: TAS_Material const propMaterialVal = id.next(); lines.push(
#${propMaterialVal}=IFCPROPERTYSINGLEVALUE('TAS_Material',$,IFCTEXT('${member.material.grade}'),$););// Property: TAS_Length_m const propLengthVal = id.next(); lines.push(
#${propLengthVal}=IFCPROPERTYSINGLEVALUE('TAS_Length_m',$,IFCREAL(${member.length.toFixed(4)}),$););// Property: TAS_Weight_kg const propWeightVal = id.next(); lines.push(
#${propWeightVal}=IFCPROPERTYSINGLEVALUE('TAS_Weight_kg',$,IFCREAL(${member.weight.toFixed(2)}),$););// Property set const psetId = id.next(); lines.push(
#${psetId}=IFCPROPERTYSET('${ifcGuid('pset-' + member.id)}',#${ownerHistoryId},'TAS_MemberProperties',$,(#${propMemberIdVal},#${propRoleVal},#${propSectionVal},#${propMaterialVal},#${propLengthVal},#${propWeightVal})););// Relate property set to entity const relDefId = id.next(); lines.push(
#${relDefId}=IFCRELDEFINESBYPROPERTIES('${ifcGuid('reldef-' + member.id)}',#${ownerHistoryId},$,$,(#${entityId}),#${psetId});); }// ─── Compute reference direction perpendicular to member axis ─────────
function computeRefDirection(dx: number, dy: number, dz: number): [number, number, number] { // Find a vector perpendicular to the member direction // Use cross product with global Z, or Y if member is along Z const absX = Math.abs(dx); const absY = Math.abs(dy); const absZ = Math.abs(dz);
let refX: number, refY: number, refZ: number;
if (absY > 0.9) { // Near-vertical member — use global X as reference refX = 1; refY = 0; refZ = 0; } else { // Cross with global Y refX = -dz; refY = 0; refZ = dx; const len = Math.sqrt(refX * refX + refZ * refZ); if (len > 1e-6) { refX /= len; refZ /= len; } else { refX = 1; refZ = 0; } }
return [refX, refY, refZ]; }
// ─── File download helper (for browser use) ───────────────────────────
export function downloadIFC(ifcContent: string, filename: string): void { const blob = new Blob([ifcContent], { type: 'application/x-step' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = filename.endsWith('.ifc') ? filename :
${filename}.ifc; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } todo write Now the critical tests — determinism, validation, BOM, and the complete pipeline:Wrote presets.ts/tas-steel/src/presets 170 lines 3.9 KB /**
- TAS Steel — Preset Specifications
- 6 realistic preset projects. All use the same generator.
- These are NOT hard-coded meshes — they are specifications
- that feed into generateBuilding(). */
import { BuildingSpec } from '../domain/types.js';
export const PRESETS: Record<string, BuildingSpec> = { 'small-workshop': { name: 'Small Workshop', span: 12, length: 24, bayCount: 4, eaveHeight: 5, roofPitch: 10, materialGrade: 'S275', columnSection: 'IPE300', rafterSection: 'IPE270', purlinSection: 'UPN140', girtSection: 'UPN120', eaveStrutSection: 'UPN140', purlinSpacing: 1.5, girtSpacing: 1.8, bracing: { wallBracingPattern: 'X', roofBracingPattern: 'X', wallBracingBays: [0, 3], roofBracingBays: [0, 3], wallBracingSection: 'L80x8', roofBracingSection: 'L80x8', }, },
'standard-warehouse': { name: 'Standard Warehouse', span: 20, length: 60, bayCount: 10, eaveHeight: 7, roofPitch: 10, materialGrade: 'S355', columnSection: 'HEA300', rafterSection: 'IPE400', purlinSection: 'UPN160', girtSection: 'UPN140', eaveStrutSection: 'UPN160', purlinSpacing: 1.5, girtSpacing: 2.0, bracing: { wallBracingPattern: 'X', roofBracingPattern: 'X', wallBracingBays: [0, 4, 9], roofBracingBays: [0, 9], wallBracingSection: 'CHS114x4', roofBracingSection: 'CHS114x4', }, },
'aircraft-hangar': { name: 'Aircraft Hangar', span: 40, length: 60, bayCount: 8, eaveHeight: 10, roofPitch: 5, materialGrade: 'S355', columnSection: 'HEB400', rafterSection: 'IPE600', purlinSection: 'UPN200', girtSection: 'UPN160', eaveStrutSection: 'UPN200', purlinSpacing: 1.8, girtSpacing: 2.5, bracing: { wallBracingPattern: 'X', roofBracingPattern: 'X', wallBracingBays: [0, 3, 7], roofBracingBays: [0, 7], wallBracingSection: 'CHS168x6', roofBracingSection: 'CHS139x5', }, },
'farm-shed': { name: 'Farm Shed', span: 15, length: 30, bayCount: 5, eaveHeight: 4.5, roofPitch: 15, materialGrade: 'S235', columnSection: 'IPE240', rafterSection: 'IPE200', purlinSection: 'UPN120', girtSection: 'UPN120', eaveStrutSection: 'UPN120', purlinSpacing: 1.5, girtSpacing: 1.5, bracing: { wallBracingPattern: 'single_diagonal', roofBracingPattern: 'X', wallBracingBays: [0, 4], roofBracingBays: [0, 4], wallBracingSection: 'L80x8', roofBracingSection: 'L80x8', }, },
'logistics-center': { name: 'Logistics Center', span: 30, length: 90, bayCount: 15, eaveHeight: 8, roofPitch: 8, materialGrade: 'S355', columnSection: 'HEB300', rafterSection: 'IPE500', purlinSection: 'UPN160', girtSection: 'UPN140', eaveStrutSection: 'UPN160', purlinSpacing: 1.5, girtSpacing: 2.0, bracing: { wallBracingPattern: 'X', roofBracingPattern: 'X', wallBracingBays: [0, 7, 14], roofBracingBays: [0, 7, 14], wallBracingSection: 'CHS139x5', roofBracingSection: 'CHS139x5', }, },
'sports-hall': { name: 'Sports Hall', span: 25, length: 40, bayCount: 8, eaveHeight: 9, roofPitch: 12, materialGrade: 'S355', columnSection: 'HEA360', rafterSection: 'IPE450', purlinSection: 'UPN160', girtSection: 'UPN140', eaveStrutSection: 'UPN160', purlinSpacing: 1.6, girtSpacing: 2.2, bracing: { wallBracingPattern: 'V', roofBracingPattern: 'X', wallBracingBays: [0, 7], roofBracingBays: [0, 7], wallBracingSection: 'CHS114x4', roofBracingSection: 'CHS114x4', }, }, };
export function getPresetNames(): string[] { return Object.keys(PRESETS); }
export function getPreset(name: string): BuildingSpec | undefined { return PRESETS[name]; } Now write the comprehensive tests:
Wrote determinism.test.ts/tas-steel/src/tests 455 lines 15.1 KB /**
- TAS Steel — Determinism Tests
- Same input MUST always produce the same output.
- Tests: IDs, member counts, weights, node positions, BOM, specHash. */
import { describe, it, expect } from 'vitest'; import { generateBuilding } from '../generators/HangarGenerator.js'; import { validateModel } from '../validation/validate.js'; import { generateBOM } from '../takeoff/bom.js'; import { exportToIFC } from '../ifc/ifcExporter.js'; import { hashSpec, type BuildingSpec } from '../domain/types.js'; import { PRESETS } from '../presets/presets.js';
// ─── Test Spec ─────────────────────────────────────────────────────────
const TEST_SPEC: BuildingSpec = { name: 'Determinism Test Building', span: 20, length: 40, bayCount: 5, eaveHeight: 7, roofPitch: 10, materialGrade: 'S355', columnSection: 'HEA300', rafterSection: 'IPE400', purlinSection: 'UPN160', girtSection: 'UPN140', eaveStrutSection: 'UPN160', purlinSpacing: 1.5, girtSpacing: 2.0, bracing: { wallBracingPattern: 'X', roofBracingPattern: 'X', wallBracingBays: [0, 4], roofBracingBays: [0, 4], wallBracingSection: 'CHS114x4', roofBracingSection: 'CHS114x4', }, };
describe('Determinism', () => { it('same spec produces same specHash', () => { const hash1 = hashSpec(TEST_SPEC); const hash2 = hashSpec(TEST_SPEC); expect(hash1).toBe(hash2); expect(hash1).toMatch(/^SPEC-[0-9A-F]{8}$/); });
it('same spec produces same member count', () => { const model1 = generateBuilding(TEST_SPEC); const model2 = generateBuilding(TEST_SPEC); expect(model1.members.size).toBe(model2.members.size); });
it('same spec produces same node count', () => { const model1 = generateBuilding(TEST_SPEC); const model2 = generateBuilding(TEST_SPEC); expect(model1.nodes.size).toBe(model2.nodes.size); });
it('same spec produces identical member IDs', () => { const model1 = generateBuilding(TEST_SPEC); const model2 = generateBuilding(TEST_SPEC);
const ids1 = [...model1.members.keys()].sort(); const ids2 = [...model2.members.keys()].sort(); expect(ids1).toEqual(ids2);});
it('same spec produces identical node IDs', () => { const model1 = generateBuilding(TEST_SPEC); const model2 = generateBuilding(TEST_SPEC);
const ids1 = [...model1.nodes.keys()].sort(); const ids2 = [...model2.nodes.keys()].sort(); expect(ids1).toEqual(ids2);});
it('same spec produces identical node positions', () => { const model1 = generateBuilding(TEST_SPEC); const model2 = generateBuilding(TEST_SPEC);
for (const [nodeId, node1] of model1.nodes) { const node2 = model2.nodes.get(nodeId); expect(node2).toBeDefined(); expect(node1.position.x).toBeCloseTo(node2!.position.x, 10); expect(node1.position.y).toBeCloseTo(node2!.position.y, 10); expect(node1.position.z).toBeCloseTo(node2!.position.z, 10); }});
it('same spec produces identical member lengths', () => { const model1 = generateBuilding(TEST_SPEC); const model2 = generateBuilding(TEST_SPEC);
for (const [memberId, member1] of model1.members) { const member2 = model2.members.get(memberId); expect(member2).toBeDefined(); expect(member1.length).toBeCloseTo(member2!.length, 10); }});
it('same spec produces identical total weight', () => { const model1 = generateBuilding(TEST_SPEC); const model2 = generateBuilding(TEST_SPEC); expect(model1.summary.totalWeight).toBeCloseTo(model2.summary.totalWeight, 6); });
it('same spec produces identical BOM', () => { const model1 = generateBuilding(TEST_SPEC); const model2 = generateBuilding(TEST_SPEC); const bom1 = generateBOM(model1); const bom2 = generateBOM(model2);
expect(bom1.totalWeight).toBe(bom2.totalWeight); expect(bom1.totalMemberCount).toBe(bom2.totalMemberCount); expect(bom1.items.length).toBe(bom2.items.length); for (let i = 0; i < bom1.items.length; i++) { expect(bom1.items[i].role).toBe(bom2.items[i].role); expect(bom1.items[i].section).toBe(bom2.items[i].section); expect(bom1.items[i].count).toBe(bom2.items[i].count); expect(bom1.items[i].totalWeight).toBe(bom2.items[i].totalWeight); }});
it('different specs produce different hashes', () => { const spec2 = { ...TEST_SPEC, span: 25 }; expect(hashSpec(TEST_SPEC)).not.toBe(hashSpec(spec2)); }); });
describe('Generator Correctness', () => { const model = generateBuilding(TEST_SPEC);
it('generates correct frame count', () => { // bayCount + 1 frames expect(model.summary.frameCount).toBe(TEST_SPEC.bayCount + 1); });
it('generates correct number of columns', () => { // 2 columns per frame expect(model.summary.memberCountByRole.column).toBe(2 * (TEST_SPEC.bayCount + 1)); });
it('generates correct number of rafters', () => { // 2 rafters per frame expect(model.summary.memberCountByRole.rafter).toBe(2 * (TEST_SPEC.bayCount + 1)); });
it('columns are vertical (same X, same Z for start/end)', () => { for (const member of model.members.values()) { if (member.role !== 'column') continue; const start = model.nodes.get(member.startNodeId)!; const end = model.nodes.get(member.endNodeId)!; expect(start.position.x).toBeCloseTo(end.position.x, 6); expect(start.position.z).toBeCloseTo(end.position.z, 6); } });
it('column height matches eaveHeight', () => { for (const member of model.members.values()) { if (member.role !== 'column') continue; expect(member.length).toBeCloseTo(TEST_SPEC.eaveHeight, 6); } });
it('ridge is at correct height', () => { const halfSpan = TEST_SPEC.span / 2; const pitchRad = (TEST_SPEC.roofPitch * Math.PI) / 180; const expectedRidgeHeight = TEST_SPEC.eaveHeight + halfSpan * Math.tan(pitchRad); expect(model.summary.ridgeHeight).toBeCloseTo(expectedRidgeHeight, 6); });
it('all members have positive length', () => { for (const member of model.members.values()) { expect(member.length).toBeGreaterThan(0); } });
it('all members have positive weight', () => { for (const member of model.members.values()) { expect(member.weight).toBeGreaterThan(0); } });
it('member weight = length × weightPerMeter', () => { for (const member of model.members.values()) { const expected = member.length * member.section.weightPerMeter; expect(member.weight).toBeCloseTo(expected, 6); } });
it('all node IDs referenced by members exist', () => { for (const member of model.members.values()) { expect(model.nodes.has(member.startNodeId)).toBe(true); expect(model.nodes.has(member.endNodeId)).toBe(true); } });
it('bay spacing is correct', () => { expect(model.summary.baySpacing).toBeCloseTo(TEST_SPEC.length / TEST_SPEC.bayCount, 6); });
it('total weight equals sum of member weights', () => { let sum = 0; for (const member of model.members.values()) { sum += member.weight; } expect(model.summary.totalWeight).toBeCloseTo(sum, 4); });
it('has bracing members', () => { expect(model.summary.memberCountByRole.bracing_wall).toBeGreaterThan(0); expect(model.summary.memberCountByRole.bracing_roof).toBeGreaterThan(0); });
it('has purlins', () => { expect(model.summary.memberCountByRole.purlin).toBeGreaterThan(0); });
it('has girts', () => { expect(model.summary.memberCountByRole.girt).toBeGreaterThan(0); });
it('has eave struts', () => { expect(model.summary.memberCountByRole.eave_strut).toBeGreaterThan(0); }); });
describe('Validation', () => { it('valid model passes validation', () => { const model = generateBuilding(TEST_SPEC); const result = validateModel(model); expect(result.passed).toBe(true); const errors = result.issues.filter(i => i.severity === 'error'); expect(errors).toHaveLength(0); });
it('invalid spec is caught', () => { const badSpec: BuildingSpec = { ...TEST_SPEC, span: -5, eaveHeight: 0, };
// Generator would throw on invalid sections, but validation catches spec issues // We test the spec validation separately const model = generateBuilding(TEST_SPEC); // use valid model const fakeModel = { ...model, spec: badSpec }; const result = validateModel(fakeModel); const errors = result.issues.filter(i => i.severity === 'error'); expect(errors.length).toBeGreaterThan(0); expect(errors.some(e => e.code === 'SPEC_SPAN_INVALID')).toBe(true);});
it('all presets pass validation', () => { for (const [name, spec] of Object.entries(PRESETS)) { const model = generateBuilding(spec); const result = validateModel(model); const errors = result.issues.filter(i => i.severity === 'error'); if (errors.length > 0) { console.error(
Preset "${name}" failed validation:, errors); } expect(errors).toHaveLength(0); } }); });describe('BOM', () => { it('BOM total weight matches model summary', () => { const model = generateBuilding(TEST_SPEC); const bom = generateBOM(model); expect(bom.totalWeight).toBeCloseTo(model.summary.totalWeight, 1); });
it('BOM total member count matches model', () => { const model = generateBuilding(TEST_SPEC); const bom = generateBOM(model); expect(bom.totalMemberCount).toBe(model.members.size); });
it('BOM has entries for all roles present in model', () => { const model = generateBuilding(TEST_SPEC); const bom = generateBOM(model); const bomRoles = new Set(bom.items.map(i => i.role)); const modelRoles = new Set([...model.members.values()].map(m => m.role)); for (const role of modelRoles) { expect(bomRoles.has(role)).toBe(true); } });
it('BOM item weights are positive', () => { const model = generateBuilding(TEST_SPEC); const bom = generateBOM(model); for (const item of bom.items) { expect(item.totalWeight).toBeGreaterThan(0); expect(item.unitWeight).toBeGreaterThan(0); } }); });
describe('IFC Export', () => { it('produces valid IFC-SPF header', () => { const model = generateBuilding(TEST_SPEC); const ifc = exportToIFC(model); expect(ifc).toContain('ISO-10303-21;'); expect(ifc).toContain('HEADER;'); expect(ifc).toContain('ENDSEC;'); expect(ifc).toContain('DATA;'); expect(ifc).toContain('END-ISO-10303-21;'); });
it('contains correct entity types', () => { const model = generateBuilding(TEST_SPEC); const ifc = exportToIFC(model); expect(ifc).toContain('IFCCOLUMN'); expect(ifc).toContain('IFCBEAM'); expect(ifc).toContain('IFCMEMBER'); });
it('contains TAS property sets', () => { const model = generateBuilding(TEST_SPEC); const ifc = exportToIFC(model); expect(ifc).toContain('TAS_MemberId'); expect(ifc).toContain('TAS_Role'); expect(ifc).toContain('TAS_Section'); expect(ifc).toContain('TAS_Material'); expect(ifc).toContain('TAS_Length_m'); expect(ifc).toContain('TAS_Weight_kg'); });
it('uses millimeter units', () => { const model = generateBuilding(TEST_SPEC); const ifc = exportToIFC(model); expect(ifc).toContain('.MILLI.'); expect(ifc).toContain('.METRE.'); });
it('IFC output is deterministic (same spec → same structure)', () => { const model1 = generateBuilding(TEST_SPEC); const model2 = generateBuilding(TEST_SPEC); const ifc1 = exportToIFC(model1); const ifc2 = exportToIFC(model2);
// Line count should be identical const lines1 = ifc1.split('\n').length; const lines2 = ifc2.split('\n').length; expect(lines1).toBe(lines2); // Entity counts should match const countEntities = (ifc: string, entity: string) => (ifc.match(new RegExp(entity, 'g')) || []).length; expect(countEntities(ifc1, 'IFCCOLUMN')).toBe(countEntities(ifc2, 'IFCCOLUMN')); expect(countEntities(ifc1, 'IFCBEAM')).toBe(countEntities(ifc2, 'IFCBEAM')); expect(countEntities(ifc1, 'IFCMEMBER')).toBe(countEntities(ifc2, 'IFCMEMBER'));}); });
describe('All Presets Generate Successfully', () => { for (const [name, spec] of Object.entries(PRESETS)) { it(
preset "${name}" generates a model, () => { const model = generateBuilding(spec); expect(model.members.size).toBeGreaterThan(0); expect(model.nodes.size).toBeGreaterThan(0); expect(model.summary.totalWeight).toBeGreaterThan(0); });it(`preset "${name}" produces a valid BOM`, () => { const model = generateBuilding(spec); const bom = generateBOM(model); expect(bom.totalMemberCount).toBe(model.members.size); expect(bom.totalWeight).toBeGreaterThan(0); }); it(`preset "${name}" exports to IFC`, () => { const model = generateBuilding(spec); const ifc = exportToIFC(model); expect(ifc.length).toBeGreaterThan(1000); expect(ifc).toContain('IFCPROJECT'); });} });
describe('Performance', () => { it('generates 20×60m hangar in under 100ms', () => { const spec = PRESETS['standard-warehouse']; const start = performance.now(); const model = generateBuilding(spec); const elapsed = performance.now() - start;
console.log(`Generate time (20×60m warehouse): ${elapsed.toFixed(2)}ms`); console.log(` Members: ${model.members.size}`); console.log(` Nodes: ${model.nodes.size}`); console.log(` Total weight: ${(model.summary.totalWeight / 1000).toFixed(2)}t`); expect(elapsed).toBeLessThan(100);});
it('generates 40×60m aircraft hangar in under 100ms', () => { const spec = PRESETS['aircraft-hangar']; const start = performance.now(); const model = generateBuilding(spec); const elapsed = performance.now() - start;
console.log(`Generate time (40×60m hangar): ${elapsed.toFixed(2)}ms`); console.log(` Members: ${model.members.size}`); console.log(` Nodes: ${model.nodes.size}`); console.log(` Total weight: ${(model.summary.totalWeight / 1000).toFixed(2)}t`); expect(elapsed).toBeLessThan(100);});
it('validates in under 200ms', () => { const model = generateBuilding(PRESETS['logistics-center']); const start = performance.now(); const result = validateModel(model); const elapsed = performance.now() - start;
console.log(`Validation time (logistics-center): ${elapsed.toFixed(2)}ms`); console.log(` Issues: ${result.issues.length}`); expect(elapsed).toBeLessThan(200);});
it('BOM generation in under 10ms', () => { const model = generateBuilding(PRESETS['logistics-center']); const start = performance.now(); const bom = generateBOM(model); const elapsed = performance.now() - start;
console.log(`BOM time (logistics-center): ${elapsed.toFixed(2)}ms`); console.log(` Line items: ${bom.items.length}`); expect(elapsed).toBeLessThan(10);});
it('IFC export in under 500ms', () => { const model = generateBuilding(PRESETS['logistics-center']); const start = performance.now(); const ifc = exportToIFC(model); const elapsed = performance.now() - start;
console.log(`IFC export time (logistics-center): ${elapsed.toFixed(2)}ms`); console.log(` IFC file size: ${(ifc.length / 1024).toFixed(1)} KB`); expect(elapsed).toBeLessThan(500);}); }); Wrote vitest.config.ts/tas-steel 19 lines 526 B import { defineConfig } from 'vitest/config';
export default defineConfig({ test: { include: ['src/tests/**/*.test.ts'], environment: 'node', }, resolve: { alias: { '@domain': '/workspace/tas-steel/src/domain', '@generators': '/workspace/tas-steel/src/generators', '@validation': '/workspace/tas-steel/src/validation', '@takeoff': '/workspace/tas-steel/src/takeoff', '@ifc': '/workspace/tas-steel/src/ifc', '@presets': '/workspace/tas-steel/src/presets', }, }, });
- Assistant
I'll analyze the current project structure and implement explicit end-plate connections and gusset plates for the rafter-to-column joint with no overlapping geometry.
Now I'll install the necessary packages and create the complete TAS Steel application with explicit end-plate connections and gusset plates for rafter-to-column joints.
Now I'll create the domain types file with the complete structural steel data model:
Now I'll create the enhanced generator with explicit end-plate connections and gusset plates:
Let me fix the type errors in the generator:
Now let me create the presets file:
Now let me create the 3D viewer component:
Now let me create the main App component with the complete UI:
Now let me update the index.html title:
Let me check the CSS file and update it:
Now let me build the project to verify everything works:
The TAS Steel portal frame generator has been successfully implemented with explicit end-plate connections and gusset plates for the rafter-to-column joint. Here's a summary of what was created:
Implementation Summary
1. Domain Types (
src/domain/types.ts)- Added new member roles:
end_plate,gusset_plate,cleat,haunch - Connection types with specifications for:
- End-plate dimensions (width, height, thickness)
- Bolt patterns (count, diameter, grade)
- Haunch geometry (depth, length)
- Base plate and anchor bolt configuration
- Stiffener plates
2. Enhanced Generator (
src/generators/HangarGenerator.ts)Key Features - No Overlapping Geometry:
- Column trimming: Top of column is cut at
eaveHeight - plateThickness/2 - Rafter cutback: Start of rafter is trimmed by full plate thickness from eave
- Explicit end-plates: Generated as separate plate members between column and rafter
- Haunch members: Optional tapered haunches for rigid connections
- Stiffener plates: Added at haunch zones when enabled
- Base plates: With configurable anchor bolt patterns
3. Presets (
src/presets/presets.ts)- 6 realistic building configurations
- Default and haunched connection options
- Aircraft hangar and logistics center use rigid haunched connections
4. 3D Viewer (
src/viewer/SteelViewer.tsx)- Full Three.js visualization
- Color-coded by member role
- Toggle connections/plates visibility
- Interactive orbit controls
5. Complete UI (
src/App.tsx)- Building preset selector
- 3D model view
- Bill of Materials table
- Detailed connection specifications panel showing:
- Eave connections (rafter-to-column)
- Ridge connections
- Base plates
- Connection weight summary
Files built:
src/domain/types.ts,src/generators/HangarGenerator.ts,src/presets/presets.ts,src/viewer/SteelViewer.tsx,src/App.tsx,index.html - Added new member roles:
- User
continue the joints and cocnectors enhancments
- Assistant
I'll continue enhancing the joints and connectors with more sophisticated connection types, bolt pattern calculations, weld specifications, and detailed geometry logic.
Let me enhance the domain types with more detailed connection specifications:
Now let me update the ConnectionConfig to use the new types:
Now let me fix the connection types in the generator:
Now let me fix the presets file:
Now let me create a sophisticated connection calculator module:
Let me fix the remaining type errors:
Let me fix the remaining unused variables:
Now let me build the project to verify everything compiles:
Excellent! The build succeeded. Now let me create a detailed connection visualization component:
Now let me update the App.tsx to use the new ConnectionDiagram component:
Now let me build the project to verify everything compiles:
Excellent! The build succeeded. Let me create a comprehensive connection engineering panel:
Files built:
src/domain/types.ts,src/generators/HangarGenerator.ts,src/presets/presets.ts,src/generators/ConnectionCalculator.ts,src/viewer/ConnectionDiagram.tsx,src/App.tsx,src/viewer/ConnectionEngineeringPanel.tsx - User
je pense que lazem tefham l probleme l joints lazem triglhom mat7otsh f west bin deux bars sphere wla jsp non accreyi mechansime real tae jointagge bles boulon b b des bars li yjo wajdin bash yboulinwhom w 7dayed hadouk li yjo binathom tu vois work on those conectors more more of a feeit in and lego concept adn alos boulounage
- Assistant
I understand! You want the joints to be real mechanical connections - not just spheres or abstract connections at nodes. The connections should show:
- Real end-plates between members (not spheres)
- Actual bolts connecting the plates
- Members trimmed to fit together properly
- Lego/kit-of-parts concept where pieces clearly interlock
- Real bolting patterns visible
Let me fix the 3D viewer and generator to show realistic bolted connections:
Now let me update the App.tsx to include the new showBolts prop:
Now let me build the project to verify everything compiles:
The build succeeded. I've now implemented real mechanical connections with:
Key Improvements:
1. No More Spheres - Real End-Plates
- Members are trimmed at connection points
- Explicit rectangular end-plates are rendered between column and rafter
- No overlapping geometry - members fit together like real steel
2. Real Bolts (Boulonnage)
- Hexagonal bolt heads visible at each connection
- Bolt patterns calculated per EN 1993-1-8
- Bolt count, diameter, and grade properly specified
3. Lego/Kit-of-Parts Concept
- Column trimmed at
eaveHeight - plateThickness/2 - Rafter cut back by full plate thickness
- End-plate sits between them - clear assembly sequence
4. Connection Types
- Eave: Extended end-plate (moment connection)
- Ridge: Flush end-plate (splice)
- Base: Pinned/fixed base plate with anchor bolts
5. New Toggle Controls
- Show/Hde Bolts
- Show/Hide Plates
- Show/Hide Connections
6. Engineering Tab
- Bolt schedule with capacities
- Weld schedule
- Connection weight summary
- Geometry logic explanation
The 3D viewer now shows:
- Gray columns with I-section profile
- Dark rafters with I-section profile
- Red end-plates clearly visible at joints
- Yellow base plates at foundations
- Bolts as hexagonal heads at each connection point
This is the real bolting mechanism (mecanisme real tae jointage bles boulon) you requested!
Files built:
src/viewer/SteelViewer.tsx,src/App.tsx