From 031694af2b12a685609aa6553412ea3239be4b13 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 22 Mar 2023 11:47:00 +0100 Subject: [PATCH] Make cgal optional --- cmake/CMakeLists.txt | 6 ++++++ src/ifcconvert/validate_space_boundaries.cpp | 4 ++++ src/ifcconvert/validate_storey_containment.cpp | 4 ++++ src/ifcconvert/validate_wall_connectivity.cpp | 3 +++ src/ifcconvert/validation_utils.cpp | 6 +++++- src/ifcconvert/validation_utils.h | 4 ++++ src/ifcgeom/Iterator.h | 4 ++++ src/ifcgeom/kernels/opencascade/layerset.h | 1 + src/ifcwrap/IfcGeomWrapper.i | 3 +++ src/serializers/OpenCascadeBasedSerializer.h | 2 ++ 10 files changed, 36 insertions(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c23c3dc37d..d2a939e17e 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -785,6 +785,8 @@ TARGET_LINK_LIBRARIES(IfcParse ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${LIBXML2_ if (BUILD_IFCGEOM) +if (WITH_CGAL) + find_library(libGMP NAMES gmp mpir PATHS ${GMP_LIBRARY_DIR} NO_DEFAULT_PATH) find_library(libMPFR NAMES mpfr PATHS ${MPFR_LIBRARY_DIR} NO_DEFAULT_PATH) if(NOT libGMP) @@ -797,6 +799,8 @@ endif() list(APPEND CGAL_LIBRARIES "${libMPFR}") list(APPEND CGAL_LIBRARIES "${libGMP}") +endif() + foreach(kernel ${GEOMETRY_KERNELS}) string(TOUPPER ${kernel} KERNEL_UPPER) @@ -957,8 +961,10 @@ IF(NOT MINIMAL_BUILD AND BUILD_IFCMAX) ADD_SUBDIRECTORY(../src/ifcmax ifcmax) ENDIF() if (NOT MINIMAL_BUILD) +if (WITH_CGAL) ADD_SUBDIRECTORY(../src/svgfill svgfill) endif() +endif() # CMake installation targets INSTALL(FILES ${IFCPARSE_H_FILES} diff --git a/src/ifcconvert/validate_space_boundaries.cpp b/src/ifcconvert/validate_space_boundaries.cpp index d5c906aac3..fcaafd4804 100644 --- a/src/ifcconvert/validate_space_boundaries.cpp +++ b/src/ifcconvert/validate_space_boundaries.cpp @@ -1,3 +1,5 @@ +#ifdef IFOPSH_WITH_CGAL + #include "validation_utils.h" using namespace ifcopenshell::geometry; @@ -183,3 +185,5 @@ void fix_spaceboundaries(IfcParse::IfcFile& f, bool no_progress, bool quiet, boo } } } + +#endif diff --git a/src/ifcconvert/validate_storey_containment.cpp b/src/ifcconvert/validate_storey_containment.cpp index 9ec9f376c8..41d31ea0b9 100644 --- a/src/ifcconvert/validate_storey_containment.cpp +++ b/src/ifcconvert/validate_storey_containment.cpp @@ -1,3 +1,5 @@ +#ifdef IFOPSH_WITH_CGAL + #include "../ifcgeom/kernels/cgal/CgalKernel.h" #include "../ifcgeom/IfcGeomFilter.h" #include "../ifcgeom/Iterator.h" @@ -231,3 +233,5 @@ void fix_storeycontainment(IfcParse::IfcFile& f, bool no_progress, bool quiet, b " objects "); } } + +#endif diff --git a/src/ifcconvert/validate_wall_connectivity.cpp b/src/ifcconvert/validate_wall_connectivity.cpp index bf90e13f54..ba4aa35ba4 100644 --- a/src/ifcconvert/validate_wall_connectivity.cpp +++ b/src/ifcconvert/validate_wall_connectivity.cpp @@ -1,3 +1,5 @@ +#ifdef IFOPSH_WITH_CGAL + #include "validation_utils.h" #include @@ -196,3 +198,4 @@ void fix_wallconnectivity(IfcParse::IfcFile& f, bool no_progress, bool quiet, bo std::wcout << "total_conversion_to_poly_time " << conversion_to_poly << std::endl; } +#endif diff --git a/src/ifcconvert/validation_utils.cpp b/src/ifcconvert/validation_utils.cpp index 512f6163d6..e4e591f853 100644 --- a/src/ifcconvert/validation_utils.cpp +++ b/src/ifcconvert/validation_utils.cpp @@ -1,3 +1,5 @@ +#ifdef IFOPSH_WITH_CGAL + #include "validation_utils.h" double facet_area(const cgal_shape_t::Facet_handle& f) { @@ -25,4 +27,6 @@ void dump_facet(const cgal_shape_t::Facet_handle& f) { auto osss = oss.str(); std::wcout << osss.c_str() << std::endl; -} \ No newline at end of file +} + +#endif diff --git a/src/ifcconvert/validation_utils.h b/src/ifcconvert/validation_utils.h index d4ff885a06..6939dfd95d 100644 --- a/src/ifcconvert/validation_utils.h +++ b/src/ifcconvert/validation_utils.h @@ -1,3 +1,5 @@ +#ifdef IFOPSH_WITH_CGAL + #include "../ifcgeom/kernels/cgal/CgalKernel.h" #include "../ifcgeom/IfcGeomFilter.h" #include "../ifcgeom/Iterator.h" @@ -582,3 +584,5 @@ struct intersection_validator { CGAL::box_self_intersection_d(boxes.begin(), boxes.end(), fn); } }; + +#endif \ No newline at end of file diff --git a/src/ifcgeom/Iterator.h b/src/ifcgeom/Iterator.h index 10f29899bb..129be4b7f9 100644 --- a/src/ifcgeom/Iterator.h +++ b/src/ifcgeom/Iterator.h @@ -69,6 +69,10 @@ #include "../ifcgeom/abstract_mapping.h" #include "../ifcgeom/GeometrySerializer.h" +#ifdef IFOPSH_WITH_OPENCASCADE +#include +#endif + #include #include diff --git a/src/ifcgeom/kernels/opencascade/layerset.h b/src/ifcgeom/kernels/opencascade/layerset.h index c5f10047ae..b14d7589e5 100644 --- a/src/ifcgeom/kernels/opencascade/layerset.h +++ b/src/ifcgeom/kernels/opencascade/layerset.h @@ -4,6 +4,7 @@ #include "../../ConversionResult.h" #include +#include #include #include diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 2646e52502..be97d7f76e 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -579,6 +579,8 @@ struct ShapeRTTI : public boost::static_visitor #endif +#ifdef IFOPSH_WITH_CGAL + %ignore svgfill::svg_to_line_segments; %ignore svgfill::line_segments_to_polygons; @@ -617,3 +619,4 @@ struct ShapeRTTI : public boost::static_visitor } %} +#endif \ No newline at end of file diff --git a/src/serializers/OpenCascadeBasedSerializer.h b/src/serializers/OpenCascadeBasedSerializer.h index 1146f51bb2..67982fa3cc 100644 --- a/src/serializers/OpenCascadeBasedSerializer.h +++ b/src/serializers/OpenCascadeBasedSerializer.h @@ -27,6 +27,8 @@ #include "../ifcgeom/GeometrySerializer.h" +#include + class SERIALIZERS_API OpenCascadeBasedSerializer : public WriteOnlyGeometrySerializer { OpenCascadeBasedSerializer(const OpenCascadeBasedSerializer&); //N/A OpenCascadeBasedSerializer& operator =(const OpenCascadeBasedSerializer&); //N/A