Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
33b3985
Merge branch 'main' of https://github.com/ThatOpen/engine_web-ifc int…
ifcapps Mar 1, 2025
e669f4a
t push origin mainMerge branch 'ThatOpen-main'
ifcapps Mar 1, 2025
1a97a85
Merge branch 'ThatOpen:main' into main
ifcapps Mar 5, 2025
e62a593
adjustable number of output curve points in BSpline curves
ifcapps Mar 6, 2025
d702ac6
IfcLoader::SaveFile: option to order the STEP lines
ifcapps Mar 6, 2025
8a75cf7
complete IFCAXIS2PLACEMENTLINEAR
ifcapps Mar 6, 2025
af83ba0
disable TriangulateCylindricalSurface
ifcapps Mar 6, 2025
47e7997
add IFCPOLYNOMIALCURVE in IfcGeometryLoader::ComputeCurve
ifcapps Mar 6, 2025
860e837
add IFCCLOTHOID, add double IfcGeometryLoader::ReadCurveMeasureSelect…
ifcapps Mar 10, 2025
ded2dd6
Merge branch 'ThatOpen:main' into main
ifcapps Mar 10, 2025
670e6d2
add IFCCOMPOSITECURVE in IfcGeometryProcessor::GetMesh
ifcapps Mar 11, 2025
5d2d2f0
complete implementation in SectionedSurface
ifcapps Mar 12, 2025
539a6f5
complete SectionedSurface
ifcapps Mar 12, 2025
fb8bbb1
fix IFCCLOTHOID curve computation
ifcapps Mar 12, 2025
bfb3532
add argument orderLinesByExpressID in SaveFile
ifcapps Mar 13, 2025
52901d2
Restore color of geometric items after flatten() and BoolProcess()
ifcapps Mar 18, 2025
0fe5aa1
Add check for nan in Nurbs. Add check for IfcTokenType::LINE_END in I…
ifcapps Mar 18, 2025
d199fb8
replace map.contains with find, to be able to compile with C++ 17
ifcapps Mar 27, 2025
b576957
add test script "regression-save-glb"
ifcapps Mar 27, 2025
ac72a20
Merge branch 'main' into pr/1289
beachtom Feb 27, 2025
4057df8
feat: Support higher precision for double values beyond 8 bytes when …
liradb2000 Feb 27, 2025
259bfdc
regenerate ifc-schema
liradb2000 Feb 27, 2025
d033403
fix: Real, Integer primitive type handle issue
liradb2000 Feb 28, 2025
a05199e
Merge pull request #1289 from liradb2000/fix/dabeom/handling_value
beachtom Feb 27, 2025
9370a2c
Bump koa from 2.15.4 to 2.16.0
dependabot[bot] Feb 28, 2025
b589f65
Bump reusify from 1.0.4 to 1.1.0
dependabot[bot] Feb 28, 2025
609b48c
Bump caniuse-lite from 1.0.30001700 to 1.0.30001701
dependabot[bot] Feb 28, 2025
7662465
Bump micromark-util-types from 2.0.1 to 2.0.2
dependabot[bot] Feb 28, 2025
4af6fc2
regenerate schema
liradb2000 Feb 28, 2025
c5bc8aa
Fix Bug
beachtom Feb 27, 2025
5a02f46
Schema Changes
beachtom Mar 1, 2025
eb631d1
Fix Argument Bug
beachtom Mar 1, 2025
58ec72a
Merge pull request #1297 from ThatOpen/dependabot/npm_and_yarn/koa-2.…
beachtom Feb 28, 2025
830850a
Allow no chunking
beachtom Mar 1, 2025
48af951
Merge pull request #1302 from ThatOpen/Test
beachtom Mar 1, 2025
83133d7
Bump call-bound from 1.0.3 to 1.0.4
dependabot[bot] Mar 4, 2025
264619d
Merge pull request #1298 from ThatOpen/dependabot/npm_and_yarn/reusif…
beachtom Feb 28, 2025
d97fa16
Merge pull request #1303 from ThatOpen/Test
beachtom Mar 1, 2025
c88ec18
Bump @types/node from 22.13.5 to 22.13.9
dependabot[bot] Mar 4, 2025
c2e34ee
Merge pull request #1309 from ThatOpen/dependabot/npm_and_yarn/call-b…
beachtom Mar 4, 2025
16f3c18
Merge pull request #1296 from ThatOpen/dependabot/npm_and_yarn/canius…
beachtom Feb 28, 2025
0109d07
Update Names
beachtom Mar 2, 2025
95ba5b0
Bump electron-to-chromium from 1.5.106 to 1.5.111
dependabot[bot] Mar 4, 2025
f35815a
Merge pull request #1308 from ThatOpen/dependabot/npm_and_yarn/types/…
beachtom Mar 4, 2025
51d9c7a
Merge pull request #1294 from ThatOpen/dependabot/npm_and_yarn/microm…
beachtom Feb 28, 2025
8d58042
Bump get-intrinsic from 1.2.7 to 1.3.0
dependabot[bot] Mar 3, 2025
79ebfd5
Merge pull request #1307 from ThatOpen/dependabot/npm_and_yarn/electr…
beachtom Mar 4, 2025
dc754f6
Merge pull request #1299 from liradb2000/fix/dabeom/handling_value
beachtom Feb 28, 2025
0467d8b
build(deps-dev): bump electron-to-chromium from 1.5.111 to 1.5.113
dependabot[bot] Mar 7, 2025
3c6cf25
build(deps-dev): bump nwsapi from 2.2.16 to 2.2.18
dependabot[bot] Mar 5, 2025
5af5dc4
build(deps-dev): bump caniuse-lite from 1.0.30001701 to 1.0.30001702
dependabot[bot] Mar 5, 2025
3c0bfd0
build(deps-dev): bump @webgpu/types from 0.1.54 to 0.1.55
dependabot[bot] Mar 5, 2025
24028bd
Merge branch 'main' of https://github.com/ThatOpen/engine_web-ifc int…
ifcapps Mar 1, 2025
51a7bdb
Merge pull request #1 from ThatOpen/main
ifcapps Feb 25, 2025
bb98736
Merge pull request #1305 from ThatOpen/dependabot/npm_and_yarn/get-in…
beachtom Mar 4, 2025
cde0139
Optimalization: Remove copy of RelVoid maps and reserve some vectors
barvirm Mar 1, 2025
5f5d97b
Merge branch 'main' into pr/1301
beachtom Mar 8, 2025
aaf900e
Update benchmark.md
beachtom Mar 8, 2025
91a8e0a
Some Fixes
beachtom Mar 8, 2025
b2931af
Merge branch 'main' into pr/1301
beachtom Mar 8, 2025
4523ed6
Merge pull request #1316 from ThatOpen/dependabot/npm_and_yarn/electr…
beachtom Mar 8, 2025
4368ebd
Fixes
beachtom Mar 8, 2025
4ccfdaa
Merge pull request #1313 from ThatOpen/dependabot/npm_and_yarn/nwsapi…
beachtom Mar 8, 2025
80eec0f
Update IfcGeometryLoader.cpp
beachtom Mar 8, 2025
da4466a
Merge pull request #1311 from ThatOpen/dependabot/npm_and_yarn/canius…
beachtom Mar 8, 2025
e5df4ce
Upgrade GLM
beachtom Mar 8, 2025
47543bd
More Optimisations
beachtom Mar 8, 2025
76774ef
Bump three and @types/three
dependabot[bot] Feb 28, 2025
5763b80
Merge pull request #1310 from ThatOpen/dependabot/npm_and_yarn/webgpu…
beachtom Mar 8, 2025
06490fb
Update CMakeLists.txt
beachtom Mar 8, 2025
205870f
Update benchmark.md
beachtom Mar 8, 2025
7975c07
Update Regression
beachtom Mar 8, 2025
b76ba6e
Update Benchmarks
beachtom Mar 8, 2025
e4a25b8
Update IfcGeometryProcessor.cpp
beachtom Mar 8, 2025
00c8fa2
Final Updates
beachtom Mar 8, 2025
3c5c98c
Merge pull request #1295 from ThatOpen/dependabot/npm_and_yarn/multi-…
beachtom Mar 8, 2025
ab012ff
Update CMakeLists.txt
beachtom Mar 8, 2025
f96c9bc
Merge pull request #1301 from barvirm/main
beachtom Mar 8, 2025
f348f60
build(deps-dev): bump caniuse-lite from 1.0.30001702 to 1.0.30001703
dependabot[bot] Mar 10, 2025
98e4def
Merge pull request #1317 from ThatOpen/upgrade-GLM
beachtom Mar 8, 2025
cc2fbbc
build(deps-dev): bump @types/node from 22.13.9 to 22.13.10
dependabot[bot] Mar 10, 2025
b499f9a
Merge pull request #1319 from ThatOpen/dependabot/npm_and_yarn/canius…
beachtom Mar 10, 2025
5fa1b8f
Merge pull request #1318 from ThatOpen/dependabot/npm_and_yarn/types/…
beachtom Mar 10, 2025
a8281bf
in VectorToAngle: add check for zero, to avoid inf values in mesh
ifcapps Feb 25, 2025
7500000
replace deprecated std::wstring_convert, close shape in Extrude()
ifcapps Feb 18, 2025
8f1a92f
In Extrude(), check if first point is equal to last point, otherwise …
ifcapps Feb 18, 2025
6ff0475
add tabs to make diff cleaner
ifcapps Feb 18, 2025
d247974
enable polylines as mesh for IFCGRID. add bounds checks
ifcapps Feb 18, 2025
23a8fce
make scaling mehses optional
ifcapps Feb 18, 2025
70d9462
t push origin mainMerge branch 'ThatOpen-main'
ifcapps Mar 1, 2025
06f8fe7
Merge branch 'ThatOpen:main' into main
ifcapps Mar 5, 2025
fa0679e
adjustable number of output curve points in BSpline curves
ifcapps Mar 6, 2025
a0f88df
IfcLoader::SaveFile: option to order the STEP lines
ifcapps Mar 6, 2025
fa6dfc1
complete IFCAXIS2PLACEMENTLINEAR
ifcapps Mar 6, 2025
cae90ff
disable TriangulateCylindricalSurface
ifcapps Mar 6, 2025
1f2d00b
add IFCPOLYNOMIALCURVE in IfcGeometryLoader::ComputeCurve
ifcapps Mar 6, 2025
fb0abca
add IFCTOPOLOGYREPRESENTATION, add IFCFACESURFACE, IFCEDGE and IFCCAR…
ifcapps Feb 28, 2025
74d0677
add IFCCLOTHOID, add double IfcGeometryLoader::ReadCurveMeasureSelect…
ifcapps Mar 10, 2025
b038cef
Merge branch 'ThatOpen:main' into main
ifcapps Mar 10, 2025
c9f2f5b
add IFCCOMPOSITECURVE in IfcGeometryProcessor::GetMesh
ifcapps Mar 11, 2025
e1a1747
complete implementation in SectionedSurface
ifcapps Mar 12, 2025
f714555
complete SectionedSurface
ifcapps Mar 12, 2025
11a2216
fix IFCCLOTHOID curve computation
ifcapps Mar 12, 2025
699d5f8
add argument orderLinesByExpressID in SaveFile
ifcapps Mar 13, 2025
0f7238a
Restore color of geometric items after flatten() and BoolProcess()
ifcapps Mar 18, 2025
cf9cfd2
Add check for nan in Nurbs. Add check for IfcTokenType::LINE_END in I…
ifcapps Mar 18, 2025
a832ccf
replace map.contains with find, to be able to compile with C++ 17
ifcapps Mar 27, 2025
6c5b3bf
add test script "regression-save-glb"
ifcapps Mar 27, 2025
85b2abe
Merge branch 'new-main' into develop
mmilian Mar 27, 2025
be02d86
exclude polygons during triangle mesh export
ifcapps Mar 28, 2025
e48c8d5
Merge pull request #5 from Creoox/main
ifcapps Mar 29, 2025
a5b00f7
remove duplicate of bool equals(glm::dvec3 A, glm::dvec3 B, double ep…
ifcapps Apr 4, 2025
5084601
merge
ifcapps Apr 10, 2025
a32ae15
Add option to export polylines as geometry
ifcapps Apr 11, 2025
e4a1e1e
fix bug in void Geometry::GetCenterExtents(glm::dvec3& center, glm::d…
ifcapps May 5, 2025
7280897
Merge branch 'develop' into new-main
ifcapps May 9, 2025
71c6dcd
Merge pull request #6 from Creoox/new-main
ifcapps May 9, 2025
9df6d23
undo some changes to be in sync with upstream. Redo changes if necessary
ifcapps May 9, 2025
a83d3ff
With flatten() and BoolProcess, the color of sub-items gets lost. Res…
ifcapps May 13, 2025
1e13ce6
In ReadLenghtMeasure(): add type "IFCLENGTHMEASURE"
ifcapps May 23, 2025
35e087c
Fix typo ReadLenghtMeasure -> ReadLengthMeasure
ifcapps May 23, 2025
e9d8ade
Make attributes in IfcGeometryProcessor protected instead of private,…
ifcapps Jun 20, 2025
ab7f4c3
Merge branch 'develop' into main
ifcapps Jun 20, 2025
1adfcca
Merge pull request #7 from Creoox/main
ifcapps Jun 20, 2025
ba53ba2
update GeometryProcessor
ifcapps Jun 20, 2025
3dc36f9
Make attributes in IfcGeometryProcessor protected instead of private,…
ifcapps Jun 20, 2025
75730da
Merge branch 'ThatOpen:main' into develop
ifcapps Jun 20, 2025
2dc4bb2
Pass on hasColor attribute to IfcPlacedGeometry
ifcapps Jun 24, 2025
e98daa5
Merge branch 'develop' of https://github.com/Creoox/engine_web-ifc in…
ifcapps Jun 24, 2025
ce28eb9
GetCircleSegments() in IfcGeometryLoader, remove duplicate _circleSeg…
ifcapps Jun 25, 2025
90dbc4e
IfcGeometryLoader& GetLoader();
ifcapps Jun 26, 2025
8fdfd37
In GeometryProcessor, add schema::IFCRIGHTCIRCULARCYLINDER, and in Ge…
ifcapps Aug 1, 2025
5137a19
GetCircleSegments() in IfcGeometryLoader, remove duplicate _circleSeg…
ifcapps Jun 25, 2025
250cc98
GetCircleSegments() in IfcGeometryLoader, remove duplicate _circleSeg…
ifcapps Jun 25, 2025
c75fa52
Merge branch 'develop' of https://github.com/Creoox/engine_web-ifc in…
ifcapps Aug 1, 2025
00d1859
Merge branch 'develop' into main
mmilian Aug 1, 2025
d67ec55
Merge pull request #9 from Creoox/main
mmilian Aug 1, 2025
862d55a
Add workaround in reading IFCAXIS2PLACEMENT3D, in case position is no…
ifcapps Aug 6, 2025
36dc840
Add bbox test before subtracting voids.
ifcapps Sep 11, 2025
9dd8cb8
Merge branch 'maino' into develop
ifcapps Sep 23, 2025
ed6fba2
fix IfcGeometryLoader.cpp
ifcapps Sep 29, 2025
b2c1c15
Fix/implement IFCSECTIONEDSOLIDHORIZONTAL, IfcClothoid, IfcGradientCu…
ifcapps Sep 29, 2025
92151ab
update
ifcapps Sep 29, 2025
a712e12
const IfcGeometryLoader& IfcGeometryProcessor::GetLoader() const
ifcapps Sep 29, 2025
1319954
Fix/implement IFCSECTIONEDSOLIDHORIZONTAL, IfcClothoid, IfcGradientCu…
ifcapps Sep 30, 2025
57ddf2d
fix IfcGeometryLoader.cpp
ifcapps Sep 29, 2025
5765607
Fix/implement IFCSECTIONEDSOLIDHORIZONTAL, IfcClothoid, IfcGradientCu…
ifcapps Sep 29, 2025
81847ea
Merge branch 'develop' of https://github.com/Creoox/engine_web-ifc in…
ifcapps Sep 30, 2025
6eaca40
add front and back caps in Geometry SectionedSurface(std::vector<std:…
ifcapps Oct 1, 2025
f2d1e4e
Fix bug in profile processing
ifcapps Oct 1, 2025
b336c0e
Merge branch 'develop' into maino
ifcquery Oct 2, 2025
c21ec84
Merge pull request #10 from Creoox/maino
ifcquery Oct 2, 2025
d88a09c
remove eps duplicate definition
ifcapps Oct 2, 2025
8e3fd2c
add check in Geometry::GetCenterExtents
ifcapps Oct 9, 2025
b3870e8
Add additional tests for meshes before CSG operation to avoid problem…
ifcapps Oct 10, 2025
1012a2c
Define _CSG_MAX_NUM_FACES to prevent very long compute times in case…
ifcapps Oct 15, 2025
875983d
Fix bug in IfcCircle trim by point
ifcapps Oct 29, 2025
20a4e1d
Merge branch 'ThatOpen:main' into develop
ifcquery Oct 29, 2025
4ec0453
Increase number of points for circle segments with a small opening angle
ifcapps Oct 29, 2025
8aab941
Revert "Increase number of points for circle segments with a small op…
ifcapps Oct 29, 2025
3e1bf43
For IfcCircle, take over simple solution from upstream: int numPoints…
ifcapps Oct 29, 2025
613f312
In TriangulateBounds, add check if face bound which is declared as OU…
ifcapps Nov 11, 2025
ef83ba1
fix WASM build
ifcapps Nov 11, 2025
79f6d08
In TriangulateBounds, add check if face bound which is declared as OU…
ifcapps Nov 11, 2025
65eb74e
Merge branch 'develop' of https://github.com/Creoox/engine_web-ifc in…
ifcapps Nov 11, 2025
b391a83
Merge branch 'ThatOpen:main' into develop
ifcquery Nov 25, 2025
7be9649
Fix bug with hard coded degree unit for IFCPARAMETERVALUE
ifcapps Nov 26, 2025
2e2a6ff
Merge pull request #11 from ThatOpen/main
ifcquery Dec 18, 2025
c7438b8
Add IFCSPHERE in IfcGeometryProcessor::GetMesh
ifcapps Dec 18, 2025
6d84d02
Merge branch 'ThatOpen:main' into develop
ifcquery Dec 29, 2025
91842b5
Merge remote-tracking branch 'upstream/main' into develop
ifcapps Jan 6, 2026
f857c35
delete regression-save-glb.mjs
ifcapps Jan 6, 2026
4099de5
update package.json to sync with upstream
ifcapps Jan 6, 2026
18abf53
sync yarn.lock with upstream
ifcapps Jan 6, 2026
59e35f8
sync IfcGeometryProcessor partly with upstream
ifcapps Jan 6, 2026
f40c638
sync geometryutils.h with upstream
ifcapps Jan 6, 2026
7345007
sync with upstream
ifcapps Jan 6, 2026
110f50f
sync with upstream
ifcapps Jan 6, 2026
5500d30
npm run regression-update
ifcapps Jan 6, 2026
c4ba007
Merge branch 'main' into develop
beachtom Jan 7, 2026
8f25f7b
Fix
beachtom Jan 7, 2026
9cd60d5
Merge branch 'main' into pr/1767
beachtom Jan 12, 2026
04caf88
Update yarn.lock
beachtom Jan 12, 2026
e8bb7b4
Update results.json
beachtom Jan 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

151 changes: 121 additions & 30 deletions src/cpp/test/dumpToThree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include <fstream>
#include <vector>
#include <string>
#include <sstream>
Expand All @@ -25,7 +26,7 @@ namespace webifc::dump
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DumpCurveToHtml</title>
<title>IFC Geometry Viewer</title>
<style>
body { margin: 0; overflow: hidden; }
canvas { display: block; }
Expand All @@ -47,7 +48,7 @@ namespace webifc::dump
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
controls.screenSpacePanning = true; // Allow panning in XY plane
controls.screenSpacePanning = true;
controls.minDistance = 1;
controls.maxDistance = 500;
controls.mouseButtons = {
Expand All @@ -57,21 +58,34 @@ namespace webifc::dump
};
controls.enablePan = true;
controls.panSpeed = 0.5;
controls.up = new THREE.Vector3(0, 0, 1); // Ensure Z is up for rotations
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
controls.up = new THREE.Vector3(0, 0, 1);

// Lighting setup
const ambientLight = new THREE.AmbientLight(0xffffff, 0.4); // Soft ambient light
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
directionalLight.position.set(1, 1, 1);
scene.add(directionalLight);
const directionalLight1 = new THREE.DirectionalLight(0xffffff, 0.6); // Primary light
directionalLight1.position.set(1, 1, 1).normalize();
scene.add(directionalLight1);
const directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.4); // Secondary light to reduce shadows
directionalLight2.position.set(-1, -1, 1).normalize();
scene.add(directionalLight2);

const objData = "{}";
const blackMaterial = new THREE.LineBasicMaterial({ color: 0x000000, linewidth: 2 });
const grayMaterial = new THREE.LineBasicMaterial({ color: 0x888888, linewidth: 2 });
const meshMaterial = new THREE.MeshStandardMaterial({
color: 0x888888,
roughness: 0.7,
metalness: 0.1,
side: THREE.DoubleSide ,
opacity: 0.7
});
const lineMaterial = new THREE.LineBasicMaterial({ color: 0x000000, linewidth: 2 });
const edgeMaterial = new THREE.LineBasicMaterial({ color: 0x333333, linewidth: 2 });

// Parse OBJ data manually to create individual line segments
// Parse OBJ data for vertices, lines, and faces
function parseOBJ(objText) {
const vertices = [];
const lines = [];
const faces = [];
const linesArray = objText.split('\n');
linesArray.forEach(line => {
line = line.trim();
Expand All @@ -80,37 +94,70 @@ namespace webifc::dump
vertices.push(new THREE.Vector3(parts[0], parts[1], parts[2]));
} else if (line.startsWith('l ')) {
const indices = line.split(/\s+/).slice(1).map(i => parseInt(i) - 1);
lines.push(indices);
if (indices.length >= 2) {
lines.push(indices);
}
} else if (line.startsWith('f ')) {
const indices = line.split(/\s+/).slice(1).map(part => parseInt(part.split('/')[0]) - 1);
if (indices.length >= 3) {
faces.push(indices.slice(0, 3)); // Only triangles
}
}
});
return { vertices, lines };
return { vertices, lines, faces };
}

// Create individual Line objects for each segment
const { vertices, lines } = parseOBJ(objData);
// Create mesh if faces exist
const { vertices, lines, faces } = parseOBJ(objData);
if (faces.length > 0) {
const geometry = new THREE.BufferGeometry();
const positions = new Float32Array(vertices.length * 3);
const indices = new Uint32Array(faces.length * 3);
vertices.forEach((v, i) => {
positions[i * 3] = v.x;
positions[i * 3 + 1] = v.y;
positions[i * 3 + 2] = v.z;
});
faces.forEach((f, i) => {
indices[i * 3] = f[0];
indices[i * 3 + 1] = f[1];
indices[i * 3 + 2] = f[2];
});
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
geometry.setIndex(new THREE.BufferAttribute(indices, 1));
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, meshMaterial);
scene.add(mesh);

// Add wireframe lines for triangle edges
const edges = new THREE.EdgesGeometry(geometry, 1); // Threshold angle of 1 degree
const edgeLines = new THREE.LineSegments(edges, edgeMaterial);
scene.add(edgeLines);
}

// Create lines if lines exist
lines.forEach((lineIndices, index) => {
const geometry = new THREE.BufferGeometry().setFromPoints([
vertices[lineIndices[0]],
vertices[lineIndices[1]]
]);
const material = (index % 2 === 0) ? blackMaterial : grayMaterial;
const line = new THREE.Line(geometry, material);
const line = new THREE.Line(geometry, lineMaterial);
scene.add(line);
});

// Compute bounding box from vertices
// Compute bounding box
const box = new THREE.Box3();
vertices.forEach(vertex => box.expandByPoint(vertex));
const minPoint = box.min;
const center = box.getCenter(new THREE.Vector3());

// Add XY grid (10x10 lines, 10m spacing, 100x100m total) in XY plane at Z=0, positioned at minPoint
// Add XY grid (100x100m, 10m spacing) at Z=min
const grid = new THREE.GridHelper(100, 10, 0x888888, 0x888888);
grid.rotation.x = -Math.PI / 2; // Rotate grid to lie in XY plane with Z up
grid.position.set(minPoint.x, minPoint.y, minPoint.z); // Position at min point
grid.rotation.x = -Math.PI / 2;
grid.position.set(minPoint.x, minPoint.y, minPoint.z);
scene.add(grid);

// Add coordinate axes (X: red, Y: green, Z: blue, 200m length), positioned at minPoint
// Add coordinate axes (X: red, Y: green, Z: blue, 200m length)
const axesGroup = new THREE.Group();
axesGroup.position.set(minPoint.x, minPoint.y, minPoint.z);
const axesMaterialX = new THREE.LineBasicMaterial({ color: 0xff0000 });
Expand All @@ -133,13 +180,24 @@ namespace webifc::dump
axesGroup.add(zAxis);
scene.add(axesGroup);

// Zoom to the bounding box
// Zoom to bounding box
const size = box.getSize(new THREE.Vector3());
const maxDim = Math.max(size.x, size.y, size.z);
let maxDim = Math.max(size.x, size.y, size.z);
if (maxDim < 0.0001) {
maxDim = 1; // Prevent division by zero
}
const aspect = window.innerWidth / window.innerHeight;
const fov = camera.fov * (Math.PI / 180);
let cameraDistance = maxDim / Math.tan(fov / 2);
const fovHorizontal = 2 * Math.atan(Math.tan(fov / 2) * aspect);
const maxDimHorizontal = Math.max(size.x, size.y);
let cameraDistance = Math.max(
maxDim / Math.tan(fov / 2),
maxDimHorizontal / Math.tan(fovHorizontal / 2)
);
cameraDistance *= 1.1; // Padding
camera.position.set(center.x, center.y, center.z + cameraDistance);
cameraDistance = Math.max(cameraDistance, camera.near * 1.1);
const offset = cameraDistance / Math.sqrt(3);
camera.position.set(center.x + offset, center.y + offset, center.z + offset);
camera.lookAt(center);
controls.target.copy(center);

Expand Down Expand Up @@ -464,7 +522,7 @@ namespace webifc::dump
return obj.str();
}

inline std::string ToObjThree(const webifc::geometry::IfcGeometry& geom, size_t& offset, glm::dmat4 transform, double inputScale = 1.0)
inline std::string ToObjThree(const webifc::geometry::IfcGeometry& geom, size_t& offset, const glm::dmat4& transform, double inputScale = 1.0)
{
std::stringstream obj;
double scale = inputScale;
Expand Down Expand Up @@ -521,7 +579,8 @@ namespace webifc::dump
{
size_t offset = 0;
std::ofstream out(path.c_str());
out << ToObjThree(geom, offset, glm::dmat4(1), inputScale);
glm::dmat4 mat(1);
out << ToObjThree(geom, offset, mat, inputScale);
}

inline std::string ToObjThree(webifc::geometry::IfcGeometry& geom, size_t& offset, glm::dmat4 transform = glm::dmat4(1))
Expand All @@ -548,17 +607,49 @@ namespace webifc::dump
std::string complete;
for (auto& geom : mesh.geometries)
{
auto flatGeom = processor.GetGeometry(geom.geometryExpressID);
webifc::geometry::IfcGeometry flatGeom = processor.GetGeometry(geom.geometryExpressID);
glm::dmat4 trans = mat * geom.transformation;
complete += ToObjThree(flatGeom, offset, trans);
}
return complete;
}

inline void DumpIfcGeometryThree(webifc::geometry::IfcGeometry& geom, std::string filename)
// Modified makeThreeJSViewer for IfcGeometry (triangle mesh)
inline std::string makeThreeJSViewer(const std::vector<webifc::geometry::IfcGeometry>& vecGeom, double inputScale = 1.0)
{
std::stringstream obj;
size_t offset = 0;
writeFile(filename, ToObjThree(geom, offset));
glm::dmat4 mat(1);
for (const webifc::geometry::IfcGeometry& geom : vecGeom)
{
obj << ToObjThree(geom, offset, mat, inputScale);
}

// Escape OBJ data for embedding
std::string objData = obj.str();
std::string escapedObjData;
for (char c : objData)
{
if (c == '\n') escapedObjData += "\\n";
else if (c == '"') escapedObjData += "\\\"";
else escapedObjData += c;
}

// Embed in HTML template
std::string html = THREE_JS_VIEWER_TEMPLATE;
size_t pos = html.find(R"({})");
if (pos != std::string::npos)
{
html.replace(pos, 2, escapedObjData);
}

return html;
}

inline void DumpIfcGeometryThree(std::vector<webifc::geometry::IfcGeometry> vecGeom, std::string filename, double epsNormal = 1e-8, double epsDist = 1e-6, double inputScale = 1.0)
{
std::string viewer = makeThreeJSViewer(vecGeom, inputScale);
writeFile(filename, viewer);
}

inline void DumpFlatMeshThree(webifc::geometry::IfcFlatMesh& mesh, webifc::geometry::IfcGeometryProcessor& processor, std::string filename)
Expand Down
17 changes: 9 additions & 8 deletions src/cpp/web-ifc/geometry/IfcGeometryLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,17 @@ namespace webifc::geometry
double length = glm::distance(point1, previousPoint);
sumLength += length;

if (sumLength > maxDistance)
{
break;
}

if (sumLength >= minDistance)
{
glm::dmat4 result = BasisCurve.getPlacementAtDistance(sumLength, IfcCurve::CurvePlacementMode::TangentAsZAxis);
mapPlacements.insert({ sumLength, result });
}

if (sumLength > maxDistance)
{
break;
}

previousPoint = point1;
}

Expand Down Expand Up @@ -2204,7 +2205,8 @@ namespace webifc::geometry
}
}
curve.arcSegments.push_back(curve.points.size());
const int numPointsCurrentArc = _circleSegments;
int numPointsCurrentArc = _circleSegments;
numPointsCurrentArc = std::max(numPointsCurrentArc, 4);
double deltaAngle = openingAngleRad / (numPointsCurrentArc - 1);
double angle = startRad;
std::vector<glm::dvec3> points;
Expand Down Expand Up @@ -2328,8 +2330,6 @@ namespace webifc::geometry
}
break;
}


case schema::IFCGRADIENTCURVE:
{
// IfcGradientCurve -----------------------------------------------------------
Expand Down Expand Up @@ -3488,6 +3488,7 @@ namespace webifc::geometry
for (uint32_t i = 0; i < profile.curve.points.size(); i++)
{
profile.curve.points[i] = transformation * glm::dvec3(profile.curve.points[i].x, profile.curve.points[i].y, 1);
profile.curve.points[i].z = 0;
}
}
else
Expand Down
5 changes: 4 additions & 1 deletion src/cpp/web-ifc/geometry/IfcGeometryProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#if defined(DEBUG_DUMP_SVG) || defined(DUMP_CSG_MESHES)
#include "../../test/io_helpers.h"
#include "../../test/dumpToThree.h"
#endif

#include "IfcGeometryProcessor.h"
Expand Down Expand Up @@ -193,6 +194,7 @@ namespace webifc::geometry

for (auto relVoidExpressID : relVoidsIt->second)
{

IfcComposedMesh voidGeom = GetMesh(relVoidExpressID);
auto flatVoidMesh = flatten(voidGeom, _expressIDToGeometry, normalizeMat);
voidGeoms.insert(voidGeoms.end(), flatVoidMesh.begin(), flatVoidMesh.end());
Expand Down Expand Up @@ -239,6 +241,7 @@ namespace webifc::geometry
{
return mesh;
}

}
else
{
Expand Down Expand Up @@ -453,7 +456,7 @@ namespace webifc::geometry
}

#ifdef DUMP_CSG_MESHES
DumpIfcGeometry(geom, "pbhs.obj");
io::DumpIfcGeometry(geom, "pbhs.obj");
#endif

// TODO: this is getting problematic.....
Expand Down
Loading