Merge remote-tracking branch 'origin/v0.8.0' into ifcviewer-wgpu

This commit is contained in:
Thomas Krijnen
2026-07-09 13:21:39 +02:00
373 changed files with 22411 additions and 4242 deletions
+36 -23
View File
@@ -41,7 +41,16 @@
#include <BRepTools.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <Standard_Version.hxx>
#if OCC_VERSION_HEX >= 0x80000
#include <Standard_Macro.hxx>
#include <TopoDS_Shape.hxx>
#include <NCollection_HSequence.hxx>
#else
#include <TopTools_HSequenceOfShape.hxx>
#endif
#include <TopExp.hxx>
#include <BRepAdaptor_Curve.hxx>
@@ -53,7 +62,6 @@
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <gp_Ax22d.hxx>
#include <Standard_Version.hxx>
#include <GeomAPI.hxx>
#include <TopoDS_Wire.hxx>
@@ -275,18 +283,18 @@ void SvgSerializer::write(path_object& p, const TopoDS_Shape& comp_or_wire, std:
Handle(Geom2d_Curve) curve2d;
if (curve.IsNull()) {
TopLoc_Location loc;
Handle_Geom_Surface surf;
opencascade::handle<Geom_Surface> surf;
BRep_Tool::CurveOnSurface(edge, curve2d, surf, loc, u1, u2);
if (curve2d.IsNull()) {
logger::error("Failed to obtain 2d and 3d curve from edge");
logger_.Error("SER", 20, "Failed to obtain 2d and 3d curve from edge");
continue;
}
Handle(Standard_Type) sty = surf->DynamicType();
if (sty != STANDARD_TYPE(Geom_Plane)) {
logger::error("Non-planar p-curves are not supported by this serializer");
logger_.Error("SER", 21, "Non-planar p-curves are not supported by this serializer");
continue;
}
@@ -363,7 +371,7 @@ void SvgSerializer::write(path_object& p, const TopoDS_Shape& comp_or_wire, std:
std::stringstream ss;
ss << "Skipping full circle/ellipse inside aggregated <path> (id "
<< p.first << ")";
logger::warning(ss.str());
logger_.Warning("SER", 22, ss.str());
}
}
@@ -790,7 +798,7 @@ void SvgSerializer::write(const IfcGeom::BRepElement* brep_obj) {
BRepBndLib::AddOBB(compound_unmirrored, *view_box_3d_, false, false, false);
#endif
} else {
logger::error("Failed to box or edge from drawing annotation");
logger_.Error("SER", 23, "Failed to box or edge from drawing annotation");
}
std::vector<string_property> props;
@@ -937,7 +945,7 @@ void SvgSerializer::write(const geometry_data& data) {
if (data.storey) {
section_heights_storage.push_back(horizontal_plan{ data.storey, data.storey_elevation, +1. });
} else {
logger::warning("No global section height and unable to determine building storey for:", data.product);
logger_.Warning("SER", 24, "No global section height and unable to determine building storey for:", data.product);
return;
}
}
@@ -952,7 +960,7 @@ void SvgSerializer::write(const geometry_data& data) {
Bnd_OBB obb;
BRepBndLib::AddOBB(compound_unmirrored, obb, false, false, false);
if (view_box_3d_->IsOut(obb)) {
logger::notice("Not including element due to viewBox", data.product);
logger_.Notice("SER", 25, "Not including element due to viewBox", data.product);
return;
}
}
@@ -999,7 +1007,7 @@ void SvgSerializer::write(const geometry_data& data) {
}
}
} catch (std::exception& e) {
logger::error(e);
logger_.Error("SER", 26, e);
}
if (operation_type && ((*operation_type == "SINGLE_SWING_LEFT") || (*operation_type == "SINGLE_SWING_RIGHT"))) {
@@ -1252,14 +1260,14 @@ void SvgSerializer::write(const geometry_data& data) {
compound_to_hlr = &subtracted_shape;
} catch (...) {
logger::error("Failed to cut element for HLR", data.product);
logger_.Error("SER", 27, "Failed to cut element for HLR", data.product);
}
}
}
TopoDS_Compound profile_edges;
if (profile_threshold_ != -1 && !(data.product.declaration().is("IfcWall") || data.product.declaration().is("IfcSlab"))) {
TopTools_IndexedDataMapOfShapeListOfShape map;
NCollection_IndexedDataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher> map;
TopExp::MapShapesAndAncestors(*compound_to_hlr, TopAbs_EDGE, TopAbs_FACE, map);
if (map.Extent() > profile_threshold_) {
BRep_Builder BB;
@@ -1344,11 +1352,11 @@ void SvgSerializer::write(const geometry_data& data) {
if (storey) {
auto it = storey_hlr.find(storey);
if (it == storey_hlr.end()) {
it = storey_hlr.insert({ storey, hlr_t(use_prefiltering_, use_hlr_poly_, segment_projection_, projection_plane) }).first;
it = storey_hlr.insert({ storey, hlr_t(logger_, use_prefiltering_, use_hlr_poly_, segment_projection_, projection_plane) }).first;
}
it->second.add(*compound_to_hlr, data.product);
} else {
logger::warning("Unable to invoke HLR due to absence of storey containment", data.product);
logger_.Warning("SER", 28, "Unable to invoke HLR due to absence of storey containment", data.product);
}
} else if (hlr) {
hlr->add(*compound_to_hlr, data.product);
@@ -1574,8 +1582,13 @@ void SvgSerializer::write(const geometry_data& data) {
result = make_transform_mirror_.Shape();
}
#if OCC_VERSION_HEX >= 0x80000
opencascade::handle<NCollection_HSequence<TopoDS_Shape>> edges = new NCollection_HSequence<TopoDS_Shape>();
opencascade::handle<NCollection_HSequence<TopoDS_Shape>> wires = new NCollection_HSequence<TopoDS_Shape>();
#else
Handle(TopTools_HSequenceOfShape) edges = new TopTools_HSequenceOfShape();
Handle(TopTools_HSequenceOfShape) wires = new TopTools_HSequenceOfShape();
#endif
{
TopExp_Explorer exp(result, TopAbs_EDGE);
for (; exp.More(); exp.Next()) {
@@ -1821,7 +1834,7 @@ void SvgSerializer::write(const geometry_data& data) {
}
if (!emitted) {
logger::warning("Element not written to SVG due to section heights", data.product);
logger_.Warning("SER", 29, "Element not written to SVG due to section heights", data.product);
}
}
@@ -2001,7 +2014,7 @@ void SvgSerializer::addTextAnnotations(const drawing_key& k) {
auto desc = (std::string) ds;
if (object_type == "Text") {
auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(file, geometry_settings_);
auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(file, geometry_settings_, logger_);
auto item = mapping->map(pl);
auto matrix = ifcopenshell::geometry::taxonomy::cast<ifcopenshell::geometry::taxonomy::matrix4>(item);
delete mapping;
@@ -2204,7 +2217,7 @@ void SvgSerializer::finalize() {
// @todo do we have always have pln here?
if (use_hlr && pln) {
hlr = new hlr_t(use_prefiltering_, use_hlr_poly_, segment_projection_, *pln);
hlr = new hlr_t(logger_, use_prefiltering_, use_hlr_poly_, segment_projection_, *pln);
}
section_data_ = std::vector<section_data>{ sd };
@@ -2466,7 +2479,7 @@ void SvgSerializer::setFile(ifcopenshell::file* f) {
auto storeys = f->instances_by_type("IfcBuildingStorey");
if (storeys.empty()) {
auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(file, geometry_settings_);
auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(file, geometry_settings_, logger_);
std::vector<const ifcopenshell::declaration*> to_derive_from;
to_derive_from.push_back(f->schema()->declaration_by_name("IfcBuilding"));
@@ -2485,9 +2498,9 @@ void SvgSerializer::setFile(ifcopenshell::file* f) {
#ifdef TAXONOMY_USE_NAKED_PTR
delete matrix;
#endif
logger::warning("No building storeys encountered, used for reference:", product);
apply_section_heights_from_storeys();
return;
logger_.Warning("SER", 30, "No building storeys encountered, used for reference:", product);
return;
}
}
}
}
@@ -2495,7 +2508,7 @@ void SvgSerializer::setFile(ifcopenshell::file* f) {
delete mapping;
logger::warning("No building storeys encountered, output might be invalid or missing");
logger_.Warning("SER", 31, "No building storeys encountered, output might be invalid or missing");
}
apply_section_heights_from_storeys();
@@ -2508,7 +2521,7 @@ void SvgSerializer::setSectionHeight(double h, express::Base storey) {
void SvgSerializer::setSectionHeightsFromStoreys(double offset) {
if (!file) {
logger::error("No file specified");
logger_.Error("SER", 32, "No file specified");
return;
}
with_section_heights_from_storey_ = true;
@@ -2523,7 +2536,7 @@ void SvgSerializer::setSectionHeightsFromStoreys(double offset) {
try {
elev = attr_value;
} catch (std::exception& e) {
logger::error(e);
logger_.Error("SER", 33, e);
continue;
}
if (!section_data_->empty()) {