Skip to content

Commit 25acec6

Browse files
authored
Merge pull request #1377 from ThatOpen/bimGeometry
Bim geometry
2 parents 4cafdfe + 66b62ff commit 25acec6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2507
-1320
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@
109109
"__node_handle": "cpp",
110110
"__split_buffer": "cpp",
111111
"__threading_support": "cpp",
112-
"__verbose_abort": "cpp"
112+
"__verbose_abort": "cpp",
113+
"coroutine": "cpp",
114+
"expected": "cpp",
115+
"source_location": "cpp"
113116
},
114117
"cmake.configureOnOpen": true,
115118
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",

src/cpp/test/io_helpers.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,19 @@ namespace webifc::io
443443

444444
for (uint32_t ia = 0; ia < geom.size(); ia++)
445445
{
446-
for (uint32_t ic = 0; ic < geom[ia].Vertical.curves.size(); ic++)
446+
if(geom[ia].Vertical.curves.size() > 0)
447447
{
448-
for (uint32_t ip = 0; ip < geom[ia].Vertical.curves[ic].points.size() - 1; ip++)
448+
for (uint32_t ic = 0; ic < geom[ia].Vertical.curves.size(); ic++)
449449
{
450-
obj << "l " << (idx) << " " << (idx + 1) << "\n";
451-
;
452-
idx++;
450+
if(geom[ia].Vertical.curves[ic].points.size() > 0)
451+
{
452+
for (uint32_t ip = 0; ip < geom[ia].Vertical.curves[ic].points.size() - 1; ip++)
453+
{
454+
obj << "l " << (idx) << " " << (idx + 1) << "\n";
455+
;
456+
idx++;
457+
}
458+
}
453459
}
454460
}
455461
}
@@ -465,10 +471,13 @@ namespace webifc::io
465471
{
466472
for (uint32_t ic = 0; ic < geom[ia].Horizontal.curves.size(); ic++)
467473
{
468-
for (uint32_t ip = 0; ip < geom[ia].Horizontal.curves[ic].points.size(); ip++)
474+
if(geom[ia].Horizontal.curves[ic].points.size() > 0)
469475
{
470-
glm::dvec3 t = glm::dvec4(geom[ia].Horizontal.curves[ic].points[ip].x, geom[ia].Horizontal.curves[ic].points[ip].y, 0, 1);
471-
obj << "v " << t.x << " " << t.y << " " << t.z << "\n";
476+
for (uint32_t ip = 0; ip < geom[ia].Horizontal.curves[ic].points.size(); ip++)
477+
{
478+
glm::dvec3 t = glm::dvec4(geom[ia].Horizontal.curves[ic].points[ip].x, geom[ia].Horizontal.curves[ic].points[ip].y, 0, 1);
479+
obj << "v " << t.x << " " << t.y << " " << t.z << "\n";
480+
}
472481
}
473482
}
474483
}
@@ -479,11 +488,14 @@ namespace webifc::io
479488
{
480489
for (uint32_t ic = 0; ic < geom[ia].Horizontal.curves.size(); ic++)
481490
{
482-
for (uint32_t ip = 0; ip < geom[ia].Horizontal.curves[ic].points.size() - 1; ip++)
491+
if(geom[ia].Horizontal.curves[ic].points.size() > 0)
483492
{
484-
obj << "l " << (idx) << " " << (idx + 1) << "\n";
485-
;
486-
idx++;
493+
for (uint32_t ip = 0; ip < geom[ia].Horizontal.curves[ic].points.size() - 1; ip++)
494+
{
495+
obj << "l " << (idx) << " " << (idx + 1) << "\n";
496+
;
497+
idx++;
498+
}
487499
}
488500
}
489501
}

src/cpp/test/web-ifc-test.cpp

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,31 @@ std::vector<webifc::geometry::IfcAlignment> GetAlignments(webifc::parsing::IfcLo
7373
DumpAlignment(alignments, "V_ALIGN.obj", "H_ALIGN.obj");
7474
}
7575

76+
for (size_t i = 0; i < alignments.size(); i++)
77+
{
78+
webifc::geometry::IfcAlignment alignment = alignments[i];
79+
std::vector<glm::dvec3> pointsH;
80+
std::vector<glm::dvec3> pointsV;
81+
for (size_t j = 0; j < alignment.Horizontal.curves.size(); j++)
82+
{
83+
for (size_t k = 0; k < alignment.Horizontal.curves[j].points.size(); k++)
84+
{
85+
pointsH.push_back(alignment.Horizontal.curves[j].points[k]);
86+
}
87+
}
88+
for (size_t j = 0; j < alignment.Vertical.curves.size(); j++)
89+
{
90+
for (size_t k = 0; k < alignment.Vertical.curves[j].points.size(); k++)
91+
{
92+
pointsV.push_back(alignment.Vertical.curves[j].points[k]);
93+
}
94+
}
95+
webifc::geometry::IfcCurve curve;
96+
curve.points = bimGeometry::Convert2DAlignmentsTo3D(pointsH, pointsV);
97+
alignments[i].Absolute.curves.push_back(curve);
98+
}
99+
100+
76101
return alignments;
77102
}
78103

@@ -275,17 +300,13 @@ std::vector<webifc::geometry::SweptDiskSolid> GetAllRebars(webifc::parsing::IfcL
275300

276301
for (size_t i = 0; i < elements.size(); i++)
277302
{
278-
if(elements[i] == 145645)
279-
{
280-
auto mesh = geometryLoader.GetFlatMesh(elements[i]);
281-
282-
for (auto &geom : mesh.geometries)
283-
{
284-
auto flatGeom = geometryLoader.GetGeometry(geom.geometryExpressID);
303+
auto mesh = geometryLoader.GetFlatMesh(elements[i]);
285304

286-
reinforcingBars.push_back(flatGeom.sweptDiskSolid);
287-
reinforcingBarsTransform.push_back(geom.transformation);
288-
}
305+
for (auto &geom : mesh.geometries)
306+
{
307+
auto flatGeom = geometryLoader.GetGeometry(geom.geometryExpressID);
308+
reinforcingBars.push_back(flatGeom.sweptDiskSolid);
309+
reinforcingBarsTransform.push_back(geom.transformation);
289310
}
290311
}
291312

@@ -437,8 +458,11 @@ int main()
437458

438459
// return 0;
439460

440-
// std::string content = ReadFile("C:/Users/qmoya/Desktop/MODELS/isolated.ifc");
441-
std::string content = ReadFile("C:/Users/qmoya/Desktop/MODELS/m3d.ifc");
461+
// std::string content = ReadFile("C:/Users/qmoya/Desktop/MODELS/VEC-IFC-INST-totaal-20130726.ifc");
462+
// std::string content = ReadFile("C:/Users/qmoya/Desktop/MODELS/15.ifc");
463+
// std::string content = ReadFile("C:/Users/qmoya/Desktop/MODELS/F_MA_160_ALT3.ifc");
464+
// std::string content = ReadFile("C:/Users/qmoya/Desktop/MODELS/1256.ifc");
465+
std::string content = ReadFile("C:/Users/qmoya/Desktop/MODELS/15.ifc");
442466

443467
struct LoaderSettings
444468
{
@@ -477,10 +501,10 @@ int main()
477501

478502
start = ms();
479503

480-
// SpecificLoadTest(loader, geometryLoader, 4553);
504+
SpecificLoadTest(loader, geometryLoader, 211736);
481505
// auto meshes = LoadAllTest(loader, geometryLoader, -1);
482-
auto rebars = GetAllRebars(loader, geometryLoader);
483-
std::cout << GetLine(loader, 225) << std::endl;
506+
// auto rebars = GetAllRebars(loader, geometryLoader);
507+
// std::cout << GetLine(loader, 225) << std::endl;
484508
// auto alignments = GetAlignments(loader, geometryLoader);
485509

486510
time = ms() - start;

src/cpp/wasm/web-ifc-wasm.cpp

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
#include <spdlog/spdlog.h>
1313
#include "../web-ifc/modelmanager/ModelManager.h"
1414
#include "../version.h"
15+
#include "../web-ifc/geometry/operations/bim-geometry/extrusion.h"
16+
#include "../web-ifc/geometry/operations/bim-geometry/sweep.h"
17+
#include "../web-ifc/geometry/operations/bim-geometry/revolution.h"
18+
#include "../web-ifc/geometry/operations/bim-geometry/cylindricalRevolution.h"
19+
#include "../web-ifc/geometry/operations/bim-geometry/parabola.h"
20+
#include "../web-ifc/geometry/operations/bim-geometry/clothoid.h"
21+
#include "../web-ifc/geometry/operations/bim-geometry/arc.h"
22+
#include "../web-ifc/geometry/operations/bim-geometry/alignment.h"
23+
#include "../web-ifc/geometry/operations/bim-geometry/utils.h"
1524

1625
namespace webifc::parsing {
1726
void p21encode(std::string_view input, std::ostringstream &output);
@@ -245,6 +254,30 @@ std::vector<webifc::geometry::IfcAlignment> GetAllAlignments(uint32_t modelID)
245254
alignments.push_back(alignment);
246255
}
247256

257+
for (size_t i = 0; i < alignments.size(); i++)
258+
{
259+
webifc::geometry::IfcAlignment alignment = alignments[i];
260+
std::vector<glm::dvec3> pointsH;
261+
std::vector<glm::dvec3> pointsV;
262+
for (size_t j = 0; j < alignment.Horizontal.curves.size(); j++)
263+
{
264+
for (size_t k = 0; k < alignment.Horizontal.curves[j].points.size(); k++)
265+
{
266+
pointsH.push_back(alignment.Horizontal.curves[j].points[k]);
267+
}
268+
}
269+
for (size_t j = 0; j < alignment.Vertical.curves.size(); j++)
270+
{
271+
for (size_t k = 0; k < alignment.Vertical.curves[j].points.size(); k++)
272+
{
273+
pointsV.push_back(alignment.Vertical.curves[j].points[k]);
274+
}
275+
}
276+
webifc::geometry::IfcCurve curve;
277+
curve.points = bimGeometry::Convert2DAlignmentsTo3D(pointsH, pointsV);
278+
alignments[i].Absolute.curves.push_back(curve);
279+
}
280+
248281
return alignments;
249282
}
250283

@@ -752,6 +785,52 @@ void ResetCache(uint32_t modelID) {
752785
if (manager.IsModelOpen(modelID)) manager.GetGeometryProcessor(modelID)->GetLoader().ResetCache();
753786
}
754787

788+
bimGeometry::AABB CreateAABB()
789+
{
790+
return bimGeometry::AABB();
791+
}
792+
793+
bimGeometry::Extrusion CreateExtrusion()
794+
{
795+
return bimGeometry::Extrusion();
796+
}
797+
798+
bimGeometry::Sweep CreateSweep()
799+
{
800+
return bimGeometry::Sweep();
801+
}
802+
803+
bimGeometry::Revolve CreateRevolution()
804+
{
805+
return bimGeometry::Revolve();
806+
}
807+
808+
bimGeometry::CylindricalRevolution CreateCylindricalRevolution()
809+
{
810+
return bimGeometry::CylindricalRevolution();
811+
}
812+
813+
bimGeometry::Parabola CreateParabola()
814+
{
815+
return bimGeometry::Parabola();
816+
}
817+
818+
bimGeometry::Clothoid CreateClothoid()
819+
{
820+
return bimGeometry::Clothoid();
821+
}
822+
823+
bimGeometry::Arc CreateArc()
824+
{
825+
return bimGeometry::Arc();
826+
}
827+
828+
bimGeometry::Alignment CreateAlignment()
829+
{
830+
return bimGeometry::Alignment();
831+
}
832+
833+
755834
EMSCRIPTEN_BINDINGS(my_module) {
756835

757836
emscripten::class_<webifc::geometry::IfcGeometry>("IfcGeometry")
@@ -832,7 +911,8 @@ EMSCRIPTEN_BINDINGS(my_module) {
832911

833912
emscripten::value_object<webifc::geometry::IfcAlignment>("IfcAlignment")
834913
.field("Horizontal", &webifc::geometry::IfcAlignment::Horizontal)
835-
.field("Vertical", &webifc::geometry::IfcAlignment::Vertical);
914+
.field("Vertical", &webifc::geometry::IfcAlignment::Vertical)
915+
.field("Absolute", &webifc::geometry::IfcAlignment::Absolute);
836916

837917
emscripten::value_object<glm::dvec3>("glmDvec3")
838918
.field("x", &glm::dvec3::x)
@@ -868,6 +948,79 @@ EMSCRIPTEN_BINDINGS(my_module) {
868948

869949
emscripten::register_vector<double>("DoubleVector");
870950

951+
//bimGeometry
952+
953+
emscripten::value_object<bimGeometry::Buffers>("Buffers")
954+
.field("fvertexData", &bimGeometry::Buffers::fvertexData)
955+
.field("indexData", &bimGeometry::Buffers::indexData)
956+
;
957+
958+
emscripten::register_vector<float>("vector<float>");
959+
960+
emscripten::class_<bimGeometry::AABB>("AABB")
961+
.constructor<>()
962+
.function("GetBuffers", &bimGeometry::AABB::GetBuffers)
963+
.function("SetValues", &bimGeometry::AABB::SetValues)
964+
;
965+
966+
967+
emscripten::class_<bimGeometry::Extrusion>("Extrusion")
968+
.constructor<>()
969+
.function("GetBuffers", &bimGeometry::Extrusion::GetBuffers)
970+
.function("SetValues", &bimGeometry::Extrusion::SetValues)
971+
;
972+
973+
emscripten::class_<bimGeometry::Sweep>("Sweep")
974+
.constructor<>()
975+
.function("GetBuffers", &bimGeometry::Sweep::GetBuffers)
976+
.function("SetValues", &bimGeometry::Sweep::SetValues)
977+
;
978+
979+
emscripten::class_<bimGeometry::Revolve>("Revolution")
980+
.constructor<>()
981+
.function("GetBuffers", &bimGeometry::Revolve::GetBuffers)
982+
.function("SetValues", &bimGeometry::Revolve::SetValues)
983+
;
984+
985+
emscripten::class_<bimGeometry::CylindricalRevolution>("CylindricalRevolution")
986+
.constructor<>()
987+
.function("GetBuffers", &bimGeometry::CylindricalRevolution::GetBuffers)
988+
.function("SetValues", &bimGeometry::CylindricalRevolution::SetValues)
989+
;
990+
991+
emscripten::class_<bimGeometry::Parabola>("Parabola")
992+
.constructor<>()
993+
.function("GetBuffers", &bimGeometry::Parabola::GetBuffers)
994+
.function("SetValues", &bimGeometry::Parabola::SetValues)
995+
;
996+
997+
emscripten::class_<bimGeometry::Clothoid>("Clothoid")
998+
.constructor<>()
999+
.function("GetBuffers", &bimGeometry::Clothoid::GetBuffers)
1000+
.function("SetValues", &bimGeometry::Clothoid::SetValues)
1001+
;
1002+
1003+
emscripten::class_<bimGeometry::Arc>("Arc")
1004+
.constructor<>()
1005+
.function("GetBuffers", &bimGeometry::Arc::GetBuffers)
1006+
.function("SetValues", &bimGeometry::Arc::SetValues)
1007+
;
1008+
1009+
emscripten::class_<bimGeometry::Alignment>("Alignment")
1010+
.constructor<>()
1011+
.function("GetBuffers", &bimGeometry::Alignment::GetBuffers)
1012+
.function("SetValues", &bimGeometry::Alignment::SetValues)
1013+
;
1014+
1015+
emscripten::function("CreateAABB", &CreateAABB);
1016+
emscripten::function("CreateExtrusion", &CreateExtrusion);
1017+
emscripten::function("CreateSweep", &CreateSweep);
1018+
emscripten::function("CreateRevolution", &CreateRevolution);
1019+
emscripten::function("CreateCylindricalRevolution", &CreateCylindricalRevolution);
1020+
emscripten::function("CreateParabola", &CreateParabola);
1021+
emscripten::function("CreateClothoid", &CreateClothoid);
1022+
emscripten::function("CreateArc", &CreateArc);
1023+
emscripten::function("CreateAlignment", &CreateAlignment);
8711024
emscripten::function("LoadAllGeometry", &LoadAllGeometry);
8721025
emscripten::function("GetAllCrossSections", &GetAllCrossSections);
8731026
emscripten::function("GetAllAlignments", &GetAllAlignments);

0 commit comments

Comments
 (0)