Skip to content

Commit a86c333

Browse files
make: Try to build and run others examples
1 parent 3983bfa commit a86c333

File tree

13 files changed

+246
-123
lines changed

13 files changed

+246
-123
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,22 @@ jobs:
215215
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
216216
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
217217
cmake --build .
218+
# To display executed command
219+
set -x
220+
./arbitrary_open_profile_def
221+
./composite_profile_def
222+
./csg_primitive
223+
./ellipse_pies
224+
./faces
225+
./ifc_curve_rebar
226+
./profiles
218227
./IfcParseExamples "../IfcParseExamples_test.ifc"
219228
./IfcOpenHouse
220229
./IfcAdvancedHouse
221230
./IfcAlignment
222231
./IfcSimplifiedAlignment
232+
./triangulated_faceset
233+
set +x
223234
224235
- name: Test ifcopenshell-python
225236
run: |

cmake/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ if(BUILD_IFCGEOM AND WITH_OPENCASCADE)
218218
find_package(OpenCASCADE REQUIRED)
219219
add_definitions(-DIFOPSH_WITH_OPENCASCADE)
220220
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_OPENCASCADE)
221+
# set(OPENCASCADE_LIBRARIES ${OpenCASCADE_LIBRARIES})
221222
list(APPEND GEOMETRY_KERNELS opencascade)
222223
endif()
223224

src/examples/CMakeLists.txt

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,107 @@ else()
3535
include_directories("${CMAKE_SOURCE_DIR}/../src")
3636
endif()
3737

38+
if(SCHEMA_VERSIONS MATCHES "4")
39+
# arbitrary_open_profile_def
40+
add_executable(arbitrary_open_profile_def arbitrary_open_profile_def.cpp)
41+
42+
if(STANDALONE_PROJECT)
43+
target_link_libraries(arbitrary_open_profile_def IfcOpenShell::IfcParse)
44+
else()
45+
target_include_directories(arbitrary_open_profile_def PRIVATE "${CMAKE_SOURCE_DIR}/../src")
46+
target_link_libraries(arbitrary_open_profile_def IfcParse)
47+
set_target_properties(arbitrary_open_profile_def PROPERTIES FOLDER Examples)
48+
endif()
49+
install(TARGETS arbitrary_open_profile_def)
50+
51+
# triangulated_faceset
52+
add_executable(triangulated_faceset triangulated_faceset.cpp)
53+
54+
if(STANDALONE_PROJECT)
55+
target_link_libraries(triangulated_faceset IfcOpenShell::IfcParse)
56+
else()
57+
target_include_directories(triangulated_faceset PRIVATE "${CMAKE_SOURCE_DIR}/../src")
58+
target_link_libraries(triangulated_faceset IfcParse)
59+
set_target_properties(triangulated_faceset PROPERTIES FOLDER Examples)
60+
endif()
61+
install(TARGETS triangulated_faceset)
62+
63+
endif()
64+
3865
if(SCHEMA_VERSIONS MATCHES "2x3")
66+
# composite_profile_def.cpp
67+
add_executable(composite_profile_def composite_profile_def.cpp)
68+
69+
if(STANDALONE_PROJECT)
70+
target_link_libraries(composite_profile_def IfcOpenShell::IfcParse)
71+
else()
72+
target_include_directories(composite_profile_def PRIVATE "${CMAKE_SOURCE_DIR}/../src")
73+
target_link_libraries(composite_profile_def IfcParse)
74+
set_target_properties(composite_profile_def PROPERTIES FOLDER Examples)
75+
endif()
76+
install(TARGETS composite_profile_def)
77+
78+
# csg_primitive
79+
add_executable(csg_primitive csg_primitive.cpp)
80+
81+
if(STANDALONE_PROJECT)
82+
target_link_libraries(csg_primitive IfcOpenShell::IfcParse)
83+
else()
84+
target_include_directories(csg_primitive PRIVATE "${CMAKE_SOURCE_DIR}/../src")
85+
target_link_libraries(csg_primitive IfcParse)
86+
set_target_properties(csg_primitive PROPERTIES FOLDER Examples)
87+
endif()
88+
install(TARGETS csg_primitive)
89+
90+
# ellipse_pies
91+
add_executable(ellipse_pies ellipse_pies.cpp)
92+
93+
if(STANDALONE_PROJECT)
94+
target_link_libraries(ellipse_pies IfcOpenShell::IfcParse)
95+
else()
96+
target_include_directories(ellipse_pies PRIVATE "${CMAKE_SOURCE_DIR}/../src")
97+
target_link_libraries(ellipse_pies IfcParse)
98+
set_target_properties(ellipse_pies PROPERTIES FOLDER Examples)
99+
endif()
100+
install(TARGETS ellipse_pies)
101+
102+
# faces
103+
add_executable(faces faces.cpp)
104+
105+
if(STANDALONE_PROJECT)
106+
target_link_libraries(faces IfcOpenShell::IfcParse)
107+
else()
108+
target_include_directories(faces PRIVATE "${CMAKE_SOURCE_DIR}/../src")
109+
target_link_libraries(faces IfcParse)
110+
set_target_properties(faces PROPERTIES FOLDER Examples)
111+
endif()
112+
install(TARGETS faces)
113+
114+
# ifc_curve_rebar
115+
add_executable(ifc_curve_rebar ifc_curve_rebar.cpp)
116+
117+
if(STANDALONE_PROJECT)
118+
target_link_libraries(ifc_curve_rebar IfcOpenShell::IfcParse)
119+
else()
120+
target_include_directories(ifc_curve_rebar PRIVATE "${CMAKE_SOURCE_DIR}/../src")
121+
target_link_libraries(ifc_curve_rebar IfcParse)
122+
set_target_properties(ifc_curve_rebar PROPERTIES FOLDER Examples)
123+
endif()
124+
install(TARGETS ifc_curve_rebar)
125+
126+
# profiles
127+
add_executable(profiles profiles.cpp)
128+
129+
if(STANDALONE_PROJECT)
130+
target_link_libraries(profiles IfcOpenShell::IfcParse)
131+
else()
132+
target_include_directories(profiles PRIVATE "${CMAKE_SOURCE_DIR}/../src")
133+
target_link_libraries(profiles IfcParse)
134+
set_target_properties(profiles PROPERTIES FOLDER Examples)
135+
endif()
136+
install(TARGETS profiles)
137+
138+
# IfcParseExamples
39139
add_executable(IfcParseExamples IfcParseExamples.cpp)
40140

41141
if(STANDALONE_PROJECT)
@@ -48,6 +148,7 @@ if(SCHEMA_VERSIONS MATCHES "2x3")
48148
install(TARGETS IfcParseExamples)
49149

50150
if(WITH_OPENCASCADE)
151+
# IfcOpenHouse and IfcAdvancedHouse
51152
add_executable(IfcOpenHouse IfcOpenHouse.cpp)
52153
add_executable(IfcAdvancedHouse IfcAdvancedHouse.cpp)
53154
add_library(IfcHouseInterface INTERFACE)
@@ -66,6 +167,7 @@ if(SCHEMA_VERSIONS MATCHES "2x3")
66167
endif()
67168

68169
if(SCHEMA_VERSIONS MATCHES "4x3_add2")
170+
# IfcAlignment and IfcSimplifiedAlignment
69171
add_executable(IfcAlignment IfcAlignment.cpp)
70172
add_executable(IfcSimplifiedAlignment IfcSimplifiedAlignment.cpp)
71173
add_library(IfcAlignmentInterface INTERFACE)

src/examples/arbitrary_open_profile_def.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
#include <iostream>
2929
#include <fstream>
3030

31-
#include "../ifcparse/Ifc2x3.h"
32-
#include "../ifcparse/IfcUtil.h"
33-
#include "../ifcparse/IfcHierarchyHelper.h"
31+
#define IfcSchema Ifc4
32+
#include "ifcparse/Ifc4.h"
33+
#include "ifcparse/IfcHierarchyHelper.h"
3434

3535
typedef std::string S;
3636
typedef IfcParse::IfcGlobalId guid;
3737
boost::none_t const null = boost::none;
3838
static int i = 0;
3939

40-
void create_product_from_item(IfcHierarchyHelper& file, IfcSchema::IfcRepresentationItem* item, const std::string& s) {
40+
void create_product_from_item(IfcHierarchyHelper<IfcSchema>& file, IfcSchema::IfcRepresentationItem* item, const std::string& s) {
4141
IfcSchema::IfcBuildingElementProxy* product = new IfcSchema::IfcBuildingElementProxy(
4242
guid(), 0, S("product"), null, null, 0, 0, null, null);
4343
file.addBuildingProduct(product);
@@ -50,7 +50,7 @@ void create_product_from_item(IfcHierarchyHelper& file, IfcSchema::IfcRepresenta
5050
items->push(item);
5151

5252
if (s == "GeometricSet") {
53-
IfcSchema::IfcGeometricSet* set = new IfcSchema::IfcGeometricSet(items->generalize());
53+
IfcSchema::IfcGeometricSet* set = new IfcSchema::IfcGeometricSet(items->as<IfcSchema::IfcGeometricSetSelect>());
5454
file.addEntity(set);
5555
items = IfcSchema::IfcRepresentationItem::list::ptr(new IfcSchema::IfcRepresentationItem::list());
5656
items->push(set);
@@ -67,7 +67,7 @@ void create_product_from_item(IfcHierarchyHelper& file, IfcSchema::IfcRepresenta
6767
product->setRepresentation(shape);
6868
}
6969

70-
void create_surfaces_from_profile(IfcHierarchyHelper& file, IfcSchema::IfcProfileDef* profile) {
70+
void create_surfaces_from_profile(IfcHierarchyHelper<IfcSchema>& file, IfcSchema::IfcProfileDef* profile) {
7171
IfcSchema::IfcSurfaceOfLinearExtrusion* extrusion = new IfcSchema::IfcSurfaceOfLinearExtrusion(profile, file.addPlacement3d(), file.addTriplet<IfcSchema::IfcDirection>(0, 0, 1), 100.);
7272
file.addEntity(extrusion);
7373

@@ -80,7 +80,7 @@ void create_surfaces_from_profile(IfcHierarchyHelper& file, IfcSchema::IfcProfil
8080
create_product_from_item(file, revolution, "GeometricSet");
8181
}
8282

83-
void create_solids_from_profile(IfcHierarchyHelper& file, IfcSchema::IfcProfileDef* profile) {
83+
void create_solids_from_profile(IfcHierarchyHelper<IfcSchema>& file, IfcSchema::IfcProfileDef* profile) {
8484
IfcSchema::IfcExtrudedAreaSolid* extrusion = new IfcSchema::IfcExtrudedAreaSolid(profile, file.addPlacement3d(), file.addTriplet<IfcSchema::IfcDirection>(0, 0, 1), 100.);
8585
file.addEntity(extrusion);
8686

@@ -96,7 +96,7 @@ void create_solids_from_profile(IfcHierarchyHelper& file, IfcSchema::IfcProfileD
9696
create_product_from_item(file, revolution2, "SweptSolid");
9797
}
9898

99-
void create_products_from_curve(IfcHierarchyHelper& file, IfcSchema::IfcBoundedCurve* curve) {
99+
void create_products_from_curve(IfcHierarchyHelper<IfcSchema>& file, IfcSchema::IfcBoundedCurve* curve) {
100100
IfcSchema::IfcArbitraryOpenProfileDef* open = new IfcSchema::IfcArbitraryOpenProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_CURVE, null, curve);
101101
IfcSchema::IfcCenterLineProfileDef* center_line = new IfcSchema::IfcCenterLineProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, curve, 10.);
102102
file.addEntity(open);
@@ -108,8 +108,8 @@ void create_products_from_curve(IfcHierarchyHelper& file, IfcSchema::IfcBoundedC
108108

109109
int main(int argc, char** argv) {
110110
const char filename[] = "IfcArbitraryOpenProfileDef.ifc";
111-
IfcHierarchyHelper file;
112-
file.header().file_name().name(filename);
111+
IfcHierarchyHelper<IfcSchema> file;
112+
file.header().file_name()->setname(filename);
113113

114114
double coords1[] = {-50.0, 0.0};
115115
double coords2[] = { 50.0, 0.0};
@@ -124,17 +124,18 @@ int main(int argc, char** argv) {
124124

125125
IfcSchema::IfcEllipse* ellipse = new IfcSchema::IfcEllipse(file.addPlacement2d(), 50., 25.);
126126
file.addEntity(ellipse);
127-
IfcEntityList::ptr trim1(new IfcEntityList);
128-
IfcEntityList::ptr trim2(new IfcEntityList);
127+
aggregate_of_instance::ptr trim1(new aggregate_of_instance);
128+
aggregate_of_instance::ptr trim2(new aggregate_of_instance);
129129
trim1->push(new IfcSchema::IfcParameterValue( 0.));
130130
trim2->push(new IfcSchema::IfcParameterValue(180.));
131-
IfcSchema::IfcTrimmedCurve* trim = new IfcSchema::IfcTrimmedCurve(ellipse, trim1, trim2, true, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER);
131+
IfcSchema::IfcTrimmedCurve* trim = new IfcSchema::IfcTrimmedCurve(ellipse, trim1->as<IfcSchema::IfcTrimmingSelect>(), trim2->as<IfcSchema::IfcTrimmingSelect>(), true, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER);
132132
file.addEntity(trim);
133133

134134
create_products_from_curve(file, trim);
135135

136-
file.getSingle<Ifc2x3::IfcProject>()->setName("IfcArbitraryOpenProfileDef");
136+
using namespace std::string_literals;
137+
file.getSingle<IfcSchema::IfcProject>()->setName("IfcArbitraryOpenProfileDef"s);
137138

138139
std::ofstream f(filename);
139140
f << file;
140-
}
141+
}

src/examples/composite_profile_def.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
#include <iostream>
2828
#include <fstream>
2929

30-
#include "../ifcparse/Ifc2x3.h"
31-
#include "../ifcparse/IfcUtil.h"
32-
#include "../ifcparse/IfcHierarchyHelper.h"
30+
#define IfcSchema Ifc2x3
31+
#include "ifcparse/Ifc2x3.h"
32+
#include "ifcparse/IfcHierarchyHelper.h"
3333

3434
typedef std::string S;
3535
typedef IfcParse::IfcGlobalId guid;
3636
boost::none_t const null = boost::none;
3737

3838
int main(int argc, char** argv) {
3939
const char filename[] = "IfcCompositeProfileDef.ifc";
40-
IfcHierarchyHelper file;
41-
file.header().file_name().name(filename);
40+
IfcHierarchyHelper<IfcSchema> file;
41+
file.header().file_name()->setname(filename);
4242

4343
double coords1[] = {100.0, 0.0};
4444
double coords2[] = {200.0, 0.0};
@@ -112,7 +112,8 @@ int main(int argc, char** argv) {
112112

113113
product->setRepresentation(shape);
114114

115-
file.getSingle<IfcSchema::IfcProject>()->setName("IfcCompositeProfileDef");
115+
using namespace std::string_literals;
116+
file.getSingle<IfcSchema::IfcProject>()->setName("IfcCompositeProfileDef"s);
116117

117118
std::ofstream f(filename);
118119
f << file;

src/examples/csg_primitive.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
#include <iostream>
2828
#include <fstream>
2929

30-
#include "../ifcparse/Ifc2x3.h"
31-
#include "../ifcparse/IfcUtil.h"
32-
#include "../ifcparse/IfcHierarchyHelper.h"
30+
#define IfcSchema Ifc2x3
31+
#include "ifcparse/Ifc2x3.h"
32+
#include "ifcparse/IfcHierarchyHelper.h"
3333

3434
typedef std::string S;
3535
typedef IfcParse::IfcGlobalId guid;
@@ -101,7 +101,7 @@ class Node {
101101
return operate(OP_INTERSECT, p);
102102
}
103103

104-
IfcSchema::IfcRepresentationItem* serialize(IfcHierarchyHelper& file) const {
104+
IfcSchema::IfcRepresentationItem* serialize(IfcHierarchyHelper<IfcSchema>& file) const {
105105
IfcSchema::IfcRepresentationItem* my;
106106
if (op == OP_TERMINAL) {
107107
IfcSchema::IfcAxis2Placement3D* place = file.addPlacement3d(x,y,z,zx,zy,zz,xx,xy,xz);
@@ -117,15 +117,15 @@ class Node {
117117
my = new IfcSchema::IfcRightCircularCone(place, b, a);
118118
}
119119
} else {
120-
IfcSchema::IfcBooleanOperator::IfcBooleanOperator o;
120+
IfcSchema::IfcBooleanOperator o = IfcSchema::IfcBooleanOperator::IfcBooleanOperator_UNION;
121121
if (op == OP_ADD) {
122122
o = IfcSchema::IfcBooleanOperator::IfcBooleanOperator_UNION;
123123
} else if (op == OP_SUBTRACT) {
124124
o = IfcSchema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE;
125125
} else if (op == OP_INTERSECT) {
126126
o = IfcSchema::IfcBooleanOperator::IfcBooleanOperator_INTERSECTION;
127127
}
128-
my = new IfcSchema::IfcBooleanResult(o, left->serialize(file), right->serialize(file));
128+
my = new IfcSchema::IfcBooleanResult(o, left->serialize(file)->as<IfcSchema::IfcBooleanOperand>(), right->serialize(file)->as<IfcSchema::IfcBooleanOperand>());
129129
}
130130
file.addEntity(my);
131131
return my;
@@ -134,8 +134,8 @@ class Node {
134134

135135
int main(int argc, char** argv) {
136136
const char filename[] = "IfcCsgPrimitive.ifc";
137-
IfcHierarchyHelper file;
138-
file.header().file_name().name(filename);
137+
IfcHierarchyHelper<IfcSchema> file;
138+
file.header().file_name()->setname(filename);
139139

140140
IfcSchema::IfcRepresentationItem* csg1 = Node::Box(8000.,6000.,3000.).subtract(
141141
Node::Box(7600.,5600.,2800.).move(200.,200.,200.)
@@ -186,7 +186,8 @@ int main(int argc, char** argv) {
186186

187187
product->setRepresentation(shape);
188188

189-
file.getSingle<IfcSchema::IfcProject>()->setName("IfcCompositeProfileDef");
189+
using namespace std::string_literals;
190+
file.getSingle<IfcSchema::IfcProject>()->setName("IfcCompositeProfileDef"s);
190191

191192
std::ofstream f(filename);
192193
f << file;

0 commit comments

Comments
 (0)