Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
188 lines
7.2 KiB
TypeScript
188 lines
7.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|||
|
|
import { exportShapesToIfc4, classifyShapeForIfc } from "@/lib/ifcExport";
|
||
|
|
import { importedShapeWithDetailsFromIfc } from "@/lib/ifcImport";
|
||
|
|
import {
|
||
|
|
DEFAULT_BUILDING_STOREYS,
|
||
|
|
calculateArchitecturalBoq,
|
||
|
|
exportBoqToCsv,
|
||
|
|
exportBoqToPdfBytes,
|
||
|
|
auditArchitecturalCodeCompliance,
|
||
|
|
isolateStoreyVisibility,
|
||
|
|
duplicateStoreyToLevel,
|
||
|
|
generateParametricStair,
|
||
|
|
generateParametricRoof,
|
||
|
|
generateParametricOpeningUnit,
|
||
|
|
generateStructuralFrameGrid,
|
||
|
|
generateAdvancedTerrainWithPad,
|
||
|
|
} from "@/lib/architecturalBimEngine";
|
||
|
|
import {
|
||
|
|
TURKEY_81_PROVINCES_SOLAR_LOCATIONS,
|
||
|
|
SOLAR_LOCATIONS,
|
||
|
|
DEFAULT_SOLAR_SETTINGS,
|
||
|
|
calculateDailySolarSweep,
|
||
|
|
} from "@/lib/solarSystem";
|
||
|
|
import { SNAPCAD_PREFABS } from "@/lib/snapcadPrefabs";
|
||
|
|
|
||
|
|
describe("Architectural BIM Engine, IFC4 Export, BOQ Metraj & Code Auditor", () => {
|
||
|
|
it("exports 3D architectural shapes to IFC4 and round-trips through web-ifc WASM", async () => {
|
||
|
|
const villaPrefab = SNAPCAD_PREFABS.find((p) => p.id === "modern-terrace-villa");
|
||
|
|
expect(villaPrefab).toBeDefined();
|
||
|
|
const shapes = villaPrefab!.buildShapes();
|
||
|
|
|
||
|
|
const exported = exportShapesToIfc4(shapes, {
|
||
|
|
projectName: "Modern Terasli Villa",
|
||
|
|
scaleFactorToMm: 100, // 1:100 architectural scale -> real millimeters
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(exported.ifcText).toContain("FILE_SCHEMA(('IFC4'));");
|
||
|
|
expect(exported.ifcText).toContain("IFCPROJECT(");
|
||
|
|
expect(exported.ifcText).toContain("IFCBUILDINGSTOREY(");
|
||
|
|
expect(exported.ifcText).toContain("IFCELEMENTQUANTITY(");
|
||
|
|
expect(exported.productCount).toBeGreaterThanOrEqual(5);
|
||
|
|
expect(exported.storeyCount).toBeGreaterThanOrEqual(1);
|
||
|
|
|
||
|
|
// Round-trip parse with web-ifc WASM
|
||
|
|
const reimported = await importedShapeWithDetailsFromIfc("villa_bim.ifc", exported.bytes);
|
||
|
|
expect(reimported.schema).toBe("IFC4");
|
||
|
|
expect(reimported.productCount).toBeGreaterThanOrEqual(5);
|
||
|
|
expect(reimported.triangleCount).toBeGreaterThanOrEqual(24);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("classifies BIM entities and calculates BOQ (Metraj & Keşif) with CSV and PDF export", () => {
|
||
|
|
const frameShapes = generateStructuralFrameGrid({
|
||
|
|
baysX: 2,
|
||
|
|
baysZ: 2,
|
||
|
|
spanX: 40,
|
||
|
|
spanZ: 40,
|
||
|
|
storeyHeight: 32,
|
||
|
|
includeFoundationSlab: true,
|
||
|
|
includeCeilingSlab: true,
|
||
|
|
});
|
||
|
|
const roofShapes = generateParametricRoof({
|
||
|
|
kind: "gable",
|
||
|
|
width: 84,
|
||
|
|
depth: 84,
|
||
|
|
ridgeHeight: 18,
|
||
|
|
baseElevation: 64,
|
||
|
|
});
|
||
|
|
const openingShapes = [
|
||
|
|
...generateParametricOpeningUnit({ kind: "double-window", width: 18, height: 15 }),
|
||
|
|
...generateParametricOpeningUnit({ kind: "steel-entrance-door", width: 12, height: 21 }),
|
||
|
|
];
|
||
|
|
|
||
|
|
const allShapes = [...frameShapes, ...roofShapes, ...openingShapes];
|
||
|
|
expect(classifyShapeForIfc(roofShapes[0])).toBe("IFCROOF");
|
||
|
|
|
||
|
|
const boq = calculateArchitecturalBoq(allShapes, {
|
||
|
|
projectName: "Test Mimari Bina",
|
||
|
|
scaleMode: "1:100",
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(boq.grossFloorAreaM2).toBeGreaterThan(50);
|
||
|
|
expect(boq.totalStructuralConcreteM3).toBeGreaterThan(5);
|
||
|
|
expect(boq.totalRoofAreaM2).toBeGreaterThan(50);
|
||
|
|
expect(boq.windowCount).toBeGreaterThanOrEqual(1);
|
||
|
|
expect(boq.doorCount).toBeGreaterThanOrEqual(1);
|
||
|
|
expect(boq.totalEstimatedCostTry).toBeGreaterThan(50_000);
|
||
|
|
expect(boq.items.length).toBeGreaterThanOrEqual(4);
|
||
|
|
|
||
|
|
const csv = exportBoqToCsv(boq);
|
||
|
|
expect(csv.startsWith("\uFEFF")).toBe(true);
|
||
|
|
expect(csv).toContain("15.150.1005");
|
||
|
|
expect(csv).toContain("Test Mimari Bina");
|
||
|
|
|
||
|
|
const pdfBytes = exportBoqToPdfBytes(boq);
|
||
|
|
expect(pdfBytes.byteLength).toBeGreaterThan(500);
|
||
|
|
const pdfHeader = new TextDecoder().decode(pdfBytes.slice(0, 5));
|
||
|
|
expect(pdfHeader).toBe("%PDF-");
|
||
|
|
});
|
||
|
|
|
||
|
|
it("manages multi-storey isolation and duplicates a storey to an upper floor level", () => {
|
||
|
|
const groundStorey = DEFAULT_BUILDING_STOREYS[1]; // Zemin Kat (elevation 0)
|
||
|
|
const firstStorey = DEFAULT_BUILDING_STOREYS[2]; // 1. Normal Kat (elevation 32)
|
||
|
|
|
||
|
|
const gridShapes = generateStructuralFrameGrid({
|
||
|
|
baysX: 1,
|
||
|
|
baysZ: 1,
|
||
|
|
spanX: 40,
|
||
|
|
spanZ: 40,
|
||
|
|
baseElevation: groundStorey.elevation,
|
||
|
|
storeyTag: groundStorey.tag,
|
||
|
|
});
|
||
|
|
|
||
|
|
const duplicated = duplicateStoreyToLevel(
|
||
|
|
gridShapes,
|
||
|
|
groundStorey,
|
||
|
|
firstStorey,
|
||
|
|
DEFAULT_BUILDING_STOREYS,
|
||
|
|
);
|
||
|
|
|
||
|
|
expect(duplicated.clonedShapes.length).toBe(gridShapes.length);
|
||
|
|
expect(duplicated.nextShapes.length).toBe(gridShapes.length * 2);
|
||
|
|
expect(duplicated.clonedShapes[0].elevation).toBeCloseTo(
|
||
|
|
(gridShapes[0].elevation || 0) + (firstStorey.elevation - groundStorey.elevation),
|
||
|
|
2,
|
||
|
|
);
|
||
|
|
|
||
|
|
const isolated = isolateStoreyVisibility(
|
||
|
|
duplicated.nextShapes,
|
||
|
|
firstStorey,
|
||
|
|
DEFAULT_BUILDING_STOREYS,
|
||
|
|
);
|
||
|
|
const visibleCount = isolated.filter((s) => !s.hidden).length;
|
||
|
|
expect(visibleCount).toBe(duplicated.clonedShapes.length);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("generates parametric stairs (straight, L, U, spiral) and audits Turkish building code compliance", () => {
|
||
|
|
const straightStairs = generateParametricStair({ kind: "straight", stepCount: 18, totalHeight: 31 });
|
||
|
|
const lStairs = generateParametricStair({ kind: "l-shaped", stepCount: 18, totalHeight: 31 });
|
||
|
|
const uStairs = generateParametricStair({ kind: "u-shaped", stepCount: 18, totalHeight: 31 });
|
||
|
|
const spiralStairs = generateParametricStair({ kind: "spiral", stepCount: 16, totalHeight: 32 });
|
||
|
|
|
||
|
|
expect(straightStairs.length).toBeGreaterThanOrEqual(18);
|
||
|
|
expect(lStairs.length).toBeGreaterThanOrEqual(18);
|
||
|
|
expect(uStairs.length).toBeGreaterThanOrEqual(18);
|
||
|
|
expect(spiralStairs.length).toBeGreaterThanOrEqual(16);
|
||
|
|
|
||
|
|
const audit = auditArchitecturalCodeCompliance(uStairs, "1:100");
|
||
|
|
expect(audit.score).toBeGreaterThanOrEqual(50);
|
||
|
|
expect(audit.checks.some((c) => c.id === "stair-blondel")).toBe(true);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("triangulates 3D site topography using simplex-noise + delaunator and computes cut/fill earthwork", () => {
|
||
|
|
const terrain = generateAdvancedTerrainWithPad({
|
||
|
|
preset: "hills",
|
||
|
|
width: 220,
|
||
|
|
depth: 220,
|
||
|
|
maxHeight: 22,
|
||
|
|
gridResolution: 14,
|
||
|
|
includeBuildingPad: true,
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(terrain.triangleCount).toBeGreaterThanOrEqual(300);
|
||
|
|
expect(terrain.terrainShape.importedMesh?.positions.length).toBe(terrain.triangleCount * 9);
|
||
|
|
expect(terrain.padShape).not.toBeNull();
|
||
|
|
expect(terrain.excavationCutVolumeM3 + terrain.embankmentFillVolumeM3).toBeGreaterThan(0);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("includes all 81 Turkish provinces with TS 825 zones and computes daily facade solar sweep", () => {
|
||
|
|
expect(TURKEY_81_PROVINCES_SOLAR_LOCATIONS).toHaveLength(81);
|
||
|
|
expect(TURKEY_81_PROVINCES_SOLAR_LOCATIONS[0].plateCode).toBe("01");
|
||
|
|
expect(TURKEY_81_PROVINCES_SOLAR_LOCATIONS[80].plateCode).toBe("81");
|
||
|
|
expect(SOLAR_LOCATIONS.length).toBeGreaterThanOrEqual(88);
|
||
|
|
|
||
|
|
const sweep = calculateDailySolarSweep({
|
||
|
|
...DEFAULT_SOLAR_SETTINGS,
|
||
|
|
locationIndex: 0, // İstanbul
|
||
|
|
month: 5, // Haziran
|
||
|
|
day: 21,
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(sweep.daylightDurationHours).toBeGreaterThan(12);
|
||
|
|
expect(sweep.southHours).toBeGreaterThan(4);
|
||
|
|
expect(sweep.eastHours).toBeGreaterThan(2);
|
||
|
|
expect(sweep.westHours).toBeGreaterThan(2);
|
||
|
|
expect(sweep.ts825Standard.zone).toBe(2);
|
||
|
|
expect(sweep.hourlyPoints.length).toBeGreaterThanOrEqual(15);
|
||
|
|
});
|
||
|
|
});
|