From 8f3715c0f14dd2a5b49020c6e7ed1319074fc608 Mon Sep 17 00:00:00 2001 From: Esteban DUGUEPEROUX Date: Fri, 23 Jan 2026 20:41:40 +0100 Subject: [PATCH] review: Take into account remarks --- .github/workflows/ci.yml | 36 +++-- cmake/CMakeLists.txt | 1 - src/examples/CMakeLists.txt | 162 +++----------------- src/examples/IfcAlignment.cpp | 2 +- src/examples/IfcSimplifiedAlignment.cpp | 2 +- src/examples/arbitrary_open_profile_def.cpp | 4 +- src/examples/composite_profile_def.cpp | 4 +- src/examples/csg_primitive.cpp | 4 +- src/examples/ifc_curve_rebar.cpp | 6 +- src/examples/triangulated_faceset.cpp | 2 +- 10 files changed, 59 insertions(+), 164 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0929efbfc4..6a2fe8ce5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -209,28 +209,36 @@ jobs: - name: Build standalone examples to test cmake package run: | + set -x cd src/examples mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake --build . - # To display executed command - set -x - ./arbitrary_open_profile_def - ./composite_profile_def - ./csg_primitive - ./ellipse_pies - ./faces - ./ifc_curve_rebar + ./arbitrary_open_profile_def && test -f arbitrary_open_profile_def.ifc + ./composite_profile_def && test -f composite_profile_def.ifc + ./csg_primitive && test -f csg_primitive.ifc + ./ellipse_pies && test -f ellipse_pies.ifc + ./faces && test -f faces.ifc + ./ifc_curve_rebar && test -f ifc_curve_rebar.ifc ./profiles + test -f IfcUShapeProfileDef.ifc + test -f IfcTShapeProfileDef.ifc + test -f IfcZShapeProfileDef.ifc + test -f IfcEllipseProfileDef.ifc + test -f IfcIShapeProfileDef.ifc + test -f IfcLShapeProfileDef.ifc + test -f IfcCShapeProfileDef.ifc + test -f IfcCircleProfileDef.ifc + test -f IfcRectangleProfileDef.ifc + test -f IfcTrapeziumProfileDef.ifc ./IfcParseExamples "../IfcParseExamples_test.ifc" - ./IfcOpenHouse - ./IfcAdvancedHouse - ./IfcAlignment - ./IfcSimplifiedAlignment - ./triangulated_faceset - set +x + ./IfcOpenHouse && test -f IfcOpenHouse.ifc + ./IfcAdvancedHouse && test -f IfcAdvancedHouse.ifc + ./IfcAlignment && test -f IfcAlignment.ifc + ./IfcSimplifiedAlignment && test -f IfcSimplifiedAlignment.ifc + ./triangulated_faceset && test -f triangulated_faceset.ifc - name: Test ifcopenshell-python run: | diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 0fb45e42eb..9e88026ac7 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -218,7 +218,6 @@ if(BUILD_IFCGEOM AND WITH_OPENCASCADE) find_package(OpenCASCADE REQUIRED) add_definitions(-DIFOPSH_WITH_OPENCASCADE) set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_OPENCASCADE) - # set(OPENCASCADE_LIBRARIES ${OpenCASCADE_LIBRARIES}) list(APPEND GEOMETRY_KERNELS opencascade) endif() diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 4eda006ecc..79a2399821 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -35,153 +35,41 @@ else() include_directories("${CMAKE_SOURCE_DIR}/../src") endif() -if(SCHEMA_VERSIONS MATCHES "4") - # arbitrary_open_profile_def - add_executable(arbitrary_open_profile_def arbitrary_open_profile_def.cpp) +macro(build_example exe_name) + set (additional_targets ${ARGN}) + add_executable(${exe_name} ${exe_name}.cpp) if(STANDALONE_PROJECT) - target_link_libraries(arbitrary_open_profile_def IfcOpenShell::IfcParse) + target_link_libraries(${exe_name} IfcOpenShell::IfcParse $<$:IfcOpenShell::${additional_targets}>) else() - target_include_directories(arbitrary_open_profile_def PRIVATE "${CMAKE_SOURCE_DIR}/../src") - target_link_libraries(arbitrary_open_profile_def IfcParse) - set_target_properties(arbitrary_open_profile_def PROPERTIES FOLDER Examples) + target_include_directories(${exe_name} PRIVATE "${CMAKE_SOURCE_DIR}/../src") + target_link_libraries(${exe_name} IfcParse ${additional_targets}) + set_target_properties(${exe_name} PROPERTIES FOLDER Examples) endif() - install(TARGETS arbitrary_open_profile_def) - - # triangulated_faceset - add_executable(triangulated_faceset triangulated_faceset.cpp) - - if(STANDALONE_PROJECT) - target_link_libraries(triangulated_faceset IfcOpenShell::IfcParse) - else() - target_include_directories(triangulated_faceset PRIVATE "${CMAKE_SOURCE_DIR}/../src") - target_link_libraries(triangulated_faceset IfcParse) - set_target_properties(triangulated_faceset PROPERTIES FOLDER Examples) - endif() - install(TARGETS triangulated_faceset) + install(TARGETS ${exe_name}) +endmacro() +if("4" IN_LIST SCHEMA_VERSIONS) + build_example(arbitrary_open_profile_def) + build_example(triangulated_faceset) endif() -if(SCHEMA_VERSIONS MATCHES "2x3") - # composite_profile_def.cpp - add_executable(composite_profile_def composite_profile_def.cpp) - - if(STANDALONE_PROJECT) - target_link_libraries(composite_profile_def IfcOpenShell::IfcParse) - else() - target_include_directories(composite_profile_def PRIVATE "${CMAKE_SOURCE_DIR}/../src") - target_link_libraries(composite_profile_def IfcParse) - set_target_properties(composite_profile_def PROPERTIES FOLDER Examples) - endif() - install(TARGETS composite_profile_def) - - # csg_primitive - add_executable(csg_primitive csg_primitive.cpp) - - if(STANDALONE_PROJECT) - target_link_libraries(csg_primitive IfcOpenShell::IfcParse) - else() - target_include_directories(csg_primitive PRIVATE "${CMAKE_SOURCE_DIR}/../src") - target_link_libraries(csg_primitive IfcParse) - set_target_properties(csg_primitive PROPERTIES FOLDER Examples) - endif() - install(TARGETS csg_primitive) - - # ellipse_pies - add_executable(ellipse_pies ellipse_pies.cpp) - - if(STANDALONE_PROJECT) - target_link_libraries(ellipse_pies IfcOpenShell::IfcParse) - else() - target_include_directories(ellipse_pies PRIVATE "${CMAKE_SOURCE_DIR}/../src") - target_link_libraries(ellipse_pies IfcParse) - set_target_properties(ellipse_pies PROPERTIES FOLDER Examples) - endif() - install(TARGETS ellipse_pies) - - # faces - add_executable(faces faces.cpp) - - if(STANDALONE_PROJECT) - target_link_libraries(faces IfcOpenShell::IfcParse) - else() - target_include_directories(faces PRIVATE "${CMAKE_SOURCE_DIR}/../src") - target_link_libraries(faces IfcParse) - set_target_properties(faces PROPERTIES FOLDER Examples) - endif() - install(TARGETS faces) - - # ifc_curve_rebar - add_executable(ifc_curve_rebar ifc_curve_rebar.cpp) - - if(STANDALONE_PROJECT) - target_link_libraries(ifc_curve_rebar IfcOpenShell::IfcParse) - else() - target_include_directories(ifc_curve_rebar PRIVATE "${CMAKE_SOURCE_DIR}/../src") - target_link_libraries(ifc_curve_rebar IfcParse) - set_target_properties(ifc_curve_rebar PROPERTIES FOLDER Examples) - endif() - install(TARGETS ifc_curve_rebar) - - # profiles - add_executable(profiles profiles.cpp) - - if(STANDALONE_PROJECT) - target_link_libraries(profiles IfcOpenShell::IfcParse) - else() - target_include_directories(profiles PRIVATE "${CMAKE_SOURCE_DIR}/../src") - target_link_libraries(profiles IfcParse) - set_target_properties(profiles PROPERTIES FOLDER Examples) - endif() - install(TARGETS profiles) - - # IfcParseExamples - add_executable(IfcParseExamples IfcParseExamples.cpp) - - if(STANDALONE_PROJECT) - target_link_libraries(IfcParseExamples IfcOpenShell::IfcParse) - else() - target_include_directories(IfcParseExamples PRIVATE "${CMAKE_SOURCE_DIR}/../src") - target_link_libraries(IfcParseExamples IfcParse) - set_target_properties(IfcParseExamples PROPERTIES FOLDER Examples) - endif() - install(TARGETS IfcParseExamples) +if("2x3" IN_LIST SCHEMA_VERSIONS) + build_example(composite_profile_def) + build_example(csg_primitive) + build_example(ellipse_pies) + build_example(faces) + build_example(ifc_curve_rebar) + build_example(profiles) + build_example(IfcParseExamples) if(WITH_OPENCASCADE) - # IfcOpenHouse and IfcAdvancedHouse - add_executable(IfcOpenHouse IfcOpenHouse.cpp) - add_executable(IfcAdvancedHouse IfcAdvancedHouse.cpp) - add_library(IfcHouseInterface INTERFACE) - - if(STANDALONE_PROJECT) - target_link_libraries(IfcHouseInterface INTERFACE IfcOpenShell::IfcParse IfcOpenShell::geometry_serializer) - else() - target_link_libraries(IfcHouseInterface INTERFACE IfcParse geometry_serializer) - set_target_properties(IfcOpenHouse PROPERTIES FOLDER Examples) - set_target_properties(IfcAdvancedHouse PROPERTIES FOLDER Examples) - endif() - target_link_libraries(IfcOpenHouse PRIVATE IfcHouseInterface) - target_link_libraries(IfcAdvancedHouse PRIVATE IfcHouseInterface) - install(TARGETS IfcOpenHouse IfcAdvancedHouse) + build_example(IfcOpenHouse geometry_serializer) + build_example(IfcAdvancedHouse geometry_serializer) endif() endif() -if(SCHEMA_VERSIONS MATCHES "4x3_add2") - # IfcAlignment and IfcSimplifiedAlignment - add_executable(IfcAlignment IfcAlignment.cpp) - add_executable(IfcSimplifiedAlignment IfcSimplifiedAlignment.cpp) - add_library(IfcAlignmentInterface INTERFACE) - - if(STANDALONE_PROJECT) - target_link_libraries(IfcAlignmentInterface INTERFACE IfcOpenShell::IfcParse) - else() - target_link_libraries(IfcAlignmentInterface INTERFACE IfcParse) - set_target_properties(IfcAlignment PROPERTIES FOLDER Examples) - set_target_properties(IfcSimplifiedAlignment PROPERTIES FOLDER Examples) - endif() - - target_link_libraries(IfcAlignment PRIVATE IfcAlignmentInterface) - target_link_libraries(IfcSimplifiedAlignment PRIVATE IfcAlignmentInterface) - - install(TARGETS IfcAlignment IfcSimplifiedAlignment) +if("4x3_add2" IN_LIST SCHEMA_VERSIONS) + build_example(IfcAlignment) + build_example(IfcSimplifiedAlignment) endif() diff --git a/src/examples/IfcAlignment.cpp b/src/examples/IfcAlignment.cpp index d4e3ed0348..491aef1e79 100644 --- a/src/examples/IfcAlignment.cpp +++ b/src/examples/IfcAlignment.cpp @@ -489,6 +489,6 @@ int main() { } // That's it - save the model to a file - std::ofstream ofs("FHWA_Bridge_Geometry_Alignment_Example.ifc"); + std::ofstream ofs("IfcAlignment.ifc"); ofs << file; } diff --git a/src/examples/IfcSimplifiedAlignment.cpp b/src/examples/IfcSimplifiedAlignment.cpp index bde0e59b61..1c88de4c29 100644 --- a/src/examples/IfcSimplifiedAlignment.cpp +++ b/src/examples/IfcSimplifiedAlignment.cpp @@ -159,6 +159,6 @@ int main() { } // That's it - save the model to a file - std::ofstream ofs("FHWA_Bridge_Geometry_Alignment_Example_Simplified.ifc"); + std::ofstream ofs("IfcSimplifiedAlignment.ifc"); ofs << file; } diff --git a/src/examples/arbitrary_open_profile_def.cpp b/src/examples/arbitrary_open_profile_def.cpp index 5393af53ae..1346c56a5d 100644 --- a/src/examples/arbitrary_open_profile_def.cpp +++ b/src/examples/arbitrary_open_profile_def.cpp @@ -107,7 +107,7 @@ void create_products_from_curve(IfcHierarchyHelper& file, IfcSchema:: } int main(int argc, char** argv) { - const char filename[] = "IfcArbitraryOpenProfileDef.ifc"; + const char filename[] = "arbitrary_open_profile_def.ifc"; IfcHierarchyHelper file; file.header().file_name()->setname(filename); @@ -134,7 +134,7 @@ int main(int argc, char** argv) { create_products_from_curve(file, trim); using namespace std::string_literals; - file.getSingle()->setName("IfcArbitraryOpenProfileDef"s); + file.getSingle()->setName("arbitrary_open_profile_def"s); std::ofstream f(filename); f << file; diff --git a/src/examples/composite_profile_def.cpp b/src/examples/composite_profile_def.cpp index 3a7281be43..2b5f082f55 100644 --- a/src/examples/composite_profile_def.cpp +++ b/src/examples/composite_profile_def.cpp @@ -36,7 +36,7 @@ typedef IfcParse::IfcGlobalId guid; boost::none_t const null = boost::none; int main(int argc, char** argv) { - const char filename[] = "IfcCompositeProfileDef.ifc"; + const char filename[] = "composite_profile_def.ifc"; IfcHierarchyHelper file; file.header().file_name()->setname(filename); @@ -113,7 +113,7 @@ int main(int argc, char** argv) { product->setRepresentation(shape); using namespace std::string_literals; - file.getSingle()->setName("IfcCompositeProfileDef"s); + file.getSingle()->setName("composite_profile_def"s); std::ofstream f(filename); f << file; diff --git a/src/examples/csg_primitive.cpp b/src/examples/csg_primitive.cpp index b157281402..4d805a3375 100644 --- a/src/examples/csg_primitive.cpp +++ b/src/examples/csg_primitive.cpp @@ -133,7 +133,7 @@ public: }; int main(int argc, char** argv) { - const char filename[] = "IfcCsgPrimitive.ifc"; + const char filename[] = "csg_primitive.ifc"; IfcHierarchyHelper file; file.header().file_name()->setname(filename); @@ -187,7 +187,7 @@ int main(int argc, char** argv) { product->setRepresentation(shape); using namespace std::string_literals; - file.getSingle()->setName("IfcCompositeProfileDef"s); + file.getSingle()->setName("csg_primitive"s); std::ofstream f(filename); f << file; diff --git a/src/examples/ifc_curve_rebar.cpp b/src/examples/ifc_curve_rebar.cpp index 4e674d5e95..81a705dc5e 100644 --- a/src/examples/ifc_curve_rebar.cpp +++ b/src/examples/ifc_curve_rebar.cpp @@ -82,8 +82,8 @@ void create_curve_rebar(IfcHierarchyHelper& file) IfcSchema::IfcCircle* circle = new IfcSchema::IfcCircle(axis1, R); file.addEntity(circle); - aggregate_of_instance::ptr trim1(new aggregate_of_instance); - aggregate_of_instance::ptr trim2(new aggregate_of_instance); + IfcSchema::IfcTrimmingSelect::list::ptr trim1(new IfcSchema::IfcTrimmingSelect::list); + IfcSchema::IfcTrimmingSelect::list::ptr trim2(new IfcSchema::IfcTrimmingSelect::list); trim1->push(new IfcSchema::IfcParameterValue(180)); trim1->push(p2); @@ -91,7 +91,7 @@ void create_curve_rebar(IfcHierarchyHelper& file) trim2->push(new IfcSchema::IfcParameterValue(270)); trim2->push(p4); - IfcSchema::IfcTrimmedCurve* trimmed_curve = new IfcSchema::IfcTrimmedCurve(circle, trim1->as(), trim2->as(), false, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); + IfcSchema::IfcTrimmedCurve* trimmed_curve = new IfcSchema::IfcTrimmedCurve(circle, trim1, trim2, false, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); file.addEntity(trimmed_curve); IfcSchema::IfcCompositeCurveSegment* segment2 = new IfcSchema::IfcCompositeCurveSegment(IfcSchema::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT, false, trimmed_curve); diff --git a/src/examples/triangulated_faceset.cpp b/src/examples/triangulated_faceset.cpp index f54ae4f3d0..18eb1c3b73 100644 --- a/src/examples/triangulated_faceset.cpp +++ b/src/examples/triangulated_faceset.cpp @@ -82,7 +82,7 @@ int main(int argc, char** argv) { product->setRepresentation(shape); - const std::string filename = "tesselated_faceset.ifc"; + const std::string filename = "triangulated_faceset.ifc"; file.header().file_name()->setname(filename); std::ofstream f(filename); f << file;