From 561a23cfbcc30bc4df085a0502ab1f895c038f40 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 9 Jul 2026 13:30:48 +0200 Subject: [PATCH] After-merge clean-ups --- cmake/CMakeLists.txt | 1 + src/examples/CMakeLists.txt | 14 -- src/examples/IfcAdvancedHouse.cpp | 7 +- src/examples/IfcOpenHouse.cpp | 7 +- src/examples/IfcParseExamples.cpp | 151 +++++--------- src/examples/arbitrary_open_profile_def.cpp | 6 +- src/examples/composite_profile_def.cpp | 6 +- src/examples/csg_primitive.cpp | 6 +- src/examples/ellipse_pies.cpp | 6 +- src/examples/faces.cpp | 6 +- src/examples/ifc_curve_rebar.cpp | 8 +- src/examples/profiles.cpp | 6 +- src/examples/triangulated_faceset.cpp | 6 +- src/ifcconvert/IfcConvert.cpp | 112 +++++----- src/ifcconvert/validate_space_boundaries.cpp | 10 +- .../validate_storey_containment.cpp | 10 +- src/ifcconvert/validate_wall_connectivity.cpp | 10 +- src/ifcconvert/validation_utils.h | 8 +- src/ifcgeom/AbstractKernel.cpp | 6 +- src/ifcgeom/AbstractKernel.h | 20 +- src/ifcgeom/ConversionResult.cpp | 2 +- src/ifcgeom/ConversionResult.h | 31 +-- src/ifcgeom/Converter.cpp | 36 ++-- src/ifcgeom/Converter.h | 6 +- src/ifcgeom/GeometrySerializer.h | 4 +- src/ifcgeom/IfcGeomElement.h | 2 +- src/ifcgeom/Iterator.cpp | 78 +++---- src/ifcgeom/Iterator.h | 14 +- .../Serialization/schema/Serialization.cpp | 6 +- src/ifcgeom/Serializer.h | 6 +- src/ifcgeom/abstract_mapping.cpp | 28 +-- src/ifcgeom/abstract_mapping.h | 12 +- src/ifcgeom/function_item_evaluator.cpp | 6 +- src/ifcgeom/function_item_evaluator.h | 8 +- src/ifcgeom/hybrid_kernel.h | 4 +- src/ifcgeom/infra_sweep_helper.cpp | 26 +-- src/ifcgeom/infra_sweep_helper.h | 2 +- .../kernels/cgal/CgalConversionResult.cpp | 20 +- .../kernels/cgal/CgalConversionResult.h | 13 +- src/ifcgeom/kernels/cgal/CgalKernel.cpp | 110 +++++----- src/ifcgeom/kernels/cgal/CgalKernel.h | 14 +- .../manifold/ManifoldConversionResult.cpp | 31 ++- .../manifold/ManifoldConversionResult.h | 12 +- .../kernels/manifold/ManifoldKernel.cpp | 46 ++--- src/ifcgeom/kernels/manifold/ManifoldKernel.h | 8 +- .../OpenCascadeConversionResult.cpp | 10 +- .../opencascade/OpenCascadeConversionResult.h | 10 +- .../kernels/opencascade/OpenCascadeKernel.cpp | 72 +++---- .../kernels/opencascade/OpenCascadeKernel.h | 4 +- .../kernels/opencascade/base_utils.cpp | 26 +-- .../kernels/opencascade/boolean_result.cpp | 6 +- .../kernels/opencascade/boolean_utils.cpp | 72 +++---- src/ifcgeom/kernels/opencascade/extrusion.cpp | 4 +- src/ifcgeom/kernels/opencascade/face.cpp | 30 +-- .../kernels/opencascade/faceset_helper.cpp | 13 +- src/ifcgeom/kernels/opencascade/layerset.cpp | 12 +- src/ifcgeom/kernels/opencascade/loft.cpp | 27 ++- src/ifcgeom/kernels/opencascade/loop.cpp | 8 +- src/ifcgeom/kernels/opencascade/shell.cpp | 14 +- src/ifcgeom/kernels/opencascade/solid.cpp | 2 +- .../kernels/opencascade/sweep_along_curve.cpp | 6 +- .../kernels/opencascade/sweep_utils.cpp | 4 +- .../kernels/opencascade/wire_builder.cpp | 20 +- .../kernels/opencascade/wire_utils.cpp | 34 +-- .../PassthroughConversionResult.cpp | 30 +-- .../passthrough/PassthroughConversionResult.h | 12 +- .../kernels/passthrough/PassthroughKernel.h | 8 +- src/ifcgeom/mapping/IfcAxis1Placement.cpp | 2 +- src/ifcgeom/mapping/IfcAxis2Placement2D.cpp | 2 +- src/ifcgeom/mapping/IfcAxis2Placement3D.cpp | 4 +- .../mapping/IfcAxis2PlacementLinear.cpp | 4 +- src/ifcgeom/mapping/IfcCShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcCircle.cpp | 2 +- src/ifcgeom/mapping/IfcCompositeCurve.cpp | 18 +- src/ifcgeom/mapping/IfcCurveSegment.cpp | 38 ++-- src/ifcgeom/mapping/IfcEdge.cpp | 4 +- src/ifcgeom/mapping/IfcEllipse.cpp | 2 +- src/ifcgeom/mapping/IfcEllipseProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcExtrudedAreaSolid.cpp | 2 +- .../mapping/IfcExtrudedAreaSolidTapered.cpp | 2 +- .../IfcFixedReferenceSweptAreaSolid.cpp | 2 +- src/ifcgeom/mapping/IfcGradientCurve.cpp | 8 +- src/ifcgeom/mapping/IfcHalfSpaceSolid.cpp | 2 +- src/ifcgeom/mapping/IfcIShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp | 2 +- src/ifcgeom/mapping/IfcLShapeProfileDef.cpp | 4 +- src/ifcgeom/mapping/IfcObjectPlacement.cpp | 10 +- .../mapping/IfcOffsetCurveByDistance.cpp | 8 +- .../mapping/IfcOpenCrossProfileDef.cpp | 4 +- src/ifcgeom/mapping/IfcPolyLoop.cpp | 8 +- src/ifcgeom/mapping/IfcPolyline.cpp | 4 +- .../mapping/IfcRectangleHollowProfileDef.cpp | 2 +- .../mapping/IfcRectangleProfileDef.cpp | 2 +- .../mapping/IfcRectangularTrimmedSurface.cpp | 2 +- src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp | 2 +- .../mapping/IfcRoundedRectangleProfileDef.cpp | 2 +- .../mapping/IfcSectionedSolidHorizontal.cpp | 6 +- src/ifcgeom/mapping/IfcSectionedSurface.cpp | 6 +- .../mapping/IfcSegmentedReferenceCurve.cpp | 8 +- .../mapping/IfcSurfaceCurveSweptAreaSolid.cpp | 6 +- src/ifcgeom/mapping/IfcSweptDiskSolid.cpp | 14 +- src/ifcgeom/mapping/IfcTShapeProfileDef.cpp | 4 +- .../mapping/IfcTrapeziumProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcTrimmedCurve.cpp | 6 +- src/ifcgeom/mapping/IfcUShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcZShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/mapping.cpp | 66 +++--- src/ifcgeom/mapping/mapping.h | 12 +- src/ifcgeom/mapping/plugin.cpp | 4 +- src/ifcgeom/profile_helper.cpp | 2 +- src/ifcgeom/taxonomy.cpp | 6 +- src/ifcgeomserver/IfcGeomServer.cpp | 4 +- src/ifcparse/alignment_helper.cpp | 26 +-- src/ifcparse/alignment_helper.h | 8 +- src/ifcparse/character_decoder.cpp | 11 +- src/ifcparse/character_decoder.h | 4 +- src/ifcparse/entity_instance_data.cpp | 9 +- src/ifcparse/file.h | 26 +-- src/ifcparse/global_id.cpp | 8 +- src/ifcparse/global_id.h | 6 +- src/ifcparse/hierarchy_helper.h | 4 +- src/ifcparse/hierarchy_helper.i | 2 +- src/ifcparse/instance_data.h | 18 +- src/ifcparse/logger.cpp | 163 ++++++++------- src/ifcparse/logger.h | 65 +++--- src/ifcparse/parse.cpp | 193 ++++++++++-------- src/ifcparse/parse.h | 4 +- src/ifcparse/spf_header.cpp | 14 +- src/ifcparse/spf_header.h | 13 +- src/ifcparse/storage.h | 11 +- src/ifcparse/utils.cpp | 4 +- src/ifcwrap/IfcGeomWrapper.i | 106 ++++++---- src/ifcwrap/IfcParseWrapper.i | 31 +-- src/serializers/CMakeLists.txt | 2 - src/serializers/ColladaSerializer.h | 2 +- src/serializers/GltfSerializer.cpp | 12 +- src/serializers/GltfSerializer.h | 2 +- src/serializers/IgesSerializer.h | 4 +- src/serializers/JsonSerializer.h | 2 +- src/serializers/OpenCascadeBasedSerializer.h | 2 +- src/serializers/RocksDbSerializer.cpp | 2 +- src/serializers/RocksDbSerializer.h | 2 +- src/serializers/StepSerializer.h | 2 +- src/serializers/SvgSerializer.cpp | 40 ++-- src/serializers/SvgSerializer.h | 10 +- src/serializers/TtlWktSerializer.cpp | 6 +- src/serializers/TtlWktSerializer.h | 2 +- src/serializers/USDSerializer.cpp | 2 +- src/serializers/USDSerializer.h | 2 +- src/serializers/WavefrontObjSerializer.cpp | 2 +- src/serializers/WavefrontObjSerializer.h | 2 +- src/serializers/XmlSerializer.h | 2 +- .../document_serializer_plugin.cpp | 6 +- .../geometry_serializer_plugin.cpp | 6 +- .../schema_dependent/CMakeLists.txt | 1 - .../schema_dependent/JsonSerializer.cpp | 49 +++-- .../schema_dependent/JsonSerializer.h | 2 +- .../schema_dependent/XmlSerializer.cpp | 161 +++++++-------- .../schema_dependent/XmlSerializer.h | 2 +- src/svgfill/CMakeLists.txt | 2 +- src/svgfill/src/arrange_polygons.cpp | 60 +++--- .../src/linework_processing_facade.cpp | 5 +- src/svgfill/src/linework_processing_plugin.h | 2 +- src/svgfill/src/svgfill.h | 4 +- 164 files changed, 1373 insertions(+), 1406 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b4b1f6011c..aca5cb63c8 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -298,6 +298,7 @@ if (WITH_ROCKSDB) message(STATUS "RocksDB: found at '${RocksDB_DIR}'.") add_library(IFCOPENSHELL_RocksDB INTERFACE) + set(IFCOPENSHELL_ROCKSDB_TARGET IFCOPENSHELL_RocksDB) set(ROCKSDB_LIBRARIES "IFCOPENSHELL_RocksDB") target_compile_definitions(IFCOPENSHELL_RocksDB INTERFACE IFOPSH_WITH_ROCKSDB) set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB) diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 2f2c3ca2d7..b0e9ef78e4 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -81,22 +81,8 @@ macro(build_schema_example exe_name schema) endif() endmacro() -if("4" IN_LIST SCHEMA_VERSIONS) - build_schema_example(arbitrary_open_profile_def 4) - build_schema_example(triangulated_faceset 4) -endif() - if("2x3" IN_LIST SCHEMA_VERSIONS) - build_schema_example(composite_profile_def 2x3) - build_schema_example(csg_primitive 2x3) - build_schema_example(ellipse_pies 2x3) - build_schema_example(faces 2x3) - build_schema_example(ifc_curve_rebar 2x3) - build_schema_example(profiles 2x3) - build_schema_example(IfcParseExamples 2x3 helpers) - if(WITH_OPENCASCADE) - build_schema_example(IfcOpenHouse 2x3 geometry_serializer) build_schema_example(IfcAdvancedHouse 2x3 geometry_serializer) endif() endif() diff --git a/src/examples/IfcAdvancedHouse.cpp b/src/examples/IfcAdvancedHouse.cpp index 86891d373f..a07ed94ed9 100644 --- a/src/examples/IfcAdvancedHouse.cpp +++ b/src/examples/IfcAdvancedHouse.cpp @@ -44,11 +44,10 @@ #define IfcSchema Ifc2x3 #endif -#include INCLUDE_SCHEMA(ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) -#include "ifcparse/IfcBaseClass.h" -#include "ifcparse/IfcHierarchyHelper.h" +#include "ifcparse/hierarchy_helper.h" #include "../ifcgeom/Serialization/Serialization.h" diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index 723b78dc6a..9a8c5e44bb 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -41,11 +41,10 @@ #define IfcSchema Ifc2x3 #endif -#include INCLUDE_SCHEMA(ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) -#include "ifcparse/IfcBaseClass.h" -#include "ifcparse/IfcHierarchyHelper.h" +#include "ifcparse/hierarchy_helper.h" #include "../ifcgeom/Serialization/Serialization.h" diff --git a/src/examples/IfcParseExamples.cpp b/src/examples/IfcParseExamples.cpp index e9fb936352..0fb1f02c8e 100644 --- a/src/examples/IfcParseExamples.cpp +++ b/src/examples/IfcParseExamples.cpp @@ -23,50 +23,16 @@ #define IfcSchema Ifc2x3 #endif -#include "ifcparse/IfcFile.h" -#include "ifcparse/IfcLogger.h" +#include "ifcparse/file.h" +#include "ifcparse/logger.h" -#include -#include -#include -#include -#include -#include +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) #ifdef _MSC_VER #define strcasecmp _stricmp #endif -#ifndef SCHEMA_SEQ -static_assert(false, "A boost preprocessor sequence of schema identifiers is needed for this file to compile."); -#endif - -// A macro cannot expand to an include directive, so unroll enough includes for -// the maximum number of schemas supported by the build configuration. -#define INCLUDE_SCHEMA_N(n) \ - BOOST_PP_IIF(BOOST_PP_GREATER(BOOST_PP_SEQ_SIZE(SCHEMA_SEQ), n), \ - BOOST_PP_STRINGIZE(ifcparse/BOOST_PP_CAT(Ifc, BOOST_PP_SEQ_ELEM(BOOST_PP_MIN(n, BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_POP_BACK(SCHEMA_SEQ))), SCHEMA_SEQ)).h), \ - "ifcgeom/empty.h") - -#include INCLUDE_SCHEMA_N(0) -#include INCLUDE_SCHEMA_N(1) -#include INCLUDE_SCHEMA_N(2) -#include INCLUDE_SCHEMA_N(3) -#include INCLUDE_SCHEMA_N(4) -#include INCLUDE_SCHEMA_N(5) -#include INCLUDE_SCHEMA_N(6) -#include INCLUDE_SCHEMA_N(7) -#include INCLUDE_SCHEMA_N(8) -#include INCLUDE_SCHEMA_N(9) -#include INCLUDE_SCHEMA_N(10) -#include INCLUDE_SCHEMA_N(11) -#include INCLUDE_SCHEMA_N(12) -#include INCLUDE_SCHEMA_N(13) -#include INCLUDE_SCHEMA_N(14) -#include INCLUDE_SCHEMA_N(15) - -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/, IfcSchema) - #include #if USE_VLD @@ -121,117 +87,104 @@ std::string format_string(const AttributeValue& argument) { } template -void process_pset(element_properties& props, const T* inst) { +void process_pset(element_properties& props, const T& inst) { // Process an individual Property or Quantity set. - if (auto pset = inst->template as()) { - if (!pset->Name()) { + if (auto pset = inst.template as()) { + if (!pset.Name()) { return; } - auto ps = pset->HasProperties(); - for (auto it = ps->begin(); it != ps->end(); ++it) { - auto& p = *it; - if (auto singleval = p->template as()) { + auto ps = pset.HasProperties(); + for (const auto& p : ps) { + if (auto singleval = p.template as()) { std::string propname, propvalue; if constexpr (is_ifc4_or_higher::value) { - if (!singleval->Name()) { + if (!singleval.Name()) { continue; } - propname = *singleval->Name(); + propname = *singleval.Name(); } if constexpr (!is_ifc4_or_higher::value) { - propname = singleval->Name(); + propname = *singleval.Name(); } - if (!singleval->NominalValue()) { + auto nominal_value = singleval.NominalValue(); + if (!nominal_value) { propvalue = "-"; } else { - props[*pset->Name()][propname] = format_string(singleval->NominalValue()->template as()->get_attribute_value(0)); + props[*pset.Name()][propname] = format_string(nominal_value.get_attribute_value(0)); } } } } - if (auto qset = inst->template as()) { - if (!qset->Name()) { + if (auto qset = inst.template as()) { + if (!qset.Name()) { return; } - auto qs = qset->Quantities(); - for (auto it = qs->begin(); it != qs->end(); ++it) { - auto& q = *it; - if (q->template as() && q->get_attribute_value(3).type() == IfcUtil::Argument_DOUBLE) { - double v = q->get_attribute_value(3); - props[*qset->Name()][q->Name()] = std::to_string(v); + auto qs = qset.Quantities(); + for (const auto& q : qs) { + if (q.template as() && q.get_attribute_value(3).type() == IfcUtil::Argument_DOUBLE) { + double v = q.get_attribute_value(3); + props[*qset.Name()][q.Name()] = std::to_string(v); } } } if constexpr (is_ifc4_or_higher::value) { - if (auto extprops = inst->template as()) { + if (auto extprops = inst.template as()) { // @todo } } } template -void get_psets_s(element_properties& props, const typename Schema::IfcObjectDefinition* inst) { +void get_psets_s(element_properties& props, const typename Schema::IfcObjectDefinition& inst) { // Extracts the property definitions for an IFC instance. - if (auto tyob = inst->template as()) { - if (tyob->HasPropertySets()) { - auto defs = *tyob->HasPropertySets(); - for (auto it = defs->begin(); it != defs->end(); ++it) { - auto& def = *it; + if (auto tyob = inst.template as()) { + if (tyob.HasPropertySets()) { + auto defs = *tyob.HasPropertySets(); + for (const auto& def : defs) { process_pset(props, def); } } } if constexpr (is_ifc4_or_higher::value) { - if (auto mdef = inst->template as()) { - auto defs = mdef->HasProperties(); - for (auto it = defs->begin(); it != defs->end(); ++it) { - auto& def = *it; + if (auto mdef = inst.template as()) { + auto defs = mdef.HasProperties(); + for (const auto& def : defs) { process_pset(props, def); } } - if (auto pdef = inst->template as()) { - auto defs = pdef->HasProperties(); - for (auto it = defs->begin(); it != defs->end(); ++it) { - auto& def = *it; + if (auto pdef = inst.template as()) { + auto defs = pdef.HasProperties(); + for (const auto& def : defs) { process_pset(props, def); } } } - if (auto ob = inst->template as()) { + if (auto ob = inst.template as()) { if constexpr (is_ifc4_or_higher::value) { - auto rels = ob->IsTypedBy(); - for (auto it = rels->begin(); it != rels->end(); ++it) { - auto& rel = *it; - get_psets_s(props, rel->RelatingType()); + auto rels = ob.IsTypedBy(); + for (const auto& rel : rels) { + get_psets_s(props, rel.RelatingType()); } } { - auto rels = ob->IsDefinedBy(); - for (auto it = rels->begin(); it != rels->end(); ++it) { - auto& rel = *it; - if (auto bytype = rel->template as()) { - get_psets_s(props, bytype->RelatingType()); - } else if (auto byprops = rel->template as()) { - process_pset(props, byprops->RelatingPropertyDefinition()); + auto rels = ob.IsDefinedBy(); + for (const auto& rel : rels) { + if (auto bytype = rel.template as()) { + get_psets_s(props, bytype.RelatingType()); + } else if (auto byprops = rel.template as()) { + process_pset(props, byprops.RelatingPropertyDefinition()); } } } } } -// What follows is machinery to create a preprocessor-based dispatch mechanism to dispatch to the -// correct get_psets_s() based on inst->declaration().schema()->name(). - -#define EXPAND_AND_CONCATENATE(elem) Ifc##elem - -#define GENERATE_LITERAL_STRING(elem) "Ifc" # elem - -#define TEST_AND_DISPATCH(r, data, elem) \ - if (strcasecmp(schema_name, GENERATE_LITERAL_STRING(elem)) == 0) { get_psets_s(props, inst->as()); } - -void get_psets(element_properties& props, const IfcUtil::IfcBaseClass* inst) { - auto schema_name = inst->declaration().schema()->name().c_str(); - BOOST_PP_SEQ_FOR_EACH(TEST_AND_DISPATCH, , SCHEMA_SEQ) +element_properties get_psets(const express::Base& inst) { + element_properties props; + if (auto object_definition = inst.as()) { + get_psets_s(props, object_definition); + } + return props; } int main(int argc, char** argv) { @@ -241,7 +194,7 @@ int main(int argc, char** argv) { } // Redirect the output (both progress and log) to stdout - Logger::Root().SetOutput(&std::cout, &std::cout); + ::logger::root().set_output(&std::cout, &std::cout); // Parse the IFC file provided in argv[1] ifcopenshell::file file(argv[1]); diff --git a/src/examples/arbitrary_open_profile_def.cpp b/src/examples/arbitrary_open_profile_def.cpp index 3e201bbd08..0c23962fbe 100644 --- a/src/examples/arbitrary_open_profile_def.cpp +++ b/src/examples/arbitrary_open_profile_def.cpp @@ -34,10 +34,10 @@ #define IfcSchema Ifc4 #endif -#include INCLUDE_SCHEMA(ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) -#include "ifcparse/IfcHierarchyHelper.h" +#include "ifcparse/hierarchy_helper.h" typedef std::string S; typedef ifcopenshell::global_id guid; diff --git a/src/examples/composite_profile_def.cpp b/src/examples/composite_profile_def.cpp index 815360d084..e2e4568bae 100644 --- a/src/examples/composite_profile_def.cpp +++ b/src/examples/composite_profile_def.cpp @@ -33,10 +33,10 @@ #define IfcSchema Ifc2x3 #endif -#include INCLUDE_SCHEMA(ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) -#include "ifcparse/IfcHierarchyHelper.h" +#include "ifcparse/hierarchy_helper.h" typedef std::string S; typedef ifcopenshell::global_id guid; diff --git a/src/examples/csg_primitive.cpp b/src/examples/csg_primitive.cpp index 98e51b6461..c83b2a8ef9 100644 --- a/src/examples/csg_primitive.cpp +++ b/src/examples/csg_primitive.cpp @@ -33,10 +33,10 @@ #define IfcSchema Ifc2x3 #endif -#include INCLUDE_SCHEMA(ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) -#include "ifcparse/IfcHierarchyHelper.h" +#include "ifcparse/hierarchy_helper.h" typedef std::string S; typedef ifcopenshell::global_id guid; diff --git a/src/examples/ellipse_pies.cpp b/src/examples/ellipse_pies.cpp index 1777a19290..91ce01fafe 100644 --- a/src/examples/ellipse_pies.cpp +++ b/src/examples/ellipse_pies.cpp @@ -33,10 +33,10 @@ #define IfcSchema Ifc2x3 #endif -#include INCLUDE_SCHEMA(ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) -#include "ifcparse/IfcHierarchyHelper.h" +#include "ifcparse/hierarchy_helper.h" typedef std::string S; typedef ifcopenshell::global_id guid; diff --git a/src/examples/faces.cpp b/src/examples/faces.cpp index 7ec928f463..34fd3d0e5a 100644 --- a/src/examples/faces.cpp +++ b/src/examples/faces.cpp @@ -29,10 +29,10 @@ #define IfcSchema Ifc2x3 #endif -#include INCLUDE_SCHEMA(ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) -#include "ifcparse/IfcHierarchyHelper.h" +#include "ifcparse/hierarchy_helper.h" typedef std::string S; typedef ifcopenshell::global_id guid; diff --git a/src/examples/ifc_curve_rebar.cpp b/src/examples/ifc_curve_rebar.cpp index dd5f0ea7b8..41d997b1e3 100644 --- a/src/examples/ifc_curve_rebar.cpp +++ b/src/examples/ifc_curve_rebar.cpp @@ -33,10 +33,10 @@ #define IfcSchema Ifc2x3 #endif -#include INCLUDE_SCHEMA(ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) -#include "ifcparse/IfcHierarchyHelper.h" +#include "ifcparse/hierarchy_helper.h" #include const static double PI = boost::math::constants::pi(); @@ -57,7 +57,7 @@ typedef IfcSchema::IfcCompositeCurveSegment curve_segment_t; #define IFC_REINFORCING_BAR_TYPE IfcSchema::IfcReinforcingBarRoleEnum::IfcReinforcingBarRole_LIGATURE #endif -void create_curve_rebar(IfcHierarchyHelper& file) +void create_curve_rebar(hierarchy_helper& file) { int dia = 24; int R = 3 * dia; diff --git a/src/examples/profiles.cpp b/src/examples/profiles.cpp index c64017affc..cf4d6b8152 100644 --- a/src/examples/profiles.cpp +++ b/src/examples/profiles.cpp @@ -33,10 +33,10 @@ #define IfcSchema Ifc2x3 #endif -#include INCLUDE_SCHEMA(ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) -#include "ifcparse/IfcHierarchyHelper.h" +#include "ifcparse/hierarchy_helper.h" typedef std::string S; typedef IfcWrite::IfcGuidHelper guid; diff --git a/src/examples/triangulated_faceset.cpp b/src/examples/triangulated_faceset.cpp index 834be80d86..8384b8d0c7 100644 --- a/src/examples/triangulated_faceset.cpp +++ b/src/examples/triangulated_faceset.cpp @@ -33,10 +33,10 @@ #define IfcSchema Ifc4 #endif -#include INCLUDE_SCHEMA(ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(ifcparse/schemas, IfcSchema) -#include "ifcparse/IfcHierarchyHelper.h" +#include "ifcparse/hierarchy_helper.h" #include "suzanne_geometry.h" diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index f8f728a55c..2637552d7d 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -219,7 +219,7 @@ bool file_exists(const std::string& filename) { static std::basic_stringstream log_stream; void write_log(bool); -void fix_quantities(ifcopenshell::file&, bool, bool, bool, Logger& logger = Logger::Root()); +void fix_quantities(ifcopenshell::file&, bool, bool, bool, logger& logger = ::logger::root()); std::string format_duration(time_t start, time_t end); /// @todo make the filters non-global @@ -249,7 +249,7 @@ size_t read_filters_from_file(const std::string&, inclusion_filter&, inclusion_t void parse_filter(geom_filter &, const std::vector&); std::vector setup_filters(const std::vector&, const std::string&); -bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, bool no_progress, bool mmap, bool bypass_properties=false, Logger& logger = Logger::Root()); +bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, bool no_progress, bool mmap, bool bypass_properties=false, logger& logger = ::logger::root()); // from https://stackoverflow.com/questions/31696328/boost-program-options-using-zero-parameter-options-multiple-times struct verbosity_counter { @@ -271,7 +271,7 @@ int main(int argc, char** argv) { typedef po::command_line_parser command_line_parser; typedef char char_t; #endif - Logger logger; + logger logger; inclusion_filter include_filter; inclusion_traverse_filter include_traverse_filter; @@ -464,15 +464,15 @@ int main(int argc, char** argv) { if (num_threads <= 0) { num_threads = std::thread::hardware_concurrency(); - logger.Notice("SYS", 7, "Using " + std::to_string(num_threads) + " threads"); + logger.notice("SYS", 7, "Using " + std::to_string(num_threads) + " threads"); } if (vmap.count("log-format") == 1) { boost::to_lower(log_format); if (log_format == "plain") { - logger.OutputFormat(Logger::FMT_PLAIN); + logger.output_format(::logger::FMT_PLAIN); } else if (log_format == "json") { - logger.OutputFormat(Logger::FMT_JSON); + logger.output_format(::logger::FMT_JSON); } else { cerr_ << "[error] --log-format should be either plain or json" << std::endl; print_usage(); @@ -483,7 +483,7 @@ int main(int argc, char** argv) { if (!filter_filename.empty()) { size_t num_filters = read_filters_from_file(ifcopenshell::path::to_utf8(filter_filename), include_filter, include_traverse_filter, exclude_filter, exclude_traverse_filter); if (num_filters) { - logger.Notice("SYS", 8, boost::lexical_cast(num_filters) + " filters read from specifified file."); + logger.notice("SYS", 8, boost::lexical_cast(num_filters) + " filters read from specifified file."); } else { cerr_ << "[error] No filters read from specifified file.\n"; return EXIT_FAILURE; @@ -547,27 +547,27 @@ int main(int argc, char** argv) { if (vmap.count("log-file")) { log_fs.open(log_file.c_str(), std::ios::app); - logger.SetOutput(quiet ? nullptr : &cout_, &log_fs); + logger.set_output(quiet ? nullptr : &cout_, &log_fs); } else { - logger.SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream); + logger.set_output(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream); } switch (vcounter.count) { case 0: - logger.Verbosity(Logger::LOG_ERROR); + logger.verbosity(::logger::LOG_ERROR); break; case 1: - logger.Verbosity(Logger::LOG_NOTICE); + logger.verbosity(::logger::LOG_NOTICE); break; case 2: - logger.Verbosity(Logger::LOG_DEBUG); + logger.verbosity(::logger::LOG_DEBUG); break; case 3: - logger.Verbosity(Logger::LOG_PERF); + logger.verbosity(::logger::LOG_PERF); break; case 4: - logger.Verbosity(Logger::LOG_PERF); - logger.PrintPerformanceStatsOnElement(true); + logger.verbosity(::logger::LOG_PERF); + logger.print_performance_stats_on_element(true); break; } @@ -637,7 +637,7 @@ int main(int argc, char** argv) { exit_code = EXIT_SUCCESS; } } catch (const std::exception& e) { - logger.Error("SYS", 9, e); + logger.error("SYS", 9, e); } write_log(!quiet); return exit_code; @@ -660,13 +660,13 @@ int main(int argc, char** argv) { fs << *ifc_file; exit_code = EXIT_SUCCESS; } else { - logger.Error("SYS", 10, "Unable to open output file for writing"); + logger.error("SYS", 10, "Unable to open output file for writing"); } time(&end); - logger.Status("Done! Writing IFC took " + format_duration(start, end)); + logger.status("Done! Writing IFC took " + format_duration(start, end)); } } catch (const std::exception& e) { - logger.Error("SYS", 11, e); + logger.error("SYS", 11, e); } write_log(!quiet); return exit_code; @@ -699,9 +699,9 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } - if (!entity_filter.entity_names.empty()) { entity_filter.update_description(); logger.Notice("SYS", 13, entity_filter.description); } - if (!layer_filter.values.empty()) { layer_filter.update_description(); logger.Notice("SYS", 14, layer_filter.description); } - if (!attribute_filter.attribute_name.empty()) { attribute_filter.update_description(); logger.Notice("SYS", 15, attribute_filter.description); } + if (!entity_filter.entity_names.empty()) { entity_filter.update_description(); logger.notice("SYS", 13, entity_filter.description); } + if (!layer_filter.values.empty()) { layer_filter.update_description(); logger.notice("SYS", 14, layer_filter.description); } + if (!attribute_filter.attribute_name.empty()) { attribute_filter.update_description(); logger.notice("SYS", 15, attribute_filter.description); } if (geometry_serializer_info && geometry_serializer_info->requires_ascii_temp_file) { // These serializers do not support opening unicode paths. Therefore @@ -767,13 +767,13 @@ int main(int argc, char** argv) { const bool is_tesselated = serializer->isTesselated(); // isTesselated() doesn't change at run-time if (!is_tesselated) { if (geometry_settings.get().get()) { - logger.Notice("SYS", 16, "Weld vertices setting ignored when writing non-tesselated output"); + logger.notice("SYS", 16, "Weld vertices setting ignored when writing non-tesselated output"); } if (geometry_settings.get().get()) { - logger.Notice("SYS", 17, "Generate UVs setting ignored when writing non-tesselated output"); + logger.notice("SYS", 17, "Generate UVs setting ignored when writing non-tesselated output"); } if (center_model || center_model_geometry) { - logger.Notice("SYS", 18, "Centering/offsetting model setting ignored when writing non-tesselated output"); + logger.notice("SYS", 18, "Centering/offsetting model setting ignored when writing non-tesselated output"); } geometry_settings.get().value = ifcopenshell::geometry::settings::NATIVE; @@ -799,9 +799,9 @@ int main(int argc, char** argv) { } if (vmap.count("log-file")) { - logger.SetOutput(quiet ? nullptr : &cout_, &log_fs); + logger.set_output(quiet ? nullptr : &cout_, &log_fs); } else { - logger.SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream); + logger.set_output(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream); } if (model_rotation) { @@ -816,13 +816,13 @@ int main(int argc, char** argv) { std::stringstream msg; msg << "Using model rotation (" << rotation[0] << "," << rotation[1] << "," << rotation[2] << "," << rotation[3] << ")"; - logger.Notice("SYS", 19, msg.str()); + logger.notice("SYS", 19, msg.str()); geometry_settings.get().value = rotation; } if (model_offset && (center_model || center_model_geometry)) { - logger.Notice("GEO", 22, "--model-offset ignored with --center-model or --center-model-geometry"); + logger.notice("GEO", 22, "--model-offset ignored with --center-model or --center-model-geometry"); } if (model_offset && !(center_model || center_model_geometry)) { @@ -837,7 +837,7 @@ int main(int argc, char** argv) { std::stringstream msg; msg << std::setprecision(std::numeric_limits::max_digits10) << "Using model offset (" << offset[0] << "," << offset[1] << "," << offset[2] << ")"; - logger.Notice("SYS", 20, msg.str()); + logger.notice("SYS", 20, msg.str()); geometry_settings.get().value = offset; } @@ -845,17 +845,17 @@ int main(int argc, char** argv) { if (is_tesselated && (center_model || center_model_geometry)) { std::vector offset(3); - IfcGeom::Iterator tmp_context_iterator(ifcopenshell::geometry::kernels::construct(ifc_file, geometry_kernel, geometry_settings, logger), geometry_settings, ifc_file, filter_funcs, num_threads, logger); + IfcGeom::Iterator tmp_context_iterator(ifcopenshell::geometry::kernels::construct(ifc_file, geometry_kernel, geometry_settings), geometry_settings, ifc_file, filter_funcs, num_threads, logger); time_t start, end; time(&start); - if (!quiet) logger.Status("Computing bounds..."); + if (!quiet) logger.status("Computing bounds..."); if (center_model_geometry) { if (!tmp_context_iterator.initialize()) { /// @todo It would be nice to know and print separate error prints for a case where we found no entities /// and for a case we found no entities that satisfy our filtering criteria. - logger.Notice("GEO", 23, "No geometrical elements found or none successfully converted"); + logger.notice("GEO", 23, "No geometrical elements found or none successfully converted"); serializer.reset(); ifcopenshell::path::delete_file(ifcopenshell::path::to_utf8(output_temp_filename)); write_log(!quiet); @@ -866,7 +866,7 @@ int main(int argc, char** argv) { tmp_context_iterator.compute_bounds(center_model_geometry); time(&end); - if (!quiet) logger.Status("Done ! Bounds computed in " + format_duration(start, end)); + if (!quiet) logger.status("Done ! Bounds computed in " + format_duration(start, end)); auto center = (tmp_context_iterator.bounds_min().ccomponents() + tmp_context_iterator.bounds_max().ccomponents()) * 0.5; offset[0] = -center(0); @@ -875,7 +875,7 @@ int main(int argc, char** argv) { std::stringstream msg; msg << std::setprecision (std::numeric_limits::max_digits10) << "Using model offset (" << offset[0] << "," << offset[1] << "," << offset[2] << ")"; - logger.Notice("SYS", 21, msg.str()); + logger.notice("SYS", 21, msg.str()); geometry_settings.get().value = offset; } @@ -891,15 +891,15 @@ int main(int argc, char** argv) { std::unique_ptr context_iterator; if (!elems_from_adaptor) { - context_iterator.reset(new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(ifc_file, geometry_kernel, geometry_settings, logger), geometry_settings, ifc_file, filter_funcs, num_threads, logger)); + context_iterator.reset(new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(ifc_file, geometry_kernel, geometry_settings), geometry_settings, ifc_file, filter_funcs, num_threads, logger)); } - logger.message(logger::LOG_PERF, "file geometry conversion"); + logger.message(::logger::LOG_PERF, "file geometry conversion"); if (context_iterator && !context_iterator->initialize()) { /// @todo It would be nice to know and print separate error prints for a case where we found no entities /// and for a case we found no entities that satisfy our filtering criteria. - logger.Notice("GEO", 25, "No geometrical elements found or none successfully converted"); + logger.notice("GEO", 25, "No geometrical elements found or none successfully converted"); serializer.reset(); ifcopenshell::path::delete_file(ifcopenshell::path::to_utf8(output_temp_filename)); write_log(!quiet); @@ -919,7 +919,7 @@ int main(int argc, char** argv) { int old_progress = quiet ? 0 : -1; if (!quiet) { - logger.Status("Creating geometry..."); + logger.status("Creating geometry..."); } // The functions IfcGeom::Iterator::get() and IfcGeom::Iterator::next() @@ -964,10 +964,10 @@ int main(int argc, char** argv) { if (stderr_progress) cerr_ << std::flush; } else if (vcounter.count == 2) { - logger.Message(Logger::LOG_DEBUG, "SYS", 23, "Progress " + boost::lexical_cast(progress)); + logger.message(::logger::LOG_DEBUG, "SYS", 23, "Progress " + boost::lexical_cast(progress)); } else { progress = progress / 2; - if (old_progress != progress) logger.ProgressBar(progress); + if (old_progress != progress) logger.progress_bar(progress); old_progress = progress; } } @@ -996,7 +996,7 @@ int main(int argc, char** argv) { } } else { const std::string task = ((num_threads == 1) ? "creating" : "writing"); - logger.Status("\rDone " + task + " geometry (" + boost::lexical_cast(num_created) + + logger.status("\rDone " + task + " geometry (" + boost::lexical_cast(num_created) + " objects) "); } @@ -1004,7 +1004,7 @@ int main(int argc, char** argv) { // Make sure the dtor is explicitly run here (e.g. output files are closed before renaming them). serializer.reset(); - logger.Message(Logger::LOG_PERF, "GEO", 26, "done file geometry conversion"); + logger.message(::logger::LOG_PERF, "GEO", 26, "done file geometry conversion"); bool successful; if (geometry_serializer_info->writes_final_output) { @@ -1022,13 +1022,13 @@ int main(int argc, char** argv) { output_temp_filename << "' for the conversion result."; } - if (geometry_settings.get().get() && logger.MaxSeverity() >= Logger::LOG_ERROR) { - logger.Error("SYS", 24, "Errors encountered during processing."); + if (geometry_settings.get().get() && logger.max_severity() >= ::logger::LOG_ERROR) { + logger.error("SYS", 24, "Errors encountered during processing."); successful = false; } - if (logger.Verbosity() == Logger::LOG_PERF) { - logger.PrintPerformanceStats(); + if (logger.verbosity() == ::logger::LOG_PERF) { + logger.print_performance_stats(); } write_log(!quiet); @@ -1036,7 +1036,7 @@ int main(int argc, char** argv) { time(&end); if (!quiet) { - logger.Status("\nConversion took " + format_duration(start, end)); + logger.status("\nConversion took " + format_duration(start, end)); } return successful ? EXIT_SUCCESS : EXIT_FAILURE; @@ -1074,7 +1074,7 @@ void write_log(bool header) { #include -bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, bool no_progress, bool mmap, bool bypass_properties, Logger& logger) { +bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, bool no_progress, bool mmap, bool bypass_properties, logger& logger) { time_t start, end; // Prevent file::Init() prints by setting output to null temporarily @@ -1111,13 +1111,13 @@ bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, } if (!ifc_file || !ifc_file->good()) { - logger.Error("SYN", 1, "Unable to parse input file '" + filename + "'"); + logger.error("SYN", 1, "Unable to parse input file '" + filename + "'"); return false; } time(&end); - if (no_progress) { logger.SetOutput(&cout_, &log_stream); } - else { logger.Status("Parsing input file took " + format_duration(start, end)); } + if (no_progress) { logger.set_output(&cout_, &log_stream); } + else { logger.status("Parsing input file took " + format_duration(start, end)); } return true; @@ -1330,7 +1330,7 @@ namespace latebound_access { } } -void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, Logger& logger) { +void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger) { { auto delete_reversed = [&f](const std::vector& insts) { // Lists are traversed back to front as the list may be mutated when @@ -1381,7 +1381,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st settings.get().value = true; settings.get().value = ifcopenshell::geometry::settings::NATIVE; - IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "opencascade", settings, logger), settings, &f, {}, 1, logger); + IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "opencascade", settings), settings, &f, {}, 1, logger); if (!context_iterator.initialize()) { return; @@ -1508,7 +1508,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st cerr_ << std::flush; } else { const int progress = context_iterator.progress() / 2; - if (old_progress != progress) logger.ProgressBar(progress); + if (old_progress != progress) logger.progress_bar(progress); old_progress = progress; } } @@ -1524,7 +1524,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st if (stderr_progress) cerr_ << std::flush; } else { - logger.Status("\rDone writing quantities for " + boost::lexical_cast(num_created) + + logger.status("\rDone writing quantities for " + boost::lexical_cast(num_created) + " objects "); } diff --git a/src/ifcconvert/validate_space_boundaries.cpp b/src/ifcconvert/validate_space_boundaries.cpp index 965ab2d1b8..0a20555481 100644 --- a/src/ifcconvert/validate_space_boundaries.cpp +++ b/src/ifcconvert/validate_space_boundaries.cpp @@ -18,7 +18,7 @@ typedef CGAL::AABB_traits Traits; typedef CGAL::AABB_tree Tree; typedef Tree::Point_and_primitive_id Point_and_primitive_id; -void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, Logger& logger = Logger::Root()) { +void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger = ::logger::root()) { intersection_validator v(f, { "IfcWall", "IfcSpace", "IfcSlab", "IfcCovering" }, 1.e-5, no_progress, quiet, stderr_progress, logger); auto rels = f.instances_by_type("IfcRelSpaceBoundary"); @@ -54,7 +54,7 @@ void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bo settings.get().value = ifcopenshell::geometry::settings::NATIVE; settings.get().value = true; - ifcopenshell::geometry::Converter c(ifcopenshell::geometry::kernels::construct(&f2, "cgal", settings, logger), &f2, settings, logger); + ifcopenshell::geometry::Converter c(ifcopenshell::geometry::kernels::construct(&f2, "cgal", settings), &f2, settings, logger); std::map, std::vector> elem_to_space_boundary_coords; @@ -128,7 +128,7 @@ void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bo auto itelem = elem_to_space_boundary_coords.find({ Aguid, Bguid }); if (itelem == elem_to_space_boundary_coords.end()) { - logger.Error("VAL", 1, "Missing space boundary relationship " + Aguid + " " + Bguid); + logger.error("VAL", 1, "Missing space boundary relationship " + Aguid + " " + Bguid); return; } @@ -141,7 +141,7 @@ void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bo bool valid = *std::max_element(distances.begin(), distances.end()) < 0.4; if (!valid) { - logger.Error("VAL", 2, "Wrong connection geometry " + Aguid + " " + Bguid); + logger.error("VAL", 2, "Wrong connection geometry " + Aguid + " " + Bguid); } /*{ @@ -178,7 +178,7 @@ void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bo auto g1 = n.substr(0, 22); auto g2 = n.substr(23); if (is_wall_space_or_slab(g1) && is_wall_space_or_slab(g2) && guid_pairs_visited.find({ g1, g2 }) == guid_pairs_visited.end()) { - logger.Error("VAL", 3, "Space boundary for non-bounding geometry " + g1 + " " + g2); + logger.error("VAL", 3, "Space boundary for non-bounding geometry " + g1 + " " + g2); } } } diff --git a/src/ifcconvert/validate_storey_containment.cpp b/src/ifcconvert/validate_storey_containment.cpp index dac07a6ff1..a4f49ac1a8 100644 --- a/src/ifcconvert/validate_storey_containment.cpp +++ b/src/ifcconvert/validate_storey_containment.cpp @@ -9,7 +9,7 @@ #include -void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, Logger& logger = Logger::Root()) { +void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger = ::logger::root()) { ifcopenshell::geometry::Settings settings; settings.get().value = false; @@ -23,7 +23,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, IfcGeom::entity_filter(false, false, {"IfcOpeningElement", "IfcSpace"}) }; - IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings, logger), settings, &f, no_openings_and_spaces, 1, logger); + IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings), settings, &f, no_openings_and_spaces, 1, logger); auto get_elevation = [](const ifcopenshell::IfcBaseClass* a) { return ((const ifcopenshell::IfcBaseEntity*)a)->get_value("Elevation", 0.); @@ -198,7 +198,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, auto s = geom_object->product()->get_value("GlobalId"); auto s1 = ((IfcUtil::IfcBaseEntity*)storeys_sorted[calc_idx])->get_value("GlobalId"); auto s2 = ((IfcUtil::IfcBaseEntity*)elem_to_storey[geom_object->product()])->get_value("GlobalId"); - logger.Error("VAL", 4, "Element " + s + " contained in " + s2 + " located on " + s1); + logger.error("VAL", 4, "Element " + s + " contained in " + s2 + " located on " + s1); } if (!no_progress) { @@ -214,7 +214,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, std::cerr << std::flush; } else { const int progress = context_iterator.progress() / 2; - if (old_progress != progress) logger.ProgressBar(progress); + if (old_progress != progress) logger.progress_bar(progress); old_progress = progress; } } @@ -230,7 +230,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, if (stderr_progress) std::cerr << std::flush; } else { - logger.Status("\rDone fixing space boundaries for " + boost::lexical_cast(num_created) + + logger.status("\rDone fixing space boundaries for " + boost::lexical_cast(num_created) + " objects "); } } diff --git a/src/ifcconvert/validate_wall_connectivity.cpp b/src/ifcconvert/validate_wall_connectivity.cpp index 13f9607cad..ebfedeafa7 100644 --- a/src/ifcconvert/validate_wall_connectivity.cpp +++ b/src/ifcconvert/validate_wall_connectivity.cpp @@ -9,7 +9,7 @@ using namespace ifcopenshell::geometry; -void fix_wallconnectivity(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, Logger& logger = Logger::Root()) { +void fix_wallconnectivity(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger = ::logger::root()) { intersection_validator v(f, { "IfcWall" }, 1.e-3, no_progress, quiet, stderr_progress, logger); ifcopenshell::geometry::Settings settings; @@ -24,7 +24,7 @@ void fix_wallconnectivity(ifcopenshell::file& f, bool no_progress, bool quiet, b settings.get().value = true; settings.get().value = false; - ifcopenshell::geometry::Converter c(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings, logger), &f, settings, logger); + ifcopenshell::geometry::Converter c(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings), &f, settings, logger); auto rels = f.instances_by_type("IfcRelConnectsPathElements"); std::map, const ifcopenshell::IfcBaseClass*> rel_by_elem; @@ -169,11 +169,11 @@ void fix_wallconnectivity(ifcopenshell::file& f, bool no_progress, bool quiet, b if (a_type != atype_computed || b_type != btype_computed) { if (rel) { - logger.Error("VAL", 5, std::string("Connection type ") + atype_computed + " " + btype_computed + " for:", rel); + logger.error("VAL", 5, std::string("Connection type ") + atype_computed + " " + btype_computed + " for:", rel); } else { auto A_str = A->get_value("GlobalId"); auto B_str = B->get_value("GlobalId"); - logger.Error("VAL", 6, "No connection for adjacent " + A_str + " " + B_str); + logger.error("VAL", 6, "No connection for adjacent " + A_str + " " + B_str); } } }); @@ -183,7 +183,7 @@ void fix_wallconnectivity(ifcopenshell::file& f, bool no_progress, bool quiet, b auto x = (ifcopenshell::IfcBaseEntity*)((ifcopenshell::IfcBaseEntity*)rel)->get_value("RelatingElement"); auto y = (ifcopenshell::IfcBaseEntity*)((ifcopenshell::IfcBaseEntity*)rel)->get_value("RelatedElement"); if (v.successfully_processed.find(x) != v.successfully_processed.end() && v.successfully_processed.find(y) != v.successfully_processed.end()) { - logger.Error("VAL", 7, "Connection for non-adjacent walls", rel); + logger.error("VAL", 7, "Connection for non-adjacent walls", rel); } } }); diff --git a/src/ifcconvert/validation_utils.h b/src/ifcconvert/validation_utils.h index 3044f70478..1068c7f3b6 100644 --- a/src/ifcconvert/validation_utils.h +++ b/src/ifcconvert/validation_utils.h @@ -446,7 +446,7 @@ struct intersection_validator { std::set successfully_processed; - intersection_validator(ifcopenshell::file& f, std::initializer_list entities, double eps, bool no_progress, bool quiet, bool stderr_progress, Logger& logger = Logger::Root()) { + intersection_validator(ifcopenshell::file& f, std::initializer_list entities, double eps, bool no_progress, bool quiet, bool stderr_progress, logger& logger = ::logger::root()) { ifcopenshell::geometry::Settings settings; settings.get().value = false; @@ -460,7 +460,7 @@ struct intersection_validator { IfcGeom::entity_filter(true, false, entities) }; - IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings, logger), settings, &f, spaces_and_walls, 1, logger); + IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings), settings, &f, spaces_and_walls, 1, logger); if (!context_iterator.initialize()) { return; @@ -563,7 +563,7 @@ struct intersection_validator { std::cerr << std::flush; } else { const int progress = context_iterator.progress() / 2; - if (old_progress != progress) logger.ProgressBar(progress); + if (old_progress != progress) logger.progress_bar(progress); old_progress = progress; } } @@ -579,7 +579,7 @@ struct intersection_validator { if (stderr_progress) std::cerr << std::flush; } else { - logger.Status("\rDone fixing space boundaries for " + boost::lexical_cast(num_created) + + logger.status("\rDone fixing space boundaries for " + boost::lexical_cast(num_created) + " objects "); } diff --git a/src/ifcgeom/AbstractKernel.cpp b/src/ifcgeom/AbstractKernel.cpp index 2031197ee3..634151880b 100644 --- a/src/ifcgeom/AbstractKernel.cpp +++ b/src/ifcgeom/AbstractKernel.cpp @@ -20,8 +20,8 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::pt auto it = cache_.find(item); if (it != cache_.end()) { results = it->second; - logger_.Notice("SYS", 25, "Cache hit #" + std::to_string(item->instance->as()->id()) + - " -> #" + std::to_string(it->first->instance->as()->id())); + logger_.notice("SYS", 25, "Cache hit #" + std::to_string(item->instance.id()) + + " -> #" + std::to_string(it->first->instance.id())); return true; } } @@ -30,7 +30,7 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::pt try { return fn(); } catch (std::exception& e) { - logger_.Error("GEO", 27, e, item->instance); + logger_.error("GEO", 27, e, item->instance); return false; } catch (...) { // @todo we can't log OCCT exceptions here, can we do some reraising to solve this? diff --git a/src/ifcgeom/AbstractKernel.h b/src/ifcgeom/AbstractKernel.h index 0e9dae180a..e6f7ad4afb 100644 --- a/src/ifcgeom/AbstractKernel.h +++ b/src/ifcgeom/AbstractKernel.h @@ -66,12 +66,12 @@ namespace ifcopenshell { protected: std::string geometry_library_; Settings settings_; - Logger& logger_; + ::logger& logger_; public: bool propagate_exceptions = false; bool partial_success_is_success = true; - AbstractKernel(const std::string& geometry_library, const Settings& settings, Logger& logger = Logger::Root()) + AbstractKernel(const std::string& geometry_library, const Settings& settings, ::logger& logger = ::logger::root()) : geometry_library_(geometry_library) , settings_(settings) , logger_(logger) {} @@ -89,7 +89,7 @@ namespace ifcopenshell { virtual bool accepts(const IfcGeom::ConversionResultShape& shape) const { return shape.backend_id() == backend_id(); } - Logger& logger() const { return logger_; } + ::logger& logger() const { return logger_; } virtual bool supports_boolean_operations() const = 0; @@ -137,7 +137,7 @@ namespace ifcopenshell { const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes) = 0; virtual bool unify_shapes(const IfcGeom::ConversionResults&, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual AbstractKernel* clone(Logger& logger) const = 0; + virtual AbstractKernel* clone(::logger& logger) const = 0; }; } } @@ -164,9 +164,9 @@ namespace { if (kernel->partial_success_is_success) { std::string created_from; if (item->instance) { - created_from = " (created from " + item->instance->declaration().name() + ")"; + created_from = " (created from " + item->instance.declaration().name() + ")"; } - kernel->logger().Error("UNS", 1, "No support for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library()); + kernel->logger().error("UNS", 1, "No support for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library()); } return false; } @@ -190,9 +190,9 @@ namespace { if (kernel->partial_success_is_success) { std::string created_from; if (item->instance) { - created_from = " (created from " + item->instance->declaration().name() + ")"; + created_from = " (created from " + item->instance.declaration().name() + ")"; } - kernel->logger().Error("UNS", 2, "No support (after considering item upgrade) for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library()); + kernel->logger().error("UNS", 2, "No support (after considering item upgrade) for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library()); } return false; } @@ -229,7 +229,7 @@ namespace { template struct dispatch_curve_creation { static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) { - Logger::Root().Error("GEO", 28, "No conversion for " + std::to_string(item->kind())); + ::logger::root().error("GEO", 28, "No conversion for " + std::to_string(item->kind())); return false; } }; @@ -251,7 +251,7 @@ namespace { template struct dispatch_surface_creation { static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) { - Logger::Root().Error("GEO", 29, "No conversion for " + std::to_string(item->kind())); + ::logger::root().error("GEO", 29, "No conversion for " + std::to_string(item->kind())); return false; } }; diff --git a/src/ifcgeom/ConversionResult.cpp b/src/ifcgeom/ConversionResult.cpp index a5749bf494..d860bba6d8 100644 --- a/src/ifcgeom/ConversionResult.cpp +++ b/src/ifcgeom/ConversionResult.cpp @@ -1,7 +1,7 @@ #include "ConversionResult.h" #include "IfcGeomRepresentation.h" -IfcGeom::Representation::Triangulation* IfcGeom::ConversionResultShape::Triangulate(const ifcopenshell::geometry::Settings& settings, Logger& logger) const +IfcGeom::Representation::Triangulation* IfcGeom::ConversionResultShape::Triangulate(const ifcopenshell::geometry::Settings& settings, ::logger& logger) const { auto t = IfcGeom::Representation::Triangulation::empty(settings); static ifcopenshell::geometry::taxonomy::matrix4 iden; diff --git a/src/ifcgeom/ConversionResult.h b/src/ifcgeom/ConversionResult.h index 40cf872d4a..3bf8a51456 100644 --- a/src/ifcgeom/ConversionResult.h +++ b/src/ifcgeom/ConversionResult.h @@ -233,9 +233,6 @@ namespace IfcGeom { template struct is_shared_ptr> : std::true_type {}; - // @todo this can simply be a template class, to remove the need for the NumberEpeck in CGAL kernel. -#ifndef SWIG - class IFC_GEOM_API NumberNativeDouble : public OpaqueNumber { private: std::shared_ptr data_; @@ -352,23 +349,6 @@ namespace IfcGeom { return negated(); } }; -#else - class IFC_GEOM_API NumberNativeDouble : public OpaqueNumber { - public: - NumberNativeDouble(double v); - virtual double to_double() const; - virtual std::string to_string() const; - virtual OpaqueNumber* operator+(OpaqueNumber* other) const; - virtual OpaqueNumber* operator-(OpaqueNumber* other) const; - virtual OpaqueNumber* operator*(OpaqueNumber* other) const; - virtual OpaqueNumber* operator/(OpaqueNumber* other) const; - virtual bool operator==(OpaqueNumber* other) const; - virtual bool operator<(OpaqueNumber* other) const; - virtual OpaqueNumber* operator-() const; - virtual OpaqueNumber* clone() const; - }; -#endif - #ifndef SWIG template struct IFC_GEOM_API OpaqueCoordinate { @@ -514,8 +494,11 @@ namespace IfcGeom { OpaqueCoordinate(const OpaqueCoordinate& other); OpaqueCoordinate& operator=(const OpaqueCoordinate& other); ~OpaqueCoordinate(); - OpaqueNumber* get(size_t i) const; - void set(size_t i, OpaqueNumber* n); + std::size_t size() const; + OpaqueNumber get(size_t i) const; + double get_double(size_t i) const; + void set(size_t i, const OpaqueNumber& n); + std::vector to_double() const; }; #endif @@ -526,8 +509,8 @@ namespace IfcGeom { #else virtual std::string_view backend_id() const = 0; #endif - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int item_id, int surface_style_id) const = 0; - IfcGeom::Representation::Triangulation* Triangulate(const ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root()) const; + virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const = 0; + IfcGeom::Representation::Triangulation* Triangulate(const ifcopenshell::geometry::Settings& settings, ::logger& logger = ::logger::root()) const; virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const = 0; virtual int surface_genus() const = 0; diff --git a/src/ifcgeom/Converter.cpp b/src/ifcgeom/Converter.cpp index e96a277426..5d454f8809 100644 --- a/src/ifcgeom/Converter.cpp +++ b/src/ifcgeom/Converter.cpp @@ -4,7 +4,7 @@ using namespace ifcopenshell::geometry; -ifcopenshell::geometry::Converter::Converter(std::unique_ptr&& geometry_library, ifcopenshell::file* file, ifcopenshell::geometry::Settings& s, Logger& logger) +ifcopenshell::geometry::Converter::Converter(std::unique_ptr&& geometry_library, ifcopenshell::file* file, ifcopenshell::geometry::Settings& s, ::logger& logger) : kernel_(std::move(geometry_library)) , logger_(logger) { @@ -18,7 +18,7 @@ ifcopenshell::geometry::Converter::~Converter() { } namespace { - void substitute_with_box_based_on_density(Logger& logger, IfcGeom::ConversionResults& items, double& density) { + void substitute_with_box_based_on_density(::logger& logger, IfcGeom::ConversionResults& items, double& density) { int nv = 0; void* box = nullptr; double volume = 0.; @@ -30,7 +30,7 @@ namespace { if (density > 1e5) { items[0].Shape()->set_box(box); items.erase(items.begin() + 1, items.end()); - logger.Notice("GEO", 30, "Substituted element with " + boost::lexical_cast(density) + " vertices / m3 with a bounding box"); + logger.notice("GEO", 30, "Substituted element with " + boost::lexical_cast(density) + " vertices / m3 with a bounding box"); } } } @@ -102,7 +102,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe } if (!success) { - logger::error("Failed processing layerset"); + ::logger::root().error("Failed processing layerset"); } } } @@ -141,7 +141,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe } } if (some_items_without_style) { - logger_.Warning("GEO", 31, "No material and surface styles for:", product); + logger_.warning("GEO", 31, "No material and surface styles for:", product); } } @@ -165,7 +165,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe parent_id = parent_object.id(); } } catch (const std::exception& e) { - logger_.Error("GEO", 32, e); + logger_.error("GEO", 32, e); } const std::string name = product.get_value("Name", ""); @@ -211,10 +211,10 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe kernel_->convert_openings(product, opening_items, shapes, *place, opened_shapes); } } catch (const std::exception& e) { - logger_.Message(Logger::LOG_ERROR, "GEO", 33, std::string("Error processing openings for: ") + e.what() + ":", product); + logger_.message(::logger::LOG_ERROR, "GEO", 33, std::string("Error processing openings for: ") + e.what() + ":", product); caught_error = true; } catch (...) { - logger_.Message(Logger::LOG_ERROR, "GEO", 34, "Error processing openings for:", product); + logger_.message(::logger::LOG_ERROR, "GEO", 34, "Error processing openings for:", product); } if (!(caught_error && opened_shapes.size() < shapes.size())) { @@ -242,7 +242,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe std::swap(shapes, unified_shapes); } } catch (std::exception& e) { - logger_.Error("GEO", 35, e); + logger_.error("GEO", 35, e); } } @@ -298,12 +298,12 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe if (elem->geometry().calculate_surface_area(a_calc)) { double diff = std::abs(a_calc - a_file); if (diff / std::sqrt(a_file) > getValue(GV_PRECISION)) { - logger::error("Validation of surface area failed for:", product); + ::logger::root().error("Validation of surface area failed for:", product); } else { - logger::notice("Validation of surface area succeeded for:", product); + ::logger::root().notice("Validation of surface area succeeded for:", product); } } else { - logger::error("Validation of surface area failed for:", product); + ::logger::root().error("Validation of surface area failed for:", product); } } else if (q->as() && q->Name() == "Volume") { double v_calc; @@ -311,12 +311,12 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe if (elem->geometry().calculate_volume(v_calc)) { double diff = std::abs(v_calc - v_file); if (diff / std::sqrt(v_file) > getValue(GV_PRECISION)) { - logger::error("Validation of volume failed for:", product); + ::logger::root().error("Validation of volume failed for:", product); } else { - logger::notice("Validation of volume succeeded for:", product); + ::logger::root().notice("Validation of volume succeeded for:", product); } } else { - logger::error("Validation of volume failed for:", product); + ::logger::root().error("Validation of volume failed for:", product); } } else if (q->as() && q->Name() == "Shape Validation Properties") { auto qs2 = q->as()->HasQuantities(); @@ -335,9 +335,9 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe } } if (!all_succeeded) { - logger::error("Validation of surface genus failed for:", product); + ::logger::root().error("Validation of surface genus failed for:", product); } else { - logger::notice("Validation of surface genus succeeded for:", product); + ::logger::root().notice("Validation of surface genus succeeded for:", product); } } } @@ -361,7 +361,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_process parent_id = parent_object.id(); } } catch (const std::exception& e) { - logger_.Error("GEO", 36, e); + logger_.error("GEO", 36, e); } const std::string guid = product.get_value("GlobalId"); diff --git a/src/ifcgeom/Converter.h b/src/ifcgeom/Converter.h index 75769de32c..1c059c66ae 100644 --- a/src/ifcgeom/Converter.h +++ b/src/ifcgeom/Converter.h @@ -21,17 +21,17 @@ namespace ifcopenshell { namespace geometry { std::unique_ptr kernel_; ifcopenshell::geometry::Settings settings_; std::map cache_; - Logger& logger_; + ::logger& logger_; public: ifcopenshell::geometry::kernels::AbstractKernel* kernel() { return &*kernel_; } - Converter(std::unique_ptr&& geometry_library, ifcopenshell::file* file, ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root()); + Converter(std::unique_ptr&& geometry_library, ifcopenshell::file* file, ifcopenshell::geometry::Settings& settings, ::logger& logger = ::logger::root()); ~Converter(); ifcopenshell::geometry::abstract_mapping* mapping() const { return mapping_; } - Logger& logger() const { return logger_; } + ::logger& logger() const { return logger_; } /* virtual NativeElement* convert( diff --git a/src/ifcgeom/GeometrySerializer.h b/src/ifcgeom/GeometrySerializer.h index 28a2dce6b8..950e7f41e9 100644 --- a/src/ifcgeom/GeometrySerializer.h +++ b/src/ifcgeom/GeometrySerializer.h @@ -346,7 +346,7 @@ class IFC_GEOM_API GeometrySerializer : public Serializer { public: enum read_type { READ_BREP, READ_TRIANGULATION }; - GeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()) + GeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger = ::logger::root()) : Serializer(logger) , geometry_settings_(geometry_settings) , settings_(settings) @@ -381,7 +381,7 @@ protected: class IFC_GEOM_API WriteOnlyGeometrySerializer : public GeometrySerializer { public: - WriteOnlyGeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()) : GeometrySerializer(geometry_settings, settings, logger) {} + WriteOnlyGeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger = ::logger::root()) : GeometrySerializer(geometry_settings, settings, logger) {} virtual IfcGeom::Element* read(ifcopenshell::file&, const std::string&, const std::string&, read_type = READ_BREP) { throw std::runtime_error("Not supported"); diff --git a/src/ifcgeom/IfcGeomElement.h b/src/ifcgeom/IfcGeomElement.h index 3501cdd0be..a115bb72a0 100644 --- a/src/ifcgeom/IfcGeomElement.h +++ b/src/ifcgeom/IfcGeomElement.h @@ -126,7 +126,7 @@ namespace IfcGeom { oss << "product-" << ifcopenshell::global_id(guid).formatted(); } catch (const std::exception& e) { oss << "product"; - Logger::Root().Error("GEO", 39, e); + ::logger::root().error("GEO", 39, e); } } diff --git a/src/ifcgeom/Iterator.cpp b/src/ifcgeom/Iterator.cpp index 1672d76a20..39d86d2008 100644 --- a/src/ifcgeom/Iterator.cpp +++ b/src/ifcgeom/Iterator.cpp @@ -31,7 +31,7 @@ bool IfcGeom::Iterator::initialize() { try { converter_->mapping()->get_representations(reps, filters_); } catch (const std::exception& e) { - logger_.Error("GEO", 50, e); + logger_.error("GEO", 50, e); } time_points[1] = high_resolution_clock::now(); @@ -94,7 +94,7 @@ bool IfcGeom::Iterator::initialize() { tasks_.back().item = p.first; tasks_.back().products = p.second; } - logger_.Notice("SYS", 26, "Merged " + std::to_string(old_size) + " tasks into " + std::to_string(tasks_.size()) + " tasks due to permissive shape reuse"); + logger_.notice("SYS", 26, "Merged " + std::to_string(old_size) + " tasks into " + std::to_string(tasks_.size()) + " tasks due to permissive shape reuse"); } } @@ -139,11 +139,11 @@ bool IfcGeom::Iterator::initialize() { } */ - logger_.Notice("SYS", 27, "Created " + boost::lexical_cast(tasks_.size()) + " tasks for " + boost::lexical_cast(num_products) + " products"); + logger_.notice("SYS", 27, "Created " + boost::lexical_cast(tasks_.size()) + " tasks for " + boost::lexical_cast(num_products) + " products"); if (tasks_.size() == 0) { - logger_.Warning("GEO", 51, "No representations encountered, aborting"); - initialization_outcome_.reset(false); + logger_.warning("GEO", 51, "No representations encountered, aborting"); + initialization_outcome_ = false; } else if (!settings_.get().get()) { task_iterator_ = tasks_.begin(); @@ -169,7 +169,7 @@ bool IfcGeom::Iterator::initialize() { void IfcGeom::Iterator::flush_worker_log(ifcopenshell::geometry::Converter* kernel) { if (kernel && &kernel->logger() != &logger_) { - logger_.Append(kernel->logger()); + logger_.append(kernel->logger()); } } @@ -203,13 +203,13 @@ void IfcGeom::Iterator::process_concurrently() { kernel_pool.reserve(conc_threads); worker_loggers_.reserve(conc_threads); for (unsigned i = 0; i < conc_threads; ++i) { - worker_loggers_.emplace_back(std::make_unique()); - Logger& worker_logger = *worker_loggers_.back(); - worker_logger.Verbosity(logger_.Verbosity()); - worker_logger.OutputFormat(logger_.OutputFormat()); - worker_logger.PrintPerformanceStatsOnElement(logger_.PrintPerformanceStatsOnElement()); - if (worker_logger.OutputFormat() != Logger::FMT_INMEMORY) { - worker_logger.SetOutput(static_cast(nullptr), static_cast(nullptr)); + worker_loggers_.emplace_back(std::make_unique()); + ::logger& worker_logger = *worker_loggers_.back(); + worker_logger.verbosity(logger_.verbosity()); + worker_logger.output_format(logger_.output_format()); + worker_logger.print_performance_stats_on_element(logger_.print_performance_stats_on_element()); + if (worker_logger.output_format() != ::logger::FMT_INMEMORY) { + worker_logger.set_output(static_cast(nullptr), static_cast(nullptr)); } kernel_pool.push_back(new ifcopenshell::geometry::Converter(std::unique_ptr(converter_->kernel()->clone(worker_logger)), ifc_file, settings_, worker_logger)); } @@ -249,14 +249,14 @@ void IfcGeom::Iterator::process_concurrently() { try { this->create_element_(kernel, settings, rep); } catch (const std::exception& e) { - kernel->logger().Error("GEO", 52, + kernel->logger().error("GEO", 52, std::string("Exception '") + e.what() + std::string("' occurred while iterator was creating a shape: "), rep->item->instance ); had_error_processing_elements_ = true; } catch (...) { - kernel->logger().Error("GEO", 53, + kernel->logger().error("GEO", 53, "Unknown exception occurred while iteartor was creating a shape: ", rep->item->instance ); @@ -281,10 +281,10 @@ void IfcGeom::Iterator::process_concurrently() { finished_ = true; - logger_.SetProduct(boost::none); + logger_.set_product(std::optional{}); if (!terminating_) { - logger_.Status("\rDone creating geometry (" + boost::lexical_cast(all_processed_elements_.size()) + + logger_.status("\rDone creating geometry (" + boost::lexical_cast(all_processed_elements_.size()) + " objects) "); } } @@ -362,7 +362,7 @@ express::Base IfcGeom::Iterator::create_shape_model_for_next_entity() { void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kernel, ifcopenshell::geometry::Settings settings, geometry_conversion_result* rep) { - Logger& kernel_logger = kernel->logger(); + ::logger& kernel_logger = kernel->logger(); if (!settings_.get().get()) { rep->item = kernel->mapping()->map(rep->representation); @@ -380,20 +380,20 @@ void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kerne const express::Base product = product_node.first; const auto& place = product_node.second; - kernel_logger.SetProduct(product); + kernel_logger.set_product(product); IfcGeom::BRepElement* brep = static_cast(create_processed_element_([kernel, settings, product, place, rep]() { return kernel->create_brep_for_representation_and_product(rep->item, product, place); })); if (!brep) { - kernel_logger.SetProduct(boost::none); + kernel_logger.set_product(std::optional{}); return; } auto elem = process_based_on_settings(settings, brep, kernel_logger); if (!elem) { - kernel_logger.SetProduct(boost::none); + kernel_logger.set_product(std::optional{}); return; } @@ -405,9 +405,9 @@ void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kerne const express::Base product2 = p.first; const auto& place2 = p.second; - kernel_logger.SetProduct(product2); + kernel_logger.set_product(product2); - IfcGeom::BRepElement* brep2 = static_cast(decorate_with_cache_(GeometrySerializer::READ_BREP, (std::string)product2->get("GlobalId"), std::to_string(rep->item->instance->as()->id()), [kernel, settings, product2, place2, brep]() { + IfcGeom::BRepElement* brep2 = static_cast(create_processed_element_([kernel, settings, product2, place2, brep]() { return kernel->create_brep_for_processed_representation(product2, place2, brep); })); if (brep2) { @@ -419,20 +419,20 @@ void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kerne } } - kernel_logger.SetProduct(boost::none); + kernel_logger.set_product(std::optional{}); } -IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geometry::Settings settings, IfcGeom::BRepElement* elem, Logger& logger, IfcGeom::TriangulationElement* previous) +IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geometry::Settings settings, IfcGeom::BRepElement* elem, ::logger& logger, IfcGeom::TriangulationElement* previous) { if (settings.get().get() == ifcopenshell::geometry::settings::SERIALIZED) { try { return new IfcGeom::SerializedElement(*elem); } catch (...) { - logger.message(logger::LOG_ERROR, "GEO", 54, "Getting a serialized element from model failed."); + logger.message(::logger::LOG_ERROR, "GEO", 54, "Getting a serialized element from model failed."); return nullptr; } } else if (settings.get().get() == ifcopenshell::geometry::settings::TRIANGULATED) { - return create_processed_element_([elem, previous]() { + return create_processed_element_([elem, previous, &logger]() { try { if (!previous) { return new TriangulationElement(*elem); @@ -440,7 +440,7 @@ IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geo return new TriangulationElement(*elem, previous->geometry_pointer()); } } catch (...) { - logger.Message(Logger::LOG_ERROR, "GEO", 55, "Getting a triangulation element from model failed."); + logger.message(::logger::LOG_ERROR, "GEO", 55, "Getting a triangulation element from model failed."); } return (TriangulationElement*)nullptr; }); @@ -481,7 +481,7 @@ void IfcGeom::Iterator::log_timepoints() const { for (auto it = time_points.begin() + 1; it != time_points.end(); ++it) { auto jt = it - 1; duration ms_double = (*it) - (*jt); - logger_.Notice("SYS", 28, labels[std::distance(time_points.begin(), jt)] + " took " + std::to_string(ms_double.count()) + "ms"); + logger_.notice("SYS", 28, labels[std::distance(time_points.begin(), jt)] + " took " + std::to_string(ms_double.count()) + "ms"); } } @@ -516,7 +516,7 @@ express::Base IfcGeom::Iterator::next() { if (num_threads_ != 1) { if (!wait_for_element()) { - logger_.SetProduct(boost::none); + logger_.set_product(std::optional{}); time_points[3] = high_resolution_clock::now(); log_timepoints(); task_result_ptr_exhausted = true; @@ -532,7 +532,7 @@ express::Base IfcGeom::Iterator::next() { // shape representation if (task_result_iterator_ == --all_processed_elements_.end()) { if (!create()) { - logger_.SetProduct(boost::none); + logger_.set_product(std::optional{}); time_points[3] = high_resolution_clock::now(); log_timepoints(); task_result_ptr_exhausted = true; @@ -569,7 +569,7 @@ IfcGeom::Element* IfcGeom::Iterator::get() try { parent_object = get_object(ret->parent_id()); } catch (const std::exception& e) { - logger_.Error("GEO", 56, e); + logger_.error("GEO", 56, e); hasParent = false; } @@ -587,7 +587,7 @@ IfcGeom::Element* IfcGeom::Iterator::get() try { parent_object = get_object(pid); } catch (const std::exception& e) { - logger_.Error("GEO", 57, e); + logger_.error("GEO", 57, e); hasParent = false; } } @@ -634,9 +634,9 @@ const IfcGeom::Element* IfcGeom::Iterator::get_object(int id) { m4 = casted->matrix; } } catch (const std::exception& e) { - logger_.Error("GEO", 58, e); + logger_.error("GEO", 58, e); } catch (...) { - logger_.Error("GEO", 59, "Unknown error returning product"); + logger_.error("GEO", 59, "Unknown error returning product"); } Element* ifc_object = new Element(settings_, id, parent_id, product_name, instance_type, product_guid, "", m4, ifc_product.as()); @@ -648,10 +648,10 @@ express::Base IfcGeom::Iterator::create() { try { product = create_shape_model_for_next_entity(); } catch (const std::exception& e) { - logger_.Error("GEO", 60, e); + logger_.error("GEO", 60, e); had_error_processing_elements_ = true; } catch (...) { - logger_.Error("GEO", 61, "Unknown error creating geometry"); + logger_.error("GEO", 61, "Unknown error creating geometry"); had_error_processing_elements_ = true; } return product; @@ -823,8 +823,8 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs } } - logger_.Notice("SYS", 29, "Removed large offsets within " + std::to_string(num_offset_applied) + " products"); - logger_.Notice("SYS", 30, "Offset applied (" + std::to_string(vec(0)) + "," + std::to_string(vec(1)) + "," + std::to_string(vec(2)) + ")"); + logger_.notice("SYS", 29, "Removed large offsets within " + std::to_string(num_offset_applied) + " products"); + logger_.notice("SYS", 30, "Offset applied (" + std::to_string(vec(0)) + "," + std::to_string(vec(1)) + "," + std::to_string(vec(2)) + ")"); return make(vec); } diff --git a/src/ifcgeom/Iterator.h b/src/ifcgeom/Iterator.h index 9dfefb61d3..cf6ba58461 100644 --- a/src/ifcgeom/Iterator.h +++ b/src/ifcgeom/Iterator.h @@ -128,14 +128,14 @@ namespace IfcGeom { std::vector filters_; int num_threads_; std::string geometry_library_; - Logger& logger_; + ::logger& logger_; // When single-threaded ifcopenshell::geometry::Converter* converter_; // When multi-threaded std::vector kernel_pool; - std::vector> worker_loggers_; + std::vector> worker_loggers_; // The object is fetched beforehand to be sure that get() returns a valid element TriangulationElement* current_triangulation; @@ -170,7 +170,7 @@ namespace IfcGeom { IfcGeom::Element* process_based_on_settings( ifcopenshell::geometry::Settings settings, IfcGeom::BRepElement* elem, - Logger& logger, + ::logger& logger, IfcGeom::TriangulationElement* previous = nullptr); void flush_worker_log(ifcopenshell::geometry::Converter* kernel); @@ -183,7 +183,7 @@ namespace IfcGeom { ifcopenshell::geometry::taxonomy::direction3::ptr remove_offset_(); public: - Iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geometry::Settings& settings, ifcopenshell::file* file, const std::vector& filters, int num_threads, Logger& logger = Logger::Root()) + Iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geometry::Settings& settings, ifcopenshell::file* file, const std::vector& filters, int num_threads, ::logger& logger = ::logger::root()) : settings_(settings) , ifc_file(file) , filters_(filters) @@ -195,7 +195,7 @@ namespace IfcGeom { { } - Iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geometry::Settings& settings, ifcopenshell::file* file, Logger& logger = Logger::Root()) + Iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geometry::Settings& settings, ifcopenshell::file* file, ::logger& logger = ::logger::root()) : settings_(settings) , ifc_file(file) , num_threads_(1) @@ -205,7 +205,7 @@ namespace IfcGeom { { } - Iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geometry::Settings& settings, ifcopenshell::file* file, int num_threads, Logger& logger = Logger::Root()) + Iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geometry::Settings& settings, ifcopenshell::file* file, int num_threads, ::logger& logger = ::logger::root()) : settings_(settings) , ifc_file(file) , num_threads_(num_threads) @@ -276,7 +276,7 @@ namespace IfcGeom { return progress_; } - std::string getLog() const { return logger_.GetLog(); } + std::string getLog() const { return logger_.get_log(); } ifcopenshell::file* file() const { return ifc_file; } diff --git a/src/ifcgeom/Serialization/schema/Serialization.cpp b/src/ifcgeom/Serialization/schema/Serialization.cpp index 0f00347f72..f7436342d2 100644 --- a/src/ifcgeom/Serialization/schema/Serialization.cpp +++ b/src/ifcgeom/Serialization/schema/Serialization.cpp @@ -112,7 +112,7 @@ namespace { #endif template <> -int convert_to_ifc(ifcopenshell::file& f, const opencascade::handle& c, IfcSchema::IfcCurve*& curve, bool advanced) { +int convert_to_ifc(ifcopenshell::file& f, const opencascade::handle& c, IfcSchema::IfcCurve& curve, bool advanced) { if (c->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) { opencascade::handle trim = opencascade::handle::DownCast(c); const opencascade::handle basis = trim->BasisCurve(); @@ -155,7 +155,7 @@ int convert_to_ifc(ifcopenshell::file& f, const opencascade::handle& IfcSchema::IfcAxis2Placement3D ax; opencascade::handle ellipse = opencascade::handle::DownCast(c); - convert_to_ifc(ellipse.Position(), ax, advanced); + convert_to_ifc(f, ellipse->Position(), ax, advanced); auto el = f.create(); el.setPosition(ax); @@ -208,6 +208,7 @@ int convert_to_ifc(ifcopenshell::file& f, const opencascade::handle& bspl.setKnots(knots); bspl.setKnotSpec(knot_spec); bspl.setWeightsData(weights); + curve = bspl; return 1; } @@ -277,6 +278,7 @@ int convert_to_ifc(ifcopenshell::file& f, const opencascade::handle& bspl.setKnotMultiplicities(mults); bspl.setKnots(knots); bspl.setKnotSpec(knot_spec); + curve = bspl; return 1; } diff --git a/src/ifcgeom/Serializer.h b/src/ifcgeom/Serializer.h index 23170fa4f6..edeaf4d63b 100644 --- a/src/ifcgeom/Serializer.h +++ b/src/ifcgeom/Serializer.h @@ -24,12 +24,12 @@ #include "../ifcparse/file.h" class IFC_GEOM_API Serializer { - Logger& logger_; + ::logger& logger_; public: - explicit Serializer(Logger& logger = Logger::Root()) : logger_(logger) {} + explicit Serializer(::logger& logger = ::logger::root()) : logger_(logger) {} virtual ~Serializer() {} - Logger& logger() const { return logger_; } + ::logger& logger() const { return logger_; } virtual bool ready() = 0; virtual bool is_streaming() const { return false; } diff --git a/src/ifcgeom/abstract_mapping.cpp b/src/ifcgeom/abstract_mapping.cpp index 53ac7f3089..19dfd17ad4 100644 --- a/src/ifcgeom/abstract_mapping.cpp +++ b/src/ifcgeom/abstract_mapping.cpp @@ -23,7 +23,7 @@ void ifcopenshell::geometry::impl::mapping_registry::bind(const std::string& sch entry.module_ = module.meta().id.empty() ? plugin::module(mapping_plugin_metadata(schema_name)) : module; } -ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::mapping_registry::construct(ifcopenshell::file* file, Settings& s) { +ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::mapping_registry::construct(ifcopenshell::file* file, Settings& s, ::logger& log) { const std::string schema_name_lower = boost::to_lower_copy(file->schema()->name()); auto it = entries_.find(schema_name_lower); if (it == entries_.end()) { @@ -33,8 +33,13 @@ ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::mapping_ if (it == entries_.end()) { throw ifcopenshell::exception("No geometry mapping registered for " + schema_name_lower); } - auto new_mapping = it->second.fn_(file, s); - new_mapping->initialize_settings(); + auto new_mapping = it->second.fn_(file, s, log); + try { + new_mapping->initialize_settings(); + } catch (const std::exception& e) { + log.error("GEO", 400, e); + log.error("GEO", 401, "Unable to initialize conversion settings"); + } return new_mapping; } @@ -51,19 +56,6 @@ void ifcopenshell::geometry::impl::MappingFactoryImplementation::bind(const std: mapping_registry_instance().bind(schema_name, fn, plugin::module(mapping_plugin_metadata(schema_name))); } -ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::MappingFactoryImplementation::construct(ifcopenshell::file* file, Settings& s, Logger& logger) { - const std::string schema_name_lower = boost::to_lower_copy(file->schema()->name()); - std::map::const_iterator it; - it = this->find(schema_name_lower); - if (it == end()) { - throw IfcParse::IfcException("No geometry mapping registered for " + schema_name_lower); - } - auto new_mapping = it->second(file, s, logger); - try { - new_mapping->initialize_settings(); - } catch (const std::exception& e) { - logger.Error("GEO", 400, e); - logger.Error("GEO", 401, "Unable to initialize conversion settings"); - } - return new_mapping; +ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::MappingFactoryImplementation::construct(ifcopenshell::file* file, Settings& s, ::logger& log) { + return mapping_registry_instance().construct(file, s, log); } diff --git a/src/ifcgeom/abstract_mapping.h b/src/ifcgeom/abstract_mapping.h index 01a872f293..5ad8b2c6cc 100644 --- a/src/ifcgeom/abstract_mapping.h +++ b/src/ifcgeom/abstract_mapping.h @@ -49,12 +49,12 @@ namespace geometry { class IFC_GEOM_API abstract_mapping { protected: Settings settings_; - Logger& logger_; + ::logger& logger_; bool use_caching_ = true; public: - abstract_mapping(Settings& s, Logger& logger = Logger::Root()) : settings_(s), logger_(logger) {} + abstract_mapping(Settings& s, ::logger& logger = ::logger::root()) : settings_(s), logger_(logger) {} virtual ~abstract_mapping() {} virtual ifcopenshell::geometry::taxonomy::ptr map(const express::Base&) = 0; @@ -73,19 +73,19 @@ namespace geometry { const Settings& settings() const { return settings_; } Settings& settings() { return settings_; } - Logger& logger() const { return logger_; } + ::logger& logger() const { return logger_; } bool use_caching() const { return use_caching_; } bool& use_caching() { return use_caching_; } }; namespace impl { - typedef boost::function3 mapping_fn; + typedef boost::function3 mapping_fn; class IFC_GEOM_API mapping_registry { public: void bind(const std::string& schema_name, mapping_fn fn, const ifcopenshell::plugin::module& module = ifcopenshell::plugin::module()); - abstract_mapping* construct(ifcopenshell::file* file, Settings& settings); + abstract_mapping* construct(ifcopenshell::file* file, Settings& settings, ::logger& logger = ::logger::root()); private: struct entry { @@ -102,7 +102,7 @@ namespace geometry { public: MappingFactoryImplementation(); void bind(const std::string& schema_name, mapping_fn); - abstract_mapping* construct(ifcopenshell::file*, Settings&, Logger& logger = Logger::Root()); + abstract_mapping* construct(ifcopenshell::file*, Settings&, ::logger& logger = ::logger::root()); }; IFC_GEOM_API MappingFactoryImplementation& mapping_implementations(); diff --git a/src/ifcgeom/function_item_evaluator.cpp b/src/ifcgeom/function_item_evaluator.cpp index 433cc36cba..4e8b890be8 100644 --- a/src/ifcgeom/function_item_evaluator.cpp +++ b/src/ifcgeom/function_item_evaluator.cpp @@ -76,7 +76,7 @@ struct piecewise_fn_evaluator : public fn_evaluator { span_start += fn->length(); } - logger_.Error("GEO", 37, "piecewise span not found."); + logger_.error("GEO", 37, "piecewise span not found."); return {0, 0, nullptr}; } @@ -208,7 +208,7 @@ struct offset_fn_evaluator : public fn_evaluator { -function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::Settings& settings,taxonomy::function_item::const_ptr fn, Logger& logger) : logger_(logger) { +function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::Settings& settings,taxonomy::function_item::const_ptr fn, logger& logger) : logger_(logger) { auto kind = fn ? fn->kind() : taxonomy::kinds::NODE; if (kind == taxonomy::FUNCTOR_ITEM) { fn_evaluator_ = new functor_fn_evaluator(std::dynamic_pointer_cast(fn),settings); @@ -221,7 +221,7 @@ function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::S } else if (kind == taxonomy::OFFSET_FUNCTION) { fn_evaluator_ = new offset_fn_evaluator(std::dynamic_pointer_cast(fn), settings); } else { - logger_.Error("GEO", 38, "Unexpected function type"); + logger_.error("GEO", 38, "Unexpected function type"); } } diff --git a/src/ifcgeom/function_item_evaluator.h b/src/ifcgeom/function_item_evaluator.h index 1b9521f948..e700da14a0 100644 --- a/src/ifcgeom/function_item_evaluator.h +++ b/src/ifcgeom/function_item_evaluator.h @@ -23,7 +23,7 @@ static taxonomy::function_item::ptr convert_loop_to_function_item(taxonomy::loop /// @brief Abstract class for evaluating a function_item. This class is specialized for each of the function_item types. struct IFC_GEOM_API fn_evaluator { - fn_evaluator(const ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root()) : settings_(settings), logger_(logger) { + fn_evaluator(const ifcopenshell::geometry::Settings& settings, logger& logger = ::logger::root()) : settings_(settings), logger_(logger) { } fn_evaluator(const fn_evaluator& other) = default; virtual ~fn_evaluator() = default; @@ -38,13 +38,13 @@ struct IFC_GEOM_API fn_evaluator { ifcopenshell::geometry::Settings settings_; protected: - Logger& logger_; + logger& logger_; }; /// @brief utility class to evaluate function_item objects. class IFC_GEOM_API function_item_evaluator { public: - function_item_evaluator(const ifcopenshell::geometry::Settings& settings, taxonomy::function_item::const_ptr fn, Logger& logger = Logger::Root()); + function_item_evaluator(const ifcopenshell::geometry::Settings& settings, taxonomy::function_item::const_ptr fn, logger& logger = ::logger::root()); function_item_evaluator(const function_item_evaluator& other); ~function_item_evaluator(); @@ -80,7 +80,7 @@ class IFC_GEOM_API function_item_evaluator { fn_evaluator* fn_evaluator_ = nullptr; mutable std::optional> eval_points_; // cache evaluation points - Logger& logger_; + logger& logger_; }; }} diff --git a/src/ifcgeom/hybrid_kernel.h b/src/ifcgeom/hybrid_kernel.h index 4a8581be22..14582e95ff 100644 --- a/src/ifcgeom/hybrid_kernel.h +++ b/src/ifcgeom/hybrid_kernel.h @@ -32,7 +32,7 @@ namespace ifcopenshell { ifcopenshell::geometry::abstract_mapping* mapping_; ifcopenshell::file* file_; public: - HybridKernel(const std::string& name, ifcopenshell::file* file, Settings& settings, std::vector>&& kernels, Logger& logger = Logger::Root()) + HybridKernel(const std::string& name, ifcopenshell::file* file, Settings& settings, std::vector>&& kernels, ::logger& logger = ::logger::root()) : AbstractKernel(name, settings, logger) , kernels_(std::move(kernels)) , mapping_(ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings, logger)) @@ -127,7 +127,7 @@ namespace ifcopenshell { } return false; } - virtual AbstractKernel* clone(Logger& logger) const + virtual AbstractKernel* clone(::logger& logger) const { std::vector> ks; for (auto& k : kernels_) { diff --git a/src/ifcgeom/infra_sweep_helper.cpp b/src/ifcgeom/infra_sweep_helper.cpp index e2f048bb45..ca30092df8 100644 --- a/src/ifcgeom/infra_sweep_helper.cpp +++ b/src/ifcgeom/infra_sweep_helper.cpp @@ -35,7 +35,7 @@ bool has_intersection(const std::set& A, } -taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, const express::Base inst, const taxonomy::function_item::ptr& fn, std::vector& cross_sections, Logger& logger) +taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, const express::Base inst, const taxonomy::function_item::ptr& fn, std::vector& cross_sections, logger& logger) { std::sort(cross_sections.begin(), cross_sections.end()); @@ -51,7 +51,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, double end = std::min(fn->length(), cross_sections.back().dist_along); if (end - start < 1.e-9) { - logger.Warning("GEO", 40, "Empty sweep domain with start at " + std::to_string(cross_sections.front().dist_along) + " end at " + std::to_string(cross_sections.back().dist_along) + " and curve domain length " + std::to_string(fn->length()), inst); + logger.warning("GEO", 40, "Empty sweep domain with start at " + std::to_string(cross_sections.front().dist_along) + " end at " + std::to_string(cross_sections.back().dist_along) + " and curve domain length " + std::to_string(fn->length()), inst); return nullptr; } @@ -130,7 +130,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, auto profile_b_f = std::static_pointer_cast(profile_b); if (profile_a_f->children.size() != profile_b_f->children.size()) { - logger.Warning("GEO", 41, "Mismatching number of face boundaries: " + + logger.warning("GEO", 41, "Mismatching number of face boundaries: " + std::to_string(profile_a_f->children.size()) + " vs " + std::to_string(profile_b_f->children.size()), inst @@ -165,7 +165,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, // in which case we would need to lerp with the rotation component below in m4b. interpolated_rotation = lerp(*rotation_a, *rotation_b, relative_dist_along); } else if (rotation_a != rotation_b) { - logger.Error("GEO", 42, "Direction vectors on cross section placements only supported when used consistently"); + logger.error("GEO", 42, "Direction vectors on cross section placements only supported when used consistently"); } taxonomy::loop::ptr w1, w2; @@ -176,12 +176,12 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, boost::tie(w1, w2) = tmp_; if (w1->closed != w2->closed) { - logger.Warning("GEO", 43, "Mismatching closed property on loops", inst); + logger.warning("GEO", 43, "Mismatching closed property on loops", inst); return nullptr; } - if (w1->tags.is_initialized() != w2->tags.is_initialized()) { - logger.Warning("GEO", 44, "Mismatching availability tags on loops", inst); + if (w1->tags.has_value() != w2->tags.has_value()) { + logger.warning("GEO", 44, "Mismatching availability tags on loops", inst); return nullptr; } @@ -190,7 +190,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, std::set tags_seen; for (const auto& t : *w1->tags) { if (tags_seen.find(t) != tags_seen.end()) { - logger.Warning("GEO", 45, "Duplicate tag '" + t + "' on loft profile", inst); + logger.warning("GEO", 45, "Duplicate tag '" + t + "' on loft profile", inst); return nullptr; } tags_seen.insert(t); @@ -202,7 +202,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, std::set tags_seen; for (const auto& t : *w2->tags) { if (tags_seen.find(t) != tags_seen.end()) { - logger.Warning("GEO", 46, "Duplicate tag '" + t + "' on loft profile", inst); + logger.warning("GEO", 46, "Duplicate tag '" + t + "' on loft profile", inst); return nullptr; } tags_seen.insert(t); @@ -303,20 +303,20 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, for (auto& p1_tags : w1_tags) { if (!has_intersection(p1_tags, w2_tags_combined)) { - logger.Warning("GEO", 47, "No matching tags found on loft profiles: " + join_tags(p1_tags) + " not in " + join_tags(w2_tags_combined), inst); + logger.warning("GEO", 47, "No matching tags found on loft profiles: " + join_tags(p1_tags) + " not in " + join_tags(w2_tags_combined), inst); return nullptr; } } for (auto& p2_tags : w2_tags) { if (!has_intersection(p2_tags, w1_tags_combined)) { - logger.Warning("GEO", 48, "No matching tags found on loft profiles: " + join_tags(p2_tags) + " not in " + join_tags(w1_tags_combined), inst); + logger.warning("GEO", 48, "No matching tags found on loft profiles: " + join_tags(p2_tags) + " not in " + join_tags(w1_tags_combined), inst); return nullptr; } } } else { if (w1->children.size() != w2->children.size()) { - logger.Warning("GEO", 49, "Mismatching number of edges: " + + logger.warning("GEO", 49, "Mismatching number of edges: " + std::to_string(w1->children.size()) + " vs " + std::to_string(w2->children.size()), inst); @@ -396,7 +396,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, auto m4 = evaluator.evaluate(dist_along); /* { - std::wcout << "#" << pwf->instance->data().id() << " " << dist_along << ": " << m4.col(3).row(2).value() << std::endl; + std::wcout << "#" << pwf->instance.data().id() << " " << dist_along << ": " << m4.col(3).row(2).value() << std::endl; }*/ Eigen::Matrix4d m4b = Eigen::Matrix4d::Identity(); diff --git a/src/ifcgeom/infra_sweep_helper.h b/src/ifcgeom/infra_sweep_helper.h index e2400dda19..296206d18d 100644 --- a/src/ifcgeom/infra_sweep_helper.h +++ b/src/ifcgeom/infra_sweep_helper.h @@ -21,7 +21,7 @@ namespace ifcopenshell { } }; - IFC_GEOM_API taxonomy::loft::ptr make_loft(const Settings& settings_, const express::Base inst, const taxonomy::function_item::ptr& directrix, std::vector& cross_sections, Logger& logger = Logger::Root()); + IFC_GEOM_API taxonomy::loft::ptr make_loft(const Settings& settings_, const express::Base inst, const taxonomy::function_item::ptr& directrix, std::vector& cross_sections, logger& logger = ::logger::root()); } } diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp index be0e4aca1c..a193b13596 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp @@ -266,7 +266,7 @@ namespace { } } -ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool convex, Logger& logger) { +ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool convex, ::logger& logger) { shape_ = shape; convex_tag_ = convex; auto& poly = std::get(*shape_); @@ -280,7 +280,7 @@ ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool con auto b2 = plane.base2(); if (V.squared_length() == 0) { - logger.Warning("GEO", 62, "Removed face due to self-intersections"); + logger.warning("GEO", 62, "Removed face due to self-intersections"); faces_to_remove.insert(face); continue; } @@ -301,7 +301,7 @@ ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool con } if (!CGAL::Polygon_2(ps.begin(), ps.end()).is_simple()) { - logger.Warning("GEO", 63, "Removed face due to self-intersections"); + logger.warning("GEO", 63, "Removed face due to self-intersections"); faces_to_remove.insert(face); } } @@ -362,7 +362,7 @@ void ifcopenshell::geometry::CgalShape::to_nef() const { } #endif -void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger) const { +void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { if (is_point() || is_wire()) { return; } @@ -415,7 +415,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett if (!all_triangles) { if (!shape_to_use->is_valid()) { - logger.Message(Logger::LOG_ERROR, "GEO", 64, "Invalid Polyhedron_3 in object (before triangulation)"); + logger.message(::logger::LOG_ERROR, "GEO", 64, "Invalid Polyhedron_3 in object (before triangulation)"); return; } @@ -423,19 +423,19 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett try { success = CGAL::Polygon_mesh_processing::triangulate_faces(*shape_to_use); } catch (...) { - logger.Message(Logger::LOG_ERROR, "GEO", 65, "Triangulation crashed"); + logger.message(::logger::LOG_ERROR, "GEO", 65, "Triangulation crashed"); return; } CGAL::Polygon_mesh_processing::remove_degenerate_faces(*shape_to_use); if (!success) { - logger.Message(Logger::LOG_ERROR, "GEO", 66, "Triangulation failed"); + logger.message(::logger::LOG_ERROR, "GEO", 66, "Triangulation failed"); return; } if (!shape_to_use->is_valid()) { - logger.Message(Logger::LOG_ERROR, "GEO", 67, "Invalid Polyhedron_3 in object (after triangulation)"); + logger.message(::logger::LOG_ERROR, "GEO", 67, "Invalid Polyhedron_3 in object (after triangulation)"); return; } } @@ -464,7 +464,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett try { CGAL::Polygon_mesh_processing::compute_face_normals(*shape_to_use, face_normals_map); } catch (...) { - logger.Message(Logger::LOG_ERROR, "GEO", 68, "Face normal calculation failed"); + logger.message(::logger::LOG_ERROR, "GEO", 68, "Face normal calculation failed"); return; } @@ -1033,7 +1033,7 @@ bool ifcopenshell::geometry::CgalShape::surface_area_along_direction(double tol, #ifndef IFOPSH_SIMPLE_KERNEL -void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger) const { +void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { throw std::runtime_error("Not implemented"); } diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.h b/src/ifcgeom/kernels/cgal/CgalConversionResult.h index 7d277e2e83..9edfd4b5e5 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.h +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.h @@ -187,13 +187,8 @@ namespace ifcopenshell { namespace geometry { mutable std::optional> nef_; #endif public: -#ifdef IFOPSH_SIMPLE_KERNEL - std::string type() const override { return "CgalSimpleShape"; } -#else - std::string type() const override { return "CgalShape"; } -#endif - CgalShape(const cgal_shape_t& shape, bool convex = false, Logger& logger = Logger::Root()); + CgalShape(const cgal_shape_t& shape, bool convex = false, ::logger& logger = ::logger::root()); CgalShape(const cgal_point_t& point, bool convex = false); CgalShape(const cgal_wire_t& wire, bool convex = false); @@ -231,7 +226,7 @@ namespace ifcopenshell { namespace geometry { const cgal_point_t& point() const { return std::get(*shape_); } const cgal_wire_t& wire() const { return std::get(*shape_); } - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const; + virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const; virtual IfcGeom::ConversionResultShape* clone() const { @@ -304,8 +299,6 @@ namespace ifcopenshell { namespace geometry { std::list> planes_; public: - std::string type() const override { return "CgalShapeHalfSpaceDecomposition"; } - CgalShapeHalfSpaceDecomposition(const CGAL::Nef_polyhedron_3& shape, bool is_convex) { if (is_convex) { shape_ = std::move(build_halfspace_tree_is_decomposed(shape, planes_)); @@ -326,7 +319,7 @@ namespace ifcopenshell { namespace geometry { #endif } - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const; + virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const; virtual int surface_genus() const; diff --git a/src/ifcgeom/kernels/cgal/CgalKernel.cpp b/src/ifcgeom/kernels/cgal/CgalKernel.cpp index fbdce8a8a6..debcd7d4cf 100644 --- a/src/ifcgeom/kernels/cgal/CgalKernel.cpp +++ b/src/ifcgeom/kernels/cgal/CgalKernel.cpp @@ -46,15 +46,15 @@ namespace { struct PolyhedronBuilder : public CGAL::Modifier_base::HalfedgeDS> { private: std::list *face_list; - Logger& logger_; + logger& logger_; public: std::optional from_soup; - PolyhedronBuilder(std::list *face_list, Logger& logger = Logger::Root()); + PolyhedronBuilder(std::list *face_list, logger& logger = ::logger::root()); void operator()(CGAL::Polyhedron_3::HalfedgeDS &hds); }; } -CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_polyhedron(std::list &face_list, bool stitch_borders, Logger& logger) { +CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_polyhedron(std::list &face_list, bool stitch_borders, logger& logger) { // Naive creation CGAL::Polyhedron_3 polyhedron; @@ -77,7 +77,7 @@ CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_polyhedron(std polyhedron.normalize_border(); if (!polyhedron.is_valid(false, 1)) { - logger.Message(Logger::LOG_ERROR, "GEO", 69, "create_polyhedron: Polyhedron not valid!"); + logger.message(::logger::LOG_ERROR, "GEO", 69, "create_polyhedron: Polyhedron not valid!"); // std::ofstream fresult; // fresult.open("/Users/ken/Desktop/invalid.off"); // fresult << polyhedron << std::endl; @@ -91,23 +91,23 @@ CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_polyhedron(std } #ifndef IFOPSH_SIMPLE_KERNEL -CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_polyhedron(const CGAL::Nef_polyhedron_3& nef_polyhedron, Logger& logger) { +CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_polyhedron(const CGAL::Nef_polyhedron_3& nef_polyhedron, logger& logger) { if (nef_polyhedron.is_simple()) { try { CGAL::Polyhedron_3 polyhedron; nef_polyhedron.convert_to_polyhedron(polyhedron); return polyhedron; } catch (...) { - logger.Message(Logger::LOG_ERROR, "GEO", 70, "Conversion from Nef to polyhedron failed!"); + logger.message(::logger::LOG_ERROR, "GEO", 70, "Conversion from Nef to polyhedron failed!"); return CGAL::Polyhedron_3(); } } else { - logger.Message(Logger::LOG_ERROR, "GEO", 71, "Nef polyhedron not simple: cannot create polyhedron!"); + logger.message(::logger::LOG_ERROR, "GEO", 71, "Nef polyhedron not simple: cannot create polyhedron!"); return CGAL::Polyhedron_3(); } } -CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhedron(std::list &face_list, Logger& logger) { +CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhedron(std::list &face_list, logger& logger) { CGAL::Polyhedron_3 polyhedron = create_polyhedron(face_list, true, logger); if (polyhedron.is_closed()) { try { @@ -115,7 +115,7 @@ CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhe CGAL::Polygon_mesh_processing::reverse_face_orientations(polyhedron); } } catch (CGAL::Failure_exception& e) { - logger.Message(Logger::LOG_ERROR, "GEO", 72, e); + logger.message(::logger::LOG_ERROR, "GEO", 72, e); } } CGAL::Polygon_mesh_processing::triangulate_faces(polyhedron); @@ -123,12 +123,12 @@ CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhe try { nef_polyhedron = CGAL::Nef_polyhedron_3(polyhedron); } catch (...) { - logger.Message(Logger::LOG_ERROR, "GEO", 73, "Conversion to Nef polyhedron failed!"); + logger.message(::logger::LOG_ERROR, "GEO", 73, "Conversion to Nef polyhedron failed!"); } return nef_polyhedron; } -CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhedron(CGAL::Polyhedron_3 &polyhedron, Logger& logger) { +CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhedron(CGAL::Polyhedron_3 &polyhedron, logger& logger) { // @todo needed? polyhedron.normalize_border(); @@ -138,7 +138,7 @@ CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhe CGAL::Polygon_mesh_processing::reverse_face_orientations(polyhedron); } } catch (CGAL::Failure_exception& e) { - logger.Message(Logger::LOG_ERROR, "GEO", 74, e); + logger.message(::logger::LOG_ERROR, "GEO", 74, e); } } @@ -149,11 +149,11 @@ CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhe try { nef_polyhedron = CGAL::Nef_polyhedron_3(polyhedron); } catch (...) { - logger.Message(Logger::LOG_ERROR, "GEO", 75, "Conversion to Nef polyhedron failed!"); + logger.message(::logger::LOG_ERROR, "GEO", 75, "Conversion to Nef polyhedron failed!"); } return nef_polyhedron; } else { - logger.Message(Logger::LOG_ERROR, "GEO", 76, "Polyhedron not valid: cannot create Nef polyhedron!"); + logger.message(::logger::LOG_ERROR, "GEO", 76, "Polyhedron not valid: cannot create Nef polyhedron!"); return CGAL::Nef_polyhedron_3(); } } @@ -162,13 +162,13 @@ CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhe bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) { for (auto& f : l->children) { if (f->basis && f->basis->kind() != taxonomy::PLANE) { - logger().Error("UNS", 3, "CGAL Kernel: Non-planar faces not supported at the moment"); + logger().error("UNS", 3, "CGAL Kernel: Non-planar faces not supported at the moment"); throw not_supported_error(); } for (auto& w : f->children) { for (auto& e : w->children) { if (e->basis && e->basis->kind() == taxonomy::BSPLINE_CURVE) { - logger().Error("UNS", 4, "CGAL Kernel: B-spline edge curves not supported at the moment"); + logger().error("UNS", 4, "CGAL Kernel: B-spline edge curves not supported at the moment"); throw not_supported_error(); } } @@ -197,9 +197,9 @@ bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) { double volume = diag(0) * diag(1) * diag(2); // @todo volume van be zero also.. double density = num_points / volume; - logger().Notice("GEO", 77, "Density " + boost::lexical_cast(density), l->instance); + logger().notice("GEO", 77, "Density " + boost::lexical_cast(density), l->instance); if (density > 5000) { - logger().Notice("GEO", 78, "Substituted element with " + boost::lexical_cast(density) + " vertices / m3 with a bounding box"); + logger().notice("GEO", 78, "Substituted element with " + boost::lexical_cast(density) + " vertices / m3 with a bounding box"); CGAL::Point_3 lower(minmax.first(0), minmax.first(1), minmax.first(2)); CGAL::Point_3 upper(minmax.second(0), minmax.second(1), minmax.second(2)); shape = utils::create_cube(lower, upper); @@ -216,10 +216,10 @@ bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) { if (!success) { if (this->partial_success_is_success) { - logger().message(logger::LOG_WARNING, "Failed to convert face, skipping:", f->instance); + logger().message(::logger::LOG_WARNING, "Failed to convert face, skipping:", f->instance); continue; } else { - logger().message(logger::LOG_ERROR, "Failed to convert face:", f->instance); + logger().message(::logger::LOG_ERROR, "Failed to convert face:", f->instance); return false; } } @@ -242,7 +242,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list& } if (face->children.size() > 1 && num_outer_bounds > 1 && face->children.size() != num_outer_bounds) { - logger().Message(Logger::LOG_ERROR, "GEO", 80, "Invalid configuration of boundaries for:", face->instance); + logger().message(::logger::LOG_ERROR, "GEO", 80, "Invalid configuration of boundaries for:", face->instance); return false; } @@ -255,7 +255,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list& cgal_wire_t wire; if (!convert(bound, wire)) { - logger().Message(Logger::LOG_ERROR, "GEO", 81, "Failed to process face boundary loop", bound->instance); + logger().message(::logger::LOG_ERROR, "GEO", 81, "Failed to process face boundary loop", bound->instance); return false; } @@ -709,7 +709,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { if (d < 1.e-5) { points.erase(points.end() - 1); } else { - logger().Warning("GEO", 82, "Loop not closed", loop->instance); + logger().warning("GEO", 82, "Loop not closed", loop->instance); } } @@ -723,7 +723,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { // A loop should consist of at least three vertices std::size_t original_count = polygon.size(); if (original_count < 3) { - logger().Warning("GEO", 83, "Not enough edges for:", loop->instance); + logger().warning("GEO", 83, "Not enough edges for:", loop->instance); return false; } @@ -734,14 +734,14 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { std::size_t count = polygon.size(); if (original_count - count != 0) { std::stringstream ss; ss << (original_count - count) << " edges removed for:"; - logger().Warning("GEO", 84, ss.str(), loop->instance); + logger().warning("GEO", 84, ss.str(), loop->instance); } { std::set visited_points; for (auto& p : polygon) { if (visited_points.find(p) != visited_points.end()) { - logger().Error("GEO", 85, "Skipping self-intersecting loop", loop->instance); + logger().error("GEO", 85, "Skipping self-intersecting loop", loop->instance); // @todo signal somehow that occt kernel might be able to solve this // @todo implement cycle detection using Arrangement_2, but that only works in exact kernel return false; @@ -763,7 +763,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { } if (do_segments_intersect(segments)) { - logger().Message(Logger::LOG_WARNING, "GEO", 86, "Skipping self-intersecting loop", loop->instance); + logger().message(::logger::LOG_WARNING, "GEO", 86, "Skipping self-intersecting loop", loop->instance); return false; } @@ -791,7 +791,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { */ if (count < 3) { - logger().Message(Logger::LOG_ERROR, "GEO", 87, "Not enough edges for:", loop->instance); + logger().message(::logger::LOG_ERROR, "GEO", 87, "Not enough edges for:", loop->instance); return false; } @@ -825,7 +825,7 @@ bool CgalKernel::convert_impl(const taxonomy::shell::ptr shell, ConversionResult bool CgalKernel::convert_impl(const taxonomy::solid::ptr solid, ConversionResults& results) { if (solid->children.size() > 1) { - logger().Error("UNS", 5, "Multiple shells in solid not supported at the moment"); + logger().error("UNS", 5, "Multiple shells in solid not supported at the moment"); return false; } cgal_shape_t shape; @@ -970,7 +970,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const express try { a.convert_to_polyhedron(a_poly); } catch (...) { - logger().Message(Logger::LOG_ERROR, "GEO", 88, "Could not convert from Nef:", entity); + logger().message(::logger::LOG_ERROR, "GEO", 88, "Could not convert from Nef:", entity); return false; } @@ -1169,7 +1169,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir try { nef_shape -= utils::create_nef_polyhedron(face_list); } catch (...) { - logger::message(logger::LOG_ERROR, "IfcExtrudedAreaSolid: cannot subtract opening for:"); + ::logger::root().message(::logger::LOG_ERROR, "IfcExtrudedAreaSolid: cannot subtract opening for:"); return false; } } @@ -1186,7 +1186,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir nef_shape.convert_to_polyhedron(shape); return true; } catch (...) { - logger::message(logger::LOG_ERROR, "IfcExtrudedAreaSolid: cannot convert Nef to polyhedron for:"); + ::logger::root().message(::logger::LOG_ERROR, "IfcExtrudedAreaSolid: cannot convert Nef to polyhedron for:"); return false; } */ @@ -1195,7 +1195,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir bool CgalKernel::convert(const taxonomy::extrusion::ptr extrusion, cgal_shape_t &shape) { const double& height = extrusion->depth; if (height < settings_.get().get()) { - logger().Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance); + logger().message(::logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance); return false; } @@ -1331,13 +1331,13 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, cgal_shape_t shape = shape_const; if (!shape.is_valid()) { - logger().Message(Logger::LOG_ERROR, "GEO", 90, "Conversion to Nef will fail. Invalid geometry:", log_reference); + logger().message(::logger::LOG_ERROR, "GEO", 90, "Conversion to Nef will fail. Invalid geometry:", log_reference); return false; } if (!shape.is_closed()) { // TODO: There can be substractions to remove parts of non-volumetric objects. Maybe iterate over all faces of an entity and put them in a Nef_polyhedron_3 through Boolean union? Highly inefficient but maybe desirable... - logger().Message(Logger::LOG_ERROR, "UNS", 6, "Subtraction of openings not supported for non-closed geometry:", log_reference); + logger().message(::logger::LOG_ERROR, "UNS", 6, "Subtraction of openings not supported for non-closed geometry:", log_reference); return false; } @@ -1346,18 +1346,18 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, try { success = CGAL::Polygon_mesh_processing::triangulate_faces(shape); } catch (CGAL::Failure_exception& e) { - logger().Notice("GEO", 91, e); - logger().Message(Logger::LOG_ERROR, "GEO", 92, "Triangulation of geometry crashed:", log_reference); + logger().notice("GEO", 91, e); + logger().message(::logger::LOG_ERROR, "GEO", 92, "Triangulation of geometry crashed:", log_reference); return false; } if (!success) { - logger().Message(Logger::LOG_ERROR, "GEO", 93, "Triangulation of geometry failed:", log_reference); + logger().message(::logger::LOG_ERROR, "GEO", 93, "Triangulation of geometry failed:", log_reference); return false; } if (CGAL::Polygon_mesh_processing::does_self_intersect(shape)) { - logger().Message(Logger::LOG_ERROR, "GEO", 94, "Conversion to Nef will fail. Self-intersecting geometry:", log_reference); + logger().message(::logger::LOG_ERROR, "GEO", 94, "Conversion to Nef will fail. Self-intersecting geometry:", log_reference); return false; } @@ -1429,8 +1429,8 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, try { result = CGAL::Nef_polyhedron_3(shape); } catch (CGAL::Failure_exception& e) { - logger().Notice("GEO", 95, e); - logger().Message(Logger::LOG_ERROR, "GEO", 96, "Could not convert geometry to Nef:", log_reference); + logger().notice("GEO", 95, e); + logger().message(::logger::LOG_ERROR, "GEO", 96, "Could not convert geometry to Nef:", log_reference); return false; } @@ -1502,8 +1502,8 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, // @todo don't dilate in 3 dimensions but only in the XY plane, orthogonal to wall axis. result = CGAL::minkowski_sum_3(result, precision_cube_); } catch (CGAL::Failure_exception& e) { - logger().Notice("GEO", 97, e); - logger().Message(Logger::LOG_ERROR, "GEO", 98, "Could not dilate boolean operand", log_reference); + logger().notice("GEO", 97, e); + logger().message(::logger::LOG_ERROR, "GEO", 98, "Could not dilate boolean operand", log_reference); return false; } } @@ -1528,8 +1528,8 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, cgal_shape_t convert_back; result.convert_to_polyhedron(convert_back); } catch (CGAL::Failure_exception& e) { - logger().Notice("GEO", 99, e); - logger().Message(Logger::LOG_WARNING, "GEO", 100, "Final conversion will likely fail. Could not convert geometry from Nef:", log_reference); + logger().notice("GEO", 99, e); + logger().message(::logger::LOG_WARNING, "GEO", 100, "Final conversion will likely fail. Could not convert geometry from Nef:", log_reference); } return true; @@ -1851,7 +1851,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion // even-odd fill rule will result in incorrect results. // See for example the Duplex model roof. - logger().Notice("GEO", 101, "Holes are not disjoint"); + logger().notice("GEO", 101, "Holes are not disjoint"); CGAL::Polygon_set_2 result; auto it = loops.begin(); @@ -1904,7 +1904,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion ); }); - logger().Notice("GEO", 102, "Processed boolean operation as 2d arrangement"); + logger().notice("GEO", 102, "Processed boolean operation as 2d arrangement"); return true; @@ -1990,7 +1990,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion ps.push_back({ p.x(), p.y() }); } if (!ps.is_simple()) { - logger().Warning("GEO", 103, "Polygonal boundary not simple", face->children[0]->instance); + logger().warning("GEO", 103, "Polygonal boundary not simple", face->children[0]->instance); continue; } @@ -2136,7 +2136,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion try { a.convert_to_polyhedron(a_poly); } catch (...) { - logger().Message(Logger::LOG_ERROR, "GEO", 104, "Could not convert geometry with openings from Nef:", br->instance); + logger().message(::logger::LOG_ERROR, "GEO", 104, "Could not convert geometry with openings from Nef:", br->instance); return false; } @@ -2151,7 +2151,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion #endif } -PolyhedronBuilder::PolyhedronBuilder(std::list* face_list, Logger& logger) : face_list(face_list), logger_(logger) { +PolyhedronBuilder::PolyhedronBuilder(std::list* face_list, logger& logger) : face_list(face_list), logger_(logger) { } #include @@ -2227,8 +2227,8 @@ void PolyhedronBuilder::operator()(CGAL::Polyhedron_3::HalfedgeDS &hds) // For now let's just skip over the triangle. We can also use // the Aff_transformation_3 stored in place to convert the 2d // coords back to 3d. - logger::warning("Ignoring triangulated facet with novel point likely due to self-intersections"); - logger_.Warning("GEO", 105, "Ignoring triangulated facet with novel point likely due to self-intersections"); + ::logger::root().warning("Ignoring triangulated facet with novel point likely due to self-intersections"); + logger_.warning("GEO", 105, "Ignoring triangulated facet with novel point likely due to self-intersections"); facet_vertices.erase(facet_vertices.end() - 1); break; } @@ -2268,7 +2268,7 @@ void PolyhedronBuilder::operator()(CGAL::Polyhedron_3::HalfedgeDS &hds) if (!CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(facet_vertices)) { // @todo seems to return false now, almost always? - // logger::warning("Reoriented polygonal surface"); + // ::logger::root().warning("Reoriented polygonal surface"); CGAL::Polygon_mesh_processing::orient_polygon_soup(unique_points_as_vector, facet_vertices); } CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(unique_points_as_vector, facet_vertices, *from_soup); @@ -2288,12 +2288,12 @@ void PolyhedronBuilder::operator()(CGAL::Polyhedron_3::HalfedgeDS &hds) if (added_edges.find(p) != added_edges.end()) { if (reoriented) { facet_indices_to_delete.push_back(fi); - logger::notice("Removed facet"); + ::logger::root().notice("Removed facet"); valid = false; break; } else { std::reverse(f.begin(), f.end()); - logger::notice("Reversed facet"); + ::logger::root().notice("Reversed facet"); reoriented = true; goto check_edge_existence; } diff --git a/src/ifcgeom/kernels/cgal/CgalKernel.h b/src/ifcgeom/kernels/cgal/CgalKernel.h index 14be3bcdbe..4001409ebb 100644 --- a/src/ifcgeom/kernels/cgal/CgalKernel.h +++ b/src/ifcgeom/kernels/cgal/CgalKernel.h @@ -20,7 +20,7 @@ #ifndef CGAL_KERNEL_H #define CGAL_KERNEL_H -#include "../../../ifcparse/IfcLogger.h" +#include "../../../ifcparse/logger.h" /* #ifdef NO_CACHE @@ -60,12 +60,12 @@ namespace ifcopenshell { namespace utils { IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_cube(double d); IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_cube(const Kernel_::Point_3& lower, const Kernel_::Point_3& upper); - IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_polyhedron(std::list &face_list, bool stitch_borders = false, Logger& logger = Logger::Root()); + IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_polyhedron(std::list &face_list, bool stitch_borders = false, logger& logger = ::logger::root()); #ifndef IFOPSH_SIMPLE_KERNEL - IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_polyhedron(const CGAL::Nef_polyhedron_3 &nef_polyhedron, Logger& logger = Logger::Root()); - IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3 create_nef_polyhedron(std::list &face_list, Logger& logger = Logger::Root()); - IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3 create_nef_polyhedron(CGAL::Polyhedron_3 &polyhedron, Logger& logger = Logger::Root()); + IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_polyhedron(const CGAL::Nef_polyhedron_3 &nef_polyhedron, logger& logger = ::logger::root()); + IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3 create_nef_polyhedron(std::list &face_list, logger& logger = ::logger::root()); + IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3 create_nef_polyhedron(CGAL::Polyhedron_3 &polyhedron, logger& logger = ::logger::root()); #endif } @@ -93,11 +93,11 @@ namespace ifcopenshell { #endif public: - CgalKernel(const Settings& settings, Logger& logger = Logger::Root()) + CgalKernel(const Settings& settings, ::logger& logger = ::logger::root()) : AbstractKernel("cgal", settings, logger) {} - virtual AbstractKernel* clone(Logger& logger) const { + virtual AbstractKernel* clone(::logger& logger) const { return new CgalKernel(settings(), logger); } diff --git a/src/ifcgeom/kernels/manifold/ManifoldConversionResult.cpp b/src/ifcgeom/kernels/manifold/ManifoldConversionResult.cpp index ec53254bcd..2ee85e0ca2 100644 --- a/src/ifcgeom/kernels/manifold/ManifoldConversionResult.cpp +++ b/src/ifcgeom/kernels/manifold/ManifoldConversionResult.cpp @@ -11,7 +11,6 @@ #include using IfcGeom::ConversionResultShape; -using IfcGeom::NumberNativeDouble; using IfcGeom::OpaqueCoordinate; using IfcGeom::OpaqueNumber; @@ -216,7 +215,7 @@ std::optional ifcopenshell::geometry::ManifoldShape::as_mani return manifold::Manifold::BatchBoolean(solids, manifold::OpType::Add); } -void ifcopenshell::geometry::ManifoldShape::Triangulate(ifcopenshell::geometry::Settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const { +void ifcopenshell::geometry::ManifoldShape::Triangulate(ifcopenshell::geometry::Settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger&) const { for (const auto& part : parts_) { auto mesh = transform_mesh(part.mesh, place); std::vector indices(mesh.NumVert()); @@ -346,13 +345,13 @@ std::pair, OpaqueCoordinate<3>> ifcopenshell::geometry::Mani } auto result = std::make_pair( OpaqueCoordinate<3>( - new NumberNativeDouble(box->min[0]), - new NumberNativeDouble(box->min[1]), - new NumberNativeDouble(box->min[2])), + OpaqueNumber(box->min[0]), + OpaqueNumber(box->min[1]), + OpaqueNumber(box->min[2])), OpaqueCoordinate<3>( - new NumberNativeDouble(box->max[0]), - new NumberNativeDouble(box->max[1]), - new NumberNativeDouble(box->max[2]))); + OpaqueNumber(box->max[0]), + OpaqueNumber(box->max[1]), + OpaqueNumber(box->max[2]))); delete box; return result; } @@ -365,28 +364,28 @@ void ifcopenshell::geometry::ManifoldShape::set_box(void* box_ptr) { parts_ = { make_box_part(*box) }; } -OpaqueNumber* ifcopenshell::geometry::ManifoldShape::length() { +OpaqueNumber ifcopenshell::geometry::ManifoldShape::length() { double total = 0.; for (const auto& part : parts_) { total += mesh_length(part.mesh); } - return new NumberNativeDouble(total); + return OpaqueNumber(total); } -OpaqueNumber* ifcopenshell::geometry::ManifoldShape::area() { +OpaqueNumber ifcopenshell::geometry::ManifoldShape::area() { double total = 0.; for (const auto& part : parts_) { total += part.solid ? part.solid->SurfaceArea() : mesh_area(part.mesh); } - return new NumberNativeDouble(total); + return OpaqueNumber(total); } -OpaqueNumber* ifcopenshell::geometry::ManifoldShape::volume() { +OpaqueNumber ifcopenshell::geometry::ManifoldShape::volume() { double total = 0.; for (const auto& part : parts_) { total += part.solid ? part.solid->Volume() : mesh_volume(part.mesh); } - return new NumberNativeDouble(total); + return OpaqueNumber(total); } OpaqueCoordinate<3> ifcopenshell::geometry::ManifoldShape::position() { @@ -494,11 +493,11 @@ ConversionResultShape* ifcopenshell::geometry::ManifoldShape::concat(ConversionR return new ManifoldShape(std::move(parts)); } -void ifcopenshell::geometry::ManifoldShape::map(OpaqueCoordinate<4>&, OpaqueCoordinate<4>&) { +std::size_t ifcopenshell::geometry::ManifoldShape::map(OpaqueCoordinate<4>&, OpaqueCoordinate<4>&) { throw std::runtime_error("Not implemented"); } -void ifcopenshell::geometry::ManifoldShape::map(const std::vector>&, const std::vector>&) { +std::size_t ifcopenshell::geometry::ManifoldShape::map(const std::vector>&, const std::vector>&) { throw std::runtime_error("Not implemented"); } diff --git a/src/ifcgeom/kernels/manifold/ManifoldConversionResult.h b/src/ifcgeom/kernels/manifold/ManifoldConversionResult.h index 1feb466287..a8d9154772 100644 --- a/src/ifcgeom/kernels/manifold/ManifoldConversionResult.h +++ b/src/ifcgeom/kernels/manifold/ManifoldConversionResult.h @@ -40,7 +40,7 @@ public: std::optional as_manifold() const; virtual std::string_view backend_id() const { return "manifold"; } - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const; + virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const; virtual int surface_genus() const; @@ -54,9 +54,9 @@ public: virtual std::pair, IfcGeom::OpaqueCoordinate<3>> bounding_box() const; virtual void set_box(void* b); - virtual IfcGeom::OpaqueNumber* length(); - virtual IfcGeom::OpaqueNumber* area(); - virtual IfcGeom::OpaqueNumber* volume(); + virtual IfcGeom::OpaqueNumber length(); + virtual IfcGeom::OpaqueNumber area(); + virtual IfcGeom::OpaqueNumber volume(); virtual IfcGeom::OpaqueCoordinate<3> position(); virtual IfcGeom::OpaqueCoordinate<3> axis(); @@ -77,8 +77,8 @@ public: virtual IfcGeom::ConversionResultShape* intersect(IfcGeom::ConversionResultShape*); virtual IfcGeom::ConversionResultShape* concat(IfcGeom::ConversionResultShape*); - virtual void map(IfcGeom::OpaqueCoordinate<4>& from, IfcGeom::OpaqueCoordinate<4>& to); - virtual void map(const std::vector>& from, const std::vector>& to); + virtual std::size_t map(IfcGeom::OpaqueCoordinate<4>& from, IfcGeom::OpaqueCoordinate<4>& to); + virtual std::size_t map(const std::vector>& from, const std::vector>& to); virtual IfcGeom::ConversionResultShape* moved(ifcopenshell::geometry::taxonomy::matrix4::ptr) const; virtual bool surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const; diff --git a/src/ifcgeom/kernels/manifold/ManifoldKernel.cpp b/src/ifcgeom/kernels/manifold/ManifoldKernel.cpp index 794be2f02e..ad18d8f584 100644 --- a/src/ifcgeom/kernels/manifold/ManifoldKernel.cpp +++ b/src/ifcgeom/kernels/manifold/ManifoldKernel.cpp @@ -769,16 +769,16 @@ namespace { const auto shell_info = diagnose_shell(shell); const auto before = diagnose_mesh(before_part.mesh, precision); const auto after = diagnose_mesh(after_mesh, precision); - logger::warning( + ::logger::root().warning( "Manifold kernel: solid shell manifold validation failed; before_transform=" + std::string(before_part.solid ? "solid" : "mesh-only") + " (" + manifold_error_string(before_status) + "), after_transform=(" + manifold_error_string(after_status) + ")", shell->instance); - logger::warning("Manifold kernel: solid shell diagnosis: " + solid_shell_failure_diagnosis(before_part, before, after, before_status, after_status), shell->instance); - logger::warning("Manifold kernel: solid shell input: " + shell_diagnostics_string(shell_info), shell->instance); - logger::warning("Manifold kernel: solid shell mesh before transform: " + mesh_diagnostics_string(before), shell->instance); - logger::warning("Manifold kernel: solid shell transform: " + matrix_diagnostics_string(place), shell->instance); - logger::warning("Manifold kernel: solid shell mesh after transform: " + mesh_diagnostics_string(after), shell->instance); + ::logger::root().warning("Manifold kernel: solid shell diagnosis: " + solid_shell_failure_diagnosis(before_part, before, after, before_status, after_status), shell->instance); + ::logger::root().warning("Manifold kernel: solid shell input: " + shell_diagnostics_string(shell_info), shell->instance); + ::logger::root().warning("Manifold kernel: solid shell mesh before transform: " + mesh_diagnostics_string(before), shell->instance); + ::logger::root().warning("Manifold kernel: solid shell transform: " + matrix_diagnostics_string(place), shell->instance); + ::logger::root().warning("Manifold kernel: solid shell mesh after transform: " + mesh_diagnostics_string(after), shell->instance); } double signed_area(const manifold::SimplePolygon& polygon) { @@ -1492,7 +1492,7 @@ namespace { bool ManifoldKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, IfcGeom::ConversionResults& results) { auto part = part_from_extrusion(extrusion, settings_.get().get(), dilation_hack, settings_.get().get()); if (!part) { - logger::warning("Manifold kernel: failed to convert extrusion, requires planar bounds with line, circle or ellipse edges", extrusion->instance); + ::logger::root().warning("Manifold kernel: failed to convert extrusion, requires planar bounds with line, circle or ellipse edges", extrusion->instance); return false; } results.emplace_back(IfcGeom::ConversionResult( @@ -1507,11 +1507,11 @@ bool ManifoldKernel::convert_impl(const taxonomy::shell::ptr shell, IfcGeom::Con manifold::Manifold::Error status = manifold::Manifold::Error::NoError; auto part = part_from_shell(shell, settings_.get().get(), dilation_hack, &status); if (!part) { - logger::warning("Manifold kernel: failed to convert shell, requires planar polygonal faces with explicit vertices", shell->instance); + ::logger::root().warning("Manifold kernel: failed to convert shell, requires planar polygonal faces with explicit vertices", shell->instance); return false; } if (!part->solid) { - logger::notice("Manifold kernel: shell converted as mesh only (" + manifold_error_string(status) + ")", shell->instance); + ::logger::root().notice("Manifold kernel: shell converted as mesh only (" + manifold_error_string(status) + ")", shell->instance); } results.emplace_back(IfcGeom::ConversionResult( shell->instance.id(), @@ -1528,7 +1528,7 @@ bool ManifoldKernel::convert_impl(const taxonomy::solid::ptr solid, IfcGeom::Con manifold::Manifold::Error before_status = manifold::Manifold::Error::NoError; auto part = part_from_shell(shell, precision, dilation_hack, &before_status); if (!part) { - logger::warning("Manifold kernel: failed to convert solid shell, requires planar polygonal faces with explicit vertices", shell->instance); + ::logger::root().warning("Manifold kernel: failed to convert solid shell, requires planar polygonal faces with explicit vertices", shell->instance); return false; } auto place = shell->matrix ? shell->matrix : taxonomy::make(); @@ -1570,21 +1570,21 @@ bool ManifoldKernel::convert_impl(const taxonomy::boolean_result::ptr br, IfcGeo dilation_hack = first ? 0. : precision * 10.; if (!first && br->operation == taxonomy::boolean_result::SUBTRACTION && face) { if (!first_bbox) { - logger::warning("Manifold kernel: cannot fit halfspace operand without a valid first operand bounds", child->instance); + ::logger::root().warning("Manifold kernel: cannot fit halfspace operand without a valid first operand bounds", child->instance); return false; } HalfspaceBuildState state; auto part = part_from_halfspace_solid(state, solid, face, *first_bbox, precision, dilation_hack); if (!part) { if (state.unchanged && br->operation == taxonomy::boolean_result::SUBTRACTION) { - logger::warning("Manifold kernel: halfspace subtraction yields unchanged volume", child->instance); + ::logger::root().warning("Manifold kernel: halfspace subtraction yields unchanged volume", child->instance); continue; } - logger::warning("Manifold kernel: failed to fit halfspace boolean operand to first operand bounds", child->instance); + ::logger::root().warning("Manifold kernel: failed to fit halfspace boolean operand to first operand bounds", child->instance); return false; } if (!part->solid) { - logger::warning("Manifold kernel: fitted halfspace operand is not a valid manifold solid", child->instance); + ::logger::root().warning("Manifold kernel: fitted halfspace operand is not a valid manifold solid", child->instance); return false; } operand = *part->solid; @@ -1594,12 +1594,12 @@ bool ManifoldKernel::convert_impl(const taxonomy::boolean_result::ptr br, IfcGeo } else { IfcGeom::ConversionResults converted; if (!AbstractKernel::convert(child, converted)) { - logger::warning("Manifold kernel: failed to convert boolean operand", child->instance); + ::logger::root().warning("Manifold kernel: failed to convert boolean operand", child->instance); return false; } operand = results_to_operand(converted); if (!operand) { - logger::warning("Manifold kernel: boolean operand is not a valid manifold solid", child->instance); + ::logger::root().warning("Manifold kernel: boolean operand is not a valid manifold solid", child->instance); return false; } if (!style) { @@ -1612,7 +1612,7 @@ bool ManifoldKernel::convert_impl(const taxonomy::boolean_result::ptr br, IfcGeo if (first) { auto bbox = operand->BoundingBox(); if (!bbox.IsFinite()) { - logger::warning("Manifold kernel: first boolean operand has no valid bounds", child->instance); + ::logger::root().warning("Manifold kernel: first boolean operand has no valid bounds", child->instance); return false; } first_bbox = bbox; @@ -1623,7 +1623,7 @@ bool ManifoldKernel::convert_impl(const taxonomy::boolean_result::ptr br, IfcGeo dilation_hack = 0.; auto result = boolean_result_from_operands(operands, br->operation); if (!result || result->IsEmpty()) { - logger::warning("Manifold kernel: boolean operation produced no result", br->instance); + ::logger::root().warning("Manifold kernel: boolean operation produced no result", br->instance); return false; } results.emplace_back(IfcGeom::ConversionResult( @@ -1638,7 +1638,7 @@ bool ManifoldKernel::convert_openings(const express::Base&, const std::vector opening_operands; auto entity_bbox = results_bbox(entity_shapes); if (!entity_bbox) { - logger::warning("Manifold kernel: host shape has no valid bounds for halfspace fitting"); + ::logger::root().warning("Manifold kernel: host shape has no valid bounds for halfspace fitting"); return false; } dilation_hack = settings_.get().get() * 10.; @@ -1646,19 +1646,19 @@ bool ManifoldKernel::convert_openings(const express::Base&, const std::vector(entity_trsf.ccomponents().inverse() * opening.second.ccomponents()); IfcGeom::ConversionResults converted; if (!AbstractKernel::convert(opening.first, converted)) { - logger::warning("Manifold kernel: failed to convert opening operand", opening.first->instance); + ::logger::root().warning("Manifold kernel: failed to convert opening operand", opening.first->instance); return false; } for (const auto& result : converted) { auto moved = std::unique_ptr(result.Shape()->moved(taxonomy::make(relative->ccomponents() * result.Placement()->ccomponents()))); auto* shape = dynamic_cast(moved.get()); if (!shape) { - logger::warning("Manifold kernel: opening result is not a manifold shape"); + ::logger::root().warning("Manifold kernel: opening result is not a manifold shape"); return false; } auto operand = shape->as_manifold(); if (!operand) { - logger::warning("Manifold kernel: opening result is not a valid manifold solid", opening.first->instance); + ::logger::root().warning("Manifold kernel: opening result is not a valid manifold solid", opening.first->instance); return false; } opening_operands.push_back(*operand); @@ -1672,7 +1672,7 @@ bool ManifoldKernel::convert_openings(const express::Base&, const std::vector().get(), false, settings.get().get()); } catch (...) { - Logger::Root().Message(Logger::LOG_ERROR, "GEO", 183, "Failed to triangulate shape"); + ::logger::root().message(::logger::LOG_ERROR, "GEO", 183, "Failed to triangulate shape"); return; } } @@ -134,7 +134,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr opencascade::handle tri = BRep_Tool::Triangulation(face, loc); if (tri.IsNull()) { - Logger::Root().Message(Logger::LOG_ERROR, "GEO", 184, "Triangulation missing for face"); + ::logger::root().message(::logger::LOG_ERROR, "GEO", 184, "Triangulation missing for face"); } else { // Keep track of the number of times an edge is used // Manifold edges (i.e. edges used twice) are deemed invisible @@ -195,7 +195,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr else triangles(i).Get(n1, n2, n3); if (dict[n1] == dict[n2] || dict[n2] == dict[n3] || dict[n3] == dict[n1]) { - logger.Warning("GEO", 185, "Mesher generated a degenerate triangle, ignoring"); + logger.warning("GEO", 185, "Mesher generated a degenerate triangle, ignoring"); continue; } @@ -640,7 +640,7 @@ namespace { try { BRepMesh_IncrementalMesh(s, tol); } catch (...) { - Logger::Root().Message(Logger::LOG_ERROR, "GEO", 186, "Failed to triangulate shape"); + ::logger::root().message(::logger::LOG_ERROR, "GEO", 186, "Failed to triangulate shape"); return; } meshed = true; diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h index 30857a3a29..5868cee64a 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h @@ -42,18 +42,14 @@ namespace ifcopenshell { class IFC_GEOMLIBRARY_API OpenCascadeShape : public IfcGeom::ConversionResultShape { public: - std::string type() const override { return "OpenCascadeShape"; } - - OpenCascadeShape(const TopoDS_Shape& shape) - : shape_(shape) {} - OpenCascadeShape(TopoDS_Shape&& shape) - : shape_(std::move(shape)) {} + OpenCascadeShape(const TopoDS_Shape& shape); + OpenCascadeShape(TopoDS_Shape&& shape); const TopoDS_Shape& shape() const; operator const TopoDS_Shape& (); virtual std::string_view backend_id() const; - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const; + virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const; virtual IfcGeom::ConversionResultShape* clone() const; diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp b/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp index 766f44a119..054e4dcfa5 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp @@ -120,7 +120,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c auto it3_shape = std::static_pointer_cast(it3->Shape())->shape(); if (it3_shape.IsNull()) { - logger_.Error("GEO", 187, "Null operand"); + logger_.error("GEO", 187, "Null operand"); continue; } @@ -145,7 +145,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c IfcGeom::util::create_solid_from_faces(list, entity_part, settings_.get().get(), true); is_manifold = util::is_manifold(entity_part); if (is_manifold) { - logger_.Warning("GEO", 188, "Successfully sewed non-manifold first operand"); + logger_.warning("GEO", 188, "Successfully sewed non-manifold first operand"); } } @@ -163,17 +163,17 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c failure = "Empty result (no faces) for BOPAlgo_MakerVolume; original was " + std::to_string(IfcGeom::util::count(entity_part, TopAbs_FACE)); } else { is_manifold = util::is_manifold(entity_part_2); - logger_.Warning("GEO", 189, std::string("Sucessfully detected exterior volume to non-manifold first operand; shape is now ") + (is_manifold ? std::string("manifold") : std::string("non-manifold"))); + logger_.warning("GEO", 189, std::string("Sucessfully detected exterior volume to non-manifold first operand; shape is now ") + (is_manifold ? std::string("manifold") : std::string("non-manifold"))); entity_part = entity_part_2; } } catch (const Standard_Failure& e) { failure.emplace(e.GetMessageString()); } if (failure) { - logger_.Warning("GEO", 190, "MakeVolume failed: " + *failure, entity); + logger_.warning("GEO", 190, "MakeVolume failed: " + *failure, entity); } } else { - logger_.Warning("GEO", 191, "Non-manifold first operand, use --make-volume to try and make manifold"); + logger_.warning("GEO", 191, "Non-manifold first operand, use --make-volume to try and make manifold"); } } @@ -189,7 +189,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c const auto& m = it3->Placement()->ccomponents(); // @todo // if (entity_shape_gtrsf.Form() == gp_Other) { - // logger::message(logger::LOG_WARNING, "Applying non uniform transformation to:", entity); + // ::logger::root().message(::logger::LOG_WARNING, "Applying non uniform transformation to:", entity); // } gp_Trsf entity_shape_gtrsf; entity_shape_gtrsf.SetValues( @@ -216,7 +216,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c if (util::boolean_operation(bst, result, opening_list, BOPAlgo_CUT, intermediate_result)) { result = intermediate_result; } else { - logger_.Message(Logger::LOG_ERROR, "GEO", 192, "Opening subtraction failed for " + boost::lexical_cast(std::distance(jt, it)) + " openings", entity); + logger_.message(::logger::LOG_ERROR, "GEO", 192, "Opening subtraction failed for " + boost::lexical_cast(std::distance(jt, it)) + " openings", entity); } jt = it; @@ -237,7 +237,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c // where we keep the first operand as is (a compound of faces probably, // unless --orient-shells was activated in which case we're already lost). if (!is_manifold) { - logger_.Warning("GEO", 193, "Retrying boolean operation on individual faces"); + logger_.warning("GEO", 193, "Retrying boolean operation on individual faces"); } continue; } @@ -416,7 +416,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // } // // if (!success) { -// logger::error("Failed processing layerset"); +// ::logger::root().error("Failed processing layerset"); // } // } // } @@ -444,7 +444,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // } // } // if (some_items_without_style) { -// logger::warning("No material and surface styles for:", product); +// ::logger::root().warning("No material and surface styles for:", product); // } // } // @@ -471,7 +471,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // parent_id = parent_object->data().id(); // } // } catch (const std::exception& e) { -// logger::error(e); +// ::logger::root().error(e); // } // // const std::string name = product->Name().value_or(""); @@ -483,9 +483,9 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // convert(product->ObjectPlacement(), trsf); // } // } catch (const std::exception& e) { -// logger::error(e); +// ::logger::root().error(e); // } catch (...) { -// logger::error("Failed to construct placement"); +// ::logger::root().error("Failed to construct placement"); // } // // // Does the IfcElement have any IfcOpenings? @@ -506,10 +506,10 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // try { // convert_openings(product, openings, shapes, trsf, opened_shapes); // } catch (const std::exception& e) { -// logger::message(logger::LOG_ERROR, std::string("error processing openings for: ") + e.what() + ":", product); +// ::logger::root().message(::logger::LOG_ERROR, std::string("error processing openings for: ") + e.what() + ":", product); // caught_error = true; // } catch (...) { -// logger::message(logger::LOG_ERROR, "error processing openings for:", product); +// ::logger::root().message(::logger::LOG_ERROR, "error processing openings for:", product); // } // // if (caught_error && opened_shapes.size() < shapes.size()) { @@ -574,12 +574,12 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // if (elem->geometry().calculate_surface_area(a_calc)) { // double diff = std::abs(a_calc - a_file); // if (diff / std::sqrt(a_file) > getValue(GV_PRECISION)) { -// logger::error("Validation of surface area failed for:", product); +// ::logger::root().error("Validation of surface area failed for:", product); // } else { -// logger::notice("Validation of surface area succeeded for:", product); +// ::logger::root().notice("Validation of surface area succeeded for:", product); // } // } else { -// logger::error("Validation of surface area failed for:", product); +// ::logger::root().error("Validation of surface area failed for:", product); // } // } else if (q->as() && q->Name() == "Volume") { // double v_calc; @@ -587,12 +587,12 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // if (elem->geometry().calculate_volume(v_calc)) { // double diff = std::abs(v_calc - v_file); // if (diff / std::sqrt(v_file) > getValue(GV_PRECISION)) { -// logger::error("Validation of volume failed for:", product); +// ::logger::root().error("Validation of volume failed for:", product); // } else { -// logger::notice("Validation of volume succeeded for:", product); +// ::logger::root().notice("Validation of volume succeeded for:", product); // } // } else { -// logger::error("Validation of volume failed for:", product); +// ::logger::root().error("Validation of volume failed for:", product); // } // } else if (q->as() && q->Name() == "Shape Validation Properties") { // auto qs2 = q->as()->HasQuantities(); @@ -611,9 +611,9 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // } // } // if (!all_succeeded) { -// logger::error("Validation of surface genus failed for:", product); +// ::logger::root().error("Validation of surface genus failed for:", product); // } else { -// logger::notice("Validation of surface genus succeeded for:", product); +// ::logger::root().notice("Validation of surface genus succeeded for:", product); // } // } // } @@ -645,7 +645,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // } // } // } catch (const ifcopenshell::exception& e) { -// logger::error(e); +// ::logger::root().error(e); // // @todo reset representation_mapped_to to zero? // } // return representation_mapped_to; @@ -669,15 +669,15 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // IfcSchema::IfcRepresentationMap::list::ptr maps = representation->RepresentationMap(); // // if (products->size() && maps->size()) { -// logger::warning("Representation used by IfcRepresentationMap and IfcProductDefinitionShape", representation); +// ::logger::root().warning("Representation used by IfcRepresentationMap and IfcProductDefinitionShape", representation); // } // // if (prodreps->size() > 1) { -// logger::warning("Multiple IfcProductDefinitionShapes for representation", representation); +// ::logger::root().warning("Multiple IfcProductDefinitionShapes for representation", representation); // } // // if (maps->size() > 1) { -// logger::warning("Multiple IfcRepresentationMaps for representation", representation); +// ::logger::root().warning("Multiple IfcRepresentationMaps for representation", representation); // } // // if (maps->size() == 1) { @@ -720,7 +720,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // parent_id = parent_object->data().id(); // } // } catch (const std::exception& e) { -// logger::error(e); +// ::logger::root().error(e); // } // // const std::string name = product->Name().value_or(""); @@ -732,9 +732,9 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // convert(product->ObjectPlacement(), trsf); // } // } catch (const std::exception& e) { -// logger::error(e); +// ::logger::root().error(e); // } catch (...) { -// logger::error("Failed to construct placement"); +// ::logger::root().error("Failed to construct placement"); // } // // std::string context_string = ""; @@ -936,7 +936,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // // range. It's only a safeguard though, so can probably be approximated. // const double axis_length = own_axis_start.Distance(own_axis_end); // if (length_required > axis_length) { -// logger::warning("The wall axis is not long enough to accommodate the fold points"); +// ::logger::root().warning("The wall axis is not long enough to accommodate the fold points"); // return false; // } // @@ -956,7 +956,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // gp_Trsf other; // if (other_wall->ObjectPlacement()) { // if (!convert(other_wall->ObjectPlacement(), other)) { -// logger::error("Failed to convert placement", other_wall); +// ::logger::root().error("Failed to convert placement", other_wall); // continue; // } // } @@ -964,7 +964,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // IfcSchema::IfcRepresentation* axis_representation = find_representation(other_wall, "Axis"); // // if (!axis_representation) { -// logger::warning("Joined wall has no axis representation", other_wall); +// ::logger::root().warning("Joined wall has no axis representation", other_wall); // continue; // } // @@ -1058,7 +1058,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // Vs1.Cross(Vs2); // // if (Vs1.IsNormal(Vc, 1.e-5)) { -// logger::warning("Connected walls are parallel"); +// ::logger::root().warning("Connected walls are parallel"); // parallel = true; // } else if (w < axis_u1 || w > axis_u2) { // point_outside_param_range = p; @@ -1287,7 +1287,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // // #define Kernel POSTFIX_SCHEMA(Kernel) // -// std::shared_ptr IfcGeom::Kernel::internalize_surface_style(const std::pair& shading_styles) { +// std::shared_ptr IfcGeom::Kernel::internalize_surface_style(const std::pair& shading_styles) { // if (shading_styles.second == 0) { // return 0; // } @@ -1393,7 +1393,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // Handle_Geom_Circle axis_line = Handle_Geom_Circle::DownCast(axis_curve); // reference_surface = new Geom_CylindricalSurface(axis_li->Position(), axis_line->Radius()); // } else { -// logger::message(logger::LOG_ERROR, "Unsupported underlying curve of Axis representation:", product); +// ::logger::root().message(::logger::LOG_ERROR, "Unsupported underlying curve of Axis representation:", product); // return false; // } // diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.h b/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.h index b9e074a034..5a5f182760 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.h +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.h @@ -110,13 +110,13 @@ private: double precision_; public: - OpenCascadeKernel(const ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root()) + OpenCascadeKernel(const ifcopenshell::geometry::Settings& settings, ::logger& logger = ::logger::root()) : AbstractKernel("opencascade", settings, logger) , faceset_helper_(nullptr) , precision_(settings.get().get()) {} - virtual AbstractKernel* clone(Logger& logger) const { + virtual AbstractKernel* clone(::logger& logger) const { return new OpenCascadeKernel(settings(), logger); } diff --git a/src/ifcgeom/kernels/opencascade/base_utils.cpp b/src/ifcgeom/kernels/opencascade/base_utils.cpp index 051a728337..c0d2ac0d7d 100644 --- a/src/ifcgeom/kernels/opencascade/base_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/base_utils.cpp @@ -714,12 +714,12 @@ bool IfcGeom::util::create_solid_from_faces(const NCollection_List valid_shell &= util::count(shape, TopAbs_SHELL) > 0; } catch (const Standard_Failure& e) { if (e.GetMessageString() && strlen(e.GetMessageString())) { - Logger::Root().Error("GEO", 106, e.GetMessageString()); + ::logger::root().error("GEO", 106, e.GetMessageString()); } else { - Logger::Root().Error("GEO", 107, "Unknown error sewing shell"); + ::logger::root().error("GEO", 107, "Unknown error sewing shell"); } } catch (...) { - Logger::Root().Error("GEO", 108, "Unknown error sewing shell"); + ::logger::root().error("GEO", 108, "Unknown error sewing shell"); } if (valid_shell) { @@ -747,22 +747,22 @@ bool IfcGeom::util::create_solid_from_faces(const NCollection_List } } catch (const Standard_Failure& e) { if (e.GetMessageString() && strlen(e.GetMessageString())) { - Logger::Root().Error("GEO", 109, e.GetMessageString()); + ::logger::root().error("GEO", 109, e.GetMessageString()); } else { - Logger::Root().Error("GEO", 110, "Unknown error classifying solid"); + ::logger::root().error("GEO", 110, "Unknown error classifying solid"); } } catch (...) { - Logger::Root().Error("GEO", 111, "Unknown error classifying solid"); + ::logger::root().error("GEO", 111, "Unknown error classifying solid"); } } } catch (const Standard_Failure& e) { if (e.GetMessageString() && strlen(e.GetMessageString())) { - Logger::Root().Error("GEO", 112, e.GetMessageString()); + ::logger::root().error("GEO", 112, e.GetMessageString()); } else { - Logger::Root().Error("GEO", 113, "Unknown error creating solid"); + ::logger::root().error("GEO", 113, "Unknown error creating solid"); } } catch (...) { - Logger::Root().Error("GEO", 114, "Unknown error creating solid"); + ::logger::root().error("GEO", 114, "Unknown error creating solid"); } if (complete_shape.IsNull()) { @@ -774,7 +774,7 @@ bool IfcGeom::util::create_solid_from_faces(const NCollection_List B.MakeCompound(C); B.Add(C, complete_shape); complete_shape = C; - Logger::Root().Warning("GEO", 115, "Multiple components in IfcConnectedFaceSet"); + ::logger::root().warning("GEO", 115, "Multiple components in IfcConnectedFaceSet"); } B.Add(complete_shape, result_shape); } @@ -789,7 +789,7 @@ bool IfcGeom::util::create_solid_from_faces(const NCollection_List B.MakeCompound(C); B.Add(C, complete_shape); complete_shape = C; - Logger::Root().Warning("GEO", 116, "Loose faces in IfcConnectedFaceSet"); + ::logger::root().warning("GEO", 116, "Loose faces in IfcConnectedFaceSet"); } B.Add(complete_shape, loose_faces.Current()); } @@ -797,7 +797,7 @@ bool IfcGeom::util::create_solid_from_faces(const NCollection_List shape = complete_shape; } else { - Logger::Root().Error("GEO", 117, "Failed to sew faceset"); + ::logger::root().error("GEO", 117, "Failed to sew faceset"); } return valid_shell; @@ -901,7 +901,7 @@ bool IfcGeom::util::validate_shape(const TopoDS_Shape& s) { dump(s); - Logger::Root().Warning("GEO", 118, str.str()); + ::logger::root().warning("GEO", 118, str.str()); return false; } diff --git a/src/ifcgeom/kernels/opencascade/boolean_result.cpp b/src/ifcgeom/kernels/opencascade/boolean_result.cpp index d401edada2..fd396a3731 100644 --- a/src/ifcgeom/kernels/opencascade/boolean_result.cpp +++ b/src/ifcgeom/kernels/opencascade/boolean_result.cpp @@ -118,14 +118,14 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con const double first_operand_volume = util::shape_volume(a); if (first_operand_volume <= ALMOST_ZERO) { - Logger::Root().Message(Logger::LOG_WARNING, "GEO", 119, "Empty solid for:", c->instance); + ::logger::root().message(::logger::LOG_WARNING, "GEO", 119, "Empty solid for:", c->instance); } } else { for (auto& r : cr) { auto S = std::static_pointer_cast(r.Shape())->shape(); if (S.IsNull()) { - Logger::Root().Error("GEO", 120, "Null operand"); + ::logger::root().error("GEO", 120, "Null operand"); continue; } gp_GTrsf trsf; @@ -140,7 +140,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con // #2665 we also set a precision-independent threshold, because in the boolean op routine // the working fuzziness might still be increased. if (d < tol * 20. || d < 0.00002) { - Logger::Root().Message(Logger::LOG_WARNING, "GEO", 121, "Halfspace subtraction yields unchanged volume:", c->instance); + ::logger::root().message(::logger::LOG_WARNING, "GEO", 121, "Halfspace subtraction yields unchanged volume:", c->instance); continue; } else { S = result; diff --git a/src/ifcgeom/kernels/opencascade/boolean_utils.cpp b/src/ifcgeom/kernels/opencascade/boolean_utils.cpp index 52ae721fd3..0cf1920607 100644 --- a/src/ifcgeom/kernels/opencascade/boolean_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/boolean_utils.cpp @@ -418,7 +418,7 @@ int IfcGeom::util::eliminate_narrow_operands(double prec, const NCollection_List bool is_narrow = min_dimension < prec; - Logger::Root().Notice("GEO", 122, "Min OBB dimension of operand = " + std::to_string(min_dimension)); + ::logger::root().notice("GEO", 122, "Min OBB dimension of operand = " + std::to_string(min_dimension)); if (!is_narrow) { c.Append(it.Value()); @@ -703,7 +703,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_ if (u11 < U1 && U1 < u12 && u21 < U2 && U2 < u22) { // Edge curves belonging to different operands intersect, don't process // using builder. - Logger::Root().Notice("GEO", 123, "Intersecting boundaries"); + ::logger::root().notice("GEO", 123, "Intersecting boundaries"); return false; } } @@ -750,7 +750,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_ // any effect and marked as redundant. Feeding it to the builder algo // will likely cause problems. redundant[std::distance(wires.begin(), it)] = true; - Logger::Root().Notice("GEO", 124, "Subtraction operand outside of outer bound"); + ::logger::root().notice("GEO", 124, "Subtraction operand outside of outer bound"); } } @@ -790,7 +790,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_ if (wire_clss[wire_index]->Perform(p2d) == TopAbs_IN) { // A wire is contained within another operand redundant[other_index] = true; - Logger::Root().Notice("GEO", 125, "Subtraction operand contained in other"); + ::logger::root().notice("GEO", 125, "Subtraction operand contained in other"); } } } @@ -848,7 +848,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To std::stringstream ss; ss << "bool-" << std::this_thread::get_id() << "-" << (operation_counter_++); debug_identifier = ss.str(); - Logger::Root().Notice("GEO", 126, "Boolean debug identifier: " + debug_identifier); + ::logger::root().notice("GEO", 126, "Boolean debug identifier: " + debug_identifier); } if (fuzziness < 0.) { @@ -884,8 +884,8 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To a = unify(a_input, fuzziness * 1000.); - Logger::Root().Message( - Logger::LOG_DEBUG, "GEO", 127, + ::logger::root().message( + ::logger::LOG_DEBUG, "GEO", 127, "Simplified operand A from "s + std::to_string(count(a_input, TopAbs_FACE)) + " to "s + @@ -896,8 +896,8 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To NCollection_List::Iterator it(b_input); for (; it.More(); it.Next()) { b.Append(unify(it.Value(), fuzziness)); - Logger::Root().Message( - Logger::LOG_DEBUG, "GEO", 128, + ::logger::root().message( + ::logger::LOG_DEBUG, "GEO", 128, "Simplified operand B from "s + std::to_string(count(it.Value(), TopAbs_FACE)) + " to "s + @@ -924,7 +924,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To auto N = bounding_box_overlap(fuzziness, a, b, b_tmp); if (N) { - Logger::Root().Notice("GEO", 129, "Eliminated " + std::to_string(N) + " disjoint operands"); + ::logger::root().notice("GEO", 129, "Eliminated " + std::to_string(N) + " disjoint operands"); std::swap(b, b_tmp); } } @@ -935,7 +935,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To b_tmp.Clear(); auto N = eliminate_touching_operands(fuzziness, a, b, b_tmp); if (N) { - Logger::Root().Notice("GEO", 130, "Eliminated " + std::to_string(N) + " touching operands"); + ::logger::root().notice("GEO", 130, "Eliminated " + std::to_string(N) + " touching operands"); std::swap(b, b_tmp); } } @@ -946,7 +946,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To b_tmp.Clear(); auto N = eliminate_narrow_operands(fuzziness, b, b_tmp); if (N) { - Logger::Root().Notice("GEO", 131, "Eliminated " + std::to_string(N) + " narrow operands"); + ::logger::root().notice("GEO", 131, "Eliminated " + std::to_string(N) + " narrow operands"); std::swap(b, b_tmp); } } @@ -960,21 +960,21 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To } if (b.Extent() == 0) { - Logger::Root().Warning("GEO", 132, "No other operands remaining, using first operand"); + ::logger::root().warning("GEO", 132, "No other operands remaining, using first operand"); result = a; return true; } - if (!is_2d && Logger::LOG_NOTICE >= Logger::Root().Verbosity()) { + if (!is_2d && ::logger::LOG_NOTICE >= ::logger::root().verbosity()) { PERF("preliminary manifoldness check"); if (!a.IsNull()) { - Logger::Root().Notice("GEO", 133, "Operand A is " + (is_manifold(a) ? ""s : "non-"s) + "manifold"); + ::logger::root().notice("GEO", 133, "Operand A is " + (is_manifold(a) ? ""s : "non-"s) + "manifold"); } NCollection_List::Iterator it(b); for (int i = 0; it.More(); it.Next(), ++i) { - Logger::Root().Notice("GEO", 134, "Operand B " + std::to_string(i) + " is " + (is_manifold(it.Value()) ? ""s : "non-"s) + "manifold"); + ::logger::root().notice("GEO", 134, "Operand B " + std::to_string(i) + " is " + (is_manifold(it.Value()) ? ""s : "non-"s) + "manifold"); } } @@ -1014,7 +1014,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To const double fuzz = (std::min)(min_length_orig / 3., fuzziness); - Logger::Root().Notice("GEO", 135, "Used fuzziness: " + std::to_string(fuzz)); + ::logger::root().notice("GEO", 135, "Used fuzziness: " + std::to_string(fuzz)); const double new_fuzziness = fuzziness * 10.; const bool allow_retry = new_fuzziness - 1e-15 <= settings.precision * 10000. && new_fuzziness < min_length_orig; @@ -1048,7 +1048,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To } if (is_extrusion_a) { - Logger::Root().Notice("GEO", 136, "Operand A 1/1 is an extrusion"); + ::logger::root().notice("GEO", 136, "Operand A 1/1 is an extrusion"); NCollection_List::Iterator it(b); for (int nb = 1; it.More(); it.Next(), ++nb) { @@ -1064,10 +1064,10 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To } if (is_extrusion_b) { - Logger::Root().Notice("GEO", 137, "Operand B " + std::to_string(nb) + "/" + std::to_string(b.Extent()) + " is an extrusion"); + ::logger::root().notice("GEO", 137, "Operand B " + std::to_string(nb) + "/" + std::to_string(b.Extent()) + " is an extrusion"); if (b_interval.first < a_interval.first + (fuzz * 100.) && b_interval.second > a_interval.second - (fuzz * 100.)) { - Logger::Root().Notice("GEO", 138, "Operand B creates a through hole"); + ::logger::root().notice("GEO", 138, "Operand B creates a through hole"); // Align b with a operand gp_Trsf trsf; @@ -1107,23 +1107,23 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To BRepPrimAPI_MakePrism mp(face_result, gp_Vec(gp::DY()) * (a_interval.second - a_interval.first)); if (mp.IsDone()) { if (b_remainder_3d.Extent()) { - Logger::Root().Notice("GEO", 139, std::to_string(b_remainder_3d.Extent()) + " operands remaining to process in 3D"); + ::logger::root().notice("GEO", 139, std::to_string(b_remainder_3d.Extent()) + " operands remaining to process in 3D"); b = b_remainder_3d; s1s.Clear(); s1s.Append(mp.Shape()); } else { - Logger::Root().Notice("GEO", 140, "Processed fully in 2D"); + ::logger::root().notice("GEO", 140, "Processed fully in 2D"); result = mp.Shape(); return true; } } else { - Logger::Root().Notice("GEO", 141, "Failed to extrude 2D boolean result. Retrying in 3D."); + ::logger::root().notice("GEO", 141, "Failed to extrude 2D boolean result. Retrying in 3D."); } } else { - Logger::Root().Notice("GEO", 142, "Failed to perform 2D boolean operation. Retrying in 3D."); + ::logger::root().notice("GEO", 142, "Failed to perform 2D boolean operation. Retrying in 3D."); } } else { - Logger::Root().Notice("GEO", 143, "No second operands can be processed as 2D inner bounds. Retrying in 3D."); + ::logger::root().notice("GEO", 143, "No second operands can be processed as 2D inner bounds. Retrying in 3D."); } } } @@ -1145,7 +1145,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To } if (builder->IsDone()) { if (false && builder->DSFiller()->HasWarning(STANDARD_TYPE(BOPAlgo_AlertAcquiredSelfIntersection))) { - Logger::Root().Notice("GEO", 144, "Builder reports self-intersection in output"); + ::logger::root().notice("GEO", 144, "Builder reports self-intersection in output"); success = false; /* @@ -1159,7 +1159,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To } */ } else if(builder->DSFiller()->HasWarning(STANDARD_TYPE(BOPAlgo_AlertBadPositioning)) && !TopoDS_Iterator(*builder).More()) { - Logger::Root().Notice("GEO", 145, "Builder reports bad positioning and result is empty"); + ::logger::root().notice("GEO", 145, "Builder reports bad positioning and result is empty"); success = false; } else { TopoDS_Shape r = *builder; @@ -1173,7 +1173,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To fix.Perform(); r = fix.Shape(); } catch (...) { - Logger::Root().Error("GEO", 146, "Shape healing failed on boolean result"); + ::logger::root().error("GEO", 146, "Shape healing failed on boolean result"); } } @@ -1184,7 +1184,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To success = ana.IsValid() != 0; if (!success) { - Logger::Root().Notice("GEO", 147, "Boolean operation yields invalid result"); + ::logger::root().notice("GEO", 147, "Boolean operation yields invalid result"); std::stringstream str; bool any_emitted = false; @@ -1214,7 +1214,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To dump(r); - Logger::Root().Notice("GEO", 148, str.str()); + ::logger::root().notice("GEO", 148, str.str()); } } @@ -1334,7 +1334,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To if (op == BOPAlgo_CUT && has_open_shells && all_faces_included_in_result && result_n_faces > first_op_n_faces) { success = false; - Logger::Root().Notice("GEO", 149, "Boolean result discarded because subtractions results in only the addition of faces"); + ::logger::root().notice("GEO", 149, "Boolean result discarded because subtractions results in only the addition of faces"); } else { // when there are edges or vertex-edge distances close to the used fuzziness, the // output is not trusted and the operation is attempted with a higher fuzziness. @@ -1380,7 +1380,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To static const char* const reason_strings[] = { "edge length", "vertex-edge", "face-face" }; std::stringstream str; str << "Boolean operation result failing " << reason_strings[reason] << " interference check, with fuzziness " << fuzziness << " with length " << v; - Logger::Root().Notice("GEO", 150, str.str()); + ::logger::root().notice("GEO", 150, str.str()); } } @@ -1389,7 +1389,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To } } else { - Logger::Root().Notice("GEO", 151, "Boolean operation yields non-manifold result"); + ::logger::root().notice("GEO", 151, "Boolean operation yields non-manifold result"); } } } @@ -1399,7 +1399,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To #if OCC_VERSION_HEX >= 0x70200 if (builder->HasError(STANDARD_TYPE(BOPAlgo_AlertBOPNotAllowed))) { - Logger::Root().Error("GEO", 152, "Invalid operands. Using first operand"); + ::logger::root().error("GEO", 152, "Invalid operands. Using first operand"); result = a; success = true; } @@ -1412,14 +1412,14 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To #endif std::string str_str = str.str(); if (str_str.size()) { - Logger::Root().Notice("GEO", 153, str_str); + ::logger::root().notice("GEO", 153, str_str); } } if (!success) { if (allow_retry) { return boolean_operation(settings, a, b, op, result, new_fuzziness); } else { - Logger::Root().Notice("GEO", 154, "No longer attempting boolean operation with higher fuzziness"); + ::logger::root().notice("GEO", 154, "No longer attempting boolean operation with higher fuzziness"); } } return success && !result.IsNull(); diff --git a/src/ifcgeom/kernels/opencascade/extrusion.cpp b/src/ifcgeom/kernels/opencascade/extrusion.cpp index 07ebb089d8..c306b11ada 100644 --- a/src/ifcgeom/kernels/opencascade/extrusion.cpp +++ b/src/ifcgeom/kernels/opencascade/extrusion.cpp @@ -10,7 +10,7 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS const double& height = extrusion->depth; if (height < settings_.get().get()) { - Logger::Root().Error("GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance); + ::logger::root().error("GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance); return false; } @@ -24,7 +24,7 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS // move the TopoDS_Shape, but obviously not both. gp_GTrsf gtrsf; if (!convert(&extrusion->matrix, gtrsf)) { - logger::error("Unable to move extrusion"); + ::logger::root().error("Unable to move extrusion"); } auto trsf = gtrsf.Trsf(); */ diff --git a/src/ifcgeom/kernels/opencascade/face.cpp b/src/ifcgeom/kernels/opencascade/face.cpp index 758e5ff052..4adbd750dd 100644 --- a/src/ifcgeom/kernels/opencascade/face.cpp +++ b/src/ifcgeom/kernels/opencascade/face.cpp @@ -174,8 +174,8 @@ namespace { } else if (crv_or_wire.index() == 2) { // @todo const double precision_ = 1.e-5; - Logger::Root().Warning("GEO", 156, "Approximating BasisCurve due to possible discontinuities", i->instance); - const auto& w = boost::get(crv_or_wire); + ::logger::root().warning("GEO", 156, "Approximating BasisCurve due to possible discontinuities", i->instance); + const auto& w = std::get(crv_or_wire); #if OCC_VERSION_HEX < 0x70600 BRepAdaptor_CompCurve cc(w, true); Handle(Adaptor3d_HCurve) hcc = Handle(Adaptor3d_HCurve)(new BRepAdaptor_HCompCurve(cc)); @@ -294,12 +294,12 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re // the face will still be processed as long as there are no holes. A compound of faces // is returned in that case. if (num_bounds > 1 && num_outer_bounds > 1 && num_bounds != num_outer_bounds) { - Logger::Root().Message(Logger::LOG_ERROR, "GEO", 157, "Invalid configuration of boundaries for:", face->instance); + ::logger::root().message(::logger::LOG_ERROR, "GEO", 157, "Invalid configuration of boundaries for:", face->instance); return false; } if (num_outer_bounds > 1) { - Logger::Root().Message(Logger::LOG_WARNING, "GEO", 158, "Multiple outer boundaries for:", face->instance); + ::logger::root().message(::logger::LOG_WARNING, "GEO", 158, "Multiple outer boundaries for:", face->instance); fd.all_outer() = true; } @@ -320,11 +320,11 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re TopoDS_Wire wire; if (faceset_helper_ && bound->is_polyhedron()) { if (!faceset_helper_->wire(bound, wire)) { - Logger::Root().Message(Logger::LOG_WARNING, "GEO", 159, "Face boundary loop not included", bound->instance); + ::logger::root().message(::logger::LOG_WARNING, "GEO", 159, "Face boundary loop not included", bound->instance); continue; } } else if (!convert(bound, wire)) { - Logger::Root().Message(Logger::LOG_ERROR, "GEO", 160, "Failed to process face boundary loop", bound->instance); + ::logger::root().message(::logger::LOG_ERROR, "GEO", 160, "Failed to process face boundary loop", bound->instance); return false; } @@ -341,7 +341,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re }; NCollection_List results; if (settings.use_wire_intersection_check && util::wire_intersections(wire, results, settings)) { - Logger::Root().Warning("GEO", 161, "Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); + ::logger::root().warning("GEO", 161, "Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); util::select_largest(results, wire); } @@ -352,7 +352,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re } if (fd.wires().empty()) { - Logger::Root().Warning("GEO", 162, "Face with no boundaries", face->instance); + ::logger::root().warning("GEO", 162, "Face with no boundaries", face->instance); return false; } @@ -409,7 +409,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re if (fd.surface().IsNull()) { // The set of wires is triangulated in case no surface can be found - Logger::Root().Message(Logger::LOG_WARNING, "GEO", 163, "Triangulating face boundaries for face", face->instance); + ::logger::root().message(::logger::LOG_WARNING, "GEO", 163, "Triangulating face boundaries for face", face->instance); if (fd.all_outer()) { for (const auto& w : fd.wires()) { @@ -462,7 +462,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re kt.Value().Original().ToUTF8CString(c); std::string message = c; delete[] c; - Logger::Root().Warning("GEO", 164, message, face->instance); + ::logger::root().warning("GEO", 164, message, face->instance); } } @@ -474,17 +474,17 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re if (it.Value().ShapeType() == TopAbs_FACE) { face_list.Append(it.Value()); } else { - Logger::Root().Error("UNS", 7, "Unsupported output from face healing"); + ::logger::root().error("UNS", 7, "Unsupported output from face healing"); } } } else { - Logger::Root().Error("UNS", 8, "Unsupported output from face healing"); + ::logger::root().error("UNS", 8, "Unsupported output from face healing"); } } else { face_list.Append(f); } } else { - Logger::Root().Error("GEO", 165, "Internal error in face creation"); + ::logger::root().error("GEO", 165, "Internal error in face creation"); return false; } } else { @@ -525,14 +525,14 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re delete[] c; #if OCC_VERSION_MAJOR==7 && OCC_VERSION_MINOR >= 7 if (!reversed_surface && !fd.surface().IsNull() && fd.surface()->IsUPeriodic() && message == "Unknown message invoked with the keyword FixAdvFace.FixOrientation.MSG0") { - Logger::Root().Notice("GEO", 166, "Detected reversed wire, reattempting with reversed basis surface"); + ::logger::root().notice("GEO", 166, "Detected reversed wire, reattempting with reversed basis surface"); TopoDS_Face reversed_result; convert(face, reversed_result, true); result = reversed_result; return true; } else #endif - Logger::Root().Warning("GEO", 167, message, face->instance); + ::logger::root().warning("GEO", 167, message, face->instance); } } } diff --git a/src/ifcgeom/kernels/opencascade/faceset_helper.cpp b/src/ifcgeom/kernels/opencascade/faceset_helper.cpp index 65c7a216e1..1fa862de0e 100644 --- a/src/ifcgeom/kernels/opencascade/faceset_helper.cpp +++ b/src/ifcgeom/kernels/opencascade/faceset_helper.cpp @@ -149,7 +149,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( auto num_retained = std::count(retained.begin(), retained.end(), true); if (unique.size() != num_retained) { - Logger::Root().Notice("GEO", 168, "Collapsed vertices from " + std::to_string(pnts.size()) + " (" + std::to_string(unique.size()) + " unique) to " + std::to_string(num_retained)); + ::logger::root().notice("GEO", 168, "Collapsed vertices from " + std::to_string(pnts.size()) + " (" + std::to_string(unique.size()) + " unique) to " + std::to_string(num_retained)); } typedef std::array edge_t; @@ -171,12 +171,13 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( segments.push_back(std::make_pair(C, D)); }); - if (edge_sets.find({loop->external.get_value_or(false), segment_set}) != edge_sets.end()) { + const auto edge_set_key = std::make_pair(loop->external.value_or(false), segment_set); + if (edge_sets.find(edge_set_key) != edge_sets.end()) { duplicate_faces++; duplicates_.insert(loop->identity()); continue; } - edge_sets.insert({loop->external.get_value_or(false), segment_set}); + edge_sets.insert(edge_set_key); if (segments.size() >= 3) { for (auto& p : segments) { @@ -204,8 +205,8 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( } } - if (duplicates_.size() || loops_removed || (non_manifold && shell->closed.get_value_or(false))) { - Logger::Root().Warning("GEO", 169, boost::lexical_cast(duplicate_faces) + " duplicate faces removed, " + boost::lexical_cast(loops_removed) + " degenerate loops eliminated and " + boost::lexical_cast(non_manifold) + " non-manifold edges"); + if (duplicates_.size() || loops_removed || (non_manifold && shell->closed.value_or(false))) { + ::logger::root().warning("GEO", 169, boost::lexical_cast(duplicate_faces) + " duplicate faces removed, " + boost::lexical_cast(loops_removed) + " degenerate loops eliminated and " + boost::lexical_cast(non_manifold) + " non-manifold edges"); } } @@ -276,7 +277,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const ifcopenshell::geome !kernel_->settings().get().get(), 0., kernel_->settings().get().get()})) { - Logger::Root().Warning("GEO", 170, "Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); + ::logger::root().warning("GEO", 170, "Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); non_manifold_ = true; wires = results; } else { diff --git a/src/ifcgeom/kernels/opencascade/layerset.cpp b/src/ifcgeom/kernels/opencascade/layerset.cpp index 0b7b17a65b..0668871ca0 100644 --- a/src/ifcgeom/kernels/opencascade/layerset.cpp +++ b/src/ifcgeom/kernels/opencascade/layerset.cpp @@ -132,7 +132,7 @@ namespace { } } - Logger::Root().Error("GEO", 171, "Unable to map layer geometry to material index"); + ::logger::root().error("GEO", 171, "Unable to map layer geometry to material index"); return false; } } @@ -237,7 +237,7 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const if (s.ShapeType() == TopAbs_SHELL) { shells.Append(TopoDS::Shell(s)); } else { - Logger::Root().Error("GEO", 172, "Expected shell type in layerset processing"); + ::logger::root().error("GEO", 172, "Expected shell type in layerset processing"); return false; } } @@ -436,12 +436,12 @@ bool IfcGeom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS } } catch (const Standard_Failure& e) { if (e.GetMessageString() && strlen(e.GetMessageString())) { - Logger::Root().Error("GEO", 173, e.GetMessageString()); + ::logger::root().error("GEO", 173, e.GetMessageString()); } else { - Logger::Root().Error("GEO", 174, "Unknown error performing fixes"); + ::logger::root().error("GEO", 174, "Unknown error performing fixes"); } } catch (...) { - Logger::Root().Error("GEO", 175, "Unknown error performing fixes"); + ::logger::root().error("GEO", 175, "Unknown error performing fixes"); } BRepCheck_Analyzer analyser(shape); bool is_valid = analyser.IsValid() != 0; @@ -451,7 +451,7 @@ bool IfcGeom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS } if (is_null[0] || is_null[1]) { - Logger::Root().Message(Logger::LOG_ERROR, "GEO", 176, "Null result obtained from layerset slicing"); + ::logger::root().message(::logger::LOG_ERROR, "GEO", 176, "Null result obtained from layerset slicing"); if (is_null[0] && is_null[1]) { return false; } diff --git a/src/ifcgeom/kernels/opencascade/loft.cpp b/src/ifcgeom/kernels/opencascade/loft.cpp index 68da3b0468..706515b4df 100644 --- a/src/ifcgeom/kernels/opencascade/loft.cpp +++ b/src/ifcgeom/kernels/opencascade/loft.cpp @@ -83,12 +83,13 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re if (non_polygonal) { if (loft->children.size() < 2) { - Logger::Root().Error("GEO", 177, "Not enough sections to loft"); + ::logger::root().error("GEO", 177, "Not enough sections to loft"); return false; } TopoDS_Shape f0, f1; + std::vector> sections; // Convert all children to vectors of wires for (const auto& child : loft->children) { @@ -122,13 +123,19 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re auto first_wire_count = sections.front().size(); for (auto& section : sections) { if (section.size() != first_wire_count) { - Logger::Root().Error("GEO", 178, "Inconsistent number of wires in sections"); - return false; - } - if (f0.ShapeType() != TopAbs_FACE || f1.ShapeType() != TopAbs_FACE) { + ::logger::root().error("GEO", 178, "Inconsistent number of wires in sections"); return false; } + } + if (f0.ShapeType() != TopAbs_FACE || f1.ShapeType() != TopAbs_FACE) { + return false; + } + + if (sections.size() == 2) { + TopoDS_Shell comp; + BRep_Builder BB; + BB.MakeShell(comp); TopExp_Explorer exp1(f0, TopAbs_WIRE); TopExp_Explorer exp2(f1, TopAbs_WIRE); for (; exp1.More() && exp2.More(); exp1.Next(), exp2.Next()) { @@ -153,7 +160,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re return true; } else { - logger::error("Lofting more than two sections is not supported"); + ::logger::root().error("Lofting more than two sections is not supported"); return false; } } @@ -269,7 +276,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re */ if (shps.size() < 2) { - Logger::Root().Error("GEO", 179, "Not enough sections to loft"); + ::logger::root().error("GEO", 179, "Not enough sections to loft"); return false; } @@ -309,11 +316,11 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re // When processing a sectioned *surface* there are no // begin and end caps that need to be added. if (it == shps.begin()) { - // faces.Append(shps[0]); + // faces.append(shps[0]); BB.Add(comp, shps[0]); } if (jt == shps.end() - 1) { - // faces.Append(shps[1]); + // faces.append(shps[1]); BB.Add(comp, shps[1]); } } @@ -428,7 +435,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re fill.Add(e3, GeomAbs_C0); fill.Add(e4, GeomAbs_C0); fill.Build(); - // faces.Append(fill.Face()); + // faces.append(fill.Face()); BB.Add(comp, fill.Face()); */ diff --git a/src/ifcgeom/kernels/opencascade/loop.cpp b/src/ifcgeom/kernels/opencascade/loop.cpp index 3ba0a30712..630da6ebef 100644 --- a/src/ifcgeom/kernels/opencascade/loop.cpp +++ b/src/ifcgeom/kernels/opencascade/loop.cpp @@ -130,8 +130,8 @@ namespace { } else { // @todo const double precision_ = 1.e-5; - Logger::Root().Warning("GEO", 180, "Approximating BasisCurve due to possible discontinuities", e->instance); - const auto& w = boost::get(crv_or_wire); + ::logger::root().warning("GEO", 180, "Approximating BasisCurve due to possible discontinuities", e->instance); + const auto& w = std::get(crv_or_wire); #if OCC_VERSION_HEX < 0x70600 BRepAdaptor_CompCurve cc(w, true); Handle(Adaptor3d_HCurve) hcc = Handle(Adaptor3d_HCurve)(new BRepAdaptor_HCompCurve(cc)); @@ -284,7 +284,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir } if (converted_segments.Extent() == 0) { - Logger::Root().Message(Logger::LOG_ERROR, "GEO", 181, "No segment successfully converted:", loop->instance); + ::logger::root().message(::logger::LOG_ERROR, "GEO", 181, "No segment successfully converted:", loop->instance); return false; } @@ -349,7 +349,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir if (ang < 0.0314) { edges_to_tesselate.Add(crv1->DynamicType() == STANDARD_TYPE(Geom_Circle) ? edges.First() : edges.Last()); - Logger::Root().Notice("GEO", 182, "Sharp circular corner detecting, substituting with linear approximation"); + ::logger::root().notice("GEO", 182, "Sharp circular corner detecting, substituting with linear approximation"); } } } diff --git a/src/ifcgeom/kernels/opencascade/shell.cpp b/src/ifcgeom/kernels/opencascade/shell.cpp index 7cb6554f01..0a7d80cbfd 100644 --- a/src/ifcgeom/kernels/opencascade/shell.cpp +++ b/src/ifcgeom/kernels/opencascade/shell.cpp @@ -46,19 +46,19 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap try { success = convert(face, occ_face); } catch (const std::exception& e) { - logger_.Error("GEO", 194, e); + logger_.error("GEO", 194, e); } catch (const Standard_Failure& e) { if (e.GetMessageString() && strlen(e.GetMessageString())) { - logger_.Error("GEO", 195, e.GetMessageString()); + logger_.error("GEO", 195, e.GetMessageString()); } else { - logger_.Error("GEO", 196, "Unknown error creating face"); + logger_.error("GEO", 196, "Unknown error creating face"); } } catch (...) { - logger_.Error("GEO", 197, "Unknown error creating face"); + logger_.error("GEO", 197, "Unknown error creating face"); } if (!success) { - logger_.Message(Logger::LOG_WARNING, "GEO", 198, "Failed to convert face:", face->instance); + logger_.message(::logger::LOG_WARNING, "GEO", 198, "Failed to convert face:", face->instance); continue; } @@ -71,7 +71,7 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap if (face_area(triangle) > min_face_area) { face_list.Append(triangle); } else { - logger_.Message(Logger::LOG_WARNING, "GEO", 199, "Degenerate face:", face->instance); + logger_.message(::logger::LOG_WARNING, "GEO", 199, "Degenerate face:", face->instance); } } } @@ -79,7 +79,7 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap if (face_area(occ_face) > min_face_area) { face_list.Append(occ_face); } else { - logger_.Message(Logger::LOG_WARNING, "GEO", 200, "Degenerate face:", face->instance); + logger_.message(::logger::LOG_WARNING, "GEO", 200, "Degenerate face:", face->instance); } } } diff --git a/src/ifcgeom/kernels/opencascade/solid.cpp b/src/ifcgeom/kernels/opencascade/solid.cpp index 0f071904f5..14ff26f3a9 100644 --- a/src/ifcgeom/kernels/opencascade/solid.cpp +++ b/src/ifcgeom/kernels/opencascade/solid.cpp @@ -92,7 +92,7 @@ bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& throw std::runtime_error("Unexpected configuration of subshapes"); } } else { - logger_.Warning("GEO", 201, "Ignored shell", s->instance); + logger_.warning("GEO", 201, "Ignored shell", s->instance); } } if (!S.IsNull()) { diff --git a/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp b/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp index 7063106b3b..d0c0207714 100644 --- a/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp +++ b/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp @@ -129,8 +129,8 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo } auto w = convert_curve(scs->curve); - if (w.which() != 2) { - logger_.Error("UNS", 9, "Unsupported directrix"); + if (w.index() != 2) { + logger_.error("UNS", 9, "Unsupported directrix"); return false; } TopoDS_Shape face_; @@ -178,7 +178,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo for (TopExp_Explorer exp(wire, TopAbs_VERTEX); exp.More(); exp.Next()) { if (pln.Distance(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()))) > ALMOST_ZERO) { directrix_on_plane = false; - logger_.Message(Logger::LOG_WARNING, "GEO", 202, "The Directrix does not lie on the ReferenceSurface", scs->instance); + logger_.message(::logger::LOG_WARNING, "GEO", 202, "The Directrix does not lie on the ReferenceSurface", scs->instance); break; } } diff --git a/src/ifcgeom/kernels/opencascade/sweep_utils.cpp b/src/ifcgeom/kernels/opencascade/sweep_utils.cpp index 2cd91a17c6..246531dea3 100644 --- a/src/ifcgeom/kernels/opencascade/sweep_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/sweep_utils.cpp @@ -97,7 +97,7 @@ bool IfcGeom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & directrix) { Handle(Geom_Curve) crv = BRep_Tool::Curve(edge, u0, u1); crv->D1(u0, directrix_origin, directrix_tangent); } else { - Logger::Root().Error("GEO", 203, "Unable to locate first edge"); + ::logger::root().error("GEO", 203, "Unable to locate first edge"); return false; } @@ -187,7 +187,7 @@ void IfcGeom::util::sort_edges(const TopoDS_Wire & wire, std::vector 2) { - Logger::Root().Warning("GEO", 204, "Self-intersecting Directrix"); + ::logger::root().warning("GEO", 204, "Self-intersecting Directrix"); } } diff --git a/src/ifcgeom/kernels/opencascade/wire_builder.cpp b/src/ifcgeom/kernels/opencascade/wire_builder.cpp index 9c6c12b0cc..8c33172d0b 100644 --- a/src/ifcgeom/kernels/opencascade/wire_builder.cpp +++ b/src/ifcgeom/kernels/opencascade/wire_builder.cpp @@ -117,12 +117,12 @@ bool IfcGeom::util::create_edge_over_curve_with_log_messages(const opencascade:: } } if (dmin == std::numeric_limits::infinity()) { - Logger::Root().Error("GEO", 205, "No extrema for point"); + ::logger::root().error("GEO", 205, "No extrema for point"); } else if (dmin > eps2) { - Logger::Root().Error("GEO", 206, "Distance of " + boost::lexical_cast(std::sqrt(dmin)) + " exceeds tolerance"); + ::logger::root().error("GEO", 206, "Distance of " + boost::lexical_cast(std::sqrt(dmin)) + " exceeds tolerance"); } } else { - Logger::Root().Error("GEO", 207, "Failed to calculate extrema for point"); + ::logger::root().error("GEO", 207, "Failed to calculate extrema for point"); } } } @@ -172,7 +172,7 @@ void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS if (dist > 1000. * p_) { mw_.Add(w1); mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2)); - Logger::Root().Warning("GEO", 208, "Added additional segment to close gap with length " + boost::lexical_cast(dist) + " to:", inst_); + ::logger::root().warning("GEO", 208, "Added additional segment to close gap with length " + boost::lexical_cast(dist) + " to:", inst_); goto check; } @@ -200,28 +200,28 @@ void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS // Preferably adjust the segment that is linear if (is_line1 || (is_circle1 && !is_line2)) { mw_.Add(adjust(w1, w12, p2)); - Logger::Root().Notice("GEO", 209, "Adjusted edge end-point with distance " + boost::lexical_cast(dist) + " on:", inst_); + ::logger::root().notice("GEO", 209, "Adjusted edge end-point with distance " + boost::lexical_cast(dist) + " on:", inst_); } else if ((is_line2 || is_circle2) && !last) { mw_.Add(w1); override_next_ = true; next_override_ = p1; - Logger::Root().Notice("GEO", 210, "Adjusted edge end-point with distance " + boost::lexical_cast(dist) + " on:", inst_); + ::logger::root().notice("GEO", 210, "Adjusted edge end-point with distance " + boost::lexical_cast(dist) + " on:", inst_); } else { // In all other cases an edge is added mw_.Add(w1); mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2)); - Logger::Root().Warning("GEO", 211, "Added additional segment to close gap with length " + boost::lexical_cast(dist) + " to:", inst_); + ::logger::root().warning("GEO", 211, "Added additional segment to close gap with length " + boost::lexical_cast(dist) + " to:", inst_); } } else { - Logger::Root().Error("GEO", 212, "Internal error, inconsistent wire segments", inst_); + ::logger::root().error("GEO", 212, "Internal error, inconsistent wire segments", inst_); mw_.Add(w1); } } check: if (mw_.Error() == BRepBuilderAPI_NonManifoldWire) { - Logger::Root().Error("GEO", 213, "Non-manifold curve segments:", inst_); + ::logger::root().error("GEO", 213, "Non-manifold curve segments:", inst_); } else if (mw_.Error() == BRepBuilderAPI_DisconnectedWire) { - Logger::Root().Error("GEO", 214, "Failed to join curve segments:", inst_); + ::logger::root().error("GEO", 214, "Failed to join curve segments:", inst_); } } diff --git a/src/ifcgeom/kernels/opencascade/wire_utils.cpp b/src/ifcgeom/kernels/opencascade/wire_utils.cpp index 59af6b6834..399e32e929 100644 --- a/src/ifcgeom/kernels/opencascade/wire_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/wire_utils.cpp @@ -90,7 +90,7 @@ bool IfcGeom::util::approximate_plane_through_wire(const TopoDS_Wire& wire, gp_P // obtaining a 2d points for the Delaunay, infinity is passed here, so this // can't for assessing degenerativeness. if (v.Magnitude() < 1.e-7) { - Logger::Root().Warning("GEO", 215, "Degenerate face boundary in normal estimation"); + ::logger::root().warning("GEO", 215, "Degenerate face boundary in normal estimation"); return false; } @@ -237,7 +237,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std auto it = mapping.find(uvnodes[k]); if (it == mapping.end()) { - Logger::Root().Error("GEO", 216, "Internal error: unable to unproject uv-mesh"); + ::logger::root().error("GEO", 216, "Internal error: unable to unproject uv-mesh"); return TRIANGULATE_WIRE_FAIL; } @@ -281,7 +281,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std } faces.Append(triangle_face); } else { - Logger::Root().Error("GEO", 217, "Internal error: missing face"); + ::logger::root().error("GEO", 217, "Internal error: missing face"); return TRIANGULATE_WIRE_FAIL; } } @@ -312,7 +312,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std if (!contains) { #endif // All existing edges need to exist in the new faces - Logger::Root().Error("GEO", 218, "Internal error, missing edge from triangulation"); + ::logger::root().error("GEO", 218, "Internal error, missing edge from triangulation"); non_manifold = true; } } @@ -323,7 +323,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std // Existing edges are boundaries with use 1 // New edges are internal with use 2 if (n != (mape.Contains(v) ? 1 : 2)) { - Logger::Root().Error("GEO", 219, "Internal error, non-manifold result from triangulation"); + ::logger::root().error("GEO", 219, "Internal error, non-manifold result from triangulation"); non_manifold = true; } } @@ -794,12 +794,12 @@ bool IfcGeom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape shape = solid.SolidFromShell(TopoDS::Shell(shape)); } catch (const Standard_Failure& e) { if (e.GetMessageString() && strlen(e.GetMessageString())) { - Logger::Root().Error("GEO", 220, e.GetMessageString()); + ::logger::root().error("GEO", 220, e.GetMessageString()); } else { - Logger::Root().Error("GEO", 221, "Unknown error creating solid"); + ::logger::root().error("GEO", 221, "Unknown error creating solid"); } } catch (...) { - Logger::Root().Error("GEO", 222, "Unknown error creating solid"); + ::logger::root().error("GEO", 222, "Unknown error creating solid"); } return true; @@ -812,12 +812,12 @@ bool IfcGeom::util::convert_curve_to_wire(const opencascade::handle& return true; } catch (const Standard_Failure& e) { if (e.GetMessageString() && strlen(e.GetMessageString())) { - Logger::Root().Error("GEO", 223, e.GetMessageString()); + ::logger::root().error("GEO", 223, e.GetMessageString()); } else { - Logger::Root().Error("GEO", 224, "Unknown error converting curve to wire"); + ::logger::root().error("GEO", 224, "Unknown error converting curve to wire"); } } catch (...) { - Logger::Root().Error("GEO", 225, "Unknown error converting curve to wire"); + ::logger::root().error("GEO", 225, "Unknown error converting curve to wire"); } return false; } @@ -838,7 +838,7 @@ void IfcGeom::util::assert_closed_wire(TopoDS_Wire& wire, double tol) { wire = mw.Wire(); } - Logger::Root().Warning("GEO", 226, "Wire not closed"); + ::logger::root().warning("GEO", 226, "Wire not closed"); } } @@ -848,7 +848,7 @@ bool IfcGeom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face NCollection_List results; if (settings.use_wire_intersection_check && util::wire_intersections(wire, results, settings)) { - Logger::Root().Warning("GEO", 227, "Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); + ::logger::root().warning("GEO", 227, "Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); util::select_largest(results, wire); } @@ -879,7 +879,7 @@ bool IfcGeom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face BRepBuilderAPI_FaceError er = mf.Error(); if (er != BRepBuilderAPI_FaceDone) { - Logger::Root().Error("GEO", 228, "Failed to create face."); + ::logger::root().error("GEO", 228, "Failed to create face."); return false; } face = mf.Face(); @@ -906,7 +906,7 @@ bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound& NCollection_List results; if (settings.use_wire_intersection_check && util::wire_intersections(w, results, settings)) { - Logger::Root().Warning("GEO", 229, "Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); + ::logger::root().warning("GEO", 229, "Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); } else { results.Clear(); results.Append(w); @@ -932,7 +932,7 @@ bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound& BRepBuilderAPI_FaceError er = mf.Error(); if (er != BRepBuilderAPI_FaceDone) { - Logger::Root().Error("GEO", 230, "Failed to create face."); + ::logger::root().error("GEO", 230, "Failed to create face."); continue; } @@ -949,7 +949,7 @@ bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound& if (p.first >= max_area / 10.) { B.Add(faces, p.second); } else { - Logger::Root().Warning("GEO", 231, "Ignoring self-intersection loop with area " + boost::lexical_cast(p.first)); + ::logger::root().warning("GEO", 231, "Ignoring self-intersection loop with area " + boost::lexical_cast(p.first)); } } diff --git a/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.cpp b/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.cpp index eff22dd042..3d20e5c6e4 100644 --- a/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.cpp +++ b/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.cpp @@ -286,7 +286,7 @@ ifcopenshell::geometry::PassthroughShape::PassthroughShape(const std::vector&& parts) : parts_(normalize_parts(parts)) {} -void ifcopenshell::geometry::PassthroughShape::Triangulate(ifcopenshell::geometry::Settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const { +void ifcopenshell::geometry::PassthroughShape::Triangulate(ifcopenshell::geometry::Settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger&) const { auto mesh = build_mesh(parts_, &place); std::vector indices(mesh.vertices.size()); for (size_t i = 0; i < mesh.vertices.size(); ++i) { @@ -356,13 +356,13 @@ std::pair, IfcGeom::OpaqueCoordinate<3>> ifcopenshe } auto result = std::make_pair( IfcGeom::OpaqueCoordinate<3>( - new IfcGeom::NumberNativeDouble(box->min(0)), - new IfcGeom::NumberNativeDouble(box->min(1)), - new IfcGeom::NumberNativeDouble(box->min(2))), + IfcGeom::OpaqueNumber(box->min(0)), + IfcGeom::OpaqueNumber(box->min(1)), + IfcGeom::OpaqueNumber(box->min(2))), IfcGeom::OpaqueCoordinate<3>( - new IfcGeom::NumberNativeDouble(box->max(0)), - new IfcGeom::NumberNativeDouble(box->max(1)), - new IfcGeom::NumberNativeDouble(box->max(2)))); + IfcGeom::OpaqueNumber(box->max(0)), + IfcGeom::OpaqueNumber(box->max(1)), + IfcGeom::OpaqueNumber(box->max(2)))); delete box; return result; } @@ -375,16 +375,16 @@ void ifcopenshell::geometry::PassthroughShape::set_box(void* box_ptr) { parts_ = { { make_box_shell(box->min, box->max), taxonomy::make(), true } }; } -IfcGeom::OpaqueNumber* ifcopenshell::geometry::PassthroughShape::length() { - return new IfcGeom::NumberNativeDouble(mesh_length(build_mesh(parts_))); +IfcGeom::OpaqueNumber ifcopenshell::geometry::PassthroughShape::length() { + return IfcGeom::OpaqueNumber(mesh_length(build_mesh(parts_))); } -IfcGeom::OpaqueNumber* ifcopenshell::geometry::PassthroughShape::area() { - return new IfcGeom::NumberNativeDouble(mesh_area(build_mesh(parts_))); +IfcGeom::OpaqueNumber ifcopenshell::geometry::PassthroughShape::area() { + return IfcGeom::OpaqueNumber(mesh_area(build_mesh(parts_))); } -IfcGeom::OpaqueNumber* ifcopenshell::geometry::PassthroughShape::volume() { - return new IfcGeom::NumberNativeDouble(is_manifold() ? mesh_volume(build_mesh(parts_)) : 0.); +IfcGeom::OpaqueNumber ifcopenshell::geometry::PassthroughShape::volume() { + return IfcGeom::OpaqueNumber(is_manifold() ? mesh_volume(build_mesh(parts_)) : 0.); } IfcGeom::OpaqueCoordinate<3> ifcopenshell::geometry::PassthroughShape::position() { @@ -465,11 +465,11 @@ IfcGeom::ConversionResultShape* ifcopenshell::geometry::PassthroughShape::concat return new PassthroughShape(std::move(parts)); } -void ifcopenshell::geometry::PassthroughShape::map(IfcGeom::OpaqueCoordinate<4>&, IfcGeom::OpaqueCoordinate<4>&) { +std::size_t ifcopenshell::geometry::PassthroughShape::map(IfcGeom::OpaqueCoordinate<4>&, IfcGeom::OpaqueCoordinate<4>&) { throw std::runtime_error("Not implemented"); } -void ifcopenshell::geometry::PassthroughShape::map(const std::vector>&, const std::vector>&) { +std::size_t ifcopenshell::geometry::PassthroughShape::map(const std::vector>&, const std::vector>&) { throw std::runtime_error("Not implemented"); } diff --git a/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.h b/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.h index 47af9a3076..5ed9bd7465 100644 --- a/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.h +++ b/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.h @@ -24,7 +24,7 @@ public: const std::vector& parts() const { return parts_; } virtual std::string_view backend_id() const { return "passthrough"; } - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const; + virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const; virtual int surface_genus() const; @@ -38,9 +38,9 @@ public: virtual std::pair, IfcGeom::OpaqueCoordinate<3>> bounding_box() const; virtual void set_box(void* b); - virtual IfcGeom::OpaqueNumber* length(); - virtual IfcGeom::OpaqueNumber* area(); - virtual IfcGeom::OpaqueNumber* volume(); + virtual IfcGeom::OpaqueNumber length(); + virtual IfcGeom::OpaqueNumber area(); + virtual IfcGeom::OpaqueNumber volume(); virtual IfcGeom::OpaqueCoordinate<3> position(); virtual IfcGeom::OpaqueCoordinate<3> axis(); @@ -61,8 +61,8 @@ public: virtual IfcGeom::ConversionResultShape* intersect(IfcGeom::ConversionResultShape*); virtual IfcGeom::ConversionResultShape* concat(IfcGeom::ConversionResultShape*); - virtual void map(IfcGeom::OpaqueCoordinate<4>& from, IfcGeom::OpaqueCoordinate<4>& to); - virtual void map(const std::vector>& from, const std::vector>& to); + virtual std::size_t map(IfcGeom::OpaqueCoordinate<4>& from, IfcGeom::OpaqueCoordinate<4>& to); + virtual std::size_t map(const std::vector>& from, const std::vector>& to); virtual IfcGeom::ConversionResultShape* moved(ifcopenshell::geometry::taxonomy::matrix4::ptr) const; virtual bool surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const; diff --git a/src/ifcgeom/kernels/passthrough/PassthroughKernel.h b/src/ifcgeom/kernels/passthrough/PassthroughKernel.h index 3d11585671..cdda057a7d 100644 --- a/src/ifcgeom/kernels/passthrough/PassthroughKernel.h +++ b/src/ifcgeom/kernels/passthrough/PassthroughKernel.h @@ -11,11 +11,11 @@ namespace kernels { class IFC_GEOMLIBRARY_API PassthroughKernel : public AbstractKernel { public: - PassthroughKernel(const Settings& settings) - : AbstractKernel("passthrough", settings) {} + PassthroughKernel(const Settings& settings, ::logger& logger = ::logger::root()) + : AbstractKernel("passthrough", settings, logger) {} - virtual AbstractKernel* clone() const { - return new PassthroughKernel(settings()); + virtual AbstractKernel* clone(::logger& logger) const { + return new PassthroughKernel(settings(), logger); } virtual bool supports_boolean_operations() const { return false; } diff --git a/src/ifcgeom/mapping/IfcAxis1Placement.cpp b/src/ifcgeom/mapping/IfcAxis1Placement.cpp index 0f5501856a..c10f2cf2d2 100644 --- a/src/ifcgeom/mapping/IfcAxis1Placement.cpp +++ b/src/ifcgeom/mapping/IfcAxis1Placement.cpp @@ -28,7 +28,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis1Placement& inst) { taxonomy::point3::ptr v = taxonomy::cast(map(inst.Location())); P = *v->components_; } catch (const std::exception&) { - logger_.Warning("GEO", 232, "Placement with invalid Location:", inst); + logger_.warning("GEO", 232, "Placement with invalid Location:", inst); } const bool hasAxis = inst.Axis(); if (hasAxis) { diff --git a/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp b/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp index 824809d552..d286934d2e 100644 --- a/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp +++ b/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp @@ -29,7 +29,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement2D& inst) { taxonomy::point3::ptr v = taxonomy::cast(map(inst.Location())); P = *v->components_; } catch (const std::exception&) { - logger_.Warning("GEO", 233, "Placement with invalid Location:", inst); + logger_.warning("GEO", 233, "Placement with invalid Location:", inst); } const bool hasRef = !!inst.RefDirection(); if (hasRef) { diff --git a/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp b/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp index 11a86b5670..c1f41f78ca 100644 --- a/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp +++ b/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp @@ -29,13 +29,13 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement3D& inst) { taxonomy::point3::ptr v = taxonomy::cast(map(inst.Location())); o = *v->components_; } catch (const std::exception&) { - logger_.Warning("GEO", 234, "Placement with invalid Location:", inst); + logger_.warning("GEO", 234, "Placement with invalid Location:", inst); } const bool hasAxis = !!inst.Axis(); const bool hasRef = !!inst.RefDirection(); if (hasAxis != hasRef) { - logger_.Warning("GEO", 235, "Axis and RefDirection should be specified together", inst); + logger_.warning("GEO", 235, "Axis and RefDirection should be specified together", inst); } if (hasAxis) { diff --git a/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp b/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp index c576c72df1..6673a75ae5 100644 --- a/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp +++ b/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp @@ -26,7 +26,7 @@ using namespace ifcopenshell::geometry; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear& inst) { if (!inst.Location().as()) { - logger_.Error("GEO", 236, std::runtime_error("Location must be IfcPointByDistanceExpression for IfcAxis2PlacementLinear")); + logger_.error("GEO", 236, std::runtime_error("Location must be IfcPointByDistanceExpression for IfcAxis2PlacementLinear")); } Eigen::Vector3d o, axis(0, 0, 1), refDirection; @@ -45,7 +45,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear& inst) /* if (hasAxis != hasRef) { - logger::warning("Axis and RefDirection should be specified together", inst); + ::logger::root().warning("Axis and RefDirection should be specified together", inst); } */ diff --git a/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp index 62dbd9e313..6bff1e2b45 100644 --- a/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp @@ -43,7 +43,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCShapeProfileDef& inst) { const double tol = settings_.get().get(); if ( x < tol || y < tol || d1 < tol || d2 < tol) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 241, "Skipping zero sized profile:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 241, "Skipping zero sized profile:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcCircle.cpp b/src/ifcgeom/mapping/IfcCircle.cpp index 995e0e35b3..c7bd9cf0ff 100644 --- a/src/ifcgeom/mapping/IfcCircle.cpp +++ b/src/ifcgeom/mapping/IfcCircle.cpp @@ -24,7 +24,7 @@ using namespace ifcopenshell::geometry; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircle& inst) { const double r = inst.Radius() * length_unit_; if (r < settings_.get().get()) { - logger_.Message(Logger::LOG_ERROR, "GEO", 237, "Radius not greater than zero for:", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 237, "Radius not greater than zero for:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcCompositeCurve.cpp b/src/ifcgeom/mapping/IfcCompositeCurve.cpp index 17c4473b4a..dc2a04358b 100644 --- a/src/ifcgeom/mapping/IfcCompositeCurve.cpp +++ b/src/ifcgeom/mapping/IfcCompositeCurve.cpp @@ -34,11 +34,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve& inst) { for (auto& segment : segments) { if (segment.as() && segment.as().ParentCurve().as()) { - logger_.Notice("GEO", 238, "Infinite IfcLine used as ParentCurve of segment, treating as a segment", segment); + logger_.notice("GEO", 238, "Infinite IfcLine used as ParentCurve of segment, treating as a segment", segment); double u0 = 0.0; double u1 = segment.as().ParentCurve().as().Dir().Magnitude() * length_unit_; if (u1 < settings_.get().get()) { - logger_.Warning("GEO", 239, "Segment length below tolerance", segment); + logger_.warning("GEO", 239, "Segment length below tolerance", segment); } auto e = taxonomy::make(); @@ -70,7 +70,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve& inst) { e->end = 2.0 * boost::math::constants::pi(); loop->children.push_back(e); } else { - logger_.Warning("GEO", 240, "Unexpected segment type", segment); + logger_.warning("GEO", 240, "Unexpected segment type", segment); return nullptr; } } @@ -128,7 +128,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi for (auto it = segments->begin(); it != segments->end(); ++it) { if (!(*it)->declaration().is(IfcSchema::IfcCompositeCurveSegment::Class())) { - logger::error("Not implemented", *it); + ::logger::root().error("Not implemented", *it); return false; } @@ -141,13 +141,13 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi TopoDS_Wire segment; if (curve->as()) { - logger::notice("Infinite IfcLine used as ParentCurve of segment, treating as a segment", *it); + ::logger::root().notice("Infinite IfcLine used as ParentCurve of segment, treating as a segment", *it); Handle_Geom_Curve handle; convert_curve(curve, handle); double u0 = 0.0; double u1 = curve->as()->Dir()->Magnitude() * length_unit_; if (u1 < getValue(GV_PRECISION)) { - logger::warning("Segment length below tolerance", *it); + ::logger::root().warning("Segment length below tolerance", *it); } BRepBuilderAPI_MakeEdge me(handle, u0, u1); if (me.IsDone()) { @@ -157,7 +157,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi } } else if (!convert_wire(curve, segment)) { const bool failed_on_purpose = curve->as() && !segment.IsNull(); - logger::message(failed_on_purpose ? logger::LOG_WARNING : logger::LOG_ERROR, "Failed to convert curve:", curve); + ::logger::root().message(failed_on_purpose ? ::logger::LOG_WARNING : ::logger::LOG_ERROR, "Failed to convert curve:", curve); continue; } @@ -168,12 +168,12 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi ShapeFix_ShapeTolerance FTol; FTol.SetTolerance(segment, getValue(GV_PRECISION), TopAbs_WIRE); - converted_segments.Append(segment); + converted_segments.append(segment); } if (converted_segments.Extent() == 0) { - logger::message(logger::LOG_ERROR, "No segment successfully converted:", l); + ::logger::root().message(::logger::LOG_ERROR, "No segment successfully converted:", l); return false; } diff --git a/src/ifcgeom/mapping/IfcCurveSegment.cpp b/src/ifcgeom/mapping/IfcCurveSegment.cpp index c44bd2d9f0..c1a28ec4b0 100644 --- a/src/ifcgeom/mapping/IfcCurveSegment.cpp +++ b/src/ifcgeom/mapping/IfcCurveSegment.cpp @@ -216,7 +216,7 @@ struct cant_curve_segment_function { class curve_segment_evaluator { private: mapping* mapping_ = nullptr; - Logger& logger_; + logger& logger_; IfcSchema::IfcCurveSegment inst_; // this curve segment instance double length_unit_; double start_; @@ -260,10 +260,10 @@ class curve_segment_evaluator { emit_next = true; } } else { - mapping_->logger().Warning("GEO", 242, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment."); + mapping_->logger().warning("GEO", 242, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment."); } } else { - logger::warning("IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment."); + ::logger::root().warning("IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment."); } bool is_horizontal = false; @@ -283,7 +283,7 @@ class curve_segment_evaluator { if ((is_horizontal + is_vertical + is_cant) != 1) { // We have to choose the correct functor based on usage. We can't // support multiple, because we don't know the caller at this point. - mapping_->logger().Error("UNS", 10, std::runtime_error("multiple uses of IfcSegmentCurve not supported"), inst_); + mapping_->logger().error("UNS", 10, std::runtime_error("multiple uses of IfcSegmentCurve not supported"), inst_); } segment_type_ = is_horizontal ? ST_HORIZONTAL : is_vertical ? ST_VERTICAL : is_cant ? ST_CANT : ST_HORIZONTAL; @@ -321,7 +321,7 @@ class curve_segment_evaluator { end_point = segmented_reference_curve.EndPoint(); } } else { - mapping_->logger().Warning("GEO", 243, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the end point."); + mapping_->logger().warning("GEO", 243, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the end point."); } if (end_point) { next_segment_placement_ = taxonomy::cast(mapping_->map(end_point))->ccomponents(); @@ -343,7 +343,7 @@ class curve_segment_evaluator { taxonomy::ptr get_segment_curve_function() { if (!parent_curve_fn_ || !parent_curve_start_point_) { - mapping_->logger().Error("UNS", 11, std::runtime_error(inst_->ParentCurve()->declaration().name() + " not implemented"), inst_); + mapping_->logger().error("UNS", 11, std::runtime_error(inst_->ParentCurve()->declaration().name() + " not implemented"), inst_); } auto length = fabs(this->length()); @@ -476,13 +476,13 @@ class curve_segment_evaluator { projected_length_ = length_; } } else if (segment_type_ == ST_CANT) { - mapping_->logger().Error("GEO", 244, std::runtime_error("Unexpected segment type encountered - cant is handled in set_cant_spiral_function - should never get here")); + mapping_->logger().error("GEO", 244, std::runtime_error("Unexpected segment type encountered - cant is handled in set_cant_spiral_function - should never get here")); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); } ); } else { - mapping_->logger().Error("GEO", 245, "Unexpected segment type encountered"); + mapping_->logger().error("GEO", 245, "Unexpected segment type encountered"); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); } @@ -643,13 +643,13 @@ class curve_segment_evaluator { set_cant_spiral_function(*super, *slope, cant); } else if (segment_type_ == ST_VERTICAL) { - mapping_->logger().Error("GEO", 246, "IfcCosineSpiral cannot be used for vertical alignment"); + mapping_->logger().error("GEO", 246, "IfcCosineSpiral cannot be used for vertical alignment"); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); } ); } else { - mapping_->logger().Error("GEO", 247, "Unexpected segment type encountered"); + mapping_->logger().error("GEO", 247, "Unexpected segment type encountered"); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); } @@ -712,12 +712,12 @@ class curve_segment_evaluator { set_cant_spiral_function(*super, *slope, cant); } else if (segment_type_ == ST_VERTICAL) { - mapping_->logger().Error("GEO", 248, "IfcSineSpiral cannot be used for vertical alignment"); + mapping_->logger().error("GEO", 248, "IfcSineSpiral cannot be used for vertical alignment"); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }); } else { - mapping_->logger().Error("GEO", 249, "Unexpected segment type encountered"); + mapping_->logger().error("GEO", 249, "Unexpected segment type encountered"); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }); @@ -978,12 +978,12 @@ class curve_segment_evaluator { } } else if (segment_type_ == ST_CANT) { - mapping_->logger().Warning("UNS", 12, "Use of IfcCircle for cant is not supported"); + mapping_->logger().warning("UNS", 12, "Use of IfcCircle for cant is not supported"); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }); } else { - mapping_->logger().Error("GEO", 250, "Unexpected segment type encountered"); + mapping_->logger().error("GEO", 250, "Unexpected segment type encountered"); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }); @@ -1069,7 +1069,7 @@ class curve_segment_evaluator { parent_curve_start_point_ = (*parent_curve_fn_)(start_); } else { - mapping_->logger().Warning("GEO", 251, "Unexpected segment type encountered"); + mapping_->logger().warning("GEO", 251, "Unexpected segment type encountered"); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }); @@ -1083,7 +1083,7 @@ class curve_segment_evaluator { auto coeffY = pc.CoefficientsY().value_or(std::vector()); auto coeffZ = pc.CoefficientsZ().value_or(std::vector()); if (!coeffZ.empty()) { - mapping_->logger().Warning("GEO", 252, "Expected IfcPolynomialCurve.CoefficientsZ to be undefined for alignment geometry. Coefficients ignored.", pc); + mapping_->logger().warning("GEO", 252, "Expected IfcPolynomialCurve.CoefficientsZ to be undefined for alignment geometry. Coefficients ignored.", pc); } if (segment_type_ == ST_HORIZONTAL || segment_type_ == ST_VERTICAL) { @@ -1149,7 +1149,7 @@ class curve_segment_evaluator { auto result = boost::math::tools::bracket_and_solve_root(f, x, 2.0, true, tol, max_iter); x = result.first; } catch (...) { - logger_.Warning("GEO", 253, "root solver failed"); + logger_.warning("GEO", 253, "root solver failed"); } return x; }; @@ -1210,12 +1210,12 @@ class curve_segment_evaluator { parent_curve_start_point_ = (*parent_curve_fn_)(0.0); // start is added to u in parent_curve_fn_, so use 0.0 here } else if (segment_type_ == ST_CANT) { - mapping_->logger().Warning("UNS", 13, std::runtime_error("Use of IfcPolynomialCurve for cant is not supported")); + mapping_->logger().warning("UNS", 13, std::runtime_error("Use of IfcPolynomialCurve for cant is not supported")); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }); } else { - mapping_->logger().Error("GEO", 254, std::runtime_error("Unexpected segment type encountered")); + mapping_->logger().error("GEO", 254, std::runtime_error("Unexpected segment type encountered")); parent_curve_fn_ = std::make_shared( [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }, [](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }); diff --git a/src/ifcgeom/mapping/IfcEdge.cpp b/src/ifcgeom/mapping/IfcEdge.cpp index c9cba5bc46..16d272082f 100644 --- a/src/ifcgeom/mapping/IfcEdge.cpp +++ b/src/ifcgeom/mapping/IfcEdge.cpp @@ -25,14 +25,14 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdge& inst) { auto v1 = inst.EdgeStart().as(); auto v2 = inst.EdgeEnd().as(); if (!v1 || !v2) { - logger_.Message(Logger::LOG_ERROR, "GEO", 255, "Only IfcVertexPoints are supported for EdgeStart and -End", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 255, "Only IfcVertexPoints are supported for EdgeStart and -End", inst); return nullptr; } auto pnt1 = v1.VertexGeometry(); auto pnt2 = v2.VertexGeometry(); if (!pnt1.declaration().is(IfcSchema::IfcCartesianPoint::Class()) || !pnt2.declaration().is(IfcSchema::IfcCartesianPoint::Class())) { - logger_.Message(Logger::LOG_ERROR, "GEO", 256, "Only IfcCartesianPoints are supported for VertexGeometry", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 256, "Only IfcCartesianPoints are supported for VertexGeometry", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcEllipse.cpp b/src/ifcgeom/mapping/IfcEllipse.cpp index 8ef51acbea..2c72f71974 100644 --- a/src/ifcgeom/mapping/IfcEllipse.cpp +++ b/src/ifcgeom/mapping/IfcEllipse.cpp @@ -26,7 +26,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipse& inst) { double y = inst.SemiAxis2() * length_unit_; const double tol = settings_.get().get(); if (x < tol || y < tol) { - logger_.Message(Logger::LOG_ERROR, "GEO", 257, "Radius not greater than zero for:", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 257, "Radius not greater than zero for:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp b/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp index de68dea5ef..0d79ee8104 100644 --- a/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp @@ -26,7 +26,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipseProfileDef& inst) { double ry = inst.SemiAxis2() * length_unit_; const double tol = settings_.get().get(); if (rx < tol || ry < tol) { - logger_.Message(Logger::LOG_ERROR, "GEO", 258, "Radius not greater than zero for:", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 258, "Radius not greater than zero for:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcExtrudedAreaSolid.cpp b/src/ifcgeom/mapping/IfcExtrudedAreaSolid.cpp index a36b33ea02..d756b2ec67 100644 --- a/src/ifcgeom/mapping/IfcExtrudedAreaSolid.cpp +++ b/src/ifcgeom/mapping/IfcExtrudedAreaSolid.cpp @@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid& inst) { const double height = inst.Depth() * length_unit_; if (height < settings_.get().get()) { - logger_.Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst); #ifndef PERMISSIVE_EXTRUSION return nullptr; #endif diff --git a/src/ifcgeom/mapping/IfcExtrudedAreaSolidTapered.cpp b/src/ifcgeom/mapping/IfcExtrudedAreaSolidTapered.cpp index 033ef82085..f497db1019 100644 --- a/src/ifcgeom/mapping/IfcExtrudedAreaSolidTapered.cpp +++ b/src/ifcgeom/mapping/IfcExtrudedAreaSolidTapered.cpp @@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolidTapered& inst) { const double height = inst.Depth() * length_unit_; if (height < settings_.get().get()) { - logger_.Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcFixedReferenceSweptAreaSolid.cpp b/src/ifcgeom/mapping/IfcFixedReferenceSweptAreaSolid.cpp index ef0f7451cf..91e9d29a40 100644 --- a/src/ifcgeom/mapping/IfcFixedReferenceSweptAreaSolid.cpp +++ b/src/ifcgeom/mapping/IfcFixedReferenceSweptAreaSolid.cpp @@ -98,7 +98,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFixedReferenceSweptAreaSolid auto condition_number = svd.singularValues()(0) / svd.singularValues()(svd.singularValues().size() - 1); if (condition_number > 1.e10) { - logger::error("Non-invertible matrix at " + std::to_string(distalong) + " conversion will likely fail."); + ::logger::root().error("Non-invertible matrix at " + std::to_string(distalong) + " conversion will likely fail."); } */ } diff --git a/src/ifcgeom/mapping/IfcGradientCurve.cpp b/src/ifcgeom/mapping/IfcGradientCurve.cpp index 0cf4cd0a37..e512f9bdc6 100644 --- a/src/ifcgeom/mapping/IfcGradientCurve.cpp +++ b/src/ifcgeom/mapping/IfcGradientCurve.cpp @@ -26,7 +26,7 @@ using namespace ifcopenshell::geometry; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve& inst) { if (!inst.BaseCurve().as()) - logger_.Warning("GEO", 261, "Expected IfcGradientCurve.BaseCurve to be IfcCompositeCurve", inst); // CT 4.1.7.1.1.2 + logger_.warning("GEO", 261, "Expected IfcGradientCurve.BaseCurve to be IfcCompositeCurve", inst); // CT 4.1.7.1.1.2 auto segments = inst.Segments(); @@ -41,11 +41,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve& inst) { // for this reason, a dynamic cast is used and if crv is a function_item it is added to the span spans.push_back(fi); } else { - logger_.Error("UNS", 14, "Unsupported"); + logger_.error("UNS", 14, "Unsupported"); return nullptr; } } else { - logger_.Error("UNS", 15, "Unsupported"); + logger_.error("UNS", 15, "Unsupported"); return nullptr; } } @@ -73,7 +73,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve& inst) { // check to see if there is valid overlap of the horizontal and vertical domains if (!(0 < gradient_function->length())) { - logger_.Error("GEO", 262, "IfcGradientCurve does not have a common domain with BaseCurve"); + logger_.error("GEO", 262, "IfcGradientCurve does not have a common domain with BaseCurve"); gradient_function = nullptr; // not valid } diff --git a/src/ifcgeom/mapping/IfcHalfSpaceSolid.cpp b/src/ifcgeom/mapping/IfcHalfSpaceSolid.cpp index d8eca18c0d..f101cb8f64 100644 --- a/src/ifcgeom/mapping/IfcHalfSpaceSolid.cpp +++ b/src/ifcgeom/mapping/IfcHalfSpaceSolid.cpp @@ -25,7 +25,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid& inst) { auto surface = inst.BaseSurface(); auto plane = surface.as(); if (!plane) { - logger_.Message(Logger::LOG_ERROR, "UNS", 16, "Unsupported BaseSurface:", surface); + logger_.message(::logger::LOG_ERROR, "UNS", 16, "Unsupported BaseSurface:", surface); return nullptr; } auto p = taxonomy::make(); diff --git a/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp index 723755330e..dfc913477d 100644 --- a/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp @@ -80,7 +80,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIShapeProfileDef& inst) { const double tol = settings_.get().get(); if (x1 < tol || x2 < tol || y < tol || d1 < tol || ft1 < tol || ft2 < tol) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 264, "Skipping zero sized profile:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 264, "Skipping zero sized profile:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp b/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp index 0cd30e0756..4327e94388 100644 --- a/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp +++ b/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp @@ -87,7 +87,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve& inst) { e->basis = circ; loop->children.push_back(e); } else { - logger_.Warning("GEO", 263, "Ignoring segment on", inst); + logger_.warning("GEO", 263, "Ignoring segment on", inst); } } else { throw ifcopenshell::exception("Unexpected IfcIndexedPolyCurve segment of type " + segment.concrete().declaration().name()); diff --git a/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp index cfb3e54d7b..3cd8c41c9e 100644 --- a/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp @@ -45,7 +45,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLShapeProfileDef& inst) { const double tol = settings_.get().get(); if ( x < tol || y < tol || d < tol) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 265, "Skipping zero sized profile:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 265, "Skipping zero sized profile:", inst); return nullptr; } @@ -77,7 +77,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLShapeProfileDef& inst) { const double det = a1*b2 - a2*b1; if (std::fabs(det) < 1.e-5) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 266, "Legs do not intersect for:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 266, "Legs do not intersect for:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcObjectPlacement.cpp b/src/ifcgeom/mapping/IfcObjectPlacement.cpp index a308f321e0..7560e632b0 100644 --- a/src/ifcgeom/mapping/IfcObjectPlacement.cpp +++ b/src/ifcgeom/mapping/IfcObjectPlacement.cpp @@ -47,13 +47,13 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement& inst) { // element we're ignoring, but we don't want to traverse the entire model. #ifdef SCHEMA_IfcObjectPlacement_HAS_ReferencedByPlacements if (depth < 2) { - std::vector refs = placement.ReferencedByPlacements(); + auto refs = placement.ReferencedByPlacements(); for (auto& ref : refs) { - q.emplace_back(ref, depth + 1); + q.emplace_back(ref.template as(), depth + 1); } } #else - logger::warning("Using --site-local-placement or --building-local-placement on IFC4.2 might have issues"); + ::logger::root().warning("Using --site-local-placement or --building-local-placement on IFC4.2 might have issues"); #endif } } @@ -126,7 +126,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement& inst) { if (fallback) { auto mapped_fallback = taxonomy::cast(map(fallback)); if (!result->ccomponents().isApprox(mapped_fallback->ccomponents())) { - logger::warning("Computed placement differs from fallback", inst); + ::logger::root().warning("Computed placement differs from fallback", inst); } } @@ -134,7 +134,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement& inst) { auto abs_det = std::abs(result->ccomponents().determinant()); if (abs_det < 1.e-7) { - logger::warning("Ignoring singular matrix:", inst); + ::logger::root().warning("Ignoring singular matrix:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcOffsetCurveByDistance.cpp b/src/ifcgeom/mapping/IfcOffsetCurveByDistance.cpp index 4c5f7815ea..008d0fb581 100644 --- a/src/ifcgeom/mapping/IfcOffsetCurveByDistance.cpp +++ b/src/ifcgeom/mapping/IfcOffsetCurveByDistance.cpp @@ -33,7 +33,7 @@ using namespace ifcopenshell::geometry; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances& inst) { auto offset_values = inst.OffsetValues(); if (offset_values.empty()) { - logger_.Error("GEO", 270, "IfcOffsetCurveByDistances must have at least one offset value"); + logger_.error("GEO", 270, "IfcOffsetCurveByDistances must have at least one offset value"); } auto& first_offset_value = offset_values.front(); @@ -56,7 +56,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances& inst auto basis_curve_fn = taxonomy::dcast(map(basis_curve)); if (!basis_curve_fn) { // Only implement on alignment curves - logger_.Warning("GEO", 271, "IfcOffsetCurveByDistances is only implemented for BasisCurves curves based on taxonomy::function_item", inst); + logger_.warning("GEO", 271, "IfcOffsetCurveByDistances is only implemented for BasisCurves curves based on taxonomy::function_item", inst); return nullptr; } @@ -73,7 +73,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances& inst first_distance *= length_unit_; if (first_distance < 0.0) { - logger_.Warning("GEO", 272, "IfcOffsetCurveByDistance first offset value is before the start of the curve."); + logger_.warning("GEO", 272, "IfcOffsetCurveByDistance first offset value is before the start of the curve."); } if(0.0 < first_distance) @@ -110,7 +110,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances& inst if (dn < dp) // next is before previous { - logger_.Warning("GEO", 273, "IfcOffsetCurveByDistance offset value is out of bounds."); + logger_.warning("GEO", 273, "IfcOffsetCurveByDistance offset value is out of bounds."); continue; } diff --git a/src/ifcgeom/mapping/IfcOpenCrossProfileDef.cpp b/src/ifcgeom/mapping/IfcOpenCrossProfileDef.cpp index 32f4ab1478..8b375ded4f 100644 --- a/src/ifcgeom/mapping/IfcOpenCrossProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcOpenCrossProfileDef.cpp @@ -32,7 +32,7 @@ const double PI = boost::math::constants::pi(); taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOpenCrossProfileDef& inst) { if (inst.ProfileType() != IfcSchema::IfcProfileTypeEnum::IfcProfileType_CURVE) { - logger_.Warning("GEO", 274, "Expected IfcOpenCrossProfileDef.ProfileType to be CURVE", inst); + logger_.warning("GEO", 274, "Expected IfcOpenCrossProfileDef.ProfileType to be CURVE", inst); return nullptr; } @@ -56,7 +56,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOpenCrossProfileDef& inst) { auto angles = inst.Slopes(); // these are actually angles, but the attribute is called Slopes if (widths.size() != angles.size()) { - logger_.Warning("GEO", 275, "Expected Widths and Slopes to be equal length, but got " + std::to_string(widths.size()) + " and " + std::to_string(angles.size()) + " respectively", inst); + logger_.warning("GEO", 275, "Expected Widths and Slopes to be equal length, but got " + std::to_string(widths.size()) + " and " + std::to_string(angles.size()) + " respectively", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcPolyLoop.cpp b/src/ifcgeom/mapping/IfcPolyLoop.cpp index 4e50c8055f..371ff6d975 100644 --- a/src/ifcgeom/mapping/IfcPolyLoop.cpp +++ b/src/ifcgeom/mapping/IfcPolyLoop.cpp @@ -36,7 +36,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyLoop& inst) { // A loop should consist of at least three vertices int original_count = polygon.size(); if (original_count < 3) { - logger_.Message(Logger::LOG_WARNING, "GEO", 278, "Not enough edges for:", inst); + logger_.message(::logger::LOG_WARNING, "GEO", 278, "Not enough edges for:", inst); return nullptr; } @@ -45,17 +45,17 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyLoop& inst) { auto previous_size = polygon.size(); remove_duplicate_points_from_loop(polygon, true, eps); if (polygon.size() != previous_size) { - logger_.Warning("GEO", 279, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst); + logger_.warning("GEO", 279, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst); } int count = polygon.size(); if (original_count - count != 0) { std::stringstream ss; ss << (original_count - count) << " edges removed for:"; - logger_.Message(Logger::LOG_WARNING, "GEO", 280, ss.str(), inst); + logger_.message(::logger::LOG_WARNING, "GEO", 280, ss.str(), inst); } if (count < 3) { - logger_.Message(Logger::LOG_WARNING, "GEO", 281, "Not enough edges for:", inst); + logger_.message(::logger::LOG_WARNING, "GEO", 281, "Not enough edges for:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcPolyline.cpp b/src/ifcgeom/mapping/IfcPolyline.cpp index a2b3b1ca6b..2d22cb3b23 100644 --- a/src/ifcgeom/mapping/IfcPolyline.cpp +++ b/src/ifcgeom/mapping/IfcPolyline.cpp @@ -44,12 +44,12 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyline& inst) { auto previous_size = polygon.size(); remove_duplicate_points_from_loop(polygon, closed_by_proximity, eps); if (polygon.size() != previous_size) { - logger_.Warning("GEO", 276, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst); + logger_.warning("GEO", 276, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst); } if (polygon.size() < 2) { // We somehow need to signal we fail this curve on purpose not to trigger an error. - logger_.Warning("GEO", 277, "Invalid polyline with " + std::to_string(polygon.size()) + " points:", inst); + logger_.warning("GEO", 277, "Invalid polyline with " + std::to_string(polygon.size()) + " points:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp b/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp index e3dad2a72d..6caa9a0d67 100644 --- a/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp @@ -37,7 +37,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef& i const double tol = settings_.get().get(); if (x < tol || y < tol) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 282, "Skipping zero sized profile:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 282, "Skipping zero sized profile:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp b/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp index 39167a2fed..9f5acc7890 100644 --- a/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp @@ -30,7 +30,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleProfileDef& inst) { const double tol = settings_.get().get(); if (x < tol || y < tol) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 283, "Skipping zero sized profile:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 283, "Skipping zero sized profile:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp b/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp index 621e93f339..03d636cc6f 100644 --- a/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp +++ b/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp @@ -27,7 +27,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularTrimmedSurface& i /* if (!inst.BasisSurface()->declaration().is(IfcSchema::IfcPlane::Class())) { - logger::message(logger::LOG_ERROR, "Unsupported BasisSurface:", inst.BasisSurface()); + ::logger::root().message(::logger::LOG_ERROR, "Unsupported BasisSurface:", inst.BasisSurface()); return false; } gp_Pln pln; diff --git a/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp b/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp index ca87c35d14..e24c1bca8f 100644 --- a/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp +++ b/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp @@ -86,7 +86,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRevolvedAreaSolid& inst) { } if (intersecting) { - logger::warning("Warning Axis and SweptArea intersecting", l); + ::logger::root().warning("Warning Axis and SweptArea intersecting", l); } } */ diff --git a/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp b/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp index fdb251c124..f03b81f3f3 100644 --- a/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp @@ -31,7 +31,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef& const double tol = settings_.get().get(); if (x < tol || y < tol) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 284, "Skipping zero sized profile:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 284, "Skipping zero sized profile:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp b/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp index c408141f30..36baea8d26 100644 --- a/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp +++ b/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp @@ -34,7 +34,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSolidHorizontal& in auto fn = taxonomy::dcast(dir); if (!fn) { // Only implement on alignment curves - logger_.Warning("GEO", 285, "IfcSectionedSolidHorizontal is only implemented for Directrix curves based on taxonomy::function_item", inst); + logger_.warning("GEO", 285, "IfcSectionedSolidHorizontal is only implemented for Directrix curves based on taxonomy::function_item", inst); return nullptr; } @@ -91,11 +91,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSolidHorizontal& in profile_rotations.push_back(rot); } if (faces.size() != profile_offsets.size()) { - logger_.Warning("GEO", 286, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst); + logger_.warning("GEO", 286, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst); return nullptr; } if (faces.size() < 2) { - logger_.Warning("GEO", 287, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst); + logger_.warning("GEO", 287, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcSectionedSurface.cpp b/src/ifcgeom/mapping/IfcSectionedSurface.cpp index bbbacec788..7499cfc07c 100644 --- a/src/ifcgeom/mapping/IfcSectionedSurface.cpp +++ b/src/ifcgeom/mapping/IfcSectionedSurface.cpp @@ -34,7 +34,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSurface& inst) { auto fn = taxonomy::dcast(dir); if (!fn) { // Only implement on alignment curves - logger_.Warning("GEO", 288, "IfcSectionedSurface is only implemented for Directrix curves based on taxonomy::function_item", inst); + logger_.warning("GEO", 288, "IfcSectionedSurface is only implemented for Directrix curves based on taxonomy::function_item", inst); return nullptr; } @@ -97,11 +97,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSurface& inst) { return nullptr; #endif if (faces.size() != profile_offsets.size()) { - logger_.Warning("GEO", 289, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst); + logger_.warning("GEO", 289, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst); return nullptr; } if (faces.size() < 2) { - logger_.Warning("GEO", 290, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst); + logger_.warning("GEO", 290, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcSegmentedReferenceCurve.cpp b/src/ifcgeom/mapping/IfcSegmentedReferenceCurve.cpp index 8e18375de5..4e7bfb2dd1 100644 --- a/src/ifcgeom/mapping/IfcSegmentedReferenceCurve.cpp +++ b/src/ifcgeom/mapping/IfcSegmentedReferenceCurve.cpp @@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve& inst) { if (!inst.BaseCurve().as()) - logger_.Warning("GEO", 291, "Expected IfcSegmentedReferenceCurve.BaseCurve to be IfcGradient", inst); // CT 4.1.7.1.1.3 + logger_.warning("GEO", 291, "Expected IfcSegmentedReferenceCurve.BaseCurve to be IfcGradient", inst); // CT 4.1.7.1.1.3 auto segments = inst.Segments(); @@ -41,11 +41,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve& ins // for this reason, a dynamic cast is used and if crv is a function_item it is added to the span spans.push_back(fi); } else { - logger_.Error("UNS", 17, "Unsupported"); + logger_.error("UNS", 17, "Unsupported"); return nullptr; } } else { - logger_.Error("UNS", 18, "Unsupported"); + logger_.error("UNS", 18, "Unsupported"); return nullptr; } } @@ -67,7 +67,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve& ins auto cant_function = taxonomy::make(gradient, cant, inst); if (!(0 < cant_function->length())) { - logger_.Error("GEO", 292, "IfcSegmentedReferenceCurve does not have a common domain with BaseCurve"); + logger_.error("GEO", 292, "IfcSegmentedReferenceCurve does not have a common domain with BaseCurve"); cant_function = nullptr; } return cant_function; diff --git a/src/ifcgeom/mapping/IfcSurfaceCurveSweptAreaSolid.cpp b/src/ifcgeom/mapping/IfcSurfaceCurveSweptAreaSolid.cpp index 17e3488be7..b20f39475d 100644 --- a/src/ifcgeom/mapping/IfcSurfaceCurveSweptAreaSolid.cpp +++ b/src/ifcgeom/mapping/IfcSurfaceCurveSweptAreaSolid.cpp @@ -49,11 +49,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid& if (!is_plane) { TopoDS_Shape surface_shell; if (!convert_shape(inst.ReferenceSurface(), surface_shell)) { - logger::error("Failed to convert reference surface", l); + ::logger::root().error("Failed to convert reference surface", l); return false; } if (util::count(surface_shell, TopAbs_FACE) != 1) { - logger::error("Non-continuous reference surface", l); + ::logger::root().error("Non-continuous reference surface", l); return false; } surface_face = TopoDS::Face(TopExp_Explorer(surface_shell, TopAbs_FACE).Current()); @@ -76,7 +76,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid& for (TopExp_Explorer exp(wire, TopAbs_VERTEX); exp.More(); exp.Next()) { if (pln.Distance(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()))) > ALMOST_ZERO) { directrix_on_plane = false; - logger::message(logger::LOG_WARNING, "The Directrix does not lie on the ReferenceSurface", l); + ::logger::root().message(::logger::LOG_WARNING, "The Directrix does not lie on the ReferenceSurface", l); break; } } diff --git a/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp b/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp index f4d6f7c804..ea6e70a538 100644 --- a/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp +++ b/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp @@ -62,7 +62,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid& inst) { sp = inst.StartParam(); ep = inst.EndParam(); } catch (const ifcopenshell::exception& e) { - logger_.Warning("GEO", 293, e); + logger_.warning("GEO", 293, e); } #endif @@ -241,19 +241,19 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid& inst) { i += 1; j += 1; } else { - logger::error("Unexpected amount of fillet edges generated"); + ::logger::root().error("Unexpected amount of fillet edges generated"); } } else { - logger::error("Unable to build fillet, probably edge too short"); + ::logger::root().error("Unable to build fillet, probably edge too short"); } } else { - logger::error("Colinear edges, not applying fillet"); + ::logger::root().error("Colinear edges, not applying fillet"); } i++; j++; } } else { - logger::error("Not enough edges for applying fillet"); + ::logger::root().error("Not enough edges for applying fillet"); } TopoDS_Wire new_wire; @@ -266,7 +266,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid& inst) { wire = new_wire; } else { - logger::error("Directrix is not polyhedral, ignoring FilletRadius"); + ::logger::root().error("Directrix is not polyhedral, ignoring FilletRadius"); } } @@ -317,7 +317,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid& inst) { } if (!is_valid) { - logger::message(logger::LOG_WARNING, "Failed to subtract inner radius void for:", l); + ::logger::root().message(::logger::LOG_WARNING, "Failed to subtract inner radius void for:", l); } } diff --git a/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp index 0f8727d15f..521db4c8b7 100644 --- a/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp @@ -40,7 +40,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTShapeProfileDef& inst) { const double tol = settings_.get().get(); if (x < tol || y < tol || d1 < tol || d2 < tol) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 296, "Skipping zero sized profile:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 296, "Skipping zero sized profile:", inst); return nullptr; } @@ -88,7 +88,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTShapeProfileDef& inst) { const double det = a1*b2 - a2*b1; if (std::fabs(det) < 1.e-5) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 297, "Web and flange do not intersect for:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 297, "Web and flange do not intersect for:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp b/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp index 9cd103ef4c..205242cff3 100644 --- a/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp @@ -36,7 +36,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrapeziumProfileDef& inst) { const double tol = settings_.get().get(); if (x1 < tol || w < tol || y < tol) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 294, "Skipping zero sized profile:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 294, "Skipping zero sized profile:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcTrimmedCurve.cpp b/src/ifcgeom/mapping/IfcTrimmedCurve.cpp index 923958c5a1..ede59d2488 100644 --- a/src/ifcgeom/mapping/IfcTrimmedCurve.cpp +++ b/src/ifcgeom/mapping/IfcTrimmedCurve.cpp @@ -76,7 +76,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve& inst) { bool trim_cartesian_failed = !trim_cartesian; if (trim_cartesian) { if ((pnts[0]->ccomponents() - pnts[1]->ccomponents()).norm() < (2 * tol)) { - logger_.Message(Logger::LOG_WARNING, "GEO", 295, "Skipping segment with length below tolerance level:", inst); + logger_.message(::logger::LOG_WARNING, "GEO", 295, "Skipping segment with length below tolerance level:", inst); return nullptr; } tc->start = pnts[0]; @@ -140,7 +140,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve& inst) { TopoDS_Vertex v0, v1; TopExp::Vertices(e, v0, v1); if (v0.IsSame(v1)) { - logger::warning("Skipping degenerate segment", l); + ::logger::root().warning("Skipping degenerate segment", l); return false; } } @@ -168,7 +168,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve& inst) { TopoDS_Vertex v0, v1; TopExp::Vertices(e, v0, v1); e = TopoDS::Edge(BRepBuilderAPI_MakeEdge(v0, v1).Edge().Oriented(e.Orientation())); - logger::warning("Substituted edge with linear approximation", l); + ::logger::root().warning("Substituted edge with linear approximation", l); } } diff --git a/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp index feaee22ebb..05869ac58d 100644 --- a/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp @@ -54,7 +54,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcUShapeProfileDef& inst) { const double tol = settings_.get().get(); if (x < tol || y < tol || d1 < tol || d2 < tol) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 298, "Skipping zero sized profile:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 298, "Skipping zero sized profile:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp index 03363d5a0c..dc09b12de4 100644 --- a/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp @@ -45,7 +45,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcZShapeProfileDef& inst) { const double tol = settings_.get().get(); if (x < tol || y < tol || dx < tol || dy < tol) { - logger_.Message(Logger::LOG_NOTICE, "GEO", 299, "Skipping zero sized profile:", inst); + logger_.message(::logger::LOG_NOTICE, "GEO", 299, "Skipping zero sized profile:", inst); return nullptr; } diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index 7bc68b88fd..2d04b9e025 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -32,7 +32,7 @@ using namespace IfcGeom; namespace { struct POSTFIX_SCHEMA(factory_t) { - abstract_mapping* operator()(ifcopenshell::file* file, Settings& settings, Logger& logger) const { + abstract_mapping* operator()(ifcopenshell::file* file, Settings& settings, ::logger& logger) const { ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)(file, settings, logger); return m; } @@ -84,7 +84,7 @@ std::vector mapping::products_represented_by(const IfcSch try { target = taxonomy::cast(map(item.MappingTarget())); } catch (const std::exception& e) { - logger_.Error("GEO", 300, e); + logger_.error("GEO", 300, e); continue; } if (!target->is_identity()) { @@ -335,8 +335,8 @@ const express::Base mapping::get_single_material_association(const express::Base try { associated_material = associated_materials.front().RelatingMaterial().concrete(); - } catch(IfcParse::IfcException& e) { - logger_.Error("GEO", 301, e.what()); + } catch(ifcopenshell::exception& e) { + logger_.error("GEO", 301, e.what()); } if (associated_material) { @@ -349,7 +349,7 @@ const express::Base mapping::get_single_material_association(const express::Base IfcSchema::IfcMaterialLayerSet layerset; if (auto m = associated_material.as()) { if (m.get("ForLayerSet").isNull()) { - logger_.Warning("GEO", 302, "Missing ForLayerSet for:", m); + logger_.warning("GEO", 302, "Missing ForLayerSet for:", m); return express::Base{}; } layerset = m.ForLayerSet(); @@ -369,7 +369,7 @@ const express::Base mapping::get_single_material_association(const express::Base IfcSchema::IfcMaterialProfileSet profileset; if (auto m = associated_material.as()) { if (m.get("ForProfileSet").isNull()) { - logger_.Warning("GEO", 303, "Missing ForProfileSet for:", m); + logger_.warning("GEO", 303, "Missing ForProfileSet for:", m); return express::Base{}; } profileset = m.ForProfileSet(); @@ -414,7 +414,7 @@ IfcSchema::IfcRepresentation mapping::representation_mapped_to(const IfcSchema:: try { target = taxonomy::cast(map(mapped_item.MappingTarget())); } catch (const std::exception& e) { - logger_.Error("GEO", 304, e); + logger_.error("GEO", 304, e); } if (target && target->is_identity()) { IfcSchema::IfcRepresentationMap rmap = mapped_item.MappingSource(); @@ -587,7 +587,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMaterial& material) { failed_on_purpose_.insert(material); return nullptr; } - logger_.Warning("UNS", 19, "Skipping unsupported material style for material: ", material); + logger_.warning("UNS", 19, "Skipping unsupported material style for material: ", material); } } @@ -620,7 +620,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem& inst) { if (!style) { // E.g. IfcCurveStyle is skipped as unsupported. - logger_.Warning("GEO", 305, "Only IfcSurfaceStyle is supported, couldn't find it in IfcStyledItem: ", inst); + logger_.warning("GEO", 305, "Only IfcSurfaceStyle is supported, couldn't find it in IfcStyledItem: ", inst); failed_on_purpose_.insert(inst); return nullptr; } @@ -715,7 +715,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceStyle& style) { taxonomy::ptr mapping::map(const express::Base& inst) { if (!inst) { - logger_.Error("GEO", 306, "Warning nullptr passed to map() function"); + logger_.error("GEO", 306, "Warning nullptr passed to map() function"); return nullptr; } auto iden = inst.identity(); @@ -742,7 +742,7 @@ taxonomy::ptr mapping::map(const express::Base& inst) { cache_.insert({iden, item}); } } else if (!matched) { - logger_.Message(Logger::LOG_ERROR, "GEO", 307, "No operation defined for:", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 307, "No operation defined for:", inst); } return item; } @@ -850,10 +850,10 @@ void mapping::initialize_units_() { auto& project = projects.front(); unit_assignment = project.UnitsInContext(); } else { - logger_.Warning("GEO", 308, "Not a single project or context in file"); + logger_.warning("GEO", 308, "Not a single project or context in file"); } if (!unit_assignment) { - logger_.Warning("GEO", 309, "Unable to detect unit information"); + logger_.warning("GEO", 309, "Unable to detect unit information"); return; } @@ -862,7 +862,7 @@ void mapping::initialize_units_() { try { auto units = unit_assignment.Units(); if (units.empty()) { - logger_.Warning("GEO", 310, "No unit information found"); + logger_.warning("GEO", 310, "No unit information found"); } else { for (auto& base : units) { if (auto named_unit = base.as()) { @@ -895,15 +895,15 @@ void mapping::initialize_units_() { } catch (const ifcopenshell::exception& ex) { std::stringstream ss; ss << "Failed to determine unit information '" << ex.what() << "'"; - logger_.Message(Logger::LOG_ERROR, "GEO", 311, ss.str()); + logger_.message(::logger::LOG_ERROR, "GEO", 311, ss.str()); } if (!length_unit_encountered) { - logger_.Warning("GEO", 312, "No length unit encountered"); + logger_.warning("GEO", 312, "No length unit encountered"); } if (!angle_unit_encountered) { - logger_.Warning("GEO", 313, "No plane angle unit encountered"); + logger_.warning("GEO", 313, "No plane angle unit encountered"); } // @todo move to a more descriptive function @@ -920,7 +920,7 @@ void mapping::initialize_units_() { if (vs.size() == 3) { offset_and_rotation_ *= Eigen::Affine3d(Eigen::Translation3d(vs[0], vs[1], vs[2])).matrix(); } else { - logger_.Error("SYS", 31, "Expected 3 values for model-offset setting"); + logger_.error("SYS", 31, "Expected 3 values for model-offset setting"); } } @@ -933,7 +933,7 @@ void mapping::initialize_units_() { m4 << m3; offset_and_rotation_ *= m4; } else { - logger_.Error("SYS", 32, "Expected 4 values for model-rotation setting"); + logger_.error("SYS", 32, "Expected 4 values for model-rotation setting"); } } } @@ -980,7 +980,7 @@ void mapping::initialize_settings() { if (any_precision_encountered) { if (lowest_precision_encountered < 1.e-7) { - logger_.Message(Logger::LOG_WARNING, "SYS", 33, "Precision lower than 0.0000001 meter not enforced"); + logger_.message(::logger::LOG_WARNING, "SYS", 33, "Precision lower than 0.0000001 meter not enforced"); precision_to_set = 1.e-7; } else { precision_to_set = lowest_precision_encountered; @@ -1017,7 +1017,7 @@ bool mapping::get_layerset_information(const express::Base& p, layerset_informat IfcSchema::IfcRepresentation body_representation = find_representation(product, "Body"); if (!body_representation) { - logger_.Warning("GEO", 314, "No body representation for product", product); + logger_.warning("GEO", 314, "No body representation for product", product); return false; } @@ -1031,7 +1031,7 @@ bool mapping::get_layerset_information(const express::Base& p, layerset_informat IfcSchema::IfcRepresentation axis_representation = find_representation(product, "Axis"); if (!axis_representation) { - logger_.Message(Logger::LOG_WARNING, "GEO", 315, "No axis representation for:", product); + logger_.message(::logger::LOG_WARNING, "GEO", 315, "No axis representation for:", product); return false; } @@ -1106,7 +1106,7 @@ bool mapping::get_layerset_information(const express::Base& p, layerset_informat } if (extrusions.size() != 1) { - logger_.Message(Logger::LOG_WARNING, "GEO", 316, "No single extrusion found in body representation for:", product); + logger_.message(::logger::LOG_WARNING, "GEO", 316, "No single extrusion found in body representation for:", product); return false; } @@ -1121,7 +1121,7 @@ bool mapping::get_layerset_information(const express::Base& p, layerset_informat if (has_position) { auto m4 = taxonomy::cast(map(extrusion.Position())); if (!m4) { - logger_.Message(Logger::LOG_ERROR, "GEO", 317, "Failed to convert placement for extrusion of:", product); + logger_.message(::logger::LOG_ERROR, "GEO", 317, "Failed to convert placement for extrusion of:", product); return false; } else { extrusion_position = m4; @@ -1131,7 +1131,7 @@ bool mapping::get_layerset_information(const express::Base& p, layerset_informat taxonomy::direction3::ptr extrusion_direction = taxonomy::cast(map(extrusion.ExtrudedDirection())); if (!extrusion_direction) { - logger_.Message(Logger::LOG_ERROR, "GEO", 318, "Failed to convert direction for extrusion of:", product); + logger_.message(::logger::LOG_ERROR, "GEO", 318, "Failed to convert direction for extrusion of:", product); return false; } @@ -1203,13 +1203,13 @@ void mapping::addRepresentationsFromContextIds(std::vectorinstance_by_id(context_id).as(); - } catch (IfcParse::IfcException& e) { - logger_.Error("GEO", 319, e); + } catch (ifcopenshell::exception& e) { + logger_.error("GEO", 319, e); continue; } if (!context) { - logger_.Error("GEO", 320, "Failed to process context ID " + std::to_string(context_id)); + logger_.error("GEO", 320, "Failed to process context ID " + std::to_string(context_id)); continue; } @@ -1258,14 +1258,14 @@ void mapping::addRepresentationsFromDefaultContexts(std::vectorContextType() + "' not allowed:", context); + logger_.warning("GEO", 321, std::string("ContextType '") + *context.ContextType() + "' not allowed:", context); } if (context_types.find(context_type) != context_types.end()) { filtered_contexts.push_back(context); } } } catch (const std::exception& e) { - logger_.Error("GEO", 322, e); + logger_.error("GEO", 322, e); } } @@ -1294,7 +1294,7 @@ void mapping::addRepresentationsFromDefaultContexts(std::vectorinstances_by_type(); representations = all_reps; } @@ -1375,8 +1375,8 @@ express::Base mapping::representation_of(const express::Base& product) { } intersection_no_box.push_back(r); } - if (intersection_no_box->size() > 1) { - logger_.Warning("GEO", 324, "Multiple applicable representations found for element, selecting arbitrary"); + if (intersection_no_box.size() > 1) { + logger_.warning("GEO", 324, "Multiple applicable representations found for element, selecting arbitrary"); } if (intersection_no_box.size()) { return intersection_no_box.front(); diff --git a/src/ifcgeom/mapping/mapping.h b/src/ifcgeom/mapping/mapping.h index 18d062758e..3f11646a4d 100644 --- a/src/ifcgeom/mapping/mapping.h +++ b/src/ifcgeom/mapping/mapping.h @@ -10,8 +10,8 @@ #include #include -#include INCLUDE_SCHEMA(../../ifcparse, IfcSchema) -#include INCLUDE_SCHEMA_DEFINITIONS(../../ifcparse, IfcSchema) +#include INCLUDE_SCHEMA(../../ifcparse/schemas, IfcSchema) +#include INCLUDE_SCHEMA_DEFINITIONS(../../ifcparse/schemas, IfcSchema) namespace ifcopenshell { @@ -71,19 +71,19 @@ namespace geometry { } } } catch (const std::exception& e) { - logger_.Message(Logger::LOG_ERROR, "GEO", 325, std::string(e.what()) + "\nFailed to convert:", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 325, std::string(e.what()) + "\nFailed to convert:", inst); } } else if (failed_on_purpose_.find(inst) == failed_on_purpose_.end()) { - logger_.Message(Logger::LOG_ERROR, "GEO", 326, "Failed to convert:", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 326, "Failed to convert:", inst); } } catch (const std::exception& e) { - logger_.Message(Logger::LOG_ERROR, "GEO", 327, std::string(e.what()) + "\nFailed to convert:", inst); + logger_.message(::logger::LOG_ERROR, "GEO", 327, std::string(e.what()) + "\nFailed to convert:", inst); } } } IfcSchema::IfcStyledItem find_style(const IfcSchema::IfcRepresentationItem&); public: - POSTFIX_SCHEMA(mapping)(ifcopenshell::file* file, Settings& settings, Logger& logger = Logger::Root()) : abstract_mapping(settings), file_(file), placement_rel_to_type_(nullptr) { + POSTFIX_SCHEMA(mapping)(ifcopenshell::file* file, Settings& settings, ::logger& logger = ::logger::root()) : abstract_mapping(settings, logger), file_(file), placement_rel_to_type_(nullptr) { initialize_units_(); } virtual ifcopenshell::geometry::taxonomy::ptr map(const express::Base&); diff --git a/src/ifcgeom/mapping/plugin.cpp b/src/ifcgeom/mapping/plugin.cpp index ebddd6387b..e89c75075a 100644 --- a/src/ifcgeom/mapping/plugin.cpp +++ b/src/ifcgeom/mapping/plugin.cpp @@ -29,8 +29,8 @@ namespace ifcopenshell { namespace { struct POSTFIX_SCHEMA(factory_t) { - abstract_mapping* operator()(ifcopenshell::file* file, Settings& settings) const { - return new POSTFIX_SCHEMA(mapping)(file, settings); + abstract_mapping* operator()(ifcopenshell::file* file, Settings& settings, ::logger& logger) const { + return new POSTFIX_SCHEMA(mapping)(file, settings, logger); } }; } diff --git a/src/ifcgeom/profile_helper.cpp b/src/ifcgeom/profile_helper.cpp index 637f9a0703..1b9d1899cc 100644 --- a/src/ifcgeom/profile_helper.cpp +++ b/src/ifcgeom/profile_helper.cpp @@ -120,7 +120,7 @@ taxonomy::loop::ptr ifcopenshell::geometry::profile_helper(const taxonomy::matri if (fillet.IsDone()) { face = TopoDS::Face(fillet.Shape()); } else { - logger::error("Failed to process profile fillets"); + ::logger::root().error("Failed to process profile fillets"); } } */ diff --git a/src/ifcgeom/taxonomy.cpp b/src/ifcgeom/taxonomy.cpp index e13b87cfde..e36701b43c 100644 --- a/src/ifcgeom/taxonomy.cpp +++ b/src/ifcgeom/taxonomy.cpp @@ -861,7 +861,7 @@ std::optional ifcopenshell::geometry::taxonomy::loop_to_func spans.emplace_back(taxonomy::make(l, fn)); } else if (edge_->start.index() == 1 && edge_->end.index() == 1) { if (edge_->basis && edge_->basis->kind() != LINE) { - Logger::Root().Message(Logger::Severity::LOG_WARNING, "UNS", 20, "Basis curve not supported - edge is treated as a straight line edge"); + ::logger::root().message(::logger::Severity::LOG_WARNING, "UNS", 20, "Basis curve not supported - edge is treated as a straight line edge"); } const auto& s = std::get(edge_->start)->ccomponents(); const auto& e = std::get(edge_->end)->ccomponents(); @@ -876,8 +876,8 @@ std::optional ifcopenshell::geometry::taxonomy::loop_to_func }; spans.emplace_back(taxonomy::make(l, fn)); } else { - Logger::Root().Message(Logger::Severity::LOG_ERROR, "UNS", 21, "Basis curve not supported"); - return boost::none; + ::logger::root().message(::logger::Severity::LOG_ERROR, "UNS", 21, "Basis curve not supported"); + return std::nullopt; } } fi_ = make(0.0,spans); diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp index a355bc158b..8f46e73c37 100644 --- a/src/ifcgeomserver/IfcGeomServer.cpp +++ b/src/ifcgeomserver/IfcGeomServer.cpp @@ -629,7 +629,7 @@ int main () { } case NEXT: { Next n; n.read(std::cin); - has_more = iterator->next() != 0; + has_more = static_cast(iterator->next()); if (!has_more) { delete file; delete iterator; @@ -641,7 +641,7 @@ int main () { } case GET_LOG: { get_log gl; gl.read(std::cin); - WriteLog(logger::Root().get_log()).write(std::cout); + WriteLog(logger::root().get_log()).write(std::cout); continue; } case BYE: { diff --git a/src/ifcparse/alignment_helper.cpp b/src/ifcparse/alignment_helper.cpp index af74acc907..91b6ee5173 100644 --- a/src/ifcparse/alignment_helper.cpp +++ b/src/ifcparse/alignment_helper.cpp @@ -501,7 +501,7 @@ std::pair mapAlignme } else if (cant) { result = mapAlignmentCantSegment(file, cant); } else { - logger::error(std::string("Unexpected IfcAlignmentSegment subtype encountered")); + ::logger::root().error(std::string("Unexpected IfcAlignmentSegment subtype encountered")); } return result; } @@ -762,9 +762,9 @@ std::pair mapAlignme result.first = curve_segment; } else if (type == Ifc4x3_add2::IfcAlignmentHorizontalSegmentTypeEnum::IfcAlignmentHorizontalSegmentType_VIENNESEBEND) { - logger::warning(std::string("mapping of AlignmentHorizontalSegmentType VIENNESEBEND not supported")); + ::logger::root().warning(std::string("mapping of AlignmentHorizontalSegmentType VIENNESEBEND not supported")); } else { - logger::error(std::string("unexpected AlignmentHorizontalSegmentType encountered")); + ::logger::root().error(std::string("unexpected AlignmentHorizontalSegmentType encountered")); } return result; @@ -830,7 +830,7 @@ std::pair mapAlignme result.first = curve_segment; } else if (type == Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CLOTHOID) { - logger::warning(std::string("mapping of AlignmentVerticalSegmentType CLOTHOID not supported")); + ::logger::root().warning(std::string("mapping of AlignmentVerticalSegmentType CLOTHOID not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CIRCULARARC) { auto start_angle = atan(start_gradient); auto end_angle = atan(end_gradient); @@ -856,7 +856,7 @@ std::pair mapAlignme result.first = curve_segment; } else { - logger::error(std::string("unexpected AlignmentVerticalSegmentType encountered")); + ::logger::root().error(std::string("unexpected AlignmentVerticalSegmentType encountered")); } return result; @@ -866,21 +866,21 @@ std::pair mapAlignme std::pair result; auto type = segment.PredefinedType(); if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_BLOSSCURVE) { - logger::warning(std::string("mapping of AlignmentCantSegmentType BLOSSCURVE not supported")); + ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType BLOSSCURVE not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_CONSTANTCANT) { - logger::warning(std::string("mapping of AlignmentCantSegmentType CONSTANTCANT not supported")); + ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType CONSTANTCANT not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_COSINECURVE) { - logger::warning(std::string("mapping of AlignmentCantSegmentType COSINECURVE not supported")); + ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType COSINECURVE not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_HELMERTCURVE) { - logger::warning(std::string("mapping of AlignmentCantSegmentType HELMERTCURVE not supported")); + ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType HELMERTCURVE not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_LINEARTRANSITION) { - logger::warning(std::string("mapping of AlignmentCantSegmentType LINEARTRANSTION not supported")); + ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType LINEARTRANSTION not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_SINECURVE) { - logger::warning(std::string("mapping of AlignmentCantSegmentType SINECURVE not supported")); + ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType SINECURVE not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_VIENNESEBEND) { - logger::warning(std::string("mapping of AlignmentCantSegmentType VIENNESEBEND not supported")); + ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType VIENNESEBEND not supported")); } else { - logger::error(std::string("unexpected AlignmentCantSegmentType encountered")); + ::logger::root().error(std::string("unexpected AlignmentCantSegmentType encountered")); } return result; } diff --git a/src/ifcparse/alignment_helper.h b/src/ifcparse/alignment_helper.h index f265637fe7..f95c5f5683 100644 --- a/src/ifcparse/alignment_helper.h +++ b/src/ifcparse/alignment_helper.h @@ -45,10 +45,10 @@ IFC_SCHEMA_API Ifc4x3_add2::IfcAlignment addAlignment(hierarchy_helper mapAlignmentSegment(hierarchy_helper& model, const Ifc4x3_add2::IfcAlignmentSegment& segment, Logger& logger = Logger::Root()); -IFC_SCHEMA_API std::pair mapAlignmentHorizontalSegment(hierarchy_helper& model, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, Logger& logger = Logger::Root()); -IFC_SCHEMA_API std::pair mapAlignmentVerticalSegment(hierarchy_helper& model, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, Logger& logger = Logger::Root()); -IFC_SCHEMA_API std::pair mapAlignmentCantSegment(hierarchy_helper& model, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, Logger& logger = Logger::Root()); +IFC_SCHEMA_API std::pair mapAlignmentSegment(hierarchy_helper& model, const Ifc4x3_add2::IfcAlignmentSegment& segment, logger& logger = ::logger::root()); +IFC_SCHEMA_API std::pair mapAlignmentHorizontalSegment(hierarchy_helper& model, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, logger& logger = ::logger::root()); +IFC_SCHEMA_API std::pair mapAlignmentVerticalSegment(hierarchy_helper& model, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, logger& logger = ::logger::root()); +IFC_SCHEMA_API std::pair mapAlignmentCantSegment(hierarchy_helper& model, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, logger& logger = ::logger::root()); #endif diff --git a/src/ifcparse/character_decoder.cpp b/src/ifcparse/character_decoder.cpp index ef28d98923..b00de24c10 100644 --- a/src/ifcparse/character_decoder.cpp +++ b/src/ifcparse/character_decoder.cpp @@ -139,7 +139,8 @@ inline void append_ascii(std::u32string& builder, const char* bytes, size_t coun } // namespace SWAR template -character_decoder::character_decoder(Reader* stream) { +character_decoder::character_decoder(Reader* stream, logger& logger) + : logger_(logger) { stream_ = stream; codepage_ = 0; builder_.reserve(1024); @@ -151,7 +152,7 @@ character_decoder::~character_decoder() { namespace { template - std::string read_string(std::u32string& builder_, Reader& stream_, typename ifcopenshell::character_decoder::ConversionMode mode, char substitution_character) { + std::string read_string(std::u32string& builder_, Reader& stream_, logger& logger_, typename ifcopenshell::character_decoder::ConversionMode mode, char substitution_character) { unsigned int parse_state = 0; builder_.clear(); // builder_.push_back('\''); @@ -224,7 +225,7 @@ namespace { parse_state += PAGE; } else if (IS_HEXADECIMAL(current_char) && EXPECTS_HEX(parse_state)) { if (IS_LOWERCASE_HEX(current_char)) { - logger.Warning("SYN", 2, "Lowercase hexadecimal character '" + std::string(1, current_char) + + logger_.warning("SYN", 2, "Lowercase hexadecimal character '" + std::string(1, current_char) + "' found at offset " + std::to_string(stream_.tell()) + ". It is recommended to use uppercase for hexadecimal."); } @@ -299,14 +300,14 @@ namespace { template character_decoder::operator std::string() { - return read_string(builder_, *stream_, mode, substitution_character); + return read_string(builder_, *stream_, logger_, mode, substitution_character); } template std::string character_decoder::get(size_t& ptr) { auto local_stream = *stream_; local_stream.seek(ptr); - auto s = read_string(builder_, local_stream, mode, substitution_character); + auto s = read_string(builder_, local_stream, logger_, mode, substitution_character); ptr = local_stream.tell(); return s; } diff --git a/src/ifcparse/character_decoder.h b/src/ifcparse/character_decoder.h index 51ca88a84b..8d1f26460d 100644 --- a/src/ifcparse/character_decoder.h +++ b/src/ifcparse/character_decoder.h @@ -44,7 +44,7 @@ template class IFC_PARSE_API character_decoder { private: Reader* stream_; - Logger& logger_; + logger& logger_; int codepage_; std::u32string builder_; @@ -57,7 +57,7 @@ class IFC_PARSE_API character_decoder { inline static ConversionMode mode = UTF8; inline static char substitution_character = '_'; - character_decoder(Reader* stream, Logger& logger = Logger::Root()); + character_decoder(Reader* stream, logger& logger = ::logger::root()); ~character_decoder(); // Gets a decoded string representation at the token stream // read pointer and advances the underlying token stream. diff --git a/src/ifcparse/entity_instance_data.cpp b/src/ifcparse/entity_instance_data.cpp index 6a73f2fa8b..8ca174e977 100644 --- a/src/ifcparse/entity_instance_data.cpp +++ b/src/ifcparse/entity_instance_data.cpp @@ -1,5 +1,6 @@ #include "instance_data.h" #include "express.h" +#include "exception.h" #include "file.h" // @todo is size() still needed? @@ -37,14 +38,14 @@ namespace { try { return array_.storage_ptr->get(index_); } catch (const impl::storage_type_mismatch& e) { - throw IfcParse::IfcException( + throw ifcopenshell::exception( // entity_or_type not passed, but in v0.9 this is beginning to make sense (entity_or_type ? std::string("On instance #" + std::to_string(instance_name_) + " of " + entity_or_type->name() + ": ") : std::string("")) + "Requested type <" + e.requested() + "> does not match actual type <" + e.actual() + "> at index " + std::to_string(index_)); } catch (const std::out_of_range& e) { - throw IfcParse::IfcException( + throw ifcopenshell::exception( (entity_or_type ? std::string("On instance #" + std::to_string(instance_name_) + " of " + entity_or_type->name() + ": ") : std::string("")) + @@ -70,7 +71,7 @@ namespace { static_assert( std::is_same_v || std::is_same_v, express::Base>, - "RocksDB deserialization must be specialized for this enumeration_reference and IfcBaseClass*" + "RocksDB deserialization must be specialized for this enumeration_reference and express::Base" ); } return val; @@ -580,4 +581,4 @@ T* instance_data::get_storage_of_type() const { template IFC_PARSE_API ifcopenshell::impl::in_memory_file_storage* instance_data::get_storage_of_type() const; template IFC_PARSE_API ifcopenshell::impl::rocks_db_file_storage* instance_data::get_storage_of_type() const; -#endif \ No newline at end of file +#endif diff --git a/src/ifcparse/file.h b/src/ifcparse/file.h index 6a0cc47d63..106afecbd2 100644 --- a/src/ifcparse/file.h +++ b/src/ifcparse/file.h @@ -103,7 +103,7 @@ private: const ifcopenshell::schema_definition* schema_; ifcopenshell::impl::in_memory_file_storage storage_; ifcopenshell::file_open_status good_ = ifcopenshell::file_open_status::SUCCESS; - std::reference_wrapper logger_; + std::reference_wrapper<::logger> logger_; int progress_; ifcopenshell::unresolved_references references_to_resolve_; int yielded_header_instances_ = 0; @@ -157,13 +157,13 @@ private: void push_page(const std::string& page_data); - instance_streamer(ifcopenshell::file* owner_file = nullptr, Logger& logger = Logger::Root()); + instance_streamer(ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()); - instance_streamer(const std::string& path, bool use_mmap = false, ifcopenshell::file* owner_file = nullptr, Logger& logger = Logger::Root()); + instance_streamer(const std::string& path, bool use_mmap = false, ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()); - instance_streamer(void* data, int data_size, ifcopenshell::file* owner_file = nullptr, Logger& logger = Logger::Root()); + instance_streamer(void* data, int data_size, ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()); - instance_streamer(Reader* stream, ifcopenshell::file* owner_file = nullptr, Logger& logger = Logger::Root()); + instance_streamer(Reader* stream, ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()); void bypass_types(const std::set& type_names); @@ -211,7 +211,7 @@ public: private: file_open_status good_ = file_open_status::SUCCESS; - std::reference_wrapper logger_; + std::reference_wrapper<::logger> logger_; const ifcopenshell::schema_definition* schema_; const ifcopenshell::declaration* ifcroot_type_; @@ -242,7 +242,7 @@ public: /// /// UTF-8 file path to an IFC-SPF file /// Whether to use memory-mapped I/O - file(const std::string& path, bool use_mmap, Logger& logger = Logger::Root()); + file(const std::string& path, bool use_mmap, ::logger& logger = ::logger::root()); #endif /// /// Constructs an file object from a file path, supports IFC-SPF and the IfcOpenShell-specific RocksDB format. @@ -250,17 +250,17 @@ public: /// UTF-8 file path to an IFC-SPF file or RocksDB database directory /// File type of the path /// Whether to open in read-only mode, only supported on RocksDB databases - file(const std::string& path, filetype type = FT_AUTODETECT, bool read_only = false, Logger& logger = Logger::Root()); + file(const std::string& path, filetype type = FT_AUTODETECT, bool read_only = false, ::logger& logger = ::logger::root()); /// /// Constructs an file object from a stream containing IFC-SPF data. /// - file(std::istream& stream, int data_size, Logger& logger = Logger::Root()); + file(std::istream& stream, int data_size, ::logger& logger = ::logger::root()); /// /// Constructs an file object from a memory buffer containing IFC-SPF data. /// - file(void* data, int data_size, Logger& logger = Logger::Root()); + file(void* data, int data_size, ::logger& logger = ::logger::root()); /// /// Constructs an file object with the specified schema, file type, and file path. @@ -269,12 +269,12 @@ public: /// Pointer to the schema definition to use. Defaults to the IFC4 schema if not specified. /// The file type to use for the file. Defaults to FT_AUTODETECT. /// The file system path to the IFC file. Defaults to an empty string. - file(const ifcopenshell::schema_definition* schema = ifcopenshell::schema_by_name("IFC4"), filetype type = FT_AUTODETECT, const std::string& path = "", Logger& logger = Logger::Root()); + file(const ifcopenshell::schema_definition* schema = ifcopenshell::schema_by_name("IFC4"), filetype type = FT_AUTODETECT, const std::string& path = "", ::logger& logger = ::logger::root()); /// /// Constructs an unitialized file object. Call initialize() later on. Allows to specify which types to bypass during load. /// - file(const uninitialized_tag& tag, Logger& logger = Logger::Root()); + file(const uninitialized_tag& tag, ::logger& logger = ::logger::root()); bool initialize(const std::string& path, filetype type = FT_AUTODETECT, bool read_only = false); #ifdef USE_MMAP @@ -288,7 +288,7 @@ public: ~file(); ifcopenshell::file_open_status good() const { return good_; } - Logger& logger() const { return logger_.get(); } + ::logger& logger() const { return logger_.get(); } /// Returns the first entity in the range of instances contained in the model, /// in arbitrary order diff --git a/src/ifcparse/global_id.cpp b/src/ifcparse/global_id.cpp index d32ac1a4cb..e26753a4c6 100644 --- a/src/ifcparse/global_id.cpp +++ b/src/ifcparse/global_id.cpp @@ -94,7 +94,7 @@ void expand(const std::string& s, std::vector& v) { static boost::uuids::basic_random_generator gen; #endif -ifcopenshell::global_id::global_id(Logger& logger) { +ifcopenshell::global_id::global_id(logger& logger) { uuid_data_ = gen(); std::vector v(uuid_data_.size()); std::copy(uuid_data_.begin(), uuid_data_.end(), v.begin()); @@ -111,12 +111,12 @@ ifcopenshell::global_id::global_id(Logger& logger) { boost::uuids::uuid test_uuid; std::copy(test_vector.begin(), test_vector.end(), test_uuid.begin()); if (uuid_data_ != test_uuid) { - logger.Message(Logger::LOG_ERROR, "SYS", 34, "Internal error generating GlobalId"); + logger.message(::logger::LOG_ERROR, "SYS", 34, "Internal error generating GlobalId"); } #endif } -ifcopenshell::global_id::global_id(const std::string& string, Logger& logger) +ifcopenshell::global_id::global_id(const std::string& string, logger& logger) : string_data_(string) { std::vector result; expand(string_data_, result); @@ -130,7 +130,7 @@ ifcopenshell::global_id::global_id(const std::string& string, Logger& logger) #ifndef NDEBUG const std::string test_string = compress(&uuid_data_.data[0]); if (string_data_ != test_string) { - logger.Message(Logger::LOG_ERROR, "SYS", 35, "Internal error generating GlobalId"); + logger.message(::logger::LOG_ERROR, "SYS", 35, "Internal error generating GlobalId"); } #endif } diff --git a/src/ifcparse/global_id.h b/src/ifcparse/global_id.h index 9859eab02b..b2be0f4d24 100644 --- a/src/ifcparse/global_id.h +++ b/src/ifcparse/global_id.h @@ -21,7 +21,7 @@ #define IFCGLOBALID_H #include "ifc_parse_api.h" -#include "IfcLogger.h" +#include "logger.h" #include #include @@ -37,8 +37,8 @@ class IFC_PARSE_API global_id { public: static const unsigned int length = 22; - global_id(Logger& logger = Logger::Root()); - global_id(const std::string& value, Logger& logger = Logger::Root()); + global_id(logger& logger = ::logger::root()); + global_id(const std::string& value, logger& logger = ::logger::root()); operator const std::string&() const; operator const boost::uuids::uuid&() const; const std::string& formatted() const; diff --git a/src/ifcparse/hierarchy_helper.h b/src/ifcparse/hierarchy_helper.h index 1f72efd1ee..0d16db8a59 100644 --- a/src/ifcparse/hierarchy_helper.h +++ b/src/ifcparse/hierarchy_helper.h @@ -180,9 +180,9 @@ class IFC_SCHEMA_API hierarchy_helper : public ifcopenshell::file { break; } } catch (std::exception& e) { - logger::error(e); + ::logger::root().error(e); } catch (...) { - logger::error("Unknown error in addRelatedObject()"); + ::logger::root().error("Unknown error in addRelatedObject()"); } } if (!found) { diff --git a/src/ifcparse/hierarchy_helper.i b/src/ifcparse/hierarchy_helper.i index 13812ab21b..a9257d2b54 100644 --- a/src/ifcparse/hierarchy_helper.i +++ b/src/ifcparse/hierarchy_helper.i @@ -174,7 +174,7 @@ void hierarchy_helper::relatePlacements(typename Schema::IfcProduct pare if (local_place != parent.ObjectPlacement()) { local_place.setPlacementRelTo(parent.ObjectPlacement()); } else { - logger::notice("Placement cannot be relative to self"); + ::logger::root().notice("Placement cannot be relative to self"); } } } diff --git a/src/ifcparse/instance_data.h b/src/ifcparse/instance_data.h index 588fbf9194..46eaa4e73a 100644 --- a/src/ifcparse/instance_data.h +++ b/src/ifcparse/instance_data.h @@ -75,12 +75,12 @@ class IFC_PARSE_API empty_aggregate_of_aggregate_t {}; namespace impl { template <> - struct VariantTypeName { + struct VariantTypeName { static std::string get() { return "null"; } }; template <> - struct VariantTypeName { + struct VariantTypeName { static std::string get() { return "derived"; } }; @@ -115,12 +115,12 @@ namespace impl { }; template <> - struct VariantTypeName { + struct VariantTypeName { static std::string get() { return "enumeration"; } }; template <> - struct VariantTypeName { + struct VariantTypeName { static std::string get() { return "instance"; } }; @@ -134,20 +134,10 @@ namespace impl { static std::string get() { return "aggregate of " + VariantTypeName::get(); } }; - template <> - struct VariantTypeName { - static std::string get() { return "aggregate of instance"; } - }; - template <> struct VariantTypeName { static std::string get() { return "aggregate of aggregate"; } }; - - template <> - struct VariantTypeName { - static std::string get() { return "aggregate of aggregate of instance"; } - }; } template diff --git a/src/ifcparse/logger.cpp b/src/ifcparse/logger.cpp index 42e0f79031..6655d29eff 100644 --- a/src/ifcparse/logger.cpp +++ b/src/ifcparse/logger.cpp @@ -23,8 +23,6 @@ #include "instance_data.h" #include -#include -#include #include #include #include @@ -33,9 +31,6 @@ #include #include #include -#include - -static thread_local express::Base current_product_; namespace { @@ -71,13 +66,23 @@ std::string format_code(const char (&code_prefix)[4], uint16_t code_number) { } template -void plain_text_message(T& out, const express::Base& current_product, Logger::Severity type, const std::string& code, const std::string& message, const express::Base& instance) { +void write_code(T& out, const std::string& code) { + if (!code.empty()) { + out << "[" << code.c_str() << "] "; + } +} + +template +void plain_text_message(T& out, const express::Base& current_product, logger::Severity type, const std::string& code, const std::string& message, const express::Base& instance) { out << "[" << severity_strings::value[type] << "] "; - out << "[" << code.c_str() << "] "; - out << "[" << get_time(type <= Logger::LOG_PERF).c_str() << "] "; + write_code(out, code); + out << "[" << get_time(type <= logger::LOG_PERF).c_str() << "] "; if (current_product) { - std::string global_id = current_product.as().get("GlobalId"); - out << "{" << global_id.c_str() << "} "; + express::Entity entity = current_product.as(); + if (entity) { + std::string global_id = entity.get("GlobalId"); + out << "{" << global_id.c_str() << "} "; + } } out << message.c_str() << std::endl; if (instance) { @@ -99,10 +104,9 @@ std::basic_string string_as(const std::string& string) { } template -void json_message(T& out, const express::Base* current_product, Logger::Severity type, const std::string& code, const std::string& message, const express::Base& instance) { +void json_message(T& out, const express::Base& current_product, logger::Severity type, const std::string& code, const std::string& message, const express::Base& instance) { boost::property_tree::basic_ptree, std::basic_string> property_tree; - // @todo this is crazy static const typename T::char_type time_string[] = {'t', 'i', 'm', 'e', 0}; static const typename T::char_type level_string[] = {'l', 'e', 'v', 'e', 'l', 0}; static const typename T::char_type code_string[] = {'c', 'o', 'd', 'e', 0}; @@ -111,7 +115,9 @@ void json_message(T& out, const express::Base* current_product, Logger::Severity static const typename T::char_type instance_string[] = {'i', 'n', 's', 't', 'a', 'n', 'c', 'e', 0}; property_tree.put(level_string, severity_strings::value[type]); - property_tree.put(code_string, string_as(code)); + if (!code.empty()) { + property_tree.put(code_string, string_as(code)); + } if (current_product) { std::ostringstream oss; current_product.to_string(oss); @@ -128,68 +134,63 @@ void json_message(T& out, const express::Base* current_product, Logger::Severity boost::property_tree::write_json(out, property_tree, false); - // Append a newline after the JSON object if the Boost version is 1.86 or higher #if BOOST_VERSION >= 108600 out << '\n'; #endif - } + } // namespace log_message::log_message( int severity, - const char (&code_prefix)[4], - uint16_t code_number, + const std::string& code, const std::string& timestamp, const std::string& message, - const IfcUtil::IfcBaseInterface* inst, - const IfcUtil::IfcBaseClass* current_product) + const express::Base& instance, + const express::Base& current_product) : severity(severity) , timestamp(timestamp) , message(message) { - snprintf(code, 7, "%s%03u", code_prefix, code_number); - if (inst) { + snprintf(this->code, sizeof(this->code), "%s", code.c_str()); + if (instance) { std::ostringstream oss; - inst->as()->toString(oss); - instance = oss.str(); + instance.to_string(oss); + this->instance = oss.str(); } if (current_product) { std::ostringstream oss; - current_product->toString(oss); + current_product.to_string(oss); product = oss.str(); } } -Logger& Logger::Root() { - static Logger logger; - return logger; +logger& logger::root() { + static logger root_logger; + return root_logger; } -const express::Base& Logger::current_product() const { +const express::Base& logger::current_product() const { return current_product_; } -void logger::set_product(std::optional product) { - if (verbosity_ <= LOG_DEBUG && product) { - message(LOG_DEBUG, "Begin processing", *product); - } +void logger::current_product(const express::Base& product) { current_product_ = product; } -void Logger::SetProduct(boost::optional product) { +void logger::set_product(std::optional product) { if (verbosity_ <= LOG_DEBUG && product) { - Message(LOG_DEBUG, "SYS", 3, "Begin processing", *product); + message(LOG_DEBUG, "SYS", 3, "Begin processing", *product); } if (!product && print_perf_stats_on_element_) { print_performance_stats(); performance_statistics_.clear(); } - current_product_ = product.value_or(express::Base{}); + current_product(product.value_or(express::Base{})); } void logger::set_output(std::ostream* stream1, std::ostream* stream2) { - wlog1_ = wlog2_ = 0; + wlog1_ = wlog2_ = nullptr; log1_ = stream1; log2_ = stream2; if (log2_ == nullptr) { @@ -198,21 +199,33 @@ void logger::set_output(std::ostream* stream1, std::ostream* stream2) { } void logger::set_output(std::wostream* stream1, std::wostream* stream2) { - log1_ = log2_ = 0; + log1_ = log2_ = nullptr; wlog1_ = stream1; wlog2_ = stream2; - if (wlog2_ == nullptr) { - log2_ = &log_stream_; - } } -void Logger::Message(Logger::Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance) { +void logger::message(logger::Severity type, const std::string& text, const express::Base& instance) { + message(type, std::string(), text, instance); +} + +void logger::message(logger::Severity type, const std::exception& exception, const express::Base& instance) { + message(type, std::string(exception.what()), instance); +} + +void logger::message(logger::Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& text, const express::Base& instance) { + message(type, format_code(code_prefix, code_number), text, instance); +} + +void logger::message(logger::Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance) { + message(type, code_prefix, code_number, std::string(exception.what()), instance); +} + +void logger::message(logger::Severity type, const std::string& code, const std::string& text, const express::Base& instance) { if (type < verbosity_) { return; } std::lock_guard lock(mutex_); - const std::string code = format_code(code_prefix, code_number); if (type == LOG_PERF) { if (!first_timepoint_) { @@ -232,28 +245,24 @@ void Logger::Message(Logger::Severity type, const char (&code_prefix)[4], uint16 } if (format_ == FMT_INMEMORY) { - log_messages_.emplace_back(type, code_prefix, code_number, get_time(), message, instance, current_product()); + log_messages_.emplace_back(type, code, get_time(), text, instance, current_product()); } else if (((log2_ != nullptr) || (wlog2_ != nullptr))) { if (format_ == FMT_PLAIN) { if (log2_ != nullptr) { - plain_text_message(*log2_, current_product(), type, code, message, instance); + plain_text_message(*log2_, current_product(), type, code, text, instance); } else if (wlog2_ != nullptr) { - plain_text_message(*wlog2_, current_product(), type, code, message, instance); + plain_text_message(*wlog2_, current_product(), type, code, text, instance); } } else if (format_ == FMT_JSON) { if (log2_ != nullptr) { - json_message(*log2_, current_product(), type, code, message, instance); + json_message(*log2_, current_product(), type, code, text, instance); } else if (wlog2_ != nullptr) { - json_message(*wlog2_, current_product(), type, code, message, instance); + json_message(*wlog2_, current_product(), type, code, text, instance); } } } } -void Logger::Message(Logger::Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base&) { - Message(type, code_prefix, code_number, std::string(exception.what()), instance); -} - template void write_status(T& log1, const std::string& text, bool new_line) { log1 << text.c_str(); @@ -277,36 +286,32 @@ void logger::progress_bar(int progress) { } std::string logger::get_log() { - return log_stream_.str(); -} - -std::string Logger::GetLog() { std::lock_guard lock(mutex_); return log_stream_.str(); } -void Logger::ClearLog() { +void logger::clear() { std::lock_guard lock(mutex_); log_stream_.str(std::string()); log_stream_.clear(); log_messages_.clear(); } -void Logger::Append(Logger& logger) { - if (&logger == this) { +void logger::append(logger& other) { + if (&other == this) { return; } - std::scoped_lock lock(mutex_, logger.mutex_); + std::scoped_lock lock(mutex_, other.mutex_); - if (logger.max_severity_ > max_severity_) { - max_severity_ = logger.max_severity_; + if (other.max_severity_ > max_severity_) { + max_severity_ = other.max_severity_; } if (format_ == FMT_INMEMORY) { - log_messages_.insert(log_messages_.end(), logger.log_messages_.begin(), logger.log_messages_.end()); + log_messages_.insert(log_messages_.end(), other.log_messages_.begin(), other.log_messages_.end()); } else { - const std::string log = logger.log_stream_.str(); + const std::string log = other.log_stream_.str(); if (!log.empty()) { if (log2_ != nullptr) { *log2_ << log; @@ -318,9 +323,9 @@ void Logger::Append(Logger& logger) { } } - logger.log_stream_.str(std::string()); - logger.log_stream_.clear(); - logger.log_messages_.clear(); + other.log_stream_.str(std::string()); + other.log_stream_.clear(); + other.log_messages_.clear(); } void logger::print_performance_stats() { @@ -340,15 +345,27 @@ void logger::print_performance_stats() { } for (auto& item : items) { - auto message = item.second + std::string(max_size - item.second.size(), ' ') + ": " + std::to_string(item.first); - Message(LOG_PERF, "SYS", 4, message); + auto text = item.second + std::string(max_size - item.second.size(), ' ') + ": " + std::to_string(item.first); + message(LOG_PERF, "SYS", 4, text); } } -void Logger::Verbosity(Logger::Severity severity) { verbosity_ = severity; } -Logger::Severity Logger::Verbosity() const { return verbosity_; } +void logger::verbosity(logger::Severity severity) { + verbosity_ = severity; +} -Logger::Severity Logger::MaxSeverity() const { return max_severity_; } +logger::Severity logger::verbosity() const { + return verbosity_; +} -void Logger::OutputFormat(Format format) { format_ = format; } -Logger::Format Logger::OutputFormat() const { return format_; } +logger::Severity logger::max_severity() const { + return max_severity_; +} + +void logger::output_format(Format format) { + format_ = format; +} + +logger::Format logger::output_format() const { + return format_; +} diff --git a/src/ifcparse/logger.h b/src/ifcparse/logger.h index 9081c21e2e..3e4f05b7f8 100644 --- a/src/ifcparse/logger.h +++ b/src/ifcparse/logger.h @@ -23,12 +23,12 @@ #include "ifc_parse_api.h" #include "express.h" -#include #include #include #include #include #include +#include #include #include #include @@ -41,12 +41,11 @@ class IFC_PARSE_API log_message { log_message( int severity, - const char (&code_prefix)[4], - uint16_t code_number, + const std::string& code, const std::string& timestamp, const std::string& message, - const IfcUtil::IfcBaseInterface* inst = 0, - const IfcUtil::IfcBaseClass* current_product = 0); + const express::Base& instance = express::Base(), + const express::Base& current_product = express::Base()); }; class IFC_PARSE_API logger { @@ -68,8 +67,6 @@ class IFC_PARSE_API logger { private: std::vector log_messages_; - // To both stream variants need to exist at runtime or should this be a - // template argument of Logger or controlled using preprocessor directives? std::ostream* log1_ = nullptr; std::ostream* log2_ = nullptr; @@ -77,7 +74,7 @@ class IFC_PARSE_API logger { std::wostream* wlog2_ = nullptr; std::stringstream log_stream_; - const IfcUtil::IfcBaseClass* current_product_ = nullptr; + express::Base current_product_; Severity verbosity_ = LOG_NOTICE; Format format_ = FMT_PLAIN; @@ -90,64 +87,70 @@ class IFC_PARSE_API logger { bool print_perf_stats_on_element_ = false; std::mutex mutex_; - const IfcUtil::IfcBaseClass* current_product() const; - void current_product(const IfcUtil::IfcBaseClass* product); + const express::Base& current_product() const; + void current_product(const express::Base& product); + void message(Severity type, const std::string& code, const std::string& message, const express::Base& instance); public: logger() = default; logger(const logger&) = delete; logger& operator=(const logger&) = delete; - static logger& Root(); + static logger& root(); - void set_product(std::optional product); + void set_product(std::optional product); + void set_product(const express::Base& product) { set_product(std::optional(product)); } - /// Determines to what stream respectively progress and errors are logged void set_output(std::wostream* stream1, std::wostream* stream2); - - /// Determines to what stream respectively progress and errors are logged void set_output(std::ostream* stream1, std::ostream* stream2); - /// Determines the types of log messages to get logged void verbosity(Severity severity); Severity verbosity() const; Severity max_severity() const; - /// Determines output format: plain text or sequence of JSON objects void output_format(Format format); Format output_format() const; - /// Log a message to the output stream - void message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0); - void message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0); + void message(Severity type, const std::string& message, const express::Base& instance = express::Base()); + void message(Severity type, const std::exception& exception, const express::Base& instance = express::Base()); + void message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()); + void message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()); - void notice(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, code_prefix, code_number, message, instance); } - void warning(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, code_prefix, code_number, message, instance); } - void error(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, code_prefix, code_number, message, instance); } + void notice(const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_NOTICE, message, instance); } + void warning(const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_WARNING, message, instance); } + void error(const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_ERROR, message, instance); } - void notice(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, code_prefix, code_number, exception, instance); } - void warning(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, code_prefix, code_number, exception, instance); } - void error(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, code_prefix, code_number, exception, instance); } + void notice(const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_NOTICE, exception, instance); } + void warning(const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_WARNING, exception, instance); } + void error(const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_ERROR, exception, instance); } + + void notice(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_NOTICE, code_prefix, code_number, message, instance); } + void warning(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_WARNING, code_prefix, code_number, message, instance); } + void error(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_ERROR, code_prefix, code_number, message, instance); } + + void notice(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_NOTICE, code_prefix, code_number, exception, instance); } + void warning(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_WARNING, code_prefix, code_number, exception, instance); } + void error(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_ERROR, code_prefix, code_number, exception, instance); } void status(const std::string& message, bool new_line = true); void progress_bar(int progress); std::string get_log(); void clear(); - void append(Logger& logger); + void append(logger& other); void print_performance_stats(); - void print_performance_stats(bool b) { print_perf_stats_on_element_ = b; } - bool print_performance_stats() const { return print_perf_stats_on_element_; } + void print_performance_stats_on_element(bool enabled) { print_perf_stats_on_element_ = enabled; } + bool print_performance_stats_on_element() const { return print_perf_stats_on_element_; } const std::vector& log_messages() const { return log_messages_; } }; #define PERF(x) \ \ - Logger::Root().Message(Logger::LOG_PERF, "SYS", 1, x); \ + ::logger::root().message(::logger::LOG_PERF, x); \ \ BOOST_SCOPE_EXIT(void) { \ - Logger::Root().Message(Logger::LOG_PERF, "SYS", 2, "done " + std::string(x)); \ + ::logger::root().message(::logger::LOG_PERF, "done " + std::string(x)); \ } \ BOOST_SCOPE_EXIT_END diff --git a/src/ifcparse/parse.cpp b/src/ifcparse/parse.cpp index f7ebc0f357..6ced5415dc 100644 --- a/src/ifcparse/parse.cpp +++ b/src/ifcparse/parse.cpp @@ -50,9 +50,11 @@ using namespace ifcopenshell; template -spf_lexer::spf_lexer(Reader* stream_) { +spf_lexer::spf_lexer(Reader* stream_, ::logger& log) + : decoder_(nullptr) + , logger_(log) { stream = stream_; - decoder_ = new character_decoder(stream_); + decoder_ = new character_decoder(stream_, logger_); } template @@ -602,20 +604,20 @@ void warn_attribute_count( std::optional instance_name, size_t expected_size, size_t actual_size, - ::Logger& logger + ::logger& logger ) { if (!declaration || expected_size == actual_size) { return; } if (declaration->schema() == &Header_section_schema::get_schema()) { - logger.Warning("VAL", 15, "Expected " + std::to_string(expected_size) + " attribute values, found " + std::to_string(actual_size) + " for header entity " + declaration->name()); + logger.warning("VAL", 15, "Expected " + std::to_string(expected_size) + " attribute values, found " + std::to_string(actual_size) + " for header entity " + declaration->name()); } else { - logger.Warning("VAL", 16, "Expected " + std::to_string(expected_size) + " attribute values, found " + std::to_string(actual_size) + (instance_name ? std::string(" for instance #" + std::to_string(*instance_name)) : std::string(""))); + logger.warning("VAL", 16, "Expected " + std::to_string(expected_size) + " attribute values, found " + std::to_string(actual_size) + (instance_name ? std::string(" for instance #" + std::to_string(*instance_name)) : std::string(""))); } } template -void dispatch_token_direct(ifcopenshell::token token, ifcopenshell::declaration* declaration, int attribute_index, Logger& logger, Fn&& fn) { +void dispatch_token_direct(ifcopenshell::token token, ifcopenshell::declaration* declaration, int attribute_index, logger& logger, Fn&& fn) { if (token.is_binary()) { fn(token.as_binary()); } else if (token.is_bool()) { @@ -628,10 +630,10 @@ void dispatch_token_direct(ifcopenshell::token token, ifcopenshell::declaration* try { fn(enumeration_reference(declaration->as_enumeration_type(), declaration->as_enumeration_type()->lookup_enum_offset(value))); } catch (ifcopenshell::exception&) { - logger.Error("VAL", 12, "An enumeration literal '" + value + "' is not valid for type '" + declaration->name() + "' at offset " + std::to_string(token.start_pos)); + logger.error("VAL", 12, "An enumeration literal '" + value + "' is not valid for type '" + declaration->name() + "' at offset " + std::to_string(token.start_pos)); } } else { - logger.Error("VAL", 13, "An enumeration literal '" + value + "' is not expected at attribute index '" + std::to_string(attribute_index) + "' at offset " + std::to_string(token.start_pos)); + logger.error("VAL", 13, "An enumeration literal '" + value + "' is not expected at attribute index '" + std::to_string(attribute_index) + "' at offset " + std::to_string(token.start_pos)); } } else if (token.is_int()) { fn(token.as_int()); @@ -664,7 +666,10 @@ struct direct_aggregate { direct_aggregate_storage storage; size_t pending_empty_aggregates = 0; size_t values = 0; - Logger& logger; + ::logger& logger_; + + explicit direct_aggregate(::logger& logger) + : logger_(logger) {} template void append(const T& value) { @@ -681,7 +686,7 @@ struct direct_aggregate { } } if (pending_empty_aggregates) { - logger.Error("VAL", 14, "Inconsistent aggregate valuation while attempting to append " + std::string(typeid(T).name()) + " after an empty nested aggregate"); + logger_.error("VAL", 14, "Inconsistent aggregate valuation while attempting to append " + std::string(typeid(T).name()) + " after an empty nested aggregate"); pending_empty_aggregates = 0; } if (storage.index() == 0) { @@ -692,7 +697,7 @@ struct direct_aggregate { append_promoted(value); } } else { - logger.Error("UNS", 31, std::string("Aggregates of ") + typeid(T).name() + " are not supported in the IfcOpenShell parser"); + logger_.error("UNS", 31, std::string("Aggregates of ") + typeid(T).name() + " are not supported in the IfcOpenShell parser"); } } @@ -707,7 +712,7 @@ struct direct_aggregate { } else if (storage.index() == 0) { ++pending_empty_aggregates; } else { - logger::error("Inconsistent aggregate valuation while attempting to append an empty nested aggregate"); + logger_.error("Inconsistent aggregate valuation while attempting to append an empty nested aggregate"); } } @@ -790,7 +795,7 @@ private: return std::string{}; } }, storage); - logger::error("Inconsistent aggregate valuation while attempting to append " + std::string(typeid(T).name()) + " to an aggregate of " + current); + logger_.error("Inconsistent aggregate valuation while attempting to append " + std::string(typeid(T).name()) + " to an aggregate of " + current); } }; @@ -875,9 +880,9 @@ direct_aggregate read_direct_aggregate( const ifcopenshell::entity* entity, int attribute_index, const ifcopenshell::aggregation_type* aggregate_type, - ::Logger& logger + ::logger& logger ) { - direct_aggregate aggregate; + direct_aggregate aggregate(logger); token next = tokens->next(); while (next) { @@ -885,7 +890,7 @@ direct_aggregate read_direct_aggregate( } else if (next.is_operator(')')) { break; } else if (next.is_operator('(')) { - auto nested = read_direct_aggregate(storage, tokens, entity_instance_name, entity, attribute_index, nested_aggregation_type(aggregate_type)); + auto nested = read_direct_aggregate(storage, tokens, entity_instance_name, entity, attribute_index, nested_aggregation_type(aggregate_type), logger); if (nested.values == 0 && nested.storage.index() == 0) { aggregate.append_empty_nested(); } else { @@ -909,7 +914,7 @@ direct_aggregate read_direct_aggregate( if (next.is_identifier() && entity && entity_instance_name) { storage.register_inverse((unsigned)*entity_instance_name, entity, next.value_int, attribute_index); } - dispatch_token_direct(next, aggregate_type && aggregate_type->type_of_element()->as_named_type() ? aggregate_type->type_of_element()->as_named_type()->declared_type() : nullptr, attribute_index, [&aggregate](const auto& value) { + dispatch_token_direct(next, aggregate_type && aggregate_type->type_of_element()->as_named_type() ? aggregate_type->type_of_element()->as_named_type()->declared_type() : nullptr, attribute_index, logger, [&aggregate](const auto& value) { aggregate.append(value); }); } @@ -961,7 +966,7 @@ shared_pointer_type ifcopenshell::impl::in_memory_file_storage::load( if (next.is_operator('(')) { if (retain_value) { - auto aggregate = read_direct_aggregate(*this, tokens, entity_instance_name, entity, reference_attribute_index, aggregate_parameter_type(parameter_type)); + auto aggregate = read_direct_aggregate(*this, tokens, entity_instance_name, entity, reference_attribute_index, aggregate_parameter_type(parameter_type), logger_.get()); std::visit([&](const auto& value) { if constexpr (!std::is_same_v, blank>) { set_direct_attribute(storage, entity_instance_name, references_to_resolve, attribute_index_within_data, attribute_index, value); @@ -982,7 +987,7 @@ shared_pointer_type ifcopenshell::impl::in_memory_file_storage::load( skip_aggregate(tokens); } } catch (exception& e) { - logger::message(logger::LOG_ERROR, std::string(e.what()) + " at offset " + std::to_string(next.start_pos)); + logger_.get().message(::logger::LOG_ERROR, std::string(e.what()) + " at offset " + std::to_string(next.start_pos)); --values_read; } } else { @@ -990,7 +995,7 @@ shared_pointer_type ifcopenshell::impl::in_memory_file_storage::load( register_inverse((unsigned)*entity_instance_name, entity, next.value_int, reference_attribute_index); } if (retain_value) { - dispatch_token_direct(next, declared_type(parameter_type), (int) attribute_index_within_data, [&](const auto& value) { + dispatch_token_direct(next, declared_type(parameter_type), (int) attribute_index_within_data, logger_.get(), [&](const auto& value) { set_direct_attribute(storage, entity_instance_name, references_to_resolve, attribute_index_within_data, attribute_index, value); }); } @@ -999,7 +1004,7 @@ shared_pointer_type ifcopenshell::impl::in_memory_file_storage::load( next = tokens->next(); } - warn_attribute_count(declaration, entity_instance_name, expected_size, values_read); + warn_attribute_count(declaration, entity_instance_name, expected_size, values_read, logger_.get()); return ifcopenshell::make_pointer_type(file, declaration, (declaration && declaration->as_entity()) ? (uint32_t)entity_instance_name.value_or(0) : 0, std::move(storage)); } @@ -1068,7 +1073,7 @@ void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_f if (it != vals.end()) { vals.erase(it); } else { - logger::error("Unregistering non-existant inverse #" + std::to_string(id_from) + " on instance #" + std::to_string(inst_id) + " at attribute " + std::to_string(attribute_index)); + file->logger().error("Unregistering non-existant inverse #" + std::to_string(id_from) + " on instance #" + std::to_string(inst_id) + " at attribute " + std::to_string(attribute_index)); } s.resize(vals.size() * sizeof(uint32_t)); memcpy(s.data(), vals.data(), s.size()); @@ -1528,7 +1533,7 @@ express::Base::set_attribute_value(size_t i, const T& t) { } } } catch (ifcopenshell::exception& e) { - logger::error(e); + file()->logger().error(e); } } @@ -1556,11 +1561,11 @@ express::Base::set_attribute_value(size_t i, const T& t) { auto guid = (std::string) new_attribute; auto it = file()->internal_guid_map().find(guid); if (it != file()->internal_guid_map().end()) { - logger::warning("Duplicate guid " + guid); + file()->logger().warning("Duplicate guid " + guid); } file()->internal_guid_map().insert({guid, *this}); } catch (ifcopenshell::exception& e) { - logger::error(e); + file()->logger().error(e); } } } @@ -1579,18 +1584,23 @@ express::Base::set_attribute_value(const std::string& s, const T& t) // Creates the maps // #ifdef USE_MMAP -file::file(const std::string& fn, bool mmap) { +file::file(const std::string& fn, bool mmap, ::logger& log) + : logger_(log) + , schema_(nullptr) + , ifcroot_type_(nullptr) + , max_id_(0) + , header_(new spf_header(this, logger_.get())) { initialize(fn, mmap); } bool ifcopenshell::file::initialize(const std::string& fn, bool mmap) { if (mmap) { file_reader s(fn); - storage_.emplace<1>(this); + storage_.emplace<1>(this, logger_.get()); std::get(storage_).read_from_stream(&s, schema_, max_id_, types_to_bypass_loading_); } else { file_reader s(fn); - storage_.emplace<1>(this); + storage_.emplace<1>(this, logger_.get()); std::get(storage_).read_from_stream(&s, schema_, max_id_, types_to_bypass_loading_); } @@ -1606,8 +1616,8 @@ bool ifcopenshell::file::initialize(const std::string& fn, bool mmap) { } #endif -file::file(const uninitialized_tag&) - : schema_(nullptr), max_id_(0), header_(new ifcopenshell::spf_header(this)), good_(file_open_status::UNKNOWN), ifcroot_type_(nullptr) {} +file::file(const uninitialized_tag&, ::logger& log) + : good_(file_open_status::UNKNOWN), logger_(log), schema_(nullptr), ifcroot_type_(nullptr), max_id_(0), header_(new ifcopenshell::spf_header(this, logger_.get())) {} bool ifcopenshell::file::initialize(const std::string& path, filetype ty, bool readonly) { if (ty == FT_AUTODETECT) { @@ -1615,7 +1625,7 @@ bool ifcopenshell::file::initialize(const std::string& path, filetype ty, bool r } if (ty == FT_IFCSPF) { file_reader s(path); - storage_.emplace<1>(this); + storage_.emplace<1>(this, logger_.get()); std::get(storage_).read_from_stream(&s, schema_, max_id_, types_to_bypass_loading_); if ((good_ = std::get(storage_).good_)) { @@ -1659,18 +1669,22 @@ void ifcopenshell::file::bypass_type(const std::string& type_name) { types_to_bypass_loading_.insert(type_name); } -file::file(const std::string& path, filetype ty, bool readonly) - : schema_(nullptr) +file::file(const std::string& path, filetype ty, bool readonly, ::logger& log) + : logger_(log) + , schema_(nullptr) + , ifcroot_type_(nullptr) , max_id_(0) - , header_(new spf_header(this)) + , header_(new spf_header(this, logger_.get())) { initialize(path, ty, readonly); } -file::file(std::istream& stream, int length) - : schema_(nullptr) +file::file(std::istream& stream, int length, ::logger& log) + : logger_(log) + , schema_(nullptr) + , ifcroot_type_(nullptr) , max_id_(0) - , header_(new ifcopenshell::spf_header(this)) + , header_(new ifcopenshell::spf_header(this, logger_.get())) { file_reader s(caller_fed_tag{}); @@ -1679,7 +1693,7 @@ file::file(std::istream& stream, int length) stream.read(string_data.data(), length); s.push_next_page(string_data); - storage_.emplace<1>(this); + storage_.emplace<1>(this, logger_.get()); std::get(storage_).read_from_stream(&s, schema_, max_id_, types_to_bypass_loading_); good_ = std::get(storage_).good_; ifcroot_type_ = schema_ ? schema_->declaration_by_name("IfcRoot") : nullptr; @@ -1689,14 +1703,16 @@ file::file(std::istream& stream, int length) byguid_ = decltype(byguid_)(&std::get(storage_).byguid_); } -file::file(void* data, int length) - : schema_(nullptr) - , max_id_(0), - header_(new ifcopenshell::spf_header(this)) +file::file(void* data, int length, ::logger& log) + : logger_(log) + , schema_(nullptr) + , ifcroot_type_(nullptr) + , max_id_(0) + , header_(new ifcopenshell::spf_header(this, logger_.get())) { file_reader s(std::string((char*)data, length), caller_fed_tag{}); - storage_.emplace<1>(this); + storage_.emplace<1>(this, logger_.get()); std::get(storage_).read_from_stream(&s, schema_, max_id_, types_to_bypass_loading_); good_ = std::get(storage_).good_; ifcroot_type_ = schema_ ? schema_->declaration_by_name("IfcRoot") : nullptr; @@ -1706,8 +1722,9 @@ file::file(void* data, int length) byguid_ = decltype(byguid_)(&std::get(storage_).byguid_); } -file::file(const ifcopenshell::schema_definition* schema, filetype ty, const std::string& path) - : schema_(schema) +file::file(const ifcopenshell::schema_definition* schema, filetype ty, const std::string& path, ::logger& log) + : logger_(log) + , schema_(schema) , ifcroot_type_(schema_->declaration_by_name("IfcRoot")) , max_id_(0) { @@ -1715,7 +1732,7 @@ file::file(const ifcopenshell::schema_definition* schema, filetype ty, const std ty = guess_file_type(path); } if (ty == FT_IFCSPF) { - storage_.emplace<1>(this); + storage_.emplace<1>(this, logger_.get()); byid_ = decltype(byid_)(&std::get(storage_).byid_read_); byref_excl_ = decltype(byref_excl_)(&std::get(storage_).byref_excl_); @@ -1733,7 +1750,7 @@ file::file(const ifcopenshell::schema_definition* schema, filetype ty, const std } else { throw std::runtime_error("Unsupported file format"); } - header_.reset(new spf_header(this)); + header_.reset(new spf_header(this, logger_.get())); set_default_header_values(); } @@ -1805,7 +1822,7 @@ bool try_parse_header( parse_header(header, storage, lexer, references_to_resolve); return true; } catch (const std::exception& e) { - logger::error(e); + storage.logger_.get().error(e); return false; } } @@ -1822,7 +1839,7 @@ spf_header& ifcopenshell::instance_streamer::ensure_header() { header_ = &owner_->header(); header_->owner_file(owner_); } else { - owned_header_ = std::make_unique(owner_); + owned_header_ = std::make_unique(owner_, logger_.get()); header_ = owned_header_.get(); } @@ -1868,7 +1885,7 @@ void ifcopenshell::instance_streamer::initialize_header() { template bool ifcopenshell::instance_streamer::has_semicolon() const { auto local_stream = stream_->clone(); - auto local_lexer = spf_lexer(&local_stream); + auto local_lexer = spf_lexer(&local_stream, logger_.get()); token t; try { t = local_lexer.next(); @@ -1891,7 +1908,7 @@ bool ifcopenshell::instance_streamer::has_semicolon() const { template size_t ifcopenshell::instance_streamer::semicolon_count() const { auto local_stream = stream_->clone(); - auto local_lexer = spf_lexer(&local_stream); + auto local_lexer = spf_lexer(&local_stream, logger_.get()); token t; size_t count = 0; try { @@ -1921,12 +1938,14 @@ void ifcopenshell::instance_streamer::push_page(const std::string& page) } template -ifcopenshell::instance_streamer::instance_streamer(ifcopenshell::file* f) +ifcopenshell::instance_streamer::instance_streamer(ifcopenshell::file* f, ::logger& log) : stream_(nullptr) , header_(nullptr) , owner_(f) , token_stream_(3, token{}) , schema_(nullptr) + , storage_(nullptr, log) + , logger_(log) , progress_(0) { if constexpr (std::is_same_v>) { @@ -1938,19 +1957,21 @@ ifcopenshell::instance_streamer::instance_streamer(ifcopenshell::file* f } stream_ = owned_stream_.get(); - lexer_ = std::make_unique>(stream_); + lexer_ = std::make_unique>(stream_, logger_.get()); good_ = file_open_status::NO_HEADER; storage_.file = f; storage_.references_to_resolve = &references_to_resolve_; } template -ifcopenshell::instance_streamer::instance_streamer(const std::string& fn, bool mmap, ifcopenshell::file* f) +ifcopenshell::instance_streamer::instance_streamer(const std::string& fn, bool mmap, ifcopenshell::file* f, ::logger& log) : stream_(nullptr) , header_(nullptr) , owner_(f) , token_stream_(3, token{}) , schema_(nullptr) + , storage_(nullptr, log) + , logger_(log) , progress_(0) { if constexpr (std::is_same_v>) { @@ -1966,18 +1987,20 @@ ifcopenshell::instance_streamer::instance_streamer(const std::string& fn } stream_ = owned_stream_.get(); - lexer_ = std::make_unique>(stream_); + lexer_ = std::make_unique>(stream_, logger_.get()); good_ = file_open_status::NO_HEADER; initialize_header(); } template -ifcopenshell::instance_streamer::instance_streamer(void* data, int length, ifcopenshell::file* f) +ifcopenshell::instance_streamer::instance_streamer(void* data, int length, ifcopenshell::file* f, ::logger& log) : stream_(nullptr) , header_(nullptr) , owner_(f) , token_stream_(3, token{}) , schema_(nullptr) + , storage_(nullptr, log) + , logger_(log) , progress_(0) { if constexpr (std::is_same_v>) { @@ -1989,21 +2012,23 @@ ifcopenshell::instance_streamer::instance_streamer(void* data, int lengt } stream_ = owned_stream_.get(); - lexer_ = std::make_unique>(stream_); + lexer_ = std::make_unique>(stream_, logger_.get()); good_ = file_open_status::NO_HEADER; initialize_header(); } template -ifcopenshell::instance_streamer::instance_streamer(Reader* stream, ifcopenshell::file* f) +ifcopenshell::instance_streamer::instance_streamer(Reader* stream, ifcopenshell::file* f, ::logger& log) : stream_(stream) , header_(nullptr) , owner_(f) , token_stream_(3, token{}) , schema_(nullptr) + , storage_(nullptr, log) + , logger_(log) , progress_(0) { - lexer_ = std::make_unique>(stream_); + lexer_ = std::make_unique>(stream_, logger_.get()); good_ = file_open_status::NO_HEADER; initialize_header(); } @@ -2067,13 +2092,13 @@ std::optionaldeclaration_by_name(token_stream_[2].as_string()); } catch (const exception& ex) { - logger::message(logger::LOG_ERROR, std::string(ex.what()) + " at offset " + std::to_string(token_stream_[2].start_pos)); + logger_.get().message(::logger::LOG_ERROR, std::string(ex.what()) + " at offset " + std::to_string(token_stream_[2].start_pos)); current_id = 0; goto advance; } if (entity_type->as_entity() == nullptr) { - logger::message(logger::LOG_ERROR, "Non entity type " + entity_type->name() + " at offset " + std::to_string(token_stream_[2].start_pos)); + logger_.get().message(::logger::LOG_ERROR, "Non entity type " + entity_type->name() + " at offset " + std::to_string(token_stream_[2].start_pos)); goto advance; } @@ -2090,7 +2115,7 @@ std::optionalnext(); } catch (const exception& e) { - logger::message(logger::LOG_ERROR, std::string(e.what()) + ". Parsing terminated"); + logger_.get().message(::logger::LOG_ERROR, std::string(e.what()) + ". Parsing terminated"); } catch (...) { - logger::message(logger::LOG_ERROR, "Parsing terminated"); + logger_.get().message(::logger::LOG_ERROR, "Parsing terminated"); } if (!lexer_->stream->eof() && !next_token) { @@ -2140,7 +2165,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con std::vector schemas; - instance_streamer streamer(s, file); + instance_streamer streamer(s, file, logger_.get()); streamer.yield_header_instances(false); if (const auto* header = streamer.header()) { @@ -2156,7 +2181,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con schema = ifcopenshell::schema_by_name(schemas.front()); } catch (const ifcopenshell::exception& e) { good_ = file_open_status::UNSUPPORTED_SCHEMA; - logger::error(e); + logger_.get().error(e); } } @@ -2166,14 +2191,14 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con } else { good_ = file_open_status::UNSUPPORTED_SCHEMA; } - logger::message(logger::LOG_ERROR, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")"); + logger_.get().message(::logger::LOG_ERROR, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")"); return; } auto ifcroot_type_ = schema->declaration_by_name("IfcRoot"); streamer.bypass_types(typed_to_bypass); - logger::status("Scanning file..."); + logger_.get().status("Scanning file..."); while (streamer) { auto inst = streamer.read_instance(); @@ -2191,11 +2216,11 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con if (byguid_.find(guid) != byguid_.end()) { std::stringstream ss; ss << "Instance encountered with non-unique GlobalId " << guid; - logger::message(logger::LOG_WARNING, ss.str()); + logger_.get().message(::logger::LOG_WARNING, ss.str()); } byguid_[guid] = instance; } catch (const exception& ex) { - logger::message(logger::LOG_ERROR, ex.what()); + logger_.get().message(::logger::LOG_ERROR, ex.what()); } } @@ -2205,7 +2230,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con if (byid_.find(current_id) != byid_.end()) { std::stringstream ss; ss << "Overwriting instance with name #" << current_id; - logger::message(logger::LOG_WARNING, ss.str()); + logger_.get().message(::logger::LOG_WARNING, ss.str()); } byid_.insert({(uint32_t)current_id, std::get<2>(*inst)}); @@ -2217,7 +2242,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con byref_excl_.sort(); read_simple_type_instances = streamer.steal_instances(); - logger::status("\rDone scanning file "); + logger_.get().status("\rDone scanning file "); if (good_ != file_open_status::SUCCESS) { return; @@ -2235,7 +2260,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con } auto it = byid_.find(*name); if (it == byid_.end()) { - logger::error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); + logger_.get().error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); } else { auto& storage = byid_[p.first.name_]; auto attr_index = p.first.index_; @@ -2256,7 +2281,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con if (storage->template has_attribute_value(attr_index)) { storage->set_attribute_value(attr_index, express::Base(it->second)); } else { - logger::error("Duplicate definition for instance reference"); + logger_.get().error("Duplicate definition for instance reference"); } } } else if (auto inst = std::get_if(v)) { @@ -2272,7 +2297,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con } auto it = byid_.find(*name); if (it == byid_.end()) { - logger::error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); + logger_.get().error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); } else { instances.push_back(express::Base(it->second)); } @@ -2300,7 +2325,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con if (storage->template has_attribute_value(attr_index)) { storage->set_attribute_value(attr_index, instances); } else { - logger::error("Duplicate definition for instance reference"); + logger_.get().error("Duplicate definition for instance reference"); } } else if (auto* vvv = std::get_if>>(&p.second)) { std::vector> instances; @@ -2313,7 +2338,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con } auto it = byid_.find(*name); if (it == byid_.end()) { - logger::error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); + logger_.get().error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); } else { inner.push_back(express::Base(it->second)); } @@ -2342,12 +2367,12 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con if (storage->template has_attribute_value(attr_index)) { storage->set_attribute_value(attr_index, instances); } else { - logger::error("Duplicate definition for instance reference"); + logger_.get().error("Duplicate definition for instance reference"); } } } - logger::status("Done resolving references"); + logger_.get().status("Done resolving references"); } template void ifcopenshell::impl::in_memory_file_storage::read_from_stream(file_reader* s, const ifcopenshell::schema_definition*& schema, unsigned int& max_id, const std::set& typed_to_bypass); @@ -2490,7 +2515,7 @@ express::Base file::add_entity(const express::Base& entity, int id) { } } } catch (...) { - logger::message(logger::LOG_ERROR, "Failed to visit forward references of", entity); + logger_.get().message(::logger::LOG_ERROR, "Failed to visit forward references of", entity); } // An instance is being added from another file. A copy of the @@ -2617,11 +2642,11 @@ express::Base file::add_entity(const express::Base& entity, int id) { if (byguid_.find(guid) != byguid_.end()) { std::stringstream ss; ss << "Overwriting entity with guid " << guid; - logger::message(logger::LOG_WARNING, ss.str()); + logger_.get().message(::logger::LOG_WARNING, ss.str()); } byguid_.insert({ guid, new_entity }); } catch (const std::exception& ex) { - logger::message(logger::LOG_ERROR, ex.what()); + logger_.get().message(::logger::LOG_ERROR, ex.what()); } } */ @@ -2731,7 +2756,7 @@ void file::process_deletion_(const express::Base& entity) { if (it != byguid_.end()) { byguid_.erase(it); } else { - logger::warning("GlobalId on rooted instance not encountered in map"); + logger_.get().warning("GlobalId on rooted instance not encountered in map"); } } diff --git a/src/ifcparse/parse.h b/src/ifcparse/parse.h index 6795fc182e..2350a961b0 100644 --- a/src/ifcparse/parse.h +++ b/src/ifcparse/parse.h @@ -52,7 +52,7 @@ template class IFC_PARSE_API spf_lexer { private: character_decoder* decoder_; - Logger& logger_; + ::logger& logger_; size_t skip_whitespace() const; size_t skip_comment() const; @@ -77,7 +77,7 @@ class IFC_PARSE_API spf_lexer { Reader* stream; // file* file; - spf_lexer(Reader* stream, Logger& logger = Logger::Root()); + spf_lexer(Reader* stream, ::logger& logger = ::logger::root()); token next(); ~spf_lexer(); // void TokenString(size_t offset, std::string& result); diff --git a/src/ifcparse/spf_header.cpp b/src/ifcparse/spf_header.cpp index 178e13222e..3405aefb14 100644 --- a/src/ifcparse/spf_header.cpp +++ b/src/ifcparse/spf_header.cpp @@ -11,7 +11,8 @@ using namespace ifcopenshell; namespace { -shared_pointer_type make_header_entity(ifcopenshell::file* file, const ifcopenshell::entity& decl, Logger& logger) { +shared_pointer_type make_header_entity(ifcopenshell::file* file, const ifcopenshell::entity& decl, ::logger& logger) { + static_cast(logger); const bool in_memory = file == nullptr || std::visit([](auto& storage) { return std::is_same_v, ifcopenshell::impl::in_memory_file_storage>; }, file->storage_); @@ -25,13 +26,14 @@ shared_pointer_type make_header_entity(ifcopenshell::file* file, const ifcopensh } // namespace -ifcopenshell::spf_header::spf_header(ifcopenshell::file* file) - : file_(file) { +ifcopenshell::spf_header::spf_header(ifcopenshell::file* file, ::logger& logger) + : file_(file) + , logger_(logger) { Header_section_schema::get_schema(); - header_entities_[0] = make_header_entity(file_, Header_section_schema::file_description::Class()); - header_entities_[1] = make_header_entity(file_, Header_section_schema::file_name::Class()); - header_entities_[2] = make_header_entity(file_, Header_section_schema::file_schema::Class()); + header_entities_[0] = make_header_entity(file_, Header_section_schema::file_description::Class(), logger_); + header_entities_[1] = make_header_entity(file_, Header_section_schema::file_name::Class(), logger_); + header_entities_[2] = make_header_entity(file_, Header_section_schema::file_schema::Class(), logger_); } ifcopenshell::spf_header::~spf_header() = default; diff --git a/src/ifcparse/spf_header.h b/src/ifcparse/spf_header.h index 2fad683a51..b32bc63fd6 100644 --- a/src/ifcparse/spf_header.h +++ b/src/ifcparse/spf_header.h @@ -32,29 +32,24 @@ class file; class IFC_PARSE_API spf_header { private: ifcopenshell::file* file_; - std::reference_wrapper logger_; - IfcParse::impl::in_memory_file_storage* storage_ = nullptr; + std::reference_wrapper<::logger> logger_; std::array header_entities_; public: - explicit spf_header(ifcopenshell::file* file = nullptr, Logger& logger = Logger::Root()); - explicit spf_header(spf_lexer* lexer, Logger& logger = Logger::Root()); + explicit spf_header(ifcopenshell::file* file = nullptr, ::logger& logger = ::logger::root()); + ~spf_header(); void write(std::ostream& stream) const; ifcopenshell::file* owner_file() { return file_; } void owner_file(ifcopenshell::file* file); - Logger& logger() const { return logger_.get(); } + ::logger& logger() const { return logger_.get(); } void set_file_description(const shared_pointer_type& description_data); void set_file_name(const shared_pointer_type& name_data); void set_file_schema(const shared_pointer_type& schema_data); - void assign(const IfcSpfHeader& other); - - void write(std::ostream& out) const; - Header_section_schema::file_description file_description(); Header_section_schema::file_name file_name(); Header_section_schema::file_schema file_schema(); diff --git a/src/ifcparse/storage.h b/src/ifcparse/storage.h index 54c977675d..3a8a2cbd8c 100644 --- a/src/ifcparse/storage.h +++ b/src/ifcparse/storage.h @@ -24,7 +24,7 @@ namespace rocksdb { #include "map_transformer.h" #include "set_to_map_transformer.h" #include "file_open_status.h" -#include "IfcLogger.h" +#include "logger.h" #include #include @@ -412,8 +412,7 @@ namespace ifcopenshell { return std::move(read_simple_type_instances); } - ifcopenshell::spf_lexer* tokens; - std::reference_wrapper logger_; + std::reference_wrapper<::logger> logger_; // IfcParse::FileReader* stream; // Either one of these needs to be set @@ -423,14 +422,14 @@ namespace ifcopenshell { unresolved_references* references_to_resolve = nullptr; typedef std::map> entities_by_type_t; - typedef boost::unordered_map entity_instance_by_name_storage_t; + typedef std::unordered_map entity_instance_by_name_storage_t; typedef map_transformer> entity_instance_by_name_t; - typedef boost::unordered_map type_instance_by_name_t; + typedef std::unordered_map type_instance_by_name_t; typedef std::map entity_instance_by_guid_t; typedef inverse_index entities_by_ref_t; typedef entity_instance_by_name_t::iterator iterator; - in_memory_file_storage(ifcopenshell::file* owner_file = nullptr, Logger& logger = Logger::Root()) : logger_(logger), file(owner_file), schema(nullptr), byid_read_(&byid_, [this](const shared_pointer_type& data) { return express::Base(data); }) {}; + in_memory_file_storage(ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()) : logger_(logger), file(owner_file), schema(nullptr), byid_read_(&byid_, [this](const shared_pointer_type& data) { return express::Base(data); }) {}; in_memory_file_storage(const in_memory_file_storage& other) = delete; in_memory_file_storage(const in_memory_file_storage&& other) = delete; diff --git a/src/ifcparse/utils.cpp b/src/ifcparse/utils.cpp index 50180af49f..41366817b0 100644 --- a/src/ifcparse/utils.cpp +++ b/src/ifcparse/utils.cpp @@ -266,7 +266,7 @@ IFC_PARSE_API bool ifcopenshell::path::rename_file(const std::string& old_filena return success; } -IFC_PARSE_API bool IfcUtil::path::atomic_rename_file(const std::string& old_filename, const std::string& new_filename) { +IFC_PARSE_API bool ifcopenshell::path::atomic_rename_file(const std::string& old_filename, const std::string& new_filename) { std::wstring old_filename_w = from_utf8(old_filename); std::wstring new_filename_w = from_utf8(new_filename); // MOVEFILE_REPLACE_EXISTING makes the replace atomic on NTFS (no unlink @@ -292,7 +292,7 @@ IFC_PARSE_API bool ifcopenshell::path::rename_file(const std::string& old_filena return std::rename(old_filename.c_str(), new_filename.c_str()) == 0; } -IFC_PARSE_API bool IfcUtil::path::atomic_rename_file(const std::string& old_filename, const std::string& new_filename) { +IFC_PARSE_API bool ifcopenshell::path::atomic_rename_file(const std::string& old_filename, const std::string& new_filename) { // POSIX rename() atomically replaces an existing destination on the same // filesystem, so there is no window in which new_filename is missing. return std::rename(old_filename.c_str(), new_filename.c_str()) == 0; diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index ee5aa3ab67..a4bb0b10a7 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -46,14 +46,28 @@ %typemap(out) double& { $result = SWIG_From_double(*$1); } -%typemap(out) bool& { - $result = PyBool_FromLong(static_cast(*$1)); -} - -// Using RTTI return a more specialized type of Element -// Note that these elements are not to be owned by SWIG/Python as they will be freed automatically upon the next iteration -// except for the IfcGeom::Element instances which are returned by Iterator::getObject() calls -%typemap(out) IfcGeom::Element* { +%typemap(out) bool& { + $result = PyBool_FromLong(static_cast(*$1)); +} + +%typemap(out) IfcGeom::OpaqueNumber { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(new IfcGeom::OpaqueNumber($1)), SWIGTYPE_p_IfcGeom__OpaqueNumber, SWIG_POINTER_OWN); +} + +%typemap(in) const IfcGeom::OpaqueNumber& (IfcGeom::OpaqueNumber temp) { + void* argp = nullptr; + int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_IfcGeom__OpaqueNumber, 0); + if (!SWIG_IsOK(res) || !argp) { + SWIG_exception_fail(SWIG_ArgError(res), "Expected IfcGeom::OpaqueNumber"); + } + temp = *reinterpret_cast(argp); + $1 = &temp; +} + +// Using RTTI return a more specialized type of Element +// Note that these elements are not to be owned by SWIG/Python as they will be freed automatically upon the next iteration +// except for the IfcGeom::Element instances which are returned by Iterator::getObject() calls +%typemap(out) IfcGeom::Element* { IfcGeom::SerializedElement* serialized_elem = dynamic_cast($1); IfcGeom::TriangulationElement* triangulation_elem = dynamic_cast($1); IfcGeom::BRepElement* brep_elem = dynamic_cast($1); @@ -711,29 +725,29 @@ struct ShapeRTTI : public boost::static_visitor // I couldn't get the vector typemap to be applied when %extending Iterator constructor. // anyway it does not matter as SWIG generates C code without actual constructors - IfcGeom::Iterator* construct_iterator(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, ifcopenshell::file* file, int num_threads, Logger& logger = Logger::Root()) { - return new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(file, geometry_library, settings, logger), settings, file, num_threads, logger); - } + IfcGeom::Iterator* construct_iterator(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, ifcopenshell::file* file, int num_threads, logger& logger) { + return new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(file, geometry_library, settings), settings, file, num_threads, logger); + } - IfcGeom::Iterator* construct_iterator_with_include_exclude(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, ifcopenshell::file* file, std::vector elems, bool include, int num_threads, Logger& logger = Logger::Root()) { + IfcGeom::Iterator* construct_iterator_with_include_exclude(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, ifcopenshell::file* file, std::vector elems, bool include, int num_threads, logger& logger = ::logger::root()) { std::set elems_set(elems.begin(), elems.end()); IfcGeom::entity_filter ef{ include, false, elems_set }; - return new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(file, geometry_library, settings, logger), settings, file, {ef}, num_threads, logger); + return new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(file, geometry_library, settings), settings, file, {ef}, num_threads, logger); } - IfcGeom::Iterator* construct_iterator_with_include_exclude_globalid(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, ifcopenshell::file* file, std::vector elems, bool include, int num_threads, Logger& logger = Logger::Root()) { + IfcGeom::Iterator* construct_iterator_with_include_exclude_globalid(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, ifcopenshell::file* file, std::vector elems, bool include, int num_threads, logger& logger = ::logger::root()) { std::set elems_set(elems.begin(), elems.end()); IfcGeom::attribute_filter af; af.attribute_name = "GlobalId"; af.populate(elems_set); af.include = include; - return new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(file, geometry_library, settings, logger), settings, file, {af}, num_threads, logger); + return new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(file, geometry_library, settings), settings, file, {af}, num_threads, logger); } - IfcGeom::Iterator* construct_iterator_with_include_exclude_id(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, ifcopenshell::file* file, std::vector elems, bool include, int num_threads, Logger& logger = Logger::Root()) { + IfcGeom::Iterator* construct_iterator_with_include_exclude_id(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, ifcopenshell::file* file, std::vector elems, bool include, int num_threads, logger& logger = ::logger::root()) { std::set elems_set(elems.begin(), elems.end()); IfcGeom::instance_id_filter af(include, false, elems_set); - return new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(file, geometry_library, settings, logger), settings, file, {af}, num_threads, logger); + return new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(file, geometry_library, settings), settings, file, {af}, num_threads, logger); } %} @@ -955,10 +969,10 @@ struct ShapeRTTI : public boost::static_visitor return oss.str(); } - static std::variant helper_fn_create_shape(Logger& logger, const std::string& geometry_library, ifcopenshell::geometry::Settings& st, const express::Base& instance, const express::Base& representation = express::Base()) { + static std::variant helper_fn_create_shape(logger& logger, const std::string& geometry_library, ifcopenshell::geometry::Settings& st, const express::Base& instance, const express::Base& representation = express::Base()) { ifcopenshell::file* file = instance.file(); - ifcopenshell::geometry::Converter kernel(ifcopenshell::geometry::kernels::construct(file, geometry_library, st), file, st); + ifcopenshell::geometry::Converter kernel(ifcopenshell::geometry::kernels::construct(file, geometry_library, st), file, st, logger); if (instance.declaration().is("IfcProduct")) { if (representation && !representation.declaration().is("IfcRepresentation")) { throw ifcopenshell::exception("Supplied representation not of type IfcRepresentation"); @@ -1069,14 +1083,14 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type %} %inline %{ - static std::variant create_shape(ifcopenshell::geometry::Settings& settings, const express::Base& instance, const express::Base& representation, const char* const geometry_library="opencascade", Logger& logger = Logger::Root()) { - return helper_fn_create_shape(geometry_library, settings, instance, representation); - } - - // Manual definition of overload without representation argument - static std::variant create_shape(ifcopenshell::geometry::Settings& settings, const express::Base& instance, const char* const geometry_library="opencascade", Logger& logger = Logger::Root()) { - return create_shape(settings, instance, express::Base(), geometry_library); - } + static std::variant create_shape(ifcopenshell::geometry::Settings& settings, const express::Base& instance, const express::Base& representation, const char* const geometry_library="opencascade", logger& logger = ::logger::root()) { + return helper_fn_create_shape(logger, geometry_library, settings, instance, representation); + } + + // Manual definition of overload without representation argument + static std::variant create_shape(ifcopenshell::geometry::Settings& settings, const express::Base& instance, const char* const geometry_library="opencascade", logger& logger = ::logger::root()) { + return create_shape(settings, instance, express::Base(), geometry_library, logger); + } %} // @todo bring back serialization OCCT -> IFC by means of opencascade_geometry_ifc_writer_registry @@ -1087,16 +1101,16 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type %newobject create_epeck; %inline %{ - IfcGeom::OpaqueNumber* create_epeck(int i) { - return new IfcGeom::NumberNativeDouble(i); - } - IfcGeom::OpaqueNumber* create_epeck(double d) { - return new IfcGeom::NumberNativeDouble(d); - } - IfcGeom::OpaqueNumber* create_epeck(const std::string& s) { - return new IfcGeom::NumberNativeDouble(std::stod(s)); - } -%} + IfcGeom::OpaqueNumber* create_epeck(int i) { + return new IfcGeom::OpaqueNumber(i); + } + IfcGeom::OpaqueNumber* create_epeck(double d) { + return new IfcGeom::OpaqueNumber(d); + } + IfcGeom::OpaqueNumber* create_epeck(const std::string& s) { + return new IfcGeom::OpaqueNumber(std::stod(s)); + } +%} %inline %{ IfcGeom::ConversionResultShape* nary_union(PyObject* sequence) { @@ -1225,10 +1239,11 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type %template(OpaqueCoordinate_3) IfcGeom::OpaqueCoordinate<3>; %template(OpaqueCoordinate_4) IfcGeom::OpaqueCoordinate<4>; -%inline %{ - IfcGeom::OpaqueNumber create_epeck(int i) { - return ifcopenshell::geometry::NumberEpeck(i); - } +#if 0 +%inline %{ + IfcGeom::OpaqueNumber create_epeck(int i) { + return ifcopenshell::geometry::NumberEpeck(i); + } IfcGeom::OpaqueNumber create_epeck(double d) { return ifcopenshell::geometry::NumberEpeck(d); } @@ -1238,7 +1253,7 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type %} %inline %{ - IfcGeom::ConversionResultShape* nary_union(PyObject* sequence) { + IfcGeom::ConversionResultShape* nary_union(PyObject* sequence) { std::vector*> nefs; for(Py_ssize_t i = 0; i < PySequence_Size(sequence); ++i) { PyObject* element = PySequence_GetItem(sequence, i); @@ -1261,8 +1276,9 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type shp = new ifcopenshell::geometry::CgalShape(accum.get_union()); Py_END_ALLOW_THREADS; return shp; - } -%} + } +%} +#endif %extend IfcGeom::ConversionResultShape { std::string serialize_obj() { @@ -1331,7 +1347,7 @@ ifcopenshell::geometry::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type } } - std::vector arrange_polygons(svgfill::arrange_polygon_settings settings, const std::vector& polygons, Logger& logger = Logger::Root()) { + std::vector arrange_polygons(svgfill::arrange_polygon_settings settings, const std::vector& polygons, logger& logger = ::logger::root()) { std::vector r; if (svgfill::arrange_polygons(settings, polygons, r, logger)) { return r; diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index af185a3771..3a72f9940c 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -55,6 +55,9 @@ %ignore ifcopenshell::spf_header::file_description; %ignore ifcopenshell::spf_header::file_name; %ignore ifcopenshell::spf_header::file_schema; +%ignore ifcopenshell::spf_header::set_file_description; +%ignore ifcopenshell::spf_header::set_file_name; +%ignore ifcopenshell::spf_header::set_file_schema; %ignore ifcopenshell::HeaderEntity::is; @@ -129,7 +132,7 @@ static void helper_fn_atomic_write(T& file_obj, const std::string& fn) { const std::string temp_fn = fn + "." + std::to_string(rd()) + ".tmp"; { // Same open mode as a plain write so the bytes are identical. - std::ofstream f(IfcUtil::path::from_utf8(temp_fn).c_str()); + std::ofstream f(ifcopenshell::path::from_utf8(temp_fn).c_str()); if (!f.good()) { // The temp file could not be created (e.g. directory not // writable). Nothing was touched; report as a normal write error. @@ -141,14 +144,14 @@ static void helper_fn_atomic_write(T& file_obj, const std::string& fn) { // Serialization failed (e.g. disk full). Clean up the partial temp // and abort. The existing destination is left intact. f.close(); - IfcUtil::path::delete_file(temp_fn); + ifcopenshell::path::delete_file(temp_fn); throw std::runtime_error("Failed to write to path: '" + fn + "', the file may be incomplete."); } // The ofstream destructor at the end of this scope closes the stream. // On Windows the file must be closed before it can be renamed. } - if (!IfcUtil::path::atomic_rename_file(temp_fn, fn)) { - IfcUtil::path::delete_file(temp_fn); + if (!ifcopenshell::path::atomic_rename_file(temp_fn, fn)) { + ifcopenshell::path::delete_file(temp_fn); throw std::runtime_error("Failed to write to path: '" + fn + "', could not replace the existing file."); } } @@ -987,7 +990,7 @@ object = _old_object %include "../ifcparse/schema.h" %include "../serializers/RocksDbSerializer.h" -%include "../ifcparse/IfcLogger.h" +%include "../ifcparse/logger.h" // The file* returned by open() is to be freed by SWIG/Python %newobject open; @@ -995,7 +998,7 @@ object = _old_object %newobject stream_from_string; %inline %{ - ifcopenshell::file* open(const std::string& fn, bool readonly=false, Logger& logger=Logger::Root()) { + ifcopenshell::file* open(const std::string& fn, bool readonly=false, logger& logger=::logger::root()) { ifcopenshell::file* f; Py_BEGIN_ALLOW_THREADS; f = new ifcopenshell::file(fn, ifcopenshell::FT_AUTODETECT, readonly, logger); @@ -1156,7 +1159,7 @@ object = _old_object static std::stringstream ifcopenshell_log_stream; %} %init %{ - Logger::Root().SetOutput(0, &ifcopenshell_log_stream); + ::logger::root().set_output(0, &ifcopenshell_log_stream); %} %inline %{ std::string get_log() { @@ -1165,20 +1168,20 @@ object = _old_object return log; } void turn_on_detailed_logging() { - Logger::Root().SetOutput(&std::cout, &std::cout); - Logger::Root().Verbosity(Logger::LOG_DEBUG); + ::logger::root().set_output(&std::cout, &std::cout); + ::logger::root().verbosity(::logger::LOG_DEBUG); } void turn_off_detailed_logging() { - Logger::Root().SetOutput(0, &ifcopenshell_log_stream); - Logger::Root().Verbosity(Logger::LOG_WARNING); + ::logger::root().set_output(0, &ifcopenshell_log_stream); + ::logger::root().verbosity(::logger::LOG_WARNING); } void set_log_format_json() { ifcopenshell_log_stream.str(""); - Logger::Root().OutputFormat(Logger::FMT_JSON); + ::logger::root().output_format(::logger::FMT_JSON); } void set_log_format_text() { ifcopenshell_log_stream.str(""); - Logger::Root().OutputFormat(Logger::FMT_PLAIN); + ::logger::root().output_format(::logger::FMT_PLAIN); } %} @@ -1489,7 +1492,7 @@ object = _old_object } } -%extend Logger { +%extend logger { %pythoncode %{ def __iter__(self): return iter(self.log_messages()) diff --git a/src/serializers/CMakeLists.txt b/src/serializers/CMakeLists.txt index 355a704970..3766c15317 100644 --- a/src/serializers/CMakeLists.txt +++ b/src/serializers/CMakeLists.txt @@ -99,7 +99,5 @@ install(FILES ${SERIALIZERS_H_FILES} install(FILES ${SERIALIZERS_S_H_FILES} DESTINATION ${INCLUDEDIR}/serializers/schema_dependent ) -install(TARGETS Serializers EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}) - set(document_serializer_libraries ${document_serializer_libraries} PARENT_SCOPE) set(geometry_serializer_libraries ${geometry_serializer_libraries} PARENT_SCOPE) diff --git a/src/serializers/ColladaSerializer.h b/src/serializers/ColladaSerializer.h index 251d031790..44c391b4f7 100644 --- a/src/serializers/ColladaSerializer.h +++ b/src/serializers/ColladaSerializer.h @@ -219,7 +219,7 @@ private: std::string unit_name; float unit_magnitude; public: - ColladaSerializer(const std::string& dae_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()) + ColladaSerializer(const std::string& dae_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger = ::logger::root()) : WriteOnlyGeometrySerializer(geometry_settings, settings, logger) , exporter("IfcOpenShell", dae_filename, this, settings.get().get() >= 15) { diff --git a/src/serializers/GltfSerializer.cpp b/src/serializers/GltfSerializer.cpp index f4b34410c2..04144438e7 100644 --- a/src/serializers/GltfSerializer.cpp +++ b/src/serializers/GltfSerializer.cpp @@ -53,7 +53,7 @@ static const uint32_t PRIM_TRIANGLE_FAN = 6; static const uint32_t ELEMENT_ARRAY_BUFFER = 34963; static const uint32_t ARRAY_BUFFER = 34962; -GltfSerializer::GltfSerializer(const std::string& filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger) +GltfSerializer::GltfSerializer(const std::string& filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger) : WriteOnlyGeometrySerializer(geometry_settings, settings, logger) , filename_(filename) , tmp_filename1_(filename + ".indices.tmp") @@ -523,9 +523,9 @@ namespace { } void proj_log(void* data, int, const char* c) { - auto logger = static_cast(data); + auto logger = static_cast<::logger*>(data); if (logger) { - logger->Error("SER", 1, "PROJ: " + std::string(c)); + logger->error("SER", 1, "PROJ: " + std::string(c)); } } } @@ -655,7 +655,7 @@ void GltfSerializer::setFile(ifcopenshell::file* f) { NULL); if (!P) { - logger_.Error("SER", 2, "Failed to create PROJ transformation object"); + logger_.error("SER", 2, "Failed to create PROJ transformation object"); return; } @@ -667,7 +667,7 @@ void GltfSerializer::setFile(ifcopenshell::file* f) { wgs84_point = proj_trans(P, PJ_FWD, a); - logger_.Notice("SER", 3, "Calculated latitude: " + std::to_string(wgs84_point.lp.lam) + " longitude: " + std::to_string(wgs84_point.lp.phi)); + logger_.notice("SER", 3, "Calculated latitude: " + std::to_string(wgs84_point.lp.lam) + " longitude: " + std::to_string(wgs84_point.lp.phi)); } std::swap(wgs84_point.lp.phi, wgs84_point.lp.lam); @@ -692,7 +692,7 @@ void GltfSerializer::setFile(ifcopenshell::file* f) { PJ *ellipsoid_crs = proj_create(C, ellipsoid_def); if (!ellipsoid_crs) { - logger_.Error("SER", 4, "Failed to create ellipsoid CRS"); + logger_.error("SER", 4, "Failed to create ellipsoid CRS"); return; } diff --git a/src/serializers/GltfSerializer.h b/src/serializers/GltfSerializer.h index 26d7e31819..a6579b80ce 100644 --- a/src/serializers/GltfSerializer.h +++ b/src/serializers/GltfSerializer.h @@ -43,7 +43,7 @@ private: int writeMaterial(const ifcopenshell::geometry::taxonomy::style::ptr style); public: - GltfSerializer(const std::string& filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()); + GltfSerializer(const std::string& filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger = ::logger::root()); virtual ~GltfSerializer(); bool ready(); void writeHeader(); diff --git a/src/serializers/IgesSerializer.h b/src/serializers/IgesSerializer.h index da08e9d47a..d8b4700641 100644 --- a/src/serializers/IgesSerializer.h +++ b/src/serializers/IgesSerializer.h @@ -40,7 +40,7 @@ private: public: /// @note IGESControl_Controller::Init() must be called prior to instantiating IgesSerializer. /// See http://tracker.dev.opencascade.org/view.php?id=23679 for more information. - IgesSerializer(const std::string& out_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()) + IgesSerializer(const std::string& out_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger = ::logger::root()) : OpenCascadeBasedSerializer(out_filename, geometry_settings, settings, logger) {} virtual ~IgesSerializer() {} @@ -54,7 +54,7 @@ public: const char* symbol = getSymbolForUnitMagnitude(magnitude); if (symbol) { #ifdef HAVE_CONFIG_H - logger_.Warning("SER", 5, "Setting IGES units not supported on OCE"); + logger_.warning("SER", 5, "Setting IGES units not supported on OCE"); #else Interface_Static::SetCVal("xstep.cascade.unit", symbol); Interface_Static::SetCVal("write.iges.unit", symbol); diff --git a/src/serializers/JsonSerializer.h b/src/serializers/JsonSerializer.h index 62838559b9..94f8a80a17 100644 --- a/src/serializers/JsonSerializer.h +++ b/src/serializers/JsonSerializer.h @@ -24,7 +24,7 @@ class JsonSerializer : public Serializer { Dialect dialect_; public: - JsonSerializer(ifcopenshell::file* file, const std::string& json_filename, Dialect dialect = Dialect::JSON_DIALECT_CREOOX, Logger& logger = Logger::Root()) + JsonSerializer(ifcopenshell::file* file, const std::string& json_filename, Dialect dialect = Dialect::JSON_DIALECT_CREOOX, ::logger& logger = ::logger::root()) : json_filename(json_filename) , dialect_(dialect) { diff --git a/src/serializers/OpenCascadeBasedSerializer.h b/src/serializers/OpenCascadeBasedSerializer.h index 6dfcf2cbc5..6f6cdfc568 100644 --- a/src/serializers/OpenCascadeBasedSerializer.h +++ b/src/serializers/OpenCascadeBasedSerializer.h @@ -36,7 +36,7 @@ protected: const std::string out_filename; const char* getSymbolForUnitMagnitude(float mag); public: - explicit OpenCascadeBasedSerializer(const std::string& out_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()) + explicit OpenCascadeBasedSerializer(const std::string& out_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger = ::logger::root()) : WriteOnlyGeometrySerializer(geometry_settings, settings, logger) , out_filename(out_filename) {} diff --git a/src/serializers/RocksDbSerializer.cpp b/src/serializers/RocksDbSerializer.cpp index 936e38c4a4..d523dcc18a 100644 --- a/src/serializers/RocksDbSerializer.cpp +++ b/src/serializers/RocksDbSerializer.cpp @@ -9,7 +9,7 @@ #include "../ifcparse/logger.h" -RocksDbSerializer::RocksDbSerializer(const std::string& input_filename, const std::string& rocksdb_filename, const std::vector& skip_supertypes, Logger& logger) +RocksDbSerializer::RocksDbSerializer(const std::string& input_filename, const std::string& rocksdb_filename, const std::vector& skip_supertypes, ::logger& logger) : input_filename_(input_filename) , rocksdb_filename_(rocksdb_filename) , skip_supertypes_(skip_supertypes) diff --git a/src/serializers/RocksDbSerializer.h b/src/serializers/RocksDbSerializer.h index 0d2785042e..6edbbd6d9f 100644 --- a/src/serializers/RocksDbSerializer.h +++ b/src/serializers/RocksDbSerializer.h @@ -16,7 +16,7 @@ private: void write_streaming_(); public: - RocksDbSerializer(const std::string& input_filename, const std::string& rocksdb_filename, const std::vector& skip_supertypes = {}, Logger& logger = Logger::Root()); + RocksDbSerializer(const std::string& input_filename, const std::string& rocksdb_filename, const std::vector& skip_supertypes = {}, ::logger& logger = ::logger::root()); virtual ~RocksDbSerializer() {} diff --git a/src/serializers/StepSerializer.h b/src/serializers/StepSerializer.h index 85dabf4084..058d79d0a0 100644 --- a/src/serializers/StepSerializer.h +++ b/src/serializers/StepSerializer.h @@ -34,7 +34,7 @@ class StepSerializer : public OpenCascadeBasedSerializer private: STEPControl_Writer writer; public: - explicit StepSerializer(const std::string& out_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& serializer_settings, Logger& logger = Logger::Root()) + explicit StepSerializer(const std::string& out_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& serializer_settings, ::logger& logger = ::logger::root()) : OpenCascadeBasedSerializer(out_filename, geometry_settings, serializer_settings, logger) {} virtual ~StepSerializer() {} diff --git a/src/serializers/SvgSerializer.cpp b/src/serializers/SvgSerializer.cpp index 48f9449832..92ea24665e 100644 --- a/src/serializers/SvgSerializer.cpp +++ b/src/serializers/SvgSerializer.cpp @@ -288,13 +288,13 @@ void SvgSerializer::write(path_object& p, const TopoDS_Shape& comp_or_wire, std: BRep_Tool::CurveOnSurface(edge, curve2d, surf, loc, u1, u2); if (curve2d.IsNull()) { - logger_.Error("SER", 20, "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("SER", 21, "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; } @@ -371,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 (id " << p.first << ")"; - logger_.Warning("SER", 22, ss.str()); + logger().warning("SER", 22, ss.str()); } } @@ -798,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("SER", 23, "Failed to box or edge from drawing annotation"); + logger().error("SER", 23, "Failed to box or edge from drawing annotation"); } std::vector props; @@ -945,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("SER", 24, "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; } } @@ -960,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("SER", 25, "Not including element due to viewBox", data.product); + logger().notice("SER", 25, "Not including element due to viewBox", data.product); return; } } @@ -1007,7 +1007,7 @@ void SvgSerializer::write(const geometry_data& data) { } } } catch (std::exception& e) { - logger_.Error("SER", 26, e); + logger().error("SER", 26, e); } if (operation_type && ((*operation_type == "SINGLE_SWING_LEFT") || (*operation_type == "SINGLE_SWING_RIGHT"))) { @@ -1260,7 +1260,7 @@ void SvgSerializer::write(const geometry_data& data) { compound_to_hlr = &subtracted_shape; } catch (...) { - logger_.Error("SER", 27, "Failed to cut element for HLR", data.product); + logger().error("SER", 27, "Failed to cut element for HLR", data.product); } } } @@ -1352,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(logger_, 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("SER", 28, "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); @@ -1834,7 +1834,7 @@ void SvgSerializer::write(const geometry_data& data) { } if (!emitted) { - logger_.Warning("SER", 29, "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); } } @@ -2014,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_, logger_); + auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(file, geometry_settings_, logger()); auto item = mapping->map(pl); auto matrix = ifcopenshell::geometry::taxonomy::cast(item); delete mapping; @@ -2217,7 +2217,7 @@ void SvgSerializer::finalize() { // @todo do we have always have pln here? if (use_hlr && pln) { - hlr = new hlr_t(logger_, 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{ sd }; @@ -2479,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_, logger_); + auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(file, geometry_settings_, logger()); std::vector to_derive_from; to_derive_from.push_back(f->schema()->declaration_by_name("IfcBuilding")); @@ -2498,9 +2498,9 @@ void SvgSerializer::setFile(ifcopenshell::file* f) { #ifdef TAXONOMY_USE_NAKED_PTR delete matrix; #endif - logger_.Warning("SER", 30, "No building storeys encountered, used for reference:", product); - return; - } + delete mapping; + logger().warning("SER", 30, "No building storeys encountered, used for reference:", product); + return; } } } @@ -2508,7 +2508,7 @@ void SvgSerializer::setFile(ifcopenshell::file* f) { delete mapping; - logger_.Warning("SER", 31, "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(); @@ -2521,7 +2521,7 @@ void SvgSerializer::setSectionHeight(double h, express::Base storey) { void SvgSerializer::setSectionHeightsFromStoreys(double offset) { if (!file) { - logger_.Error("SER", 32, "No file specified"); + logger().error("SER", 32, "No file specified"); return; } with_section_heights_from_storey_ = true; @@ -2536,7 +2536,7 @@ void SvgSerializer::setSectionHeightsFromStoreys(double offset) { try { elev = attr_value; } catch (std::exception& e) { - logger_.Error("SER", 33, e); + logger().error("SER", 33, e); continue; } if (!section_data_->empty()) { diff --git a/src/serializers/SvgSerializer.h b/src/serializers/SvgSerializer.h index dfe30df491..be8c6f2889 100644 --- a/src/serializers/SvgSerializer.h +++ b/src/serializers/SvgSerializer.h @@ -368,11 +368,11 @@ namespace { std::multimap large_ortho_faces_; std::list> items_; - Logger& logger_; + ::logger& logger_; public: - prefiltered_hlr(Logger& logger, bool use_prefiltering, bool use_hlr_poly, bool segment_projection, const gp_Pln& view_direction) + prefiltered_hlr(::logger& logger, bool use_prefiltering, bool use_hlr_poly, bool segment_projection, const gp_Pln& view_direction) : logger_(logger) , use_prefiltering_(use_prefiltering) , use_hlr_poly_(use_hlr_poly) @@ -471,7 +471,7 @@ namespace { } } - logger_.Notice("SER", 34, "Included " + std::to_string(n_faces_included) + " faces out of " + std::to_string(n_total) + " after prefiltering"); + logger_.notice("SER", 34, "Included " + std::to_string(n_faces_included) + " faces out of " + std::to_string(n_total) + " after prefiltering"); auto it = items_.insert(items_.end(), { product, C }); @@ -520,7 +520,7 @@ namespace { } } if (use_prefiltering_) { - logger_.Notice("SER", 35, "Included " + std::to_string(n_included) + " elements out of " + std::to_string(items_.size()) + " after prefiltering"); + logger_.notice("SER", 35, "Included " + std::to_string(n_included) + " elements out of " + std::to_string(items_.size()) + " after prefiltering"); } hlr_calc vis(projector_); @@ -597,7 +597,7 @@ protected: subtract_before_project subtraction_settings_; public: - SvgSerializer(const stream_or_filename& out_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()) + SvgSerializer(const stream_or_filename& out_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger = ::logger::root()) : WriteOnlyGeometrySerializer(geometry_settings, settings, logger) , svg_file(out_filename) , xmin(+std::numeric_limits::infinity()) diff --git a/src/serializers/TtlWktSerializer.cpp b/src/serializers/TtlWktSerializer.cpp index 9867af261a..2341e2f7bd 100644 --- a/src/serializers/TtlWktSerializer.cpp +++ b/src/serializers/TtlWktSerializer.cpp @@ -233,7 +233,7 @@ namespace { } } -TtlWktSerializer::TtlWktSerializer(const stream_or_filename& filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger) +TtlWktSerializer::TtlWktSerializer(const stream_or_filename& filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger) : WriteOnlyGeometrySerializer(geometry_settings, settings, logger) , filename_(filename) { @@ -488,11 +488,11 @@ void TtlWktSerializer::write(const IfcGeom::BRepElement* brep_obj) { if ((polygons_by_area.rbegin()->first > (0.6 * rectangle_area)) || (height < (1. + 1.e-5))) { // Found sufficiently large polygon if (emitted_warning) { - logger_.Warning("SER", 36, "Found larger polygon area (" + std::to_string(polygons_by_area.rbegin()->first) + ")."); + logger().warning("SER", 36, "Found larger polygon area (" + std::to_string(polygons_by_area.rbegin()->first) + ")."); } break; } else if (!emitted_warning) { - logger_.Warning("SER", 37, "Section polygon area is small compared to bounding box area (" + std::to_string(polygons_by_area.rbegin()->first) + " < " + std::to_string(0.6 * rectangle_area) + "). Trying again with different section height."); + logger().warning("SER", 37, "Section polygon area is small compared to bounding box area (" + std::to_string(polygons_by_area.rbegin()->first) + " < " + std::to_string(0.6 * rectangle_area) + "). Trying again with different section height."); emitted_warning = true; } } diff --git a/src/serializers/TtlWktSerializer.h b/src/serializers/TtlWktSerializer.h index 148c6df797..83a358a906 100644 --- a/src/serializers/TtlWktSerializer.h +++ b/src/serializers/TtlWktSerializer.h @@ -32,7 +32,7 @@ class SERIALIZERS_API TtlWktSerializer : public WriteOnlyGeometrySerializer { private: stream_or_filename filename_; public: - TtlWktSerializer(const stream_or_filename& filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()); + TtlWktSerializer(const stream_or_filename& filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger = ::logger::root()); virtual ~TtlWktSerializer() {} bool ready(); void writeHeader(); diff --git a/src/serializers/USDSerializer.cpp b/src/serializers/USDSerializer.cpp index 5139ad3945..f45b1f4873 100644 --- a/src/serializers/USDSerializer.cpp +++ b/src/serializers/USDSerializer.cpp @@ -36,7 +36,7 @@ #include -USDSerializer::USDSerializer(const std::string& out_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger): +USDSerializer::USDSerializer(const std::string& out_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger): WriteOnlyGeometrySerializer(geometry_settings, settings, logger), filename_(out_filename) { diff --git a/src/serializers/USDSerializer.h b/src/serializers/USDSerializer.h index f25d174498..12a91ffc3d 100644 --- a/src/serializers/USDSerializer.h +++ b/src/serializers/USDSerializer.h @@ -86,7 +86,7 @@ private: std::set emitted_names_; std::map element_names_; public: - USDSerializer(const std::string&, const ifcopenshell::geometry::Settings&, const ifcopenshell::geometry::SerializerSettings&, Logger& logger = Logger::Root()); + USDSerializer(const std::string&, const ifcopenshell::geometry::Settings&, const ifcopenshell::geometry::SerializerSettings&, ::logger& logger = ::logger::root()); virtual ~USDSerializer(); bool ready() { return ready_; } void writeHeader(); diff --git a/src/serializers/WavefrontObjSerializer.cpp b/src/serializers/WavefrontObjSerializer.cpp index b43068d61b..26c560c21b 100644 --- a/src/serializers/WavefrontObjSerializer.cpp +++ b/src/serializers/WavefrontObjSerializer.cpp @@ -27,7 +27,7 @@ #include #include -WaveFrontOBJSerializer::WaveFrontOBJSerializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger) +WaveFrontOBJSerializer::WaveFrontOBJSerializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger) : WriteOnlyGeometrySerializer(geometry_settings, settings, logger) , obj_stream(obj_filename) , mtl_stream(mtl_filename) diff --git a/src/serializers/WavefrontObjSerializer.h b/src/serializers/WavefrontObjSerializer.h index cb17de7186..acbcc5c99e 100644 --- a/src/serializers/WavefrontObjSerializer.h +++ b/src/serializers/WavefrontObjSerializer.h @@ -35,7 +35,7 @@ private: size_t vcount_total, ncount_total; std::set materials; public: - WaveFrontOBJSerializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()); + WaveFrontOBJSerializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger& logger = ::logger::root()); virtual ~WaveFrontOBJSerializer() {} bool ready(); void writeHeader(); diff --git a/src/serializers/XmlSerializer.h b/src/serializers/XmlSerializer.h index 3f618efd68..c91dc9562d 100644 --- a/src/serializers/XmlSerializer.h +++ b/src/serializers/XmlSerializer.h @@ -19,7 +19,7 @@ protected: std::string xml_filename; public: - XmlSerializer(ifcopenshell::file* file, const std::string& xml_filename, Logger& logger = Logger::Root()) + XmlSerializer(ifcopenshell::file* file, const std::string& xml_filename, ::logger& logger = ::logger::root()) : xml_filename(xml_filename) { if (!file) { diff --git a/src/serializers/document_serializer_plugin.cpp b/src/serializers/document_serializer_plugin.cpp index 4a68a5750b..dd63d829f4 100644 --- a/src/serializers/document_serializer_plugin.cpp +++ b/src/serializers/document_serializer_plugin.cpp @@ -161,7 +161,7 @@ std::vector ifcopenshell::s try { module = manager.load(path); } catch (const std::exception& e) { - logger::error(e); + ::logger::root().error(e); continue; } if (module.meta().kind_ != ifcopenshell::plugin::kind::document_serializer) { @@ -214,7 +214,7 @@ void ifcopenshell::serializers::load_document_serializer_plugins(document_serial try { module = manager.load(path); } catch (const std::exception& e) { - logger::error(e); + ::logger::root().error(e); continue; } if (module.meta().kind_ != ifcopenshell::plugin::kind::document_serializer) { @@ -246,7 +246,7 @@ bool ifcopenshell::serializers::load_document_serializer_plugin(document_seriali try { module = manager.load(path); } catch (const std::exception& e) { - logger::error(e); + ::logger::root().error(e); continue; } if (module.meta().kind_ != ifcopenshell::plugin::kind::document_serializer || diff --git a/src/serializers/geometry_serializer_plugin.cpp b/src/serializers/geometry_serializer_plugin.cpp index 54d2e56105..c001b1d28e 100644 --- a/src/serializers/geometry_serializer_plugin.cpp +++ b/src/serializers/geometry_serializer_plugin.cpp @@ -159,7 +159,7 @@ std::vector ifcopenshell::s try { module = manager.load(path); } catch (const std::exception& e) { - logger::error(e); + ::logger::root().error(e); continue; } if (module.meta().kind_ != ifcopenshell::plugin::kind::geometry_serializer) { @@ -204,7 +204,7 @@ void ifcopenshell::serializers::load_geometry_serializer_plugins(geometry_serial try { module = manager.load(path); } catch (const std::exception& e) { - logger::error(e); + ::logger::root().error(e); continue; } if (module.meta().kind_ != ifcopenshell::plugin::kind::geometry_serializer) { @@ -230,7 +230,7 @@ bool ifcopenshell::serializers::load_geometry_serializer_plugin(geometry_seriali try { module = manager.load(path); } catch (const std::exception& e) { - logger::error(e); + ::logger::root().error(e); continue; } if (module.meta().kind_ != ifcopenshell::plugin::kind::geometry_serializer || diff --git a/src/serializers/schema_dependent/CMakeLists.txt b/src/serializers/schema_dependent/CMakeLists.txt index 3a1936f92e..419f2a90da 100644 --- a/src/serializers/schema_dependent/CMakeLists.txt +++ b/src/serializers/schema_dependent/CMakeLists.txt @@ -18,7 +18,6 @@ foreach(schema ${SCHEMA_VERSIONS}) target_link_options(document_serializer_json_ifc${schema} PRIVATE "SHELL:-s ERROR_ON_UNDEFINED_SYMBOLS=0") endif() endif() - install(TARGETS Serializers_ifc${schema} EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}) endforeach() set(document_serializer_libraries ${document_serializer_libraries} PARENT_SCOPE) diff --git a/src/serializers/schema_dependent/JsonSerializer.cpp b/src/serializers/schema_dependent/JsonSerializer.cpp index 6025a13590..d81f2a3171 100644 --- a/src/serializers/schema_dependent/JsonSerializer.cpp +++ b/src/serializers/schema_dependent/JsonSerializer.cpp @@ -69,7 +69,7 @@ class get_type_visitor : public boost::static_visitor { // Returns related entity instances using IFC's objectified relationship // model. The second and third argument require a member function pointer. template -auto get_related(T t, F f, G g) { +auto get_related(::logger& log, T t, F f, G g) { auto li = (t.*f)(); std::vector acc; for (auto& u : li) { @@ -91,13 +91,13 @@ auto get_related(T t, F f, G g) { } } } catch (ifcopenshell::exception& e) { - logger::error(e); + log.error(e); } } return acc; } -void format_entity_instance(express::Base instance, json& tree, express::Base parent = express::Base()) { +void format_entity_instance(::logger& log, express::Base instance, json& tree, express::Base parent = express::Base()) { /* { "id" : string, // Element GUID (IFC GloballyUniqueId) @@ -151,7 +151,8 @@ void format_entity_instance(express::Base instance, json& tree, express::Base pa } if (auto obj = instance.as()) { - auto property_sets = get_related(obj, &IfcSchema::IfcObject::IsDefinedBy, &IfcSchema::IfcRelDefinesByProperties::RelatingPropertyDefinition); + auto property_sets = get_related( + log, obj, &IfcSchema::IfcObject::IsDefinedBy, &IfcSchema::IfcRelDefinesByProperties::RelatingPropertyDefinition); if (!property_sets.empty()) { child["propertySetIds"] = json::array(); for (auto& pset : property_sets) { @@ -167,11 +168,11 @@ void format_entity_instance(express::Base instance, json& tree, express::Base pa // A function to be called recursively. Template specialization is used // to descend into decomposition, containment and property relationships. template -void descend(A instance, json& tree, express::Base parent = express::Base()) { +void descend(::logger& log, A instance, json& tree, express::Base parent = express::Base()) { if (instance.declaration().is(IfcSchema::IfcObjectDefinition::Class())) { - descend(instance.template as(), tree, parent); + descend(log, instance.template as(), tree, parent); } else { - format_entity_instance(instance, tree, logger); + format_entity_instance(log, instance, tree); } } @@ -180,7 +181,7 @@ void descend(A instance, json& tree, express::Base parent = express::Base()) { // Descends into the tree by recursing into IfcRelContainedInSpatialStructure, // IfcRelDecomposes, IfcRelDefinesByType, IfcRelDefinesByProperties relations. template <> -void descend(IfcSchema::IfcObjectDefinition product, json& tree, express::Base parent) { +void descend(::logger& log, IfcSchema::IfcObjectDefinition product, json& tree, express::Base parent) { if (product.declaration().is(IfcSchema::IfcElement::Class())) { auto voids = product.as().FillsVoids(); if (voids.size() == 1 && voids.front().RelatingOpeningElement() != parent) { @@ -189,46 +190,50 @@ void descend(IfcSchema::IfcObjectDefinition product, json& tree, express::Base p } } - format_entity_instance(product, tree, logger, parent); + format_entity_instance(log, product, tree, parent); if (auto opening = product.as()) { auto fills = get_related( - opening, &IfcSchema::IfcOpeningElement::HasFillings, &IfcSchema::IfcRelFillsElement::RelatedBuildingElement); + log, opening, &IfcSchema::IfcOpeningElement::HasFillings, &IfcSchema::IfcRelFillsElement::RelatedBuildingElement); for (auto& f : fills) { - descend(f, tree, product); + descend(log, f, tree, product); } } if (auto structure = product.as()) { - auto elements = get_related(structure, &IfcSchema::IfcSpatialStructureElement::ContainsElements, &IfcSchema::IfcRelContainedInSpatialStructure::RelatedElements); + auto elements = get_related( + log, structure, &IfcSchema::IfcSpatialStructureElement::ContainsElements, &IfcSchema::IfcRelContainedInSpatialStructure::RelatedElements); for (auto& el : elements) { - descend(el, tree, product); + descend(log, el, tree, product); } } if (auto element = product.as()) { auto openings = get_related( - element, &IfcSchema::IfcElement::HasOpenings, &IfcSchema::IfcRelVoidsElement::RelatedOpeningElement); + log, element, &IfcSchema::IfcElement::HasOpenings, &IfcSchema::IfcRelVoidsElement::RelatedOpeningElement); for (auto& op : openings) { - descend(op, tree, product); + descend(log, op, tree, product); } } #ifdef SCHEMA_IfcRelDecomposes_HAS_RelatedObjects - auto structures = get_related(product, &IfcSchema::IfcObjectDefinition::IsDecomposedBy, &IfcSchema::IfcRelDecomposes::RelatedObjects); + auto structures = get_related( + log, product, &IfcSchema::IfcObjectDefinition::IsDecomposedBy, &IfcSchema::IfcRelDecomposes::RelatedObjects); #else - auto structures = get_related(product, &IfcSchema::IfcObjectDefinition::IsDecomposedBy, &IfcSchema::IfcRelAggregates::RelatedObjects); + auto structures = get_related( + log, product, &IfcSchema::IfcObjectDefinition::IsDecomposedBy, &IfcSchema::IfcRelAggregates::RelatedObjects); - auto nested = get_related(product, &IfcSchema::IfcObjectDefinition::IsNestedBy, &IfcSchema::IfcRelNests::RelatedObjects); + auto nested = get_related( + log, product, &IfcSchema::IfcObjectDefinition::IsNestedBy, &IfcSchema::IfcRelNests::RelatedObjects); structures.insert(structures.end(), nested.begin(), nested.end()); #endif for (auto& ob : structures) { - descend(ob, tree, product); + descend(log, ob, tree, product); } // psets are handled as part of format_entity_instance() @@ -262,7 +267,7 @@ void POSTFIX_SCHEMA(JsonSerializer)::finalize() { auto projects = file->instances_by_type(); if (projects.size() != 1) { - logger_.Message(Logger::LOG_ERROR, "SER", 7, "Expected a single IfcProject"); + logger().message(::logger::LOG_ERROR, "SER", 7, "Expected a single IfcProject"); return; } IfcSchema::IfcProject project = projects.front(); @@ -271,7 +276,7 @@ void POSTFIX_SCHEMA(JsonSerializer)::finalize() { try { return fn(); } catch (const std::exception& e) { - logger_.Error("SER", 8, e); + logger().error("SER", 8, e); static std::invoke_result_t v; return v; } @@ -576,7 +581,7 @@ void POSTFIX_SCHEMA(JsonSerializer)::finalize() { } */ - descend(project, output["metaObjects"], logger_); + descend(logger(), project, output["metaObjects"]); std::ofstream f(ifcopenshell::path::from_utf8(json_filename).c_str()); f << output.dump(4); diff --git a/src/serializers/schema_dependent/JsonSerializer.h b/src/serializers/schema_dependent/JsonSerializer.h index 39682492f7..26ad037bcc 100644 --- a/src/serializers/schema_dependent/JsonSerializer.h +++ b/src/serializers/schema_dependent/JsonSerializer.h @@ -41,7 +41,7 @@ class POSTFIX_SCHEMA(JsonSerializer) : public JsonSerializer { ifcopenshell::geometry::abstract_mapping* mapping_; public: - POSTFIX_SCHEMA(JsonSerializer)(ifcopenshell::file* file, const std::string& json_filename, JsonSerializer::Dialect dialect, Logger& logger = Logger::Root()) + POSTFIX_SCHEMA(JsonSerializer)(ifcopenshell::file* file, const std::string& json_filename, JsonSerializer::Dialect dialect, ::logger& logger = ::logger::root()) : JsonSerializer(0, "", dialect), mapping_(ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings_, logger)) { this->file = file; diff --git a/src/serializers/schema_dependent/XmlSerializer.cpp b/src/serializers/schema_dependent/XmlSerializer.cpp index 8912364674..06eed703bf 100644 --- a/src/serializers/schema_dependent/XmlSerializer.cpp +++ b/src/serializers/schema_dependent/XmlSerializer.cpp @@ -131,13 +131,13 @@ std::optional format_attribute(ifcopenshell::geometry::abstract_map } // Appends to a node with possibly existing attributes -ptree* format_entity_instance(Logger& logger, ifcopenshell::geometry::abstract_mapping* mapping, const express::Base& instance, ptree& child, ptree& tree, bool as_link = false) { +ptree* format_entity_instance(::logger& log, ifcopenshell::geometry::abstract_mapping* mapping, const express::Base& instance, ptree& child, ptree& tree, bool as_link = false) { const unsigned n = instance.declaration().as_entity()->attribute_count(); for (unsigned i = 0; i < n; ++i) { try { instance.get_attribute_value(i); } catch (const std::exception&) { - logger.Error("SER", 9, "Expected " + boost::lexical_cast(n) + " attributes for:", instance); + log.error("SER", 9, "Expected " + boost::lexical_cast(n) + " attributes for:", instance); break; } auto argument = instance.get_attribute_value(i); @@ -156,7 +156,7 @@ ptree* format_entity_instance(Logger& logger, ifcopenshell::geometry::abstract_m try { value = format_attribute(mapping, argument, argument_type, qualified_name); } catch (const std::exception& e) { - logger.Error("SER", 10, e); + log.error("SER", 10, e); } if (value) { @@ -176,9 +176,9 @@ ptree* format_entity_instance(Logger& logger, ifcopenshell::geometry::abstract_m // Formats an entity instances as a ptree node, and insert into the DOM. Recurses // over the entity attributes and writes them as xml attributes of the node. -ptree* format_entity_instance(Logger& logger, ifcopenshell::geometry::abstract_mapping* mapping, const express::Base& instance, ptree& tree, bool as_link = false) { +ptree* format_entity_instance(::logger& log, ifcopenshell::geometry::abstract_mapping* mapping, const express::Base& instance, ptree& tree, bool as_link = false) { ptree child; - return format_entity_instance(logger, mapping, instance, child, tree, as_link); + return format_entity_instance(log, mapping, instance, child, tree, as_link); } std::string qualify_unrooted_instance(const express::Base& inst) { @@ -188,18 +188,18 @@ std::string qualify_unrooted_instance(const express::Base& inst) { // A function to be called recursively. Template specialization is used // to descend into decomposition, containment and property relationships. template -ptree* descend(ifcopenshell::geometry::abstract_mapping* mapping, A instance, ptree& tree, express::Base parent = express::Base()) { +ptree* descend(::logger& log, ifcopenshell::geometry::abstract_mapping* mapping, A instance, ptree& tree, express::Base parent = express::Base()) { if (instance.declaration().is(IfcSchema::IfcObjectDefinition::Class())) { - return descend(mapping, instance.template as(), tree, parent); + return descend(log, mapping, instance.template as(), tree, parent); } else { - return format_entity_instance(logger, mapping, instance, tree); + return format_entity_instance(log, mapping, instance, tree); } } // Returns related entity instances using IFC's objectified relationship // model. The second and third argument require a member function pointer. template -auto get_related(T t, F f, G g) { +auto get_related(::logger& log, T t, F f, G g) { auto li = (t.*f)(); std::vector acc; for (auto& u : li) { @@ -221,7 +221,7 @@ auto get_related(T t, F f, G g) { } } } catch (ifcopenshell::exception& e) { - logger::error(e); + log.error(e); } } return acc; @@ -230,7 +230,7 @@ auto get_related(T t, F f, G g) { // Descends into the tree by recursing into IfcRelContainedInSpatialStructure, // IfcRelDecomposes, IfcRelDefinesByType, IfcRelDefinesByProperties relations. template <> -ptree* descend(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::IfcObjectDefinition product, ptree& tree, express::Base parent) { +ptree* descend(::logger& log, ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::IfcObjectDefinition product, ptree& tree, express::Base parent) { if (product.declaration().is(IfcSchema::IfcElement::Class())) { auto voids = product.as().FillsVoids(); if (voids.size() == 1 && voids.front().RelatingOpeningElement() != parent) { @@ -239,65 +239,65 @@ ptree* descend(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::Ifc } } - ptree& child = *format_entity_instance(logger, mapping, product, tree); + ptree& child = *format_entity_instance(log, mapping, product, tree); if (auto opening = product.as()) { auto fills = get_related( - opening, &IfcSchema::IfcOpeningElement::HasFillings, &IfcSchema::IfcRelFillsElement::RelatedBuildingElement); + log, opening, &IfcSchema::IfcOpeningElement::HasFillings, &IfcSchema::IfcRelFillsElement::RelatedBuildingElement); for (auto& f : fills) { - descend(mapping, f, child, product); + descend(log, mapping, f, child, product); } } if (auto structure = product.as()) { auto elements = get_related - (logger, structure, &IfcSchema::IfcSpatialStructureElement::ContainsElements, &IfcSchema::IfcRelContainedInSpatialStructure::RelatedElements); + (log, structure, &IfcSchema::IfcSpatialStructureElement::ContainsElements, &IfcSchema::IfcRelContainedInSpatialStructure::RelatedElements); for (auto& el : elements) { - descend(mapping, el, child, product); + descend(log, mapping, el, child, product); } } if (auto element = product.as()) { auto openings = get_related( - element, &IfcSchema::IfcElement::HasOpenings, &IfcSchema::IfcRelVoidsElement::RelatedOpeningElement); + log, element, &IfcSchema::IfcElement::HasOpenings, &IfcSchema::IfcRelVoidsElement::RelatedOpeningElement); for (auto& op : openings) { - descend(mapping, op, child, product); + descend(log, mapping, op, child, product); } } #ifdef SCHEMA_IfcRelDecomposes_HAS_RelatedObjects auto structures = get_related - (logger, product, &IfcSchema::IfcObjectDefinition::IsDecomposedBy, &IfcSchema::IfcRelDecomposes::RelatedObjects); + (log, product, &IfcSchema::IfcObjectDefinition::IsDecomposedBy, &IfcSchema::IfcRelDecomposes::RelatedObjects); #else auto structures = get_related - (logger, product, &IfcSchema::IfcObjectDefinition::IsDecomposedBy, &IfcSchema::IfcRelAggregates::RelatedObjects); + (log, product, &IfcSchema::IfcObjectDefinition::IsDecomposedBy, &IfcSchema::IfcRelAggregates::RelatedObjects); auto nested = get_related - (product, &IfcSchema::IfcObjectDefinition::IsNestedBy, &IfcSchema::IfcRelNests::RelatedObjects); + (log, product, &IfcSchema::IfcObjectDefinition::IsNestedBy, &IfcSchema::IfcRelNests::RelatedObjects); structures.insert(structures.end(), nested.begin(), nested.end()); #endif for (auto& ob : structures) { - descend(mapping, ob, child, product); + descend(log, mapping, ob, child, product); } if (auto object = product.as()) { auto property_sets = get_related - (logger, object, &IfcSchema::IfcObject::IsDefinedBy, &IfcSchema::IfcRelDefinesByProperties::RelatingPropertyDefinition); + (log, object, &IfcSchema::IfcObject::IsDefinedBy, &IfcSchema::IfcRelDefinesByProperties::RelatingPropertyDefinition); #ifdef SCHEMAS_HAS_IfcPropertySetDefinitionSet auto property_set_sets = get_related - (logger, object, &IfcSchema::IfcObject::IsDefinedBy, &IfcSchema::IfcRelDefinesByProperties::RelatingPropertyDefinition); + (log, object, &IfcSchema::IfcObject::IsDefinedBy, &IfcSchema::IfcRelDefinesByProperties::RelatingPropertyDefinition); for (auto& s : property_set_sets) { auto set_sets_value = (decltype(property_sets))s; @@ -307,24 +307,24 @@ ptree* descend(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::Ifc for (auto& pset : property_sets) { if (pset.declaration().is(IfcSchema::IfcPropertySet::Class())) { - format_entity_instance(mapping, pset, child, true); + format_entity_instance(log, mapping, pset, child, true); } else if (pset.declaration().is(IfcSchema::IfcElementQuantity::Class())) { - format_entity_instance(mapping, pset, child, true); + format_entity_instance(log, mapping, pset, child, true); } } #ifdef SCHEMA_IfcObject_HAS_IsTypedBy auto types = get_related - (logger, object, &IfcSchema::IfcObject::IsTypedBy, &IfcSchema::IfcRelDefinesByType::RelatingType); + (log, object, &IfcSchema::IfcObject::IsTypedBy, &IfcSchema::IfcRelDefinesByType::RelatingType); #else auto types = get_related - (logger, object, &IfcSchema::IfcObject::IsDefinedBy, &IfcSchema::IfcRelDefinesByType::RelatingType); + (log, object, &IfcSchema::IfcObject::IsDefinedBy, &IfcSchema::IfcRelDefinesByType::RelatingType); #endif for (auto& type : types) { - format_entity_instance(mapping, type, child, true); + format_entity_instance(log, mapping, type, child, true); } } @@ -336,7 +336,7 @@ ptree* descend(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::Ifc // for the format_entity_instance() call. ptree node; node.put(".xlink:href", "#" + p.first); - format_entity_instance(mapping, p.second, node, child, true); + format_entity_instance(log, mapping, p.second, node, child, true); } auto associations = product.HasAssociations(); @@ -345,7 +345,7 @@ ptree* descend(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::Ifc IfcSchema::IfcMaterialSelect mat = relmat.RelatingMaterial(); ptree node; node.put(".xlink:href", "#" + qualify_unrooted_instance(mat)); - format_entity_instance(mapping, mat.concrete(), node, child, true); + format_entity_instance(log, mapping, mat.concrete(), node, child, true); } } } @@ -353,7 +353,7 @@ ptree* descend(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::Ifc #if defined(SCHEMA_HAS_IfcAlignmentSegment) && defined(SCHEMA_IfcAlignmentSegment_HAS_DesignParameters) if (auto als = product.as()) { ptree node; - format_entity_instance(mapping, als.DesignParameters(), node, child, false); + format_entity_instance(log, mapping, als.DesignParameters(), node, child, false); } #endif @@ -361,17 +361,17 @@ ptree* descend(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::Ifc } // Format IfcProperty instances and insert into the DOM. IfcComplexProperties are flattened out. -void format_properties(ifcopenshell::geometry::abstract_mapping* mapping, const std::vector& properties, ptree& node) { +void format_properties(::logger& log, ifcopenshell::geometry::abstract_mapping* mapping, const std::vector& properties, ptree& node) { for (auto& p : properties) { if (auto complex = p.as()) { - format_properties(mapping, complex.HasProperties(), node); + format_properties(log, mapping, complex.HasProperties(), node); } else { - format_entity_instance(logger, mapping, p, node); + format_entity_instance(log, mapping, p, node); } } } -void writeGroupToNode(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::IfcGroup group, ptree& node, std::set notRootGroups) { +void writeGroupToNode(::logger& log, ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::IfcGroup group, ptree& node, std::set notRootGroups) { // @todo tfk: instead of a set shouldn't we just have a set, the current approach // might not work with non-unique or NIL group names. @@ -384,44 +384,44 @@ void writeGroupToNode(ifcopenshell::geometry::abstract_mapping* mapping, IfcSche return; } // Write one group to root - ptree* node2 = descend(mapping, group, node); + ptree* node2 = descend(log, mapping, group, node); auto father = group.IsGroupedBy(); for (auto& ii : father) { auto objs = ii.RelatedObjects(); for (auto entity : objs) { if (entity.as() && entity.Name()) { - writeGroupToNode(mapping, entity.as(), *node2, notRootGroups); + writeGroupToNode(log, mapping, entity.as(), *node2, notRootGroups); notRootGroups.emplace(*entity.Name()); } else { // Write child to father group - descend(logger, mapping, entity, *node2); + descend(log, mapping, entity, *node2); } } } } // Format IfcElementQuantity instances and insert into the DOM. -void format_quantities(ifcopenshell::geometry::abstract_mapping* mapping, const std::vector& quantities, ptree& node) { +void format_quantities(::logger& log, ifcopenshell::geometry::abstract_mapping* mapping, const std::vector& quantities, ptree& node) { for (auto& p : quantities) { - ptree* node2 = format_entity_instance(mapping, p, node); + ptree* node2 = format_entity_instance(log, mapping, p, node); if (node2 && p.declaration().is(IfcSchema::IfcPhysicalComplexQuantity::Class())) { - format_quantities(mapping, p.as().HasQuantities(), *node2); + format_quantities(log, mapping, p.as().HasQuantities(), *node2); } } } // Format IfcTask instances and insert into the DOM. -void format_tasks(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::IfcTask task, ptree& node) { - ptree* ntask = format_entity_instance(mapping, task, node); +void format_tasks(::logger& log, ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema::IfcTask task, ptree& node) { + ptree* ntask = format_entity_instance(log, mapping, task, node); if (ntask) { #ifdef SCHEMA_IfcTask_HAS_TaskTime IfcSchema::IfcTaskTime task_time = task.TaskTime(); if (task_time) { - format_entity_instance(logger, mapping, task_time, *ntask); + format_entity_instance(log, mapping, task_time, *ntask); } #endif @@ -449,14 +449,14 @@ void format_tasks(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema:: auto property_sets = get_related - (logger, task, &IfcSchema::IfcObject::IsDefinedBy, &IfcSchema::IfcRelDefinesByProperties::RelatingPropertyDefinition); + (log, task, &IfcSchema::IfcObject::IsDefinedBy, &IfcSchema::IfcRelDefinesByProperties::RelatingPropertyDefinition); for (auto& pset : property_sets) { if (pset.declaration().is(IfcSchema::IfcPropertySet::Class())) { - format_entity_instance(mapping, pset, *ntask, true); + format_entity_instance(log, mapping, pset, *ntask, true); } else if (pset.declaration().is(IfcSchema::IfcElementQuantity::Class())) { - format_entity_instance(mapping, pset, *ntask, true); + format_entity_instance(log, mapping, pset, *ntask, true); } } @@ -512,7 +512,7 @@ void format_tasks(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema:: for (auto& object : related_objects) { if (auto task2 = object.as()) { - format_tasks(mapping, task2, *ntask); + format_tasks(log, mapping, task2, *ntask); } } } @@ -524,21 +524,22 @@ void format_tasks(ifcopenshell::geometry::abstract_mapping* mapping, IfcSchema:: void POSTFIX_SCHEMA(XmlSerializer)::finalize() { POSTFIX_SCHEMA(argument_name_map).insert(std::make_pair("GlobalId", "id")); + auto& log = logger(); auto projects = file->instances_by_type(); if (projects.size() != 1) { - logger::message(logger::LOG_ERROR, "Expected a single IfcProject"); + log.message(::logger::LOG_ERROR, "Expected a single IfcProject"); return; } IfcSchema::IfcProject& project = projects.front(); ptree root, header, units, decomposition, properties, quantities, types, layers, materials, work, calendars, connections, groups; - auto catch_exceptions = [this](const auto& fn) { + auto catch_exceptions = [this, &log](const auto& fn) { try { return fn(); } catch(const std::exception& e) { - logger_.Error("SER", 13, e); + log.error("SER", 13, e); static std::invoke_result_t v; return v; } @@ -563,7 +564,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { catch (const ifcopenshell::exception& ex) { std::stringstream ss; ss << "Failed to get ifc file header file_description implementation_level, error: '" << ex.what() << "'"; - logger_.Message(Logger::LOG_ERROR, "SER", 14, ss.str()); + log.message(::logger::LOG_ERROR, "SER", 14, ss.str()); } try { header.put("file_name.name", file->header().file_name().name()); @@ -571,7 +572,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { catch (const ifcopenshell::exception& ex) { std::stringstream ss; ss << "Failed to get ifc file header file_name name, error: '" << ex.what() << "'"; - logger_.Message(Logger::LOG_ERROR, "SER", 15, ss.str()); + log.message(::logger::LOG_ERROR, "SER", 15, ss.str()); } try { header.put("file_name.time_stamp", file->header().file_name().time_stamp()); @@ -579,7 +580,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { catch (const ifcopenshell::exception& ex) { std::stringstream ss; ss << "Failed to get ifc file header file_name time_stamp, error: '" << ex.what() << "'"; - logger_.Message(Logger::LOG_ERROR, "SER", 16, ss.str()); + log.message(::logger::LOG_ERROR, "SER", 16, ss.str()); } try { header.put("file_name.preprocessor_version", file->header().file_name().preprocessor_version()); @@ -587,7 +588,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { catch (const ifcopenshell::exception& ex) { std::stringstream ss; ss << "Failed to get ifc file header file_name preprocessor_version, error: '" << ex.what() << "'"; - logger_.Message(Logger::LOG_ERROR, "SER", 17, ss.str()); + log.message(::logger::LOG_ERROR, "SER", 17, ss.str()); } try { header.put("file_name.originating_system", file->header().file_name().originating_system()); @@ -595,7 +596,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { catch (const ifcopenshell::exception& ex) { std::stringstream ss; ss << "Failed to get ifc file header file_name originating_system, error: '" << ex.what() << "'"; - logger_.Message(Logger::LOG_ERROR, "SER", 18, ss.str()); + log.message(::logger::LOG_ERROR, "SER", 18, ss.str()); } try { // @nb inconsistent spelling @@ -604,18 +605,18 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { catch (const ifcopenshell::exception& ex) { std::stringstream ss; ss << "Failed to get ifc file header file_name authorization, error: '" << ex.what() << "'"; - logger_.Message(Logger::LOG_ERROR, "SER", 19, ss.str()); + log.message(::logger::LOG_ERROR, "SER", 19, ss.str()); } // Descend into the decomposition structure of the IFC file. - descend(logger_, mapping_, project, decomposition); + descend(log, mapping_, project, decomposition); // Write all property sets and values as XML nodes. auto psets = file->instances_by_type(); for (auto& pset : psets) { - ptree* node = format_entity_instance(mapping_, pset, properties); + ptree* node = format_entity_instance(log, mapping_, pset, properties); if (node) { - format_properties(mapping_, pset.HasProperties(), *node); + format_properties(log, mapping_, pset.HasProperties(), *node); } } @@ -623,7 +624,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { auto gsets = file->instances_by_type(); std::set notRootGroups; //selfname, fathername for (auto& g : gsets) { - writeGroupToNode(mapping_, g, groups, notRootGroups); + writeGroupToNode(log, mapping_, g, groups, notRootGroups); } for (auto it = groups.begin(); it != groups.end();) { if (notRootGroups.find(it->second.get(".Name")) != notRootGroups.end()) { @@ -636,9 +637,9 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { // Write all quantities and values as XML nodes. auto qtosets = file->instances_by_type(); for (auto& qto : qtosets) { - ptree* node = format_entity_instance(mapping_, qto, quantities); + ptree* node = format_entity_instance(log, mapping_, qto, quantities); if (node) { - format_quantities(mapping_, qto.Quantities(), *node); + format_quantities(log, mapping_, qto.Quantities(), *node); } } @@ -646,7 +647,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { ptree pwork_schedules; auto pschedules = file->instances_by_type(); for (auto& schedule : pschedules) { - ptree* nschedule = format_entity_instance(mapping_, schedule, pwork_schedules); + ptree* nschedule = format_entity_instance(log, mapping_, schedule, pwork_schedules); if(nschedule) { auto controls = schedule.Controls(); @@ -655,7 +656,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { for(auto& object : objects) { if (object && object.declaration().is(IfcSchema::IfcTask::Class())) { IfcSchema::IfcTask task = object.as(); - format_tasks(mapping_, task, *nschedule); + format_tasks(log, mapping_, task, *nschedule); } } } @@ -667,7 +668,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { ptree pwork_plans; auto pplans = file->instances_by_type(); for (auto& plan : pplans) { - ptree* nschedule = format_entity_instance(mapping_, plan, pwork_plans); + ptree* nschedule = format_entity_instance(log, mapping_, plan, pwork_plans); if (nschedule) { #ifdef SCHEMA_IfcObjectDefinition_HAS_IsDecomposedBy @@ -691,13 +692,13 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { #ifdef SCHEMA_HAS_IfcWorkCalendar auto pcalendars = file->instances_by_type(); for (auto& calendar : pcalendars) { - ptree* ncalendar = format_entity_instance(mapping_, calendar, calendars); + ptree* ncalendar = format_entity_instance(log, mapping_, calendar, calendars); if (ncalendar) { auto working_times = calendar.WorkingTimes().value_or(std::vector{}); for (auto& working_time : working_times) { - format_entity_instance(mapping_, working_time, *ncalendar); + format_entity_instance(log, mapping_, working_time, *ncalendar); } } } @@ -705,13 +706,13 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { auto pconnections = file->instances_by_type(); for (auto& connection : pconnections) { - ptree* nconnection = format_entity_instance(mapping_, connection, connections); + ptree* nconnection = format_entity_instance(log, mapping_, connection, connections); ptree nrelatedElement; ptree nrelatingElement; - format_entity_instance(mapping_,connection.RelatedElement(), nrelatedElement, true); - format_entity_instance(mapping_,connection.RelatingElement(), nrelatingElement, true); + format_entity_instance(log, mapping_, connection.RelatedElement(), nrelatedElement, true); + format_entity_instance(log, mapping_, connection.RelatingElement(), nrelatingElement, true); nconnection->add_child("RelatedElement", nrelatedElement); nconnection->add_child("RelatingElement", nrelatingElement); @@ -720,13 +721,13 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { // Write all type objects as XML nodes. auto type_objects = file->instances_by_type(); for (auto& type_object : type_objects) { - ptree* node = descend(mapping_, type_object, types); + ptree* node = descend(log, mapping_, type_object, types); if (node && type_object.HasPropertySets()) { auto property_sets = *type_object.HasPropertySets(); for (auto& pset : property_sets) { if (pset.declaration().is(IfcSchema::IfcPropertySet::Class())) { - format_entity_instance(mapping_, pset, *node, true); + format_entity_instance(log, mapping_, pset, *node, true); } } } @@ -736,12 +737,12 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { auto unit_assignments = project.UnitsInContext().Units(); for (auto& unit : unit_assignments) { if (auto named_unit = unit.as()) { - ptree* node = format_entity_instance(mapping_, named_unit, units); + ptree* node = format_entity_instance(log, mapping_, named_unit, units); if (node) { node->put(".SI_equivalent", ifcopenshell::get_SI_equivalent(named_unit)); } } else if (auto mon_unit = unit.as()) { - format_entity_instance(mapping_, mon_unit, units); + format_entity_instance(log, mapping_, mon_unit, units); } } @@ -756,7 +757,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { layer_names.insert(name); ptree node; node.put(".id", name); - format_entity_instance(mapping_, assignment, node, layers); + format_entity_instance(log, mapping_, assignment, node, layers); } } @@ -783,16 +784,16 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { if (layer.Material()) { subnode.put(".Name", layer.Material()); } - format_entity_instance(mapping_, layer, subnode, node); + format_entity_instance(log, mapping_, layer, subnode, node); } } else if (auto matlist = mat.concrete().as()) { auto mats = matlist.Materials(); for (auto& mat : mats) { ptree subnode; - format_entity_instance(mapping_, mat, subnode, node); + format_entity_instance(log, mapping_, mat, subnode, node); } } - format_entity_instance(mapping_, mat.concrete(), node, materials); + format_entity_instance(log, mapping_, mat.concrete(), node, materials); } } diff --git a/src/serializers/schema_dependent/XmlSerializer.h b/src/serializers/schema_dependent/XmlSerializer.h index 4e77359528..22c582f12e 100644 --- a/src/serializers/schema_dependent/XmlSerializer.h +++ b/src/serializers/schema_dependent/XmlSerializer.h @@ -39,7 +39,7 @@ private: ifcopenshell::geometry::abstract_mapping* mapping_; public: - POSTFIX_SCHEMA(XmlSerializer)(ifcopenshell::file* file, const std::string& xml_filename, Logger& logger = Logger::Root()) + POSTFIX_SCHEMA(XmlSerializer)(ifcopenshell::file* file, const std::string& xml_filename, ::logger& logger = ::logger::root()) : XmlSerializer(0, "") , mapping_(ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings_, logger)) { diff --git a/src/svgfill/CMakeLists.txt b/src/svgfill/CMakeLists.txt index b0c2079139..1cb0cc5cf9 100644 --- a/src/svgfill/CMakeLists.txt +++ b/src/svgfill/CMakeLists.txt @@ -53,7 +53,7 @@ target_compile_definitions(svgfill PRIVATE BOOST_DLL_USE_STD_FS) if(NOT WASM_BUILD) target_link_libraries(svgfill PRIVATE plugin) endif() -target_link_libraries(svgfill PRIVATE ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} LibXml2::LibXml2 IFCOPENSHELL_CGAL) +target_link_libraries(svgfill PRIVATE ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} LibXml2::LibXml2 IFCOPENSHELL_CGAL IfcParse) target_compile_definitions(svgfill PUBLIC IFC_SHARED_BUILD) set_target_properties(svgfill PROPERTIES PUBLIC_HEADER "${LIB_H_FILES}") set_target_properties(svgfill PROPERTIES OUTPUT_NAME "ifcopenshell.geometry.svgfill") diff --git a/src/svgfill/src/arrange_polygons.cpp b/src/svgfill/src/arrange_polygons.cpp index c9618d5553..55fb2cbd32 100644 --- a/src/svgfill/src/arrange_polygons.cpp +++ b/src/svgfill/src/arrange_polygons.cpp @@ -1,11 +1,11 @@ -#define SVGFILL_DEBUG +#define SVGFILL_DEBUG // #define SVGFILL_MAIN #ifndef SVGFILL_MAIN #include "svgfill.h" #endif -#include "../../ifcparse/IfcLogger.h" +#include "../../ifcparse/logger.h" #include #include @@ -1605,7 +1605,7 @@ std::map> snap_points_to_box_axes( const CenterLineGraphData& graph, const std::vector& boxes, const K::FT& max_projection_distance, - Logger& logger) { + logger& logger) { std::vector snapped_points(graph.points.size()); for (size_t i = 0; i < graph.points.size(); ++i) { @@ -1692,7 +1692,7 @@ std::map> snap_points_to_box_axes( message << "Snapping distance exceeds maximum distance: " << std::sqrt(CGAL::to_double((snapped_points[i] - best.projection).squared_length())) << " > " << max_projection_distance; - logger.Message(Logger::LOG_WARNING, "ARR", 1, message.str()); + logger.message(::logger::LOG_WARNING, "ARR", 1, message.str()); } } @@ -1719,7 +1719,7 @@ Graph2D join_segment_runs( const std::map>& line_graph, const std::map>& midpoint_to_segment, const K::FT& max_projection_distance, - Logger& logger) { + logger& logger) { auto graph = make_center_line_graph_data(line_graph, midpoint_to_segment); auto runs = runs_from_graph(graph); runs.erase(std::remove_if(runs.begin(), runs.end(), [](const LineRun& run) { @@ -2249,7 +2249,7 @@ extend_end_vertices_based_on_input_simple( const Polygon_list& outer_perimiter, const K::FT& max_projection_distance, int pass, - Logger& logger) + logger& logger) { auto max_intersection_distance = max_projection_distance / 4; @@ -2399,9 +2399,9 @@ extend_end_vertices_based_on_input_simple( } } if (within_any_perimeter) { - logger.Message(Logger::LOG_WARNING, "ARR", 2, "Within boundary but no projection or intersection solution was found"); + logger.message(::logger::LOG_WARNING, "ARR", 2, "Within boundary but no projection or intersection solution was found"); } else { - logger.Message(Logger::LOG_WARNING, "ARR", 3, "Point is outside all boundaries"); + logger.message(::logger::LOG_WARNING, "ARR", 3, "Point is outside all boundaries"); } return boost::optional{}; }; @@ -2416,7 +2416,7 @@ extend_end_vertices_based_on_input_simple( if (*result == M) { std::ostringstream message; message << "Point is already on perimeter (" << M.x() << " " << M.y() << ")"; - logger.Message(Logger::LOG_NOTICE, "ARR", 4, message.str()); + logger.message(::logger::LOG_NOTICE, "ARR", 4, message.str()); continue; } auto d = (M - *result).squared_length(); @@ -2425,7 +2425,7 @@ extend_end_vertices_based_on_input_simple( std::ostringstream message; message << "Unable to find projection or intersection point for interior boundary pass " << pass << " [round 1] (" << M.x() << " " << M.y() << ")"; - logger.Message(Logger::LOG_WARNING, "ARR", 5, message.str()); + logger.message(::logger::LOG_WARNING, "ARR", 5, message.str()); } } } @@ -2441,7 +2441,7 @@ extend_end_vertices_based_on_input_simple( auto d = CGAL::squared_distance(point, *result); std::ostringstream message; message << "Projection or intersection distance: " << std::sqrt(CGAL::to_double(d)); - logger.Message(Logger::LOG_DEBUG, "ARR", 6, message.str()); + logger.message(::logger::LOG_DEBUG, "ARR", 6, message.str()); validation_segments.emplace_back(to_3d(point), to_3d(*result)); auto inserted_it = std::prev(validation_segments.end()); validation_tree.insert(inserted_it, validation_segments.end()); @@ -2449,7 +2449,7 @@ extend_end_vertices_based_on_input_simple( std::ostringstream message; message << "Unable to find projection or intersection point for interior boundary pass " << pass << " [round 2] (" << point.x() << " " << point.y() << ")"; - logger.Message(Logger::LOG_WARNING, "ARR", 7, message.str()); + logger.message(::logger::LOG_WARNING, "ARR", 7, message.str()); } } @@ -2548,7 +2548,7 @@ class Segment_2_less { } }; -std::vector arrangement_cell_iou(DebugWriter& debug_output, Arrangement_2& left, Arrangement_2& right, Logger& logger) { +std::vector arrangement_cell_iou(DebugWriter& debug_output, Arrangement_2& left, Arrangement_2& right, logger& logger) { using Walk_pl = CGAL::Arr_walk_along_line_point_location; Walk_pl walk_pl(right); @@ -2630,7 +2630,7 @@ std::vector arrangement_cell_iou(DebugWriter& debug_output, Arrangement_2 if (visited_faces_on_right.count(*v) > 0) { // Maybe we should be more permissive, try some other points etc. return_values.push_back(0); - logger.Message(Logger::LOG_WARNING, "ARR", 8, "Already visited face on right; skipping point"); + logger.message(::logger::LOG_WARNING, "ARR", 8, "Already visited face on right; skipping point"); } else { // convert arr facet to polygon with holes auto polygon_exterior = circ_to_poly((*v)->outer_ccb()); @@ -2668,7 +2668,7 @@ std::vector arrangement_cell_iou(DebugWriter& debug_output, Arrangement_2 max_deviation_poly_pair = {pwh.outer_boundary(), pwh_right.outer_boundary()}; } } else { - logger.Message(Logger::LOG_WARNING, "ARR", 9, "No intersection; skipping point"); + logger.message(::logger::LOG_WARNING, "ARR", 9, "No intersection; skipping point"); return_values.push_back(0); } } @@ -2690,7 +2690,7 @@ std::vector arrangement_cell_iou(DebugWriter& debug_output, Arrangement_2 return return_values; } -void clean_noisy_paths(DebugWriter& debug_output, Arrangement_2& arr, SegmentLookup& segment_lookup, double& threshold, Logger& logger) { +void clean_noisy_paths(DebugWriter& debug_output, Arrangement_2& arr, SegmentLookup& segment_lookup, double& threshold, logger& logger) { using SK = CGAL::Simple_cartesian; CGAL::Cartesian_converter C{}; @@ -2906,7 +2906,7 @@ void clean_noisy_paths(DebugWriter& debug_output, Arrangement_2& arr, SegmentLoo } } if (!removed) { - logger.Message(Logger::LOG_WARNING, "ARR", 10, "Unable to locate edge for removal; skipping"); + logger.message(::logger::LOG_WARNING, "ARR", 10, "Unable to locate edge for removal; skipping"); } } @@ -3327,7 +3327,7 @@ class timer { entry( std::map::const_iterator start_it, - Logger& logger) + logger& logger) : start_it(start_it) , logger_(&logger) {} @@ -3337,16 +3337,16 @@ class timer { auto duration = std::chrono::duration(end - start_it.value()->second).count(); std::ostringstream message; message << "Timing for " << start_it.value()->first << ": " << duration << " ms"; - logger_->Message(Logger::LOG_PERF, "ARR", 11, message.str()); + logger_->message(::logger::LOG_PERF, "ARR", 11, message.str()); } } private: std::optional::const_iterator> start_it; - Logger* logger_; + logger* logger_; }; - timer(Logger& logger, bool enabled = true) + timer(logger& logger, bool enabled = true) : logger_(logger) , enabled_(enabled) {} @@ -3364,7 +3364,7 @@ class timer { std::chrono::high_resolution_clock::time_point> timings_; - Logger& logger_; + logger& logger_; bool enabled_; }; @@ -3384,7 +3384,7 @@ void arrange_cgal_polygons( svgfill::arrange_polygon_settings settings, const std::vector& input_polygons_, std::vector& output_polygons, - Logger& logger, + logger& logger, double polygon_offset_distance = -1.) { static const double OVERLAP_RESOLUTION_DISTANCE = 1.e-1; @@ -3612,7 +3612,7 @@ void arrange_cgal_polygons( for (int i = 0; i < 2; ++i) { auto it = line_graph.find(e.first); if (it == line_graph.end()) { - logger.Message(Logger::LOG_WARNING, "ARR", 12, "Unable to locate vertex for elimination; skipping"); + logger.message(::logger::LOG_WARNING, "ARR", 12, "Unable to locate vertex for elimination; skipping"); continue; } auto& neighbours = it->second; @@ -3716,7 +3716,7 @@ void arrange_cgal_polygons( std::ostringstream message; message << "Significant difference between cleaned and original arrangement; using original for topology reconstruction: " << *it; - logger.Message(Logger::LOG_WARNING, "ARR", 13, message.str()); + logger.message(::logger::LOG_WARNING, "ARR", 13, message.str()); fallback_to_line_cleaning_algo_1 = true; apply_line_cleaning_algo_1(); } else { @@ -3814,7 +3814,7 @@ bool svgfill::arrange_polygons( arrange_polygon_settings settings, const std::vector& polygons, std::vector& arranged, - Logger& logger) { + logger& logger) { std::vector cgal_polygons, cgal_polygons_out; std::transform(polygons.begin(), polygons.end(), std::back_inserter(cgal_polygons), [](auto& poly) { Polygon_2 result; @@ -3853,9 +3853,9 @@ Polygon_2 create_rectangle(T x_min, T y_min, T x_max, T y_max) { int main(int argc, char** argv) { std::vector input_polygons, output; - Logger logger; - logger.SetOutput(&std::cout, &std::cerr); - logger.Verbosity(Logger::LOG_PERF); + logger logger; + logger.set_output(&std::cout, &std::cerr); + logger.verbosity(::logger::LOG_PERF); if (argc == 2) { using json = nlohmann::json; @@ -3864,7 +3864,7 @@ int main(int argc, char** argv) { file >> jsonData; size_t i = 0; for (const auto& item : jsonData.items()) { - logger.Message(Logger::LOG_NOTICE, "ARR", 14, "Processing arrangement " + std::to_string(i)); + logger.message(::logger::LOG_NOTICE, "ARR", 14, "Processing arrangement " + std::to_string(i)); i++; input_polygons.clear(); const auto& polygonsData = item.value(); diff --git a/src/svgfill/src/linework_processing_facade.cpp b/src/svgfill/src/linework_processing_facade.cpp index 3893009495..6db12aa3ab 100644 --- a/src/svgfill/src/linework_processing_facade.cpp +++ b/src/svgfill/src/linework_processing_facade.cpp @@ -136,9 +136,10 @@ bool svgfill::svg_to_polygons( bool svgfill::arrange_polygons( arrange_polygon_settings settings, const std::vector& polygons, - std::vector& arranged) + std::vector& arranged, + logger& logger) { - return provider().api.arrange_polygons(settings, polygons, arranged); + return provider().api.arrange_polygons(settings, polygons, arranged, logger); } void svgfill::context::add(const std::vector& segments) { diff --git a/src/svgfill/src/linework_processing_plugin.h b/src/svgfill/src/linework_processing_plugin.h index 864cc3d688..96a0571c0f 100644 --- a/src/svgfill/src/linework_processing_plugin.h +++ b/src/svgfill/src/linework_processing_plugin.h @@ -56,7 +56,7 @@ struct api { const std::string&, const std::optional&, std::vector&) = nullptr; - bool (*arrange_polygons)(arrange_polygon_settings, const std::vector&, std::vector&) = nullptr; + bool (*arrange_polygons)(arrange_polygon_settings, const std::vector&, std::vector&, logger&) = nullptr; abstract_arrangement* (*create_arrangement)(solver) = nullptr; void (*destroy_arrangement)(abstract_arrangement*) = nullptr; }; diff --git a/src/svgfill/src/svgfill.h b/src/svgfill/src/svgfill.h index e1cffaef72..3b5e851bc6 100644 --- a/src/svgfill/src/svgfill.h +++ b/src/svgfill/src/svgfill.h @@ -41,7 +41,7 @@ #include #include -class Logger; +class logger; namespace svgfill { typedef std::array point_2; @@ -134,7 +134,7 @@ namespace svgfill { double subdivision_factor = 16.; }; - SVGFILL_API bool arrange_polygons(arrange_polygon_settings settings, const std::vector& polygons, std::vector& arranged, Logger& logger); + SVGFILL_API bool arrange_polygons(arrange_polygon_settings settings, const std::vector& polygons, std::vector& arranged, logger& logger); } #endif