From: Marc Fehling Date: Sat, 28 May 2022 01:15:44 +0000 (-0600) Subject: Introduce DEAL_II_OPENCASCADE_VERSION_GTE X-Git-Tag: v9.4.0-rc1~121^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13845%2Fhead;p=dealii.git Introduce DEAL_II_OPENCASCADE_VERSION_GTE --- diff --git a/cmake/modules/FindOPENCASCADE.cmake b/cmake/modules/FindOPENCASCADE.cmake index 0e2acc73ee..f8ce890ba4 100644 --- a/cmake/modules/FindOPENCASCADE.cmake +++ b/cmake/modules/FindOPENCASCADE.cmake @@ -26,6 +26,9 @@ # OPENCASCADE_INCLUDE_DIRS # OPENCASCADE_LIBRARIES # OPENCASCADE_VERSION +# OPENCASCADE_VERSION_MAJOR +# OPENCASCADE_VERSION_MINOR +# OPENCASCADE_VERSION_SUBMINOR # @@ -49,6 +52,18 @@ IF(EXISTS ${OPENCASCADE_INCLUDE_DIR}/Standard_Version.hxx) "#define OCC_VERSION_COMPLETE.*\"(.*)\"" "\\1" OPENCASCADE_VERSION "${OPENCASCADE_VERSION}" ) + STRING(REGEX REPLACE + "^([0-9]+).*$" "\\1" + OPENCASCADE_VERSION_MAJOR "${OPENCASCADE_VERSION}" + ) + STRING(REGEX REPLACE + "^[0-9]+\\.([0-9]+).*$" "\\1" + OPENCASCADE_VERSION_MINOR "${OPENCASCADE_VERSION}" + ) + STRING(REGEX REPLACE + "^[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" + OPENCASCADE_VERSION_SUBMINOR "${OPENCASCADE_VERSION}" + ) ENDIF() # These seem to be pretty much the only required ones. diff --git a/doc/doxygen/options.dox.in b/doc/doxygen/options.dox.in index 308f28dd3c..ac58e22a2e 100644 --- a/doc/doxygen/options.dox.in +++ b/doc/doxygen/options.dox.in @@ -213,6 +213,10 @@ PREDEFINED = DOXYGEN=1 \ DEAL_II_MPI_VERSION_MINOR=0 \ DEAL_II_WITH_MUPARSER=1 \ DEAL_II_WITH_OPENCASCADE=1 \ + DEAL_II_OPENCASCADE_VERSION_MAJOR=7 \ + DEAL_II_OPENCASCADE_VERSION_MINOR=6 \ + DEAL_II_OPENCASCADE_VERSION_SUBMINOR=0 \ + DEAL_II_OPENCASCADE_VERSION_GTE=1 \ DEAL_II_WITH_P4EST=1 \ DEAL_II_P4EST_VERSION_MAJOR=2 \ DEAL_II_P4EST_VERSION_MINOR=0 \ diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index ae16c5d956..706fb4a28b 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -290,6 +290,23 @@ # define DEAL_II_GMSH_EXECUTABLE_PATH "@GMSH_EXECUTABLE@" #endif +/** + * OpenCASCADE: + */ + +#ifdef DEAL_II_WITH_OPENCASCADE +# define DEAL_II_OPENCASCADE_VERSION_MAJOR @OPENCASCADE_VERSION_MAJOR@ +# define DEAL_II_OPENCASCADE_VERSION_MINOR @OPENCASCADE_VERSION_MINOR@ +# define DEAL_II_OPENCASCADE_VERSION_SUBMINOR @OPENCASCADE_VERSION_SUBMINOR@ + +# define DEAL_II_OPENCASCADE_VERSION_GTE(major,minor,subminor) \ + ((DEAL_II_OPENCASCADE_VERSION_MAJOR * 10000 + \ + DEAL_II_OPENCASCADE_VERSION_MINOR * 100 + \ + DEAL_II_OPENCASCADE_VERSION_SUBMINOR) \ + >= \ + (major)*10000 + (minor)*100 + (subminor)) +#endif + /* * p4est: */ diff --git a/source/opencascade/manifold_lib.cc b/source/opencascade/manifold_lib.cc index 69bc38b58a..af14a8c6e3 100644 --- a/source/opencascade/manifold_lib.cc +++ b/source/opencascade/manifold_lib.cc @@ -14,6 +14,8 @@ // --------------------------------------------------------------------- +#include + #include #ifdef DEAL_II_WITH_OPENCASCADE @@ -28,9 +30,8 @@ # include # include # include -# include # include -# if (OCC_VERSION_MAJOR < 7) +# if !DEAL_II_OPENCASCADE_VERSION_GTE(7, 0, 0) # include # endif diff --git a/source/opencascade/utilities.cc b/source/opencascade/utilities.cc index dbb5614e90..d955df987b 100644 --- a/source/opencascade/utilities.cc +++ b/source/opencascade/utilities.cc @@ -13,6 +13,8 @@ // // --------------------------------------------------------------------- +#include + #include #ifdef DEAL_II_WITH_OPENCASCADE @@ -27,7 +29,6 @@ # include # include # include -# include # include # include # include @@ -37,10 +38,10 @@ # include # include # include -# if (OCC_VERSION_MAJOR < 7) -# include -# else +# if DEAL_II_OPENCASCADE_VERSION_GTE(7, 0, 0) # include +# else +# include # endif # include @@ -328,12 +329,12 @@ namespace OpenCASCADE StlAPI_Writer writer; -# if ((OCC_VERSION_MAJOR * 100 + OCC_VERSION_MINOR * 10) >= 690) +# if DEAL_II_OPENCASCADE_VERSION_GTE(6, 9, 0) // opencascade versions 6.9.0 onwards return an error status const auto error = writer.Write(shape_to_be_written, filename.c_str()); // which is a custom type between 6.9.0 and 7.1.0 -# if ((OCC_VERSION_MAJOR * 100 + OCC_VERSION_MINOR * 10) < 720) +# if !DEAL_II_OPENCASCADE_VERSION_GTE(7, 2, 0) AssertThrow(error == StlAPI_StatusOK, ExcMessage("Error writing STL from shape.")); # else