Skip to content

Commit 2b1b79b

Browse files
committed
Make occt optional
1 parent cb35378 commit 2b1b79b

28 files changed

+187
-134
lines changed

cmake/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ endif()
170170
if (NOT MINIMAL_BUILD)
171171
if (WITH_CGAL)
172172
add_definitions(-DIFOPSH_WITH_CGAL)
173+
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_CGAL)
173174
list(APPEND GEOMETRY_KERNELS cgal)
174175
endif()
175176
endif()
176177

177178
if (WITH_OPENCASCADE)
178179
add_definitions(-DIFOPSH_WITH_OPENCASCADE)
180+
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_OPENCASCADE)
179181
list(APPEND GEOMETRY_KERNELS opencascade)
180182
endif()
181183

@@ -859,7 +861,7 @@ set_target_properties(Serializers PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS $
859861

860862
TARGET_LINK_LIBRARIES(Serializers ${SERIALIZER_SCHEMA_LIBRARIES} ${OPENCOLLADA_LIBRARIES})
861863

862-
endif(BUILD_CONVERT or BUILD_IFCPYTHON)
864+
endif()
863865

864866
if (BUILD_CONVERT)
865867

@@ -888,7 +890,7 @@ INSTALL(TARGETS IfcConvert
888890
endif(BUILD_CONVERT)
889891

890892
# IfcGeomServer
891-
if(NOT MINIMAL_BUILD AND BUILD_GEOMSERVER)
893+
if(NOT MINIMAL_BUILD AND BUILD_GEOMSERVER AND WITH_OPENCASCADE)
892894

893895
file(GLOB CPP_FILES ../src/ifcgeomserver/*.cpp)
894896
file(GLOB H_FILES ../src/ifcgeomserver/*.h)

src/examples/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ ADD_EXECUTABLE(IfcParseExamples IfcParseExamples.cpp)
2121
TARGET_LINK_LIBRARIES(IfcParseExamples IfcParse)
2222
set_target_properties(IfcParseExamples PROPERTIES FOLDER Examples)
2323

24+
if (WITH_OPENCASCADE)
25+
2426
ADD_EXECUTABLE(IfcOpenHouse IfcOpenHouse.cpp)
2527
TARGET_LINK_LIBRARIES(IfcOpenHouse ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES})
2628
set_target_properties(IfcOpenHouse PROPERTIES FOLDER Examples)
2729

2830
ADD_EXECUTABLE(IfcAdvancedHouse IfcAdvancedHouse.cpp)
2931
TARGET_LINK_LIBRARIES(IfcAdvancedHouse ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES})
3032
set_target_properties(IfcAdvancedHouse PROPERTIES FOLDER Examples)
33+
34+
endif()
35+

src/ifcconvert/IfcConvert.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,24 @@
4141

4242
#include "../ifcparse/utils.h"
4343

44+
#ifdef IFOPSH_WITH_OPENCASCADE
45+
4446
#include <Standard_Version.hxx>
4547

4648
#if OCC_VERSION_HEX < 0x60900
4749
#include <IGESControl_Controller.hxx>
4850
#endif
4951

52+
#endif
53+
5054
#include <boost/program_options.hpp>
5155
#include <boost/make_shared.hpp>
5256

5357
#include <fstream>
5458
#include <sstream>
5559
#include <set>
5660
#include <time.h>
61+
#include <iomanip>
5762

5863
#if USE_VLD
5964
#include <vld.h>
@@ -86,7 +91,11 @@ namespace po = boost::program_options;
8691

8792
void print_version()
8893
{
89-
cout_ << "IfcOpenShell IfcConvert " << IFCOPENSHELL_VERSION << " (OCC " << OCC_VERSION_STRING_EXT << ")\n";
94+
cout_ << "IfcOpenShell IfcConvert " << IFCOPENSHELL_VERSION;
95+
#ifdef IFOPSH_WITH_OPENCASCADE
96+
cout_ << " (OCC " << OCC_VERSION_STRING_EXT << ")";
97+
#endif
98+
cout_ << "\n";
9099
}
91100

92101
void print_usage(bool suggest_help = true)
@@ -383,7 +392,9 @@ int main(int argc, char** argv) {
383392
std::string section_ref, elevation_ref, elevation_ref_guid;
384393
// "none", "full" or "left"
385394
std::string storey_height_display;
395+
#ifdef IFOPSH_WITH_OPENCASCADE
386396
SvgSerializer::storey_height_display_types svg_storey_height_display = SvgSerializer::SH_NONE;
397+
#endif
387398

388399
po::options_description serializer_options("Serialization options");
389400
serializer_options.add_options()
@@ -549,6 +560,7 @@ int main(int argc, char** argv) {
549560
return EXIT_FAILURE;
550561
}
551562

563+
#ifdef IFOPSH_WITH_OPENCASCADE
552564
if (vmap.count("draw-storey-heights")) {
553565
boost::to_lower(storey_height_display);
554566

@@ -564,6 +576,7 @@ int main(int argc, char** argv) {
564576
return EXIT_FAILURE;
565577
}
566578
}
579+
#endif
567580

568581
if (vmap.count("log-format") == 1) {
569582
boost::to_lower(log_format);
@@ -861,6 +874,7 @@ int main(int argc, char** argv) {
861874
} else if (output_extension == GLB) {
862875
serializer = boost::make_shared<GltfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), settings);
863876
#endif
877+
#ifdef IFOPSH_WITH_OPENCASCADE
864878
} else if (output_extension == STP) {
865879
serializer = boost::make_shared<StepSerializer>(IfcUtil::path::to_utf8(output_temp_filename), settings);
866880
} else if (output_extension == IGS) {
@@ -872,15 +886,13 @@ int main(int argc, char** argv) {
872886
} else if (output_extension == SVG) {
873887
settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true);
874888
serializer = boost::make_shared<SvgSerializer>(IfcUtil::path::to_utf8(output_temp_filename), settings);
875-
}
876889
#ifdef WITH_HDF5
877-
else if (output_extension == HDF) {
890+
} else if (output_extension == HDF) {
878891
settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true);
879892
serializer = boost::make_shared<HdfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), settings);
880-
}
881893
#endif
882-
883-
else {
894+
#endif
895+
} else {
884896
cerr_ << "[Error] Unknown output filename extension '" << output_extension << "'\n";
885897
write_log(!quiet);
886898
print_usage();
@@ -1003,7 +1015,7 @@ int main(int argc, char** argv) {
10031015

10041016
IfcGeom::Iterator context_iterator(geometry_kernel, settings, ifc_file, filter_funcs, num_threads);
10051017

1006-
#ifdef WITH_HDF5
1018+
#if defined(WITH_HDF5) && defined(IFOPSH_WITH_OPENCASCADE)
10071019
std::unique_ptr<HdfSerializer> cache;
10081020
if (vmap.count("cache-file") || vmap.count("cache")) {
10091021
if (!vmap.count("cache-file")) {
@@ -1028,6 +1040,7 @@ int main(int argc, char** argv) {
10281040

10291041
serializer->setFile(context_iterator.file());
10301042

1043+
#ifdef IFOPSH_WITH_OPENCASCADE
10311044
if (output_extension == SVG) {
10321045
if (vmap.count("section-height-from-storeys") != 0) {
10331046
if (vmap.count("section-height")) {
@@ -1099,6 +1112,7 @@ int main(int argc, char** argv) {
10991112
);
11001113
}
11011114
}
1115+
#endif
11021116

11031117
if (convert_back_units) {
11041118
serializer->setUnitNameAndMagnitude(context_iterator.unit_name(), static_cast<float>(context_iterator.unit_magnitude()));

src/ifcgeom/AbstractKernel.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "AbstractKernel.h"
22

33
#include "../ifcgeom/IfcGeomElement.h"
4+
#include "../ifcgeom/ConversionSettings.h"
45

56
#ifdef IFOPSH_WITH_OPENCASCADE
67
#include "../ifcgeom/kernels/opencascade/OpenCascadeKernel.h"
@@ -11,6 +12,8 @@
1112
#include "../ifcgeom/kernels/cgal/CgalKernel.h"
1213
#endif
1314

15+
using namespace ifcopenshell::geometry;
16+
1417
bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::item* item, IfcGeom::ConversionResults& results) {
1518
// std::stringstream ss;
1619
// item->print(ss);

src/ifcgeom/ConversionResult.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
#include "../ifcgeom/IteratorSettings.h"
2525
#include "../ifcgeom/taxonomy.h"
2626

27-
#include <gp_GTrsf.hxx>
28-
#include <TopoDS_Shape.hxx>
29-
3027
#include <vector>
3128

3229
namespace IfcGeom {

src/ifcgeom/Converter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
4545
}
4646

4747
if (settings_.get(IfcGeom::IteratorSettings::APPLY_LAYERSETS)) {
48-
TopoDS_Shape merge;
49-
5048
ifcopenshell::geometry::layerset_information layerinfo;
5149
std::vector<ifcopenshell::geometry::endpoint_connection> neighbours;
5250
std::map<IfcUtil::IfcBaseEntity*, ifcopenshell::geometry::layerset_information> neigbour_layers;

0 commit comments

Comments
 (0)