diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2392ecb2e..6a2fe8ce5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -209,17 +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 . + ./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 + ./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/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 3a5c0187b5..79a2399821 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -35,51 +35,41 @@ else() include_directories("${CMAKE_SOURCE_DIR}/../src") endif() -if(SCHEMA_VERSIONS MATCHES "2x3") - add_executable(IfcParseExamples IfcParseExamples.cpp) +macro(build_example exe_name) + set (additional_targets ${ARGN}) + add_executable(${exe_name} ${exe_name}.cpp) if(STANDALONE_PROJECT) - target_link_libraries(IfcParseExamples IfcOpenShell::IfcParse) + target_link_libraries(${exe_name} IfcOpenShell::IfcParse $<$:IfcOpenShell::${additional_targets}>) else() - target_include_directories(IfcParseExamples PRIVATE "${CMAKE_SOURCE_DIR}/../src") - target_link_libraries(IfcParseExamples IfcParse) - set_target_properties(IfcParseExamples 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 IfcParseExamples) + install(TARGETS ${exe_name}) +endmacro() + +if("4" IN_LIST SCHEMA_VERSIONS) + build_example(arbitrary_open_profile_def) + build_example(triangulated_faceset) +endif() + +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) - 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") - 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 45495736d5..1346c56a5d 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); @@ -107,9 +107,9 @@ 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); + const char filename[] = "arbitrary_open_profile_def.ifc"; + 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("arbitrary_open_profile_def"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..2b5f082f55 100644 --- a/src/examples/composite_profile_def.cpp +++ b/src/examples/composite_profile_def.cpp @@ -27,18 +27,18 @@ #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; 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); + const char filename[] = "composite_profile_def.ifc"; + 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("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 190236ed6b..4d805a3375 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; @@ -133,9 +133,9 @@ public: }; int main(int argc, char** argv) { - const char filename[] = "IfcCsgPrimitive.ifc"; - IfcHierarchyHelper file; - file.header().file_name().name(filename); + const char filename[] = "csg_primitive.ifc"; + 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("csg_primitive"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..81a705dc5e 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,14 +82,15 @@ 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); - + 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); trim2->push(new IfcSchema::IfcParameterValue(270)); trim2->push(p4); + IfcSchema::IfcTrimmedCurve* trimmed_curve = new IfcSchema::IfcTrimmedCurve(circle, trim1, trim2, false, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER); file.addEntity(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..18eb1c3b73 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()); + const std::string filename = "triangulated_faceset.ifc"; + 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}