diff --git a/src/examples/IfcAlignment.cpp b/src/examples/IfcAlignment.cpp index 86e1b5e44c..a8b91607a0 100644 --- a/src/examples/IfcAlignment.cpp +++ b/src/examples/IfcAlignment.cpp @@ -30,7 +30,7 @@ // Disable warnings coming from IfcOpenShell #pragma warning(disable : 4018 4267 4250 4984 4985) -#include "../ifcparse/Ifc4x3_add2.h" +#include "../ifcparse/schemas/Ifc4x3_add2.h" #include "../ifcparse/hierarchy_helper.h" #include diff --git a/src/examples/IfcSimplifiedAlignment.cpp b/src/examples/IfcSimplifiedAlignment.cpp index b59114ec8c..979e2fd077 100644 --- a/src/examples/IfcSimplifiedAlignment.cpp +++ b/src/examples/IfcSimplifiedAlignment.cpp @@ -30,7 +30,7 @@ // Disable warnings coming from IfcOpenShell #pragma warning(disable : 4018 4267 4250 4984 4985) -#include "../ifcparse/Ifc4x3_add2.h" +#include "../ifcparse/schemas/Ifc4x3_add2.h" #include "../ifcparse/alignment_helper.h" #include diff --git a/src/ifcgeom/mapping/IfcCurveSegment.cpp b/src/ifcgeom/mapping/IfcCurveSegment.cpp index c1a28ec4b0..28a50126cc 100644 --- a/src/ifcgeom/mapping/IfcCurveSegment.cpp +++ b/src/ifcgeom/mapping/IfcCurveSegment.cpp @@ -258,12 +258,12 @@ class curve_segment_evaluator { } if (s == inst) { emit_next = true; + } else { + logger_.warning("GEO", 242, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment."); } - } else { - mapping_->logger().warning("GEO", 242, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment."); } } else { - ::logger::root().warning("IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment."); + logger_.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_); + 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."); + 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()); @@ -860,8 +860,6 @@ class curve_segment_evaluator { auto sign_l = sign(length_); - auto sign_l = sign(length_); - // center point of the parent curve auto pcCenterX = parent_curve_position(0, 3); auto pcCenterY = parent_curve_position(1, 3); diff --git a/src/ifcgeom/tests/CMakeLists.txt b/src/ifcgeom/tests/CMakeLists.txt index 4bc6ec6e17..c77b9efcf8 100644 --- a/src/ifcgeom/tests/CMakeLists.txt +++ b/src/ifcgeom/tests/CMakeLists.txt @@ -3,19 +3,34 @@ add_executable(test_ifcopenshell_geometry test_ifcopenshell_geometry.cpp ) -if(NOT TARGET parse_schema_ifc2x3) - message(FATAL_ERROR "test_ifcopenshell_geometry requires SCHEMA_VERSIONS to include 2x3.") +list(GET SCHEMA_VERSIONS -1 IFCGEOM_TEST_SCHEMA_VERSION) +set(IFCGEOM_TEST_SCHEMA_TARGET parse_schema_ifc${IFCGEOM_TEST_SCHEMA_VERSION}) +set(IFCGEOM_TEST_MAPPING_TARGET geometry_mapping_ifc${IFCGEOM_TEST_SCHEMA_VERSION}) +if(NOT TARGET ${IFCGEOM_TEST_SCHEMA_TARGET}) + message(FATAL_ERROR "test_ifcopenshell_geometry requires ${IFCGEOM_TEST_SCHEMA_TARGET}.") +endif() +if(NOT TARGET ${IFCGEOM_TEST_MAPPING_TARGET}) + message(FATAL_ERROR "test_ifcopenshell_geometry requires ${IFCGEOM_TEST_MAPPING_TARGET}.") endif() target_include_directories(test_ifcopenshell_geometry PRIVATE "${CMAKE_SOURCE_DIR}/../src") -target_link_libraries(test_ifcopenshell_geometry PRIVATE Catch2::Catch2WithMain IfcGeom IfcParse parse_schema_ifc2x3) -add_dependencies(test_ifcopenshell_geometry geometry_mapping_ifc2x3 geometry_kernel_passthrough) +target_compile_definitions(test_ifcopenshell_geometry PRIVATE + IfcSchema=Ifc${IFCGEOM_TEST_SCHEMA_VERSION} + "IFCGEOM_TEST_SCHEMA_HEADER=\"ifcparse/schemas/Ifc${IFCGEOM_TEST_SCHEMA_VERSION}.h\"" +) +target_link_libraries(test_ifcopenshell_geometry PRIVATE + Catch2::Catch2WithMain + IfcGeom + IfcParse + ${IFCGEOM_TEST_SCHEMA_TARGET} +) +add_dependencies(test_ifcopenshell_geometry ${IFCGEOM_TEST_MAPPING_TARGET} geometry_kernel_passthrough) catch_discover_tests(test_ifcopenshell_geometry DL_PATHS $ $ $ $ - $ + $ $ # Catch2 discovery uses DL_PATHS in order; CTest PATH prepends reverse it. $ diff --git a/src/ifcgeom/tests/test_ifcopenshell_geometry.cpp b/src/ifcgeom/tests/test_ifcopenshell_geometry.cpp index fbfd23309f..5090961a8b 100644 --- a/src/ifcgeom/tests/test_ifcopenshell_geometry.cpp +++ b/src/ifcgeom/tests/test_ifcopenshell_geometry.cpp @@ -6,10 +6,9 @@ #include "ifcgeom/Converter.h" #include "ifcgeom/kernel_registry.h" -#define IfcSchema Ifc2x3 #include "ifcparse/hierarchy_helper.h" #include "ifcparse/macros.h" -#include "ifcparse/schemas/Ifc2x3.h" +#include IFCGEOM_TEST_SCHEMA_HEADER namespace { diff --git a/src/ifcparse/alignment_helper.cpp b/src/ifcparse/alignment_helper.cpp index 91b6ee5173..2cd773d5d1 100644 --- a/src/ifcparse/alignment_helper.cpp +++ b/src/ifcparse/alignment_helper.cpp @@ -488,7 +488,7 @@ Ifc4x3_add2::IfcAlignment addAlignment(hierarchy_helper& file, cons return alignment; } -std::pair mapAlignmentSegment(hierarchy_helper& file, const Ifc4x3_add2::IfcAlignmentSegment& segment) { +std::pair mapAlignmentSegment(hierarchy_helper& file, const Ifc4x3_add2::IfcAlignmentSegment& segment, logger& logger) { std::pair result; auto design_parameters = segment.DesignParameters(); auto horizontal = design_parameters.as(); @@ -501,7 +501,7 @@ std::pair mapAlignme } else if (cant) { result = mapAlignmentCantSegment(file, cant); } else { - ::logger::root().error(std::string("Unexpected IfcAlignmentSegment subtype encountered")); + logger.error(std::string("Unexpected IfcAlignmentSegment subtype encountered")); } return result; } @@ -514,7 +514,7 @@ Ifc4x3_add2::IfcLengthMeasure create_length(hierarchy_helper& file, } } -std::pair mapAlignmentHorizontalSegment(hierarchy_helper& file, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment) { +std::pair mapAlignmentHorizontalSegment(hierarchy_helper& file, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, logger& logger) { std::pair result; auto start_point = segment.StartPoint(); auto start_direction = segment.StartDirection(); @@ -762,15 +762,15 @@ std::pair mapAlignme result.first = curve_segment; } else if (type == Ifc4x3_add2::IfcAlignmentHorizontalSegmentTypeEnum::IfcAlignmentHorizontalSegmentType_VIENNESEBEND) { - ::logger::root().warning(std::string("mapping of AlignmentHorizontalSegmentType VIENNESEBEND not supported")); + logger.warning(std::string("mapping of AlignmentHorizontalSegmentType VIENNESEBEND not supported")); } else { - ::logger::root().error(std::string("unexpected AlignmentHorizontalSegmentType encountered")); + logger.error(std::string("unexpected AlignmentHorizontalSegmentType encountered")); } return result; } -std::pair mapAlignmentVerticalSegment(hierarchy_helper& file, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment) { +std::pair mapAlignmentVerticalSegment(hierarchy_helper& file, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, logger& logger) { std::pair result; auto start_distance_along = segment.StartDistAlong(); auto horizontal_length = segment.HorizontalLength(); @@ -830,7 +830,7 @@ std::pair mapAlignme result.first = curve_segment; } else if (type == Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CLOTHOID) { - ::logger::root().warning(std::string("mapping of AlignmentVerticalSegmentType CLOTHOID not supported")); + logger.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,31 +856,31 @@ std::pair mapAlignme result.first = curve_segment; } else { - ::logger::root().error(std::string("unexpected AlignmentVerticalSegmentType encountered")); + logger.error(std::string("unexpected AlignmentVerticalSegmentType encountered")); } return result; } -std::pair mapAlignmentCantSegment(hierarchy_helper& file, const Ifc4x3_add2::IfcAlignmentCantSegment& segment) { +std::pair mapAlignmentCantSegment(hierarchy_helper& file, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, logger& logger) { std::pair result; auto type = segment.PredefinedType(); if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_BLOSSCURVE) { - ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType BLOSSCURVE not supported")); + logger.warning(std::string("mapping of AlignmentCantSegmentType BLOSSCURVE not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_CONSTANTCANT) { - ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType CONSTANTCANT not supported")); + logger.warning(std::string("mapping of AlignmentCantSegmentType CONSTANTCANT not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_COSINECURVE) { - ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType COSINECURVE not supported")); + logger.warning(std::string("mapping of AlignmentCantSegmentType COSINECURVE not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_HELMERTCURVE) { - ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType HELMERTCURVE not supported")); + logger.warning(std::string("mapping of AlignmentCantSegmentType HELMERTCURVE not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_LINEARTRANSITION) { - ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType LINEARTRANSTION not supported")); + logger.warning(std::string("mapping of AlignmentCantSegmentType LINEARTRANSTION not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_SINECURVE) { - ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType SINECURVE not supported")); + logger.warning(std::string("mapping of AlignmentCantSegmentType SINECURVE not supported")); } else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_VIENNESEBEND) { - ::logger::root().warning(std::string("mapping of AlignmentCantSegmentType VIENNESEBEND not supported")); + logger.warning(std::string("mapping of AlignmentCantSegmentType VIENNESEBEND not supported")); } else { - ::logger::root().error(std::string("unexpected AlignmentCantSegmentType encountered")); + logger.error(std::string("unexpected AlignmentCantSegmentType encountered")); } return result; }