From 2b1b79bf1c7c790a85d6d6f793af5a8f4fb0bb94 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 22 Mar 2023 11:17:14 +0100 Subject: [PATCH] Make occt optional --- cmake/CMakeLists.txt | 6 +- src/examples/CMakeLists.txt | 5 + src/ifcconvert/IfcConvert.cpp | 28 ++- src/ifcgeom/AbstractKernel.cpp | 3 + src/ifcgeom/ConversionResult.h | 3 - src/ifcgeom/Converter.cpp | 2 - src/ifcgeom/IfcGeomRepresentation.cpp | 177 ++++++++++-------- src/ifcgeom/Iterator.h | 16 +- src/ifcgeom/mapping/IfcAnnotationFillArea.cpp | 4 - src/ifcgeom/mapping/IfcAxis1Placement.cpp | 2 - src/ifcgeom/mapping/IfcAxis2Placement2D.cpp | 6 - src/ifcgeom/mapping/IfcAxis2Placement3D.cpp | 5 - src/ifcgeom/mapping/IfcBlock.cpp | 2 - src/ifcgeom/mapping/IfcBooleanResult.cpp | 2 - src/ifcgeom/mapping/IfcBoundingBox.cpp | 2 - .../IfcCartesianTransformationOperator3D.cpp | 5 - src/ifcwrap/IfcGeomWrapper.i | 8 + src/ifcwrap/IfcPython.i | 12 +- src/serializers/HdfSerializer.cpp | 2 +- src/serializers/HdfSerializer.h | 2 +- src/serializers/IgesSerializer.h | 3 + .../OpenCascadeBasedSerializer.cpp | 5 + src/serializers/OpenCascadeBasedSerializer.h | 3 + src/serializers/StepSerializer.h | 5 +- src/serializers/SvgSerializer.cpp | 6 +- src/serializers/SvgSerializer.h | 3 + src/svgfill | 2 +- test/input | 2 +- 28 files changed, 187 insertions(+), 134 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 0a9429aa3b..c23c3dc37d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -170,12 +170,14 @@ endif() if (NOT MINIMAL_BUILD) if (WITH_CGAL) add_definitions(-DIFOPSH_WITH_CGAL) +set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_CGAL) list(APPEND GEOMETRY_KERNELS cgal) endif() endif() if (WITH_OPENCASCADE) add_definitions(-DIFOPSH_WITH_OPENCASCADE) +set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_OPENCASCADE) list(APPEND GEOMETRY_KERNELS opencascade) endif() @@ -859,7 +861,7 @@ set_target_properties(Serializers PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS $ TARGET_LINK_LIBRARIES(Serializers ${SERIALIZER_SCHEMA_LIBRARIES} ${OPENCOLLADA_LIBRARIES}) -endif(BUILD_CONVERT or BUILD_IFCPYTHON) +endif() if (BUILD_CONVERT) @@ -888,7 +890,7 @@ INSTALL(TARGETS IfcConvert endif(BUILD_CONVERT) # IfcGeomServer -if(NOT MINIMAL_BUILD AND BUILD_GEOMSERVER) +if(NOT MINIMAL_BUILD AND BUILD_GEOMSERVER AND WITH_OPENCASCADE) file(GLOB CPP_FILES ../src/ifcgeomserver/*.cpp) file(GLOB H_FILES ../src/ifcgeomserver/*.h) diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 535dff2910..7a1f6c717e 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -21,6 +21,8 @@ ADD_EXECUTABLE(IfcParseExamples IfcParseExamples.cpp) TARGET_LINK_LIBRARIES(IfcParseExamples IfcParse) set_target_properties(IfcParseExamples PROPERTIES FOLDER Examples) +if (WITH_OPENCASCADE) + ADD_EXECUTABLE(IfcOpenHouse IfcOpenHouse.cpp) TARGET_LINK_LIBRARIES(IfcOpenHouse ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES}) set_target_properties(IfcOpenHouse PROPERTIES FOLDER Examples) @@ -28,3 +30,6 @@ set_target_properties(IfcOpenHouse PROPERTIES FOLDER Examples) ADD_EXECUTABLE(IfcAdvancedHouse IfcAdvancedHouse.cpp) TARGET_LINK_LIBRARIES(IfcAdvancedHouse ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES}) set_target_properties(IfcAdvancedHouse PROPERTIES FOLDER Examples) + +endif() + diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index dadb10b80a..0ca7e6e185 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -41,12 +41,16 @@ #include "../ifcparse/utils.h" +#ifdef IFOPSH_WITH_OPENCASCADE + #include #if OCC_VERSION_HEX < 0x60900 #include #endif +#endif + #include #include @@ -54,6 +58,7 @@ #include #include #include +#include #if USE_VLD #include @@ -86,7 +91,11 @@ namespace po = boost::program_options; void print_version() { - cout_ << "IfcOpenShell IfcConvert " << IFCOPENSHELL_VERSION << " (OCC " << OCC_VERSION_STRING_EXT << ")\n"; + cout_ << "IfcOpenShell IfcConvert " << IFCOPENSHELL_VERSION; +#ifdef IFOPSH_WITH_OPENCASCADE + cout_ << " (OCC " << OCC_VERSION_STRING_EXT << ")"; +#endif + cout_ << "\n"; } void print_usage(bool suggest_help = true) @@ -383,7 +392,9 @@ int main(int argc, char** argv) { std::string section_ref, elevation_ref, elevation_ref_guid; // "none", "full" or "left" std::string storey_height_display; +#ifdef IFOPSH_WITH_OPENCASCADE SvgSerializer::storey_height_display_types svg_storey_height_display = SvgSerializer::SH_NONE; +#endif po::options_description serializer_options("Serialization options"); serializer_options.add_options() @@ -549,6 +560,7 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } +#ifdef IFOPSH_WITH_OPENCASCADE if (vmap.count("draw-storey-heights")) { boost::to_lower(storey_height_display); @@ -564,6 +576,7 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } } +#endif if (vmap.count("log-format") == 1) { boost::to_lower(log_format); @@ -861,6 +874,7 @@ int main(int argc, char** argv) { } else if (output_extension == GLB) { serializer = boost::make_shared(IfcUtil::path::to_utf8(output_temp_filename), settings); #endif +#ifdef IFOPSH_WITH_OPENCASCADE } else if (output_extension == STP) { serializer = boost::make_shared(IfcUtil::path::to_utf8(output_temp_filename), settings); } else if (output_extension == IGS) { @@ -872,15 +886,13 @@ int main(int argc, char** argv) { } else if (output_extension == SVG) { settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true); serializer = boost::make_shared(IfcUtil::path::to_utf8(output_temp_filename), settings); - } #ifdef WITH_HDF5 - else if (output_extension == HDF) { + } else if (output_extension == HDF) { settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true); serializer = boost::make_shared(IfcUtil::path::to_utf8(output_temp_filename), settings); - } #endif - - else { +#endif + } else { cerr_ << "[Error] Unknown output filename extension '" << output_extension << "'\n"; write_log(!quiet); print_usage(); @@ -1003,7 +1015,7 @@ int main(int argc, char** argv) { IfcGeom::Iterator context_iterator(geometry_kernel, settings, ifc_file, filter_funcs, num_threads); -#ifdef WITH_HDF5 +#if defined(WITH_HDF5) && defined(IFOPSH_WITH_OPENCASCADE) std::unique_ptr cache; if (vmap.count("cache-file") || vmap.count("cache")) { if (!vmap.count("cache-file")) { @@ -1028,6 +1040,7 @@ int main(int argc, char** argv) { serializer->setFile(context_iterator.file()); +#ifdef IFOPSH_WITH_OPENCASCADE if (output_extension == SVG) { if (vmap.count("section-height-from-storeys") != 0) { if (vmap.count("section-height")) { @@ -1099,6 +1112,7 @@ int main(int argc, char** argv) { ); } } +#endif if (convert_back_units) { serializer->setUnitNameAndMagnitude(context_iterator.unit_name(), static_cast(context_iterator.unit_magnitude())); diff --git a/src/ifcgeom/AbstractKernel.cpp b/src/ifcgeom/AbstractKernel.cpp index f038ded36e..b00e4544c1 100644 --- a/src/ifcgeom/AbstractKernel.cpp +++ b/src/ifcgeom/AbstractKernel.cpp @@ -1,6 +1,7 @@ #include "AbstractKernel.h" #include "../ifcgeom/IfcGeomElement.h" +#include "../ifcgeom/ConversionSettings.h" #ifdef IFOPSH_WITH_OPENCASCADE #include "../ifcgeom/kernels/opencascade/OpenCascadeKernel.h" @@ -11,6 +12,8 @@ #include "../ifcgeom/kernels/cgal/CgalKernel.h" #endif +using namespace ifcopenshell::geometry; + bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::item* item, IfcGeom::ConversionResults& results) { // std::stringstream ss; // item->print(ss); diff --git a/src/ifcgeom/ConversionResult.h b/src/ifcgeom/ConversionResult.h index a69b03bb65..8a5eab846a 100644 --- a/src/ifcgeom/ConversionResult.h +++ b/src/ifcgeom/ConversionResult.h @@ -24,9 +24,6 @@ #include "../ifcgeom/IteratorSettings.h" #include "../ifcgeom/taxonomy.h" -#include -#include - #include namespace IfcGeom { diff --git a/src/ifcgeom/Converter.cpp b/src/ifcgeom/Converter.cpp index 620e09ddce..64c2615938 100644 --- a/src/ifcgeom/Converter.cpp +++ b/src/ifcgeom/Converter.cpp @@ -45,8 +45,6 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe } if (settings_.get(IfcGeom::IteratorSettings::APPLY_LAYERSETS)) { - TopoDS_Shape merge; - ifcopenshell::geometry::layerset_information layerinfo; std::vector neighbours; std::map neigbour_layers; diff --git a/src/ifcgeom/IfcGeomRepresentation.cpp b/src/ifcgeom/IfcGeomRepresentation.cpp index 3d2774a37b..04de3b73cb 100644 --- a/src/ifcgeom/IfcGeomRepresentation.cpp +++ b/src/ifcgeom/IfcGeomRepresentation.cpp @@ -19,6 +19,11 @@ #include "IfcGeomRepresentation.h" +#ifdef IFOPSH_WITH_OPENCASCADE +#include "../ifcparse/IfcLogger.h" +#include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h" +#include "../ifcgeom/kernels/opencascade/base_utils.h" + #include #include #include @@ -28,49 +33,6 @@ #include #include -#include "../ifcparse/IfcLogger.h" -#include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h" -#include "../ifcgeom/kernels/opencascade/base_utils.h" - -IfcGeom::Representation::Serialization::Serialization(const BRep& brep) - : Representation(brep.settings()) - , id_(brep.id()) -{ - ConversionResultShape* shape = brep.as_compound(); - TopoDS_Compound compound = TopoDS::Compound(((ifcopenshell::geometry::OpenCascadeShape*)shape)->shape()); - delete shape; - - for (auto it = brep.begin(); it != brep.end(); ++it) { - int sid = -1; - - if (it->hasStyle()) { - const auto& clr = it->Style().diffuse.ccomponents(); - surface_styles_.push_back(clr(0)); - surface_styles_.push_back(clr(1)); - surface_styles_.push_back(clr(2)); - - sid = it->Style().instance ? it->Style().instance->data().id() : -1; - } else { - surface_styles_.push_back(-1.); - surface_styles_.push_back(-1.); - surface_styles_.push_back(-1.); - } - - if (it->hasStyle() && it->Style().has_transparency()) { - surface_styles_.push_back(1. - it->Style().transparency); - } else { - surface_styles_.push_back(1.); - } - - surface_style_ids_.push_back(sid); - } - - std::stringstream sstream; - BRepTools::Write(compound,sstream); - brep_data_ = sstream.str(); -} - -// todo copied from kernel #include #include @@ -95,41 +57,6 @@ TopoDS_Shape apply_transformation(const TopoDS_Shape& s, const gp_GTrsf& t) { } } -IfcGeom::ConversionResultShape* IfcGeom::Representation::BRep::as_compound(bool force_meters) const { - TopoDS_Compound compound; - BRep_Builder builder; - builder.MakeCompound(compound); - - for (auto it = begin(); it != end(); ++it) { - const TopoDS_Shape& s = *(ifcopenshell::geometry::OpenCascadeShape*)it->Shape(); - - // @todo, check - gp_GTrsf trsf; - if (it->Placement().components_) { - gp_Trsf tr; - const auto& m = it->Placement().ccomponents(); - tr.SetValues( - m(0, 0), m(0, 1), m(0, 2), m(0, 3), - m(1, 0), m(1, 1), m(1, 2), m(1, 3), - m(2, 0), m(2, 1), m(2, 2), m(2, 3) - ); - trsf = tr; - } - - if (!force_meters && settings().get(IteratorSettings::CONVERT_BACK_UNITS)) { - gp_Trsf scale; - scale.SetScaleFactor(1.0 / settings().unit_magnitude()); - trsf.PreMultiply(scale); - } - - const TopoDS_Shape moved_shape = apply_transformation(s, trsf); - builder.Add(compound, moved_shape); - } - - return new ifcopenshell::geometry::OpenCascadeShape(compound); -} - - namespace { void accumulate(const gp_Ax3& ax, const gp_Dir& normal, double area, double& along_x, double& along_y, double& along_z) { along_x += area * fabs(ax.XDirection().Dot(normal)); @@ -212,8 +139,91 @@ namespace { } } } +#endif + +IfcGeom::Representation::Serialization::Serialization(const BRep& brep) + : Representation(brep.settings()) + , id_(brep.id()) +{ +#ifdef IFOPSH_WITH_OPENCASCADE + ConversionResultShape* shape = brep.as_compound(); + TopoDS_Compound compound = TopoDS::Compound(((ifcopenshell::geometry::OpenCascadeShape*)shape)->shape()); + delete shape; + + for (auto it = brep.begin(); it != brep.end(); ++it) { + int sid = -1; + + if (it->hasStyle()) { + const auto& clr = it->Style().diffuse.ccomponents(); + surface_styles_.push_back(clr(0)); + surface_styles_.push_back(clr(1)); + surface_styles_.push_back(clr(2)); + + sid = it->Style().instance ? it->Style().instance->data().id() : -1; + } else { + surface_styles_.push_back(-1.); + surface_styles_.push_back(-1.); + surface_styles_.push_back(-1.); + } + + if (it->hasStyle() && it->Style().has_transparency()) { + surface_styles_.push_back(1. - it->Style().transparency); + } else { + surface_styles_.push_back(1.); + } + + surface_style_ids_.push_back(sid); + } + + std::stringstream sstream; + BRepTools::Write(compound,sstream); + brep_data_ = sstream.str(); +#else + throw std::runtime_error("Not available without Open Cascade"); +#endif +} + +IfcGeom::ConversionResultShape* IfcGeom::Representation::BRep::as_compound(bool force_meters) const { +#ifdef IFOPSH_WITH_OPENCASCADE + TopoDS_Compound compound; + BRep_Builder builder; + builder.MakeCompound(compound); + + for (auto it = begin(); it != end(); ++it) { + const TopoDS_Shape& s = *(ifcopenshell::geometry::OpenCascadeShape*)it->Shape(); + + // @todo, check + gp_GTrsf trsf; + if (it->Placement().components_) { + gp_Trsf tr; + const auto& m = it->Placement().ccomponents(); + tr.SetValues( + m(0, 0), m(0, 1), m(0, 2), m(0, 3), + m(1, 0), m(1, 1), m(1, 2), m(1, 3), + m(2, 0), m(2, 1), m(2, 2), m(2, 3) + ); + trsf = tr; + } + + if (!force_meters && settings().get(IteratorSettings::CONVERT_BACK_UNITS)) { + gp_Trsf scale; + scale.SetScaleFactor(1.0 / settings().unit_magnitude()); + trsf.PreMultiply(scale); + } + + const TopoDS_Shape moved_shape = apply_transformation(s, trsf); + builder.Add(compound, moved_shape); + } + + return new ifcopenshell::geometry::OpenCascadeShape(compound); +#else + throw std::runtime_error("Not available without Open Cascade"); +#endif +} + bool IfcGeom::Representation::BRep::calculate_surface_area(double& area) const { +#ifdef IFOPSH_WITH_OPENCASCADE try { area = 0.; @@ -228,9 +238,13 @@ bool IfcGeom::Representation::BRep::calculate_surface_area(double& area) const { Logger::Error("Error during calculation of surface area"); return false; } +#else + throw std::runtime_error("Not available without Open Cascade"); +#endif } bool IfcGeom::Representation::BRep::calculate_volume(double& volume) const { +#ifdef IFOPSH_WITH_OPENCASCADE try { volume = 0.; @@ -249,9 +263,13 @@ bool IfcGeom::Representation::BRep::calculate_volume(double& volume) const { Logger::Error("Error during calculation of volume"); return false; } +#else + throw std::runtime_error("Not available without Open Cascade"); +#endif } bool IfcGeom::Representation::BRep::calculate_projected_surface_area(const ifcopenshell::geometry::taxonomy::matrix4& place, double & along_x, double & along_y, double & along_z) const { +#ifdef IFOPSH_WITH_OPENCASCADE try { gp_GTrsf trsf; @@ -291,6 +309,9 @@ bool IfcGeom::Representation::BRep::calculate_projected_surface_area(const ifcop Logger::Error("Error during calculation of projected surface area"); return false; } +#else + throw std::runtime_error("Not available without Open Cascade"); +#endif } IfcGeom::Representation::Triangulation::Triangulation(const BRep& shape_model) diff --git a/src/ifcgeom/Iterator.h b/src/ifcgeom/Iterator.h index 08d3a6fd45..10f29899bb 100644 --- a/src/ifcgeom/Iterator.h +++ b/src/ifcgeom/Iterator.h @@ -681,13 +681,17 @@ namespace IfcGeom { m4 = ((taxonomy::geom_item*) converter_->mapping()->map(ifc_product))->matrix; } catch (const std::exception& e) { Logger::Error(e); - } catch (const Standard_Failure& e) { + } +#ifdef IFOPSH_WITH_OPENCASCADE + catch (const Standard_Failure& e) { if (e.GetMessageString() && strlen(e.GetMessageString())) { Logger::Error(e.GetMessageString()); } else { Logger::Error("Unknown error returning product"); } - } catch (...) { + } +#endif + catch (...) { Logger::Error("Unknown error returning product"); } @@ -703,13 +707,17 @@ namespace IfcGeom { product = create_shape_model_for_next_entity(); } catch (const std::exception& e) { Logger::Error(e); - } catch (const Standard_Failure& e) { + } +#ifdef IFOPSH_WITH_OPENCASCADE + catch (const Standard_Failure& e) { if (e.GetMessageString() && strlen(e.GetMessageString())) { Logger::Error(e.GetMessageString()); } else { Logger::Error("Unknown error creating geometry"); } - } catch (...) { + } +#endif + catch (...) { Logger::Error("Unknown error creating geometry"); } return product; diff --git a/src/ifcgeom/mapping/IfcAnnotationFillArea.cpp b/src/ifcgeom/mapping/IfcAnnotationFillArea.cpp index 8c40c5a9af..d3dc456623 100644 --- a/src/ifcgeom/mapping/IfcAnnotationFillArea.cpp +++ b/src/ifcgeom/mapping/IfcAnnotationFillArea.cpp @@ -17,10 +17,6 @@ * * ********************************************************************************/ -#include -#include -#include -#include #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) diff --git a/src/ifcgeom/mapping/IfcAxis1Placement.cpp b/src/ifcgeom/mapping/IfcAxis1Placement.cpp index 6453400a86..345a141c49 100644 --- a/src/ifcgeom/mapping/IfcAxis1Placement.cpp +++ b/src/ifcgeom/mapping/IfcAxis1Placement.cpp @@ -17,8 +17,6 @@ * * ********************************************************************************/ -#include -#include #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) diff --git a/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp b/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp index a2b445f365..6e03b08cae 100644 --- a/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp +++ b/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp @@ -17,12 +17,6 @@ * * ********************************************************************************/ -#include -#include -#include -#include -#include -#include #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) diff --git a/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp b/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp index 66caf8d9aa..d6c2695d2d 100644 --- a/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp +++ b/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp @@ -17,11 +17,6 @@ * * ********************************************************************************/ -#include -#include -#include -#include -#include #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) diff --git a/src/ifcgeom/mapping/IfcBlock.cpp b/src/ifcgeom/mapping/IfcBlock.cpp index 1f3275deda..b2a218eb4d 100644 --- a/src/ifcgeom/mapping/IfcBlock.cpp +++ b/src/ifcgeom/mapping/IfcBlock.cpp @@ -17,8 +17,6 @@ * * ********************************************************************************/ -#include -#include #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) diff --git a/src/ifcgeom/mapping/IfcBooleanResult.cpp b/src/ifcgeom/mapping/IfcBooleanResult.cpp index f337d83ea8..2b7f4b1933 100644 --- a/src/ifcgeom/mapping/IfcBooleanResult.cpp +++ b/src/ifcgeom/mapping/IfcBooleanResult.cpp @@ -17,8 +17,6 @@ * * ********************************************************************************/ -#include -#include #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) diff --git a/src/ifcgeom/mapping/IfcBoundingBox.cpp b/src/ifcgeom/mapping/IfcBoundingBox.cpp index ea2ba64278..0b34c37192 100644 --- a/src/ifcgeom/mapping/IfcBoundingBox.cpp +++ b/src/ifcgeom/mapping/IfcBoundingBox.cpp @@ -17,8 +17,6 @@ * * ********************************************************************************/ -#include -#include #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) diff --git a/src/ifcgeom/mapping/IfcCartesianTransformationOperator3D.cpp b/src/ifcgeom/mapping/IfcCartesianTransformationOperator3D.cpp index a386ca389d..9aa073f482 100644 --- a/src/ifcgeom/mapping/IfcCartesianTransformationOperator3D.cpp +++ b/src/ifcgeom/mapping/IfcCartesianTransformationOperator3D.cpp @@ -17,11 +17,6 @@ * * ********************************************************************************/ -#include -#include -#include -#include - #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) using namespace ifcopenshell::geometry; diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 0e293566c5..2646e52502 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -73,6 +73,8 @@ %include "../serializers/XmlSerializer.h" %include "../serializers/GltfSerializer.h" +#ifdef IFOPSH_WITH_OPENCASCADE + %template(ray_intersection_results) std::vector; // A Template instantantation should be defined before it is used as a base class. @@ -138,6 +140,8 @@ } +#endif + // A visitor %{ struct ShapeRTTI : public boost::static_visitor @@ -551,6 +555,8 @@ struct ShapeRTTI : public boost::static_visitor } %} +#ifdef IFOPSH_WITH_OPENCASCADE + %inline %{ IfcUtil::IfcBaseClass* serialise(const std::string& schema_name, const std::string& shape_str, bool advanced=true) { std::stringstream stream(shape_str); @@ -571,6 +577,8 @@ struct ShapeRTTI : public boost::static_visitor } %} +#endif + %ignore svgfill::svg_to_line_segments; %ignore svgfill::line_segments_to_polygons; diff --git a/src/ifcwrap/IfcPython.i b/src/ifcwrap/IfcPython.i index 127b2d0672..153229aca5 100644 --- a/src/ifcwrap/IfcPython.i +++ b/src/ifcwrap/IfcPython.i @@ -80,9 +80,13 @@ %{ #include "../ifcgeom/Iterator.h" #include "../ifcgeom/taxonomy.h" +#ifdef IFOPSH_WITH_OPENCASCADE #include "../ifcgeom/Serialization/Serialization.h" #include "../ifcgeom/kernels/opencascade/IfcGeomTree.h" + #include +#endif + #include "../serializers/SvgSerializer.h" #include "../serializers/WavefrontObjSerializer.h" #include "../serializers/HdfSerializer.h" @@ -121,8 +125,6 @@ #include "../ifcparse/utils.h" #include "../svgfill/src/svgfill.h" - - #include %} // Create docstrings for generated python code. @@ -137,8 +139,12 @@ %module ifcopenshell_wrapper %{ #include "../ifcgeom/Converter.h" #include "../ifcgeom/taxonomy.h" +#ifdef IFOPSH_WITH_OPENCASCADE #include "../ifcgeom/Serialization/Serialization.h" #include "../ifcgeom/kernels/opencascade/IfcGeomTree.h" + + #include +#endif #include "../ifcgeom/Iterator.h" #include "../serializers/SvgSerializer.h" @@ -181,8 +187,6 @@ #include "../ifcparse/utils.h" #include "../svgfill/src/svgfill.h" - - #include %} %include "IfcGeomWrapper.i" diff --git a/src/serializers/HdfSerializer.cpp b/src/serializers/HdfSerializer.cpp index 7d61920bad..2b5aaa1c06 100644 --- a/src/serializers/HdfSerializer.cpp +++ b/src/serializers/HdfSerializer.cpp @@ -17,7 +17,7 @@ * * ********************************************************************************/ -#ifdef WITH_HDF5 +#if defined(WITH_HDF5) && defined(IFOPSH_WITH_OPENCASCADE) #include "HdfSerializer.h" diff --git a/src/serializers/HdfSerializer.h b/src/serializers/HdfSerializer.h index 25dd245fc8..0b9510bb44 100644 --- a/src/serializers/HdfSerializer.h +++ b/src/serializers/HdfSerializer.h @@ -20,7 +20,7 @@ #ifndef HDFSERIALIZER_H #define HDFSERIALIZER_H -#ifdef WITH_HDF5 +#if defined(WITH_HDF5) && defined(IFOPSH_WITH_OPENCASCADE) #include #include diff --git a/src/serializers/IgesSerializer.h b/src/serializers/IgesSerializer.h index e6a5bdf3b6..365189add3 100644 --- a/src/serializers/IgesSerializer.h +++ b/src/serializers/IgesSerializer.h @@ -17,6 +17,8 @@ * * ********************************************************************************/ +#ifdef IFOPSH_WITH_OPENCASCADE + #ifndef IGESSERIALIZER_H #define IGESSERIALIZER_H @@ -62,3 +64,4 @@ public: }; #endif +#endif diff --git a/src/serializers/OpenCascadeBasedSerializer.cpp b/src/serializers/OpenCascadeBasedSerializer.cpp index e3cc68fa78..da3f2115ac 100644 --- a/src/serializers/OpenCascadeBasedSerializer.cpp +++ b/src/serializers/OpenCascadeBasedSerializer.cpp @@ -17,6 +17,8 @@ * * ********************************************************************************/ +#ifdef IFOPSH_WITH_OPENCASCADE + #include "OpenCascadeBasedSerializer.h" #include "../ifcparse/utils.h" @@ -62,3 +64,6 @@ const char* OpenCascadeBasedSerializer::getSymbolForUnitMagnitude(float mag) { return 0; } } + +#endif + diff --git a/src/serializers/OpenCascadeBasedSerializer.h b/src/serializers/OpenCascadeBasedSerializer.h index 513cff5299..1146f51bb2 100644 --- a/src/serializers/OpenCascadeBasedSerializer.h +++ b/src/serializers/OpenCascadeBasedSerializer.h @@ -17,6 +17,8 @@ * * ********************************************************************************/ +#ifdef IFOPSH_WITH_OPENCASCADE + #ifndef OPENCASCADEBASEDSERIALIZER_H #define OPENCASCADEBASEDSERIALIZER_H @@ -47,3 +49,4 @@ public: }; #endif +#endif diff --git a/src/serializers/StepSerializer.h b/src/serializers/StepSerializer.h index f71498b9fe..5a4ade0335 100644 --- a/src/serializers/StepSerializer.h +++ b/src/serializers/StepSerializer.h @@ -17,6 +17,8 @@ * * ********************************************************************************/ +#ifdef IFOPSH_WITH_OPENCASCADE + #ifndef STEPSERIALIZER_H #define STEPSERIALIZER_H @@ -58,4 +60,5 @@ public: } }; -#endif \ No newline at end of file +#endif +#endif diff --git a/src/serializers/SvgSerializer.cpp b/src/serializers/SvgSerializer.cpp index c5c8640bdb..69fda24e65 100644 --- a/src/serializers/SvgSerializer.cpp +++ b/src/serializers/SvgSerializer.cpp @@ -19,6 +19,8 @@ * * ********************************************************************************/ +#ifdef IFOPSH_WITH_OPENCASCADE + #include "../ifcgeom/abstract_mapping.h" #include @@ -2436,4 +2438,6 @@ std::string SvgSerializer::writeMetadata(const drawing_meta& m) { }}; return namespace_prefix_ + "plane=\""+ array_to_string(m4) +"\" " + namespace_prefix_ + "matrix3=\"" + array_to_string(m.matrix_3) + "\""; -} \ No newline at end of file +} + +#endif diff --git a/src/serializers/SvgSerializer.h b/src/serializers/SvgSerializer.h index 6b417bf764..81a1cb7315 100644 --- a/src/serializers/SvgSerializer.h +++ b/src/serializers/SvgSerializer.h @@ -19,6 +19,8 @@ * * ********************************************************************************/ +#ifdef IFOPSH_WITH_OPENCASCADE + #ifndef SVGSERIALIZER_H #define SVGSERIALIZER_H @@ -343,3 +345,4 @@ protected: }; #endif +#endif diff --git a/src/svgfill b/src/svgfill index ac17050194..4d2aa7acf7 160000 --- a/src/svgfill +++ b/src/svgfill @@ -1 +1 @@ -Subproject commit ac1705019422ea012e8a5751cc5ed4639481b402 +Subproject commit 4d2aa7acf76cb8509ab3ba2961c34502adf3abe9 diff --git a/test/input b/test/input index eca4a52d7c..20a17fcf3b 160000 --- a/test/input +++ b/test/input @@ -1 +1 @@ -Subproject commit eca4a52d7c758a92bad6910fa830436a836745bf +Subproject commit 20a17fcf3b1be2bc48af0273f7604af5b7cc4068