From a86c333a99a667cd657c96a116fa3b5bee055ed6 Mon Sep 17 00:00:00 2001 From: Esteban DUGUEPEROUX Date: Fri, 12 Dec 2025 22:44:40 +0100 Subject: [PATCH] make: Try to build and run others examples --- .github/workflows/ci.yml | 11 ++ cmake/CMakeLists.txt | 1 + src/examples/CMakeLists.txt | 102 ++++++++++++++++++ src/examples/arbitrary_open_profile_def.cpp | 31 +++--- src/examples/composite_profile_def.cpp | 13 +-- src/examples/csg_primitive.cpp | 19 ++-- src/examples/ellipse_pies.cpp | 42 ++++---- src/examples/faces.cpp | 23 ++-- src/examples/ifc_curve_rebar.cpp | 22 ++-- src/examples/profiles.cpp | 81 +++++++------- src/examples/triangulated_faceset.cpp | 20 ++-- src/ifcgeom/Serialization/CMakeLists.txt | 2 +- .../Serialization/schema/CMakeLists.txt | 2 +- 13 files changed, 246 insertions(+), 123 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2392ecb2e..0929efbfc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -215,11 +215,22 @@ jobs: -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 + ./profiles ./IfcParseExamples "../IfcParseExamples_test.ifc" ./IfcOpenHouse ./IfcAdvancedHouse ./IfcAlignment ./IfcSimplifiedAlignment + ./triangulated_faceset + set +x - name: Test ifcopenshell-python run: | diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9e88026ac7..0fb45e42eb 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -218,6 +218,7 @@ 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 3a5c0187b5..4eda006ecc 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -35,7 +35,107 @@ 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) + + if(STANDALONE_PROJECT) + target_link_libraries(arbitrary_open_profile_def IfcOpenShell::IfcParse) + 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) + 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) + +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) @@ -48,6 +148,7 @@ if(SCHEMA_VERSIONS MATCHES "2x3") install(TARGETS IfcParseExamples) if(WITH_OPENCASCADE) + # IfcOpenHouse and IfcAdvancedHouse add_executable(IfcOpenHouse IfcOpenHouse.cpp) add_executable(IfcAdvancedHouse IfcAdvancedHouse.cpp) add_library(IfcHouseInterface INTERFACE) @@ -66,6 +167,7 @@ if(SCHEMA_VERSIONS MATCHES "2x3") endif() if(SCHEMA_VERSIONS MATCHES "4x3_add2") + # IfcAlignment and IfcSimplifiedAlignment add_executable(IfcAlignment IfcAlignment.cpp) add_executable(IfcSimplifiedAlignment IfcSimplifiedAlignment.cpp) add_library(IfcAlignmentInterface INTERFACE) diff --git a/src/examples/arbitrary_open_profile_def.cpp b/src/examples/arbitrary_open_profile_def.cpp index 45495736d5..5393af53ae 100644 --- a/src/examples/arbitrary_open_profile_def.cpp +++ b/src/examples/arbitrary_open_profile_def.cpp @@ -28,16 +28,16 @@ #include #include -#include "../ifcparse/Ifc2x3.h" -#include "../ifcparse/IfcUtil.h" -#include "../ifcparse/IfcHierarchyHelper.h" +#define IfcSchema Ifc4 +#include "ifcparse/Ifc4.h" +#include "ifcparse/IfcHierarchyHelper.h" typedef std::string S; typedef IfcParse::IfcGlobalId guid; boost::none_t const null = boost::none; static int i = 0; -void create_product_from_item(IfcHierarchyHelper& file, IfcSchema::IfcRepresentationItem* item, const std::string& s) { +void create_product_from_item(IfcHierarchyHelper& file, IfcSchema::IfcRepresentationItem* item, const std::string& s) { IfcSchema::IfcBuildingElementProxy* product = new IfcSchema::IfcBuildingElementProxy( guid(), 0, S("product"), null, null, 0, 0, null, null); file.addBuildingProduct(product); @@ -50,7 +50,7 @@ void create_product_from_item(IfcHierarchyHelper& file, IfcSchema::IfcRepresenta items->push(item); if (s == "GeometricSet") { - IfcSchema::IfcGeometricSet* set = new IfcSchema::IfcGeometricSet(items->generalize()); + IfcSchema::IfcGeometricSet* set = new IfcSchema::IfcGeometricSet(items->as()); file.addEntity(set); items = IfcSchema::IfcRepresentationItem::list::ptr(new IfcSchema::IfcRepresentationItem::list()); items->push(set); @@ -67,7 +67,7 @@ void create_product_from_item(IfcHierarchyHelper& file, IfcSchema::IfcRepresenta product->setRepresentation(shape); } -void create_surfaces_from_profile(IfcHierarchyHelper& file, IfcSchema::IfcProfileDef* profile) { +void create_surfaces_from_profile(IfcHierarchyHelper& file, IfcSchema::IfcProfileDef* profile) { IfcSchema::IfcSurfaceOfLinearExtrusion* extrusion = new IfcSchema::IfcSurfaceOfLinearExtrusion(profile, file.addPlacement3d(), file.addTriplet(0, 0, 1), 100.); file.addEntity(extrusion); @@ -80,7 +80,7 @@ void create_surfaces_from_profile(IfcHierarchyHelper& file, IfcSchema::IfcProfil create_product_from_item(file, revolution, "GeometricSet"); } -void create_solids_from_profile(IfcHierarchyHelper& file, IfcSchema::IfcProfileDef* profile) { +void create_solids_from_profile(IfcHierarchyHelper& file, IfcSchema::IfcProfileDef* profile) { IfcSchema::IfcExtrudedAreaSolid* extrusion = new IfcSchema::IfcExtrudedAreaSolid(profile, file.addPlacement3d(), file.addTriplet(0, 0, 1), 100.); file.addEntity(extrusion); @@ -96,7 +96,7 @@ void create_solids_from_profile(IfcHierarchyHelper& file, IfcSchema::IfcProfileD create_product_from_item(file, revolution2, "SweptSolid"); } -void create_products_from_curve(IfcHierarchyHelper& file, IfcSchema::IfcBoundedCurve* curve) { +void create_products_from_curve(IfcHierarchyHelper& file, IfcSchema::IfcBoundedCurve* curve) { IfcSchema::IfcArbitraryOpenProfileDef* open = new IfcSchema::IfcArbitraryOpenProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_CURVE, null, curve); IfcSchema::IfcCenterLineProfileDef* center_line = new IfcSchema::IfcCenterLineProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, curve, 10.); file.addEntity(open); @@ -108,8 +108,8 @@ void create_products_from_curve(IfcHierarchyHelper& file, IfcSchema::IfcBoundedC int main(int argc, char** argv) { const char filename[] = "IfcArbitraryOpenProfileDef.ifc"; - IfcHierarchyHelper file; - file.header().file_name().name(filename); + IfcHierarchyHelper file; + file.header().file_name()->setname(filename); double coords1[] = {-50.0, 0.0}; double coords2[] = { 50.0, 0.0}; @@ -124,17 +124,18 @@ int main(int argc, char** argv) { IfcSchema::IfcEllipse* ellipse = new IfcSchema::IfcEllipse(file.addPlacement2d(), 50., 25.); file.addEntity(ellipse); - IfcEntityList::ptr trim1(new IfcEntityList); - IfcEntityList::ptr trim2(new IfcEntityList); + aggregate_of_instance::ptr trim1(new aggregate_of_instance); + aggregate_of_instance::ptr trim2(new aggregate_of_instance); trim1->push(new IfcSchema::IfcParameterValue( 0.)); trim2->push(new IfcSchema::IfcParameterValue(180.)); - IfcSchema::IfcTrimmedCurve* trim = new IfcSchema::IfcTrimmedCurve(ellipse, trim1, trim2, true, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); + IfcSchema::IfcTrimmedCurve* trim = new IfcSchema::IfcTrimmedCurve(ellipse, trim1->as(), trim2->as(), true, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); file.addEntity(trim); create_products_from_curve(file, trim); - file.getSingle()->setName("IfcArbitraryOpenProfileDef"); + using namespace std::string_literals; + file.getSingle()->setName("IfcArbitraryOpenProfileDef"s); std::ofstream f(filename); f << file; -} +} \ No newline at end of file diff --git a/src/examples/composite_profile_def.cpp b/src/examples/composite_profile_def.cpp index 5ff41a3b13..3a7281be43 100644 --- a/src/examples/composite_profile_def.cpp +++ b/src/examples/composite_profile_def.cpp @@ -27,9 +27,9 @@ #include #include -#include "../ifcparse/Ifc2x3.h" -#include "../ifcparse/IfcUtil.h" -#include "../ifcparse/IfcHierarchyHelper.h" +#define IfcSchema Ifc2x3 +#include "ifcparse/Ifc2x3.h" +#include "ifcparse/IfcHierarchyHelper.h" typedef std::string S; typedef IfcParse::IfcGlobalId guid; @@ -37,8 +37,8 @@ boost::none_t const null = boost::none; int main(int argc, char** argv) { const char filename[] = "IfcCompositeProfileDef.ifc"; - IfcHierarchyHelper file; - file.header().file_name().name(filename); + IfcHierarchyHelper file; + file.header().file_name()->setname(filename); double coords1[] = {100.0, 0.0}; double coords2[] = {200.0, 0.0}; @@ -112,7 +112,8 @@ int main(int argc, char** argv) { product->setRepresentation(shape); - file.getSingle()->setName("IfcCompositeProfileDef"); + using namespace std::string_literals; + file.getSingle()->setName("IfcCompositeProfileDef"s); std::ofstream f(filename); f << file; diff --git a/src/examples/csg_primitive.cpp b/src/examples/csg_primitive.cpp index 190236ed6b..b157281402 100644 --- a/src/examples/csg_primitive.cpp +++ b/src/examples/csg_primitive.cpp @@ -27,9 +27,9 @@ #include #include -#include "../ifcparse/Ifc2x3.h" -#include "../ifcparse/IfcUtil.h" -#include "../ifcparse/IfcHierarchyHelper.h" +#define IfcSchema Ifc2x3 +#include "ifcparse/Ifc2x3.h" +#include "ifcparse/IfcHierarchyHelper.h" typedef std::string S; typedef IfcParse::IfcGlobalId guid; @@ -101,7 +101,7 @@ public: return operate(OP_INTERSECT, p); } - IfcSchema::IfcRepresentationItem* serialize(IfcHierarchyHelper& file) const { + IfcSchema::IfcRepresentationItem* serialize(IfcHierarchyHelper& file) const { IfcSchema::IfcRepresentationItem* my; if (op == OP_TERMINAL) { IfcSchema::IfcAxis2Placement3D* place = file.addPlacement3d(x,y,z,zx,zy,zz,xx,xy,xz); @@ -117,7 +117,7 @@ public: my = new IfcSchema::IfcRightCircularCone(place, b, a); } } else { - IfcSchema::IfcBooleanOperator::IfcBooleanOperator o; + IfcSchema::IfcBooleanOperator o = IfcSchema::IfcBooleanOperator::IfcBooleanOperator_UNION; if (op == OP_ADD) { o = IfcSchema::IfcBooleanOperator::IfcBooleanOperator_UNION; } else if (op == OP_SUBTRACT) { @@ -125,7 +125,7 @@ public: } else if (op == OP_INTERSECT) { o = IfcSchema::IfcBooleanOperator::IfcBooleanOperator_INTERSECTION; } - my = new IfcSchema::IfcBooleanResult(o, left->serialize(file), right->serialize(file)); + my = new IfcSchema::IfcBooleanResult(o, left->serialize(file)->as(), right->serialize(file)->as()); } file.addEntity(my); return my; @@ -134,8 +134,8 @@ public: int main(int argc, char** argv) { const char filename[] = "IfcCsgPrimitive.ifc"; - IfcHierarchyHelper file; - file.header().file_name().name(filename); + IfcHierarchyHelper file; + file.header().file_name()->setname(filename); IfcSchema::IfcRepresentationItem* csg1 = Node::Box(8000.,6000.,3000.).subtract( Node::Box(7600.,5600.,2800.).move(200.,200.,200.) @@ -186,7 +186,8 @@ int main(int argc, char** argv) { product->setRepresentation(shape); - file.getSingle()->setName("IfcCompositeProfileDef"); + using namespace std::string_literals; + file.getSingle()->setName("IfcCompositeProfileDef"s); std::ofstream f(filename); f << file; diff --git a/src/examples/ellipse_pies.cpp b/src/examples/ellipse_pies.cpp index 9994ca820d..8128c4377c 100644 --- a/src/examples/ellipse_pies.cpp +++ b/src/examples/ellipse_pies.cpp @@ -27,9 +27,9 @@ #include #include -#include "../ifcparse/Ifc2x3.h" -#include "../ifcparse/IfcUtil.h" -#include "../ifcparse/IfcHierarchyHelper.h" +#define IfcSchema Ifc2x3 +#include "ifcparse/Ifc2x3.h" +#include "ifcparse/IfcHierarchyHelper.h" typedef std::string S; typedef IfcParse::IfcGlobalId guid; @@ -44,7 +44,7 @@ typedef struct { static int i = 0; -void create_testcase_for(IfcHierarchyHelper& file, const EllipsePie& pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference pref) { +void create_testcase_for(IfcHierarchyHelper& file, const EllipsePie& pie, IfcSchema::IfcTrimmingPreference pref) { const double deg = 1. / 180. * 3.141592653; double flt1[] = {0. , 0. }; double flt2[] = {pie.r1 * cos(pie.t1*deg), pie.r2 * sin(pie.t1*deg)}; @@ -67,16 +67,16 @@ void create_testcase_for(IfcHierarchyHelper& file, const EllipsePie& pie, Ifc2x3 Ifc2x3::IfcEllipse* ellipse = new Ifc2x3::IfcEllipse(file.addPlacement2d(), pie.r1, pie.r2); file.addEntity(ellipse); - IfcEntityList::ptr trim1(new IfcEntityList); - IfcEntityList::ptr trim2(new IfcEntityList); - if (pref == Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER) { + aggregate_of_instance::ptr trim1(new aggregate_of_instance); + aggregate_of_instance::ptr trim2(new aggregate_of_instance); + if (pref == IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER) { trim1->push(new Ifc2x3::IfcParameterValue(pie.t1)); trim2->push(new Ifc2x3::IfcParameterValue(pie.t2)); } else { trim1->push(p2); trim2->push(p3); } - Ifc2x3::IfcTrimmedCurve* trim = new Ifc2x3::IfcTrimmedCurve(ellipse, trim1, trim2, true, pref); + Ifc2x3::IfcTrimmedCurve* trim = new Ifc2x3::IfcTrimmedCurve(ellipse, trim1->as(), trim2->as(), true, pref); file.addEntity(trim); Ifc2x3::IfcCompositeCurveSegment::list::ptr segments(new Ifc2x3::IfcCompositeCurveSegment::list()); @@ -124,25 +124,25 @@ void create_testcase_for(IfcHierarchyHelper& file, const EllipsePie& pie, Ifc2x3 int main(int argc, char** argv) { const std::string filename = "ellipse_pies.ifc"; - IfcHierarchyHelper file; + IfcHierarchyHelper file; { EllipsePie pie = {80., 50., 0., 150.}; - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} { EllipsePie pie = {80, 50., 30., 300.}; - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} { EllipsePie pie = {80, 50., 300., 30.}; - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} { EllipsePie pie = {50., 80., 0., 150.}; - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} { EllipsePie pie = {50, 80., 30., 300.}; - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} { EllipsePie pie = {50, 80., 300., 30.}; - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); - create_testcase_for(file, pie, Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); + create_testcase_for(file, pie, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN);} std::ofstream f(filename.c_str()); f << file; } diff --git a/src/examples/faces.cpp b/src/examples/faces.cpp index 985b23dd8e..f7e3858c58 100644 --- a/src/examples/faces.cpp +++ b/src/examples/faces.cpp @@ -22,18 +22,19 @@ * Example that generates various forms of IfcFace * * * ********************************************************************************/ +#include -#include "../ifcparse/Ifc2x3.h" -#include "../ifcparse/IfcUtil.h" -#include "../ifcparse/IfcHierarchyHelper.h" +#define IfcSchema Ifc2x3 +#include "ifcparse/Ifc2x3.h" +#include "ifcparse/IfcHierarchyHelper.h" typedef std::string S; typedef IfcParse::IfcGlobalId guid; -boost::none_t const null = (static_cast(0)); +boost::none_t const null = boost::none; static int x = 0; -void create_testcase(IfcHierarchyHelper& file, IfcSchema::IfcFace* face, const std::string& name) { +void create_testcase(IfcHierarchyHelper& file, IfcSchema::IfcFace* face, const std::string& name) { IfcSchema::IfcFace::list::ptr faces(new IfcSchema::IfcFace::list); faces->push(face); IfcSchema::IfcOpenShell* shell = new IfcSchema::IfcOpenShell(faces); @@ -57,14 +58,14 @@ void create_testcase(IfcHierarchyHelper& file, IfcSchema::IfcFace* face, const s file.getRepresentationContext("Model"), S("Body"), S("SurfaceModel"), items); reps->push(rep); - IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(0, 0, reps); + IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(boost::none, boost::none, reps); file.addEntity(shape); product->setRepresentation(shape); } int main(int argc, char** argv) { - IfcHierarchyHelper file; + IfcHierarchyHelper file; { IfcSchema::IfcCartesianPoint::list::ptr points (new IfcSchema::IfcCartesianPoint::list); points->push(file.addTriplet(-400, -400, 0)); @@ -192,7 +193,7 @@ int main(int argc, char** argv) { IfcSchema::IfcCartesianPoint::list::ptr trim2(new IfcSchema::IfcCartesianPoint::list); trim1->push(point1); trim2->push(point2); - IfcSchema::IfcTrimmedCurve* trimmed_curve = new IfcSchema::IfcTrimmedCurve(circle, trim1->generalize(), trim2->generalize(), true, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN); + IfcSchema::IfcTrimmedCurve* trimmed_curve = new IfcSchema::IfcTrimmedCurve(circle, trim1->generalize()->as(), trim2->generalize()->as(), true, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN); IfcSchema::IfcArbitraryOpenProfileDef* profile = new IfcSchema::IfcArbitraryOpenProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_CURVE, boost::none, trimmed_curve); IfcSchema::IfcAxis1Placement* place = new IfcSchema::IfcAxis1Placement(file.addTriplet(0., 0., 0.), file.addTriplet(1., 0., 0.)); IfcSchema::IfcSurfaceOfRevolution* surface = new IfcSchema::IfcSurfaceOfRevolution(profile, file.addPlacement3d(), place); @@ -200,8 +201,8 @@ int main(int argc, char** argv) { IfcSchema::IfcFace* face = new IfcSchema::IfcFaceSurface(bounds, surface, true); create_testcase(file, face, "face surface"); } - const std::string filename = "faces.ifc"; - file.header().file_name().name(filename); - std::ofstream f(filename.c_str()); + const char filename[] = "faces.ifc"; + file.header().file_name()->setname(filename); + std::ofstream f(filename); f << file; } \ No newline at end of file diff --git a/src/examples/ifc_curve_rebar.cpp b/src/examples/ifc_curve_rebar.cpp index 2ba269e015..4e674d5e95 100644 --- a/src/examples/ifc_curve_rebar.cpp +++ b/src/examples/ifc_curve_rebar.cpp @@ -27,16 +27,15 @@ #include #include -#include "ifcparse\Ifc2x3.h" -#include "ifcparse\IfcUtil.h" -#include "ifcparse\IfcHierarchyHelper.h" -#include "ifcgeom\IfcGeom.h" +#define IfcSchema Ifc2x3 +#include "ifcparse/Ifc2x3.h" +#include "ifcparse/IfcHierarchyHelper.h" typedef std::string S; typedef IfcParse::IfcGlobalId guid; boost::none_t const null = boost::none; -void create_curve_rebar(IfcHierarchyHelper& file) +void create_curve_rebar(IfcHierarchyHelper& file) { int dia = 24; int R = 3 * dia; @@ -83,15 +82,16 @@ void create_curve_rebar(IfcHierarchyHelper& file) IfcSchema::IfcCircle* circle = new IfcSchema::IfcCircle(axis1, R); file.addEntity(circle); - IfcEntityList::ptr trim1(new IfcEntityList); - IfcEntityList::ptr trim2(new IfcEntityList); - + aggregate_of_instance::ptr trim1(new aggregate_of_instance); + aggregate_of_instance::ptr trim2(new aggregate_of_instance); + trim1->push(new IfcSchema::IfcParameterValue(180)); trim1->push(p2); trim2->push(new IfcSchema::IfcParameterValue(270)); trim2->push(p4); - IfcSchema::IfcTrimmedCurve* trimmed_curve = new IfcSchema::IfcTrimmedCurve(circle, trim1, trim2, false, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); + + IfcSchema::IfcTrimmedCurve* trimmed_curve = new IfcSchema::IfcTrimmedCurve(circle, trim1->as(), trim2->as(), false, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); file.addEntity(trimmed_curve); IfcSchema::IfcCompositeCurveSegment* segment2 = new IfcSchema::IfcCompositeCurveSegment(IfcSchema::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT, false, trimmed_curve); @@ -133,8 +133,8 @@ void create_curve_rebar(IfcHierarchyHelper& file) int main() { - IfcHierarchyHelper file; - file.header().file_name().name("ifc_curve_rebar.ifc"); + IfcHierarchyHelper file; + file.header().file_name()->setname("ifc_curve_rebar.ifc"); create_curve_rebar(file); std::ofstream f("ifc_curve_rebar.ifc"); f << file; diff --git a/src/examples/profiles.cpp b/src/examples/profiles.cpp index d171745dc7..78cc67f13f 100644 --- a/src/examples/profiles.cpp +++ b/src/examples/profiles.cpp @@ -27,21 +27,21 @@ #include #include -#include "../ifcparse/Ifc2x3.h" -#include "../ifcparse/IfcUtil.h" -#include "../ifcparse/IfcHierarchyHelper.h" +#define IfcSchema Ifc2x3 +#include "ifcparse/Ifc2x3.h" +#include "ifcparse/IfcHierarchyHelper.h" typedef std::string S; -typedef IfcWrite::IfcGuidHelper guid; -boost::none_t const null = (static_cast(0)); +typedef IfcParse::IfcGlobalId guid; +boost::none_t const null = boost::none; void create_testcase_for(IfcSchema::IfcProfileDef::list::ptr profiles) { IfcSchema::IfcProfileDef* profile = *profiles->begin(); - const std::string profile_type = IfcSchema::Type::ToString(profile->type()); + const std::string& profile_type = profile->declaration().name(); const std::string filename = profile_type + ".ifc"; - IfcHierarchyHelper file; - file.filename(filename); + IfcHierarchyHelper file; + file.header().file_name()->setname(filename); int i = 0; for (IfcSchema::IfcProfileDef::list::it it = profiles->begin(); it != profiles->end(); ++it, ++i) { @@ -54,7 +54,7 @@ void create_testcase_for(IfcSchema::IfcProfileDef::list::ptr profiles) { product->setObjectPlacement(file.addLocalPlacement(0, 100. * i)); - if (profile->is(IfcSchema::Type::IfcParameterizedProfileDef)) { + if (profile->declaration().is(IfcSchema::IfcParameterizedProfileDef::Class())) { ((IfcSchema::IfcParameterizedProfileDef*) profile)->setPosition(file.addPlacement2d()); } @@ -72,7 +72,7 @@ void create_testcase_for(IfcSchema::IfcProfileDef::list::ptr profiles) { file.getSingle(), S("Body"), S("SweptSolid"), items); reps->push(rep); - IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(0, 0, reps); + IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(null, null, reps); file.addEntity(rep); file.addEntity(shape); @@ -84,122 +84,123 @@ void create_testcase_for(IfcSchema::IfcProfileDef::list::ptr profiles) { } int main(int argc, char** argv) { + IfcSchema::get_schema(); // Ensure schema is initialized { IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list); - profiles->push(new Ifc2x3::IfcUShapeProfileDef( + profiles->push(new IfcSchema::IfcUShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 5.0, null, null, null, null)); - profiles->push(new Ifc2x3::IfcUShapeProfileDef( + profiles->push(new IfcSchema::IfcUShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 5.0, 2.0, 2.0, null, null)); - profiles->push(new Ifc2x3::IfcUShapeProfileDef( + profiles->push(new IfcSchema::IfcUShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 5.0, null, null, 4.0, null)); - profiles->push(new Ifc2x3::IfcUShapeProfileDef( + profiles->push(new IfcSchema::IfcUShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 5.0, 1.0, 3.0, 6.0, null)); create_testcase_for(profiles); } { IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list); - profiles->push(new Ifc2x3::IfcTShapeProfileDef( + profiles->push(new IfcSchema::IfcTShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 5.0, null, null, null, null, null, null)); - profiles->push(new Ifc2x3::IfcTShapeProfileDef( + profiles->push(new IfcSchema::IfcTShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 5.0, 2.0, 2.0, 2.0, null, null, null)); - profiles->push(new Ifc2x3::IfcTShapeProfileDef( + profiles->push(new IfcSchema::IfcTShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 5.0, null, null, null, 2.0, 2.0, null)); - profiles->push(new Ifc2x3::IfcTShapeProfileDef( + profiles->push(new IfcSchema::IfcTShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 5.0, 3.0, 2.0, 1.0, 2.0, 2.0, null)); create_testcase_for(profiles); } { IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list); - profiles->push(new Ifc2x3::IfcZShapeProfileDef( + profiles->push(new IfcSchema::IfcZShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 5.0, null, null)); - profiles->push(new Ifc2x3::IfcZShapeProfileDef( + profiles->push(new IfcSchema::IfcZShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 5.0, 2.0, 2.0)); create_testcase_for(profiles); } { IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list); - profiles->push(new Ifc2x3::IfcEllipseProfileDef( + profiles->push(new IfcSchema::IfcEllipseProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 25.0, 15.0)); - profiles->push(new Ifc2x3::IfcEllipseProfileDef( + profiles->push(new IfcSchema::IfcEllipseProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 15.0, 25.0)); create_testcase_for(profiles); } { IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list); - profiles->push(new Ifc2x3::IfcIShapeProfileDef( + profiles->push(new IfcSchema::IfcIShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 25.0, 50.0, 5.0, 5.0, null)); - profiles->push(new Ifc2x3::IfcIShapeProfileDef( + profiles->push(new IfcSchema::IfcIShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 25.0, 50.0, 5.0, 5.0, 2.0)); - profiles->push(new Ifc2x3::IfcAsymmetricIShapeProfileDef( + profiles->push(new IfcSchema::IfcAsymmetricIShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 25.0, 50.0, 5.0, 5.0, 2.0, 20.0, 10.0, 5.0, null)); create_testcase_for(profiles); } { IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list); - profiles->push(new Ifc2x3::IfcLShapeProfileDef( + profiles->push(new IfcSchema::IfcLShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, null, null, null, null, null)); - profiles->push(new Ifc2x3::IfcLShapeProfileDef( + profiles->push(new IfcSchema::IfcLShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 2.0, 2.0, null, null, null)); - profiles->push(new Ifc2x3::IfcLShapeProfileDef( + profiles->push(new IfcSchema::IfcLShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, null, null, 2.0, null, null)); - profiles->push(new Ifc2x3::IfcLShapeProfileDef( + profiles->push(new IfcSchema::IfcLShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 1.0, 2.0, 2.0, null, null)); create_testcase_for(profiles); } { IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list); - profiles->push(new Ifc2x3::IfcCShapeProfileDef( + profiles->push(new IfcSchema::IfcCShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 10.0, null, null)); - profiles->push(new Ifc2x3::IfcCShapeProfileDef( + profiles->push(new IfcSchema::IfcCShapeProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 10.0, 2.0, null)); create_testcase_for(profiles); } { IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list); - profiles->push(new Ifc2x3::IfcCircleProfileDef( + profiles->push(new IfcSchema::IfcCircleProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 25.0)); - profiles->push(new Ifc2x3::IfcCircleHollowProfileDef( + profiles->push(new IfcSchema::IfcCircleHollowProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 25.0, 5.0)); create_testcase_for(profiles); } { IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list); - profiles->push(new Ifc2x3::IfcRectangleProfileDef( + profiles->push(new IfcSchema::IfcRectangleProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0)); - profiles->push(new Ifc2x3::IfcRoundedRectangleProfileDef( + profiles->push(new IfcSchema::IfcRoundedRectangleProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0)); - profiles->push(new Ifc2x3::IfcRectangleHollowProfileDef( + profiles->push(new IfcSchema::IfcRectangleHollowProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, null, null)); - profiles->push(new Ifc2x3::IfcRectangleHollowProfileDef( + profiles->push(new IfcSchema::IfcRectangleHollowProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 25.0, 5.0, 2.0, 4.0)); create_testcase_for(profiles); } { IfcSchema::IfcProfileDef::list::ptr profiles (new IfcSchema::IfcProfileDef::list); - profiles->push(new Ifc2x3::IfcTrapeziumProfileDef( + profiles->push(new IfcSchema::IfcTrapeziumProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 30.0, 25.0, 0.0)); - profiles->push(new Ifc2x3::IfcTrapeziumProfileDef( + profiles->push(new IfcSchema::IfcTrapeziumProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 60.0, 25.0, -20.0)); - profiles->push(new Ifc2x3::IfcTrapeziumProfileDef( + profiles->push(new IfcSchema::IfcTrapeziumProfileDef( IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, 0, 50.0, 10.0, 25.0, 30.0)); create_testcase_for(profiles); } diff --git a/src/examples/triangulated_faceset.cpp b/src/examples/triangulated_faceset.cpp index acf56d60c1..f54ae4f3d0 100644 --- a/src/examples/triangulated_faceset.cpp +++ b/src/examples/triangulated_faceset.cpp @@ -23,15 +23,19 @@ * * ********************************************************************************/ -#include "../ifcparse/Ifc4.h" -#include "../ifcparse/IfcUtil.h" -#include "../ifcparse/IfcHierarchyHelper.h" +#include +#include +#include + +#define IfcSchema Ifc4 +#include "ifcparse/Ifc4.h" +#include "ifcparse/IfcHierarchyHelper.h" #include "suzanne_geometry.h" typedef std::string S; typedef IfcParse::IfcGlobalId guid; -boost::none_t const null = (static_cast(0)); +boost::none_t const null = boost::none; template std::vector< std::vector > create_vector_from_array(const T* arr, unsigned size) { @@ -50,7 +54,7 @@ std::vector< std::vector > create_vector_from_array(const T* arr, unsigned si } int main(int argc, char** argv) { - IfcHierarchyHelper file; + IfcHierarchyHelper file; IfcSchema::IfcBuildingElementProxy* product = new IfcSchema::IfcBuildingElementProxy( guid(), 0, S("Blender's Suzanne"), null, null, 0, 0, null, null); @@ -73,13 +77,13 @@ int main(int argc, char** argv) { file.getRepresentationContext("Model"), S("Body"), S("SurfaceModel"), items); reps->push(rep); - IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(0, 0, reps); + IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(boost::none, boost::none, reps); file.addEntity(shape); product->setRepresentation(shape); const std::string filename = "tesselated_faceset.ifc"; - file.header().file_name().name(filename); - std::ofstream f(filename.c_str()); + file.header().file_name()->setname(filename); + std::ofstream f(filename); f << file; } diff --git a/src/ifcgeom/Serialization/CMakeLists.txt b/src/ifcgeom/Serialization/CMakeLists.txt index 4463cabcc9..0c49136101 100644 --- a/src/ifcgeom/Serialization/CMakeLists.txt +++ b/src/ifcgeom/Serialization/CMakeLists.txt @@ -1,6 +1,6 @@ add_subdirectory(schema) -add_library(geometry_serializer STATIC Serialization.cpp) +add_library(geometry_serializer Serialization.cpp) file(GLOB IFCGEOM_SERIALIZATION_H_FILE *.h) set_target_properties( diff --git a/src/ifcgeom/Serialization/schema/CMakeLists.txt b/src/ifcgeom/Serialization/schema/CMakeLists.txt index b6daf97cd9..583c177634 100644 --- a/src/ifcgeom/Serialization/schema/CMakeLists.txt +++ b/src/ifcgeom/Serialization/schema/CMakeLists.txt @@ -1,5 +1,5 @@ foreach(schema ${SCHEMA_VERSIONS}) - add_library(geometry_serializer_ifc${schema} STATIC Serialization.cpp) + add_library(geometry_serializer_ifc${schema} OBJECT Serialization.cpp) target_link_libraries(geometry_serializer_ifc${schema} ${OpenCASCADE_LIBRARIES}) set_target_properties( geometry_serializer_ifc${schema}