From 0610528e3f9346712386220bd5042f7badd3fa4f Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 8 Sep 2022 17:29:22 +0300 Subject: [PATCH] Provide compatibility with older OCCT versions --- CMakeLists.txt | 3 +- ...all.cmake => CTestTestfileInstall.cmake.in | 3 + .../GEOMImpl_ICanonicalRecognition.cxx | 70 +++++++++++++++---- test/test_CR.py | 2 +- test/tests.set | 7 +- 5 files changed, 67 insertions(+), 18 deletions(-) rename CTestTestfileInstall.cmake => CTestTestfileInstall.cmake.in (91%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fd233644..21b0c03ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,8 @@ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${ # =============== SET(GEOM_TEST_DIR ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test) IF(SALOME_BUILD_TESTS) - INSTALL(FILES CTestTestfileInstall.cmake + CONFIGURE_FILE(CTestTestfileInstall.cmake.in CTestTestfileInstall.cmake @ONLY) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileInstall.cmake DESTINATION ${GEOM_TEST_DIR} RENAME CTestTestfile.cmake) ENDIF() diff --git a/CTestTestfileInstall.cmake b/CTestTestfileInstall.cmake.in similarity index 91% rename from CTestTestfileInstall.cmake rename to CTestTestfileInstall.cmake.in index cba60b0ca..c47c8b151 100644 --- a/CTestTestfileInstall.cmake +++ b/CTestTestfileInstall.cmake.in @@ -17,6 +17,9 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +SET(OpenCASCADE_VERSION @OpenCASCADE_VERSION@) +SET(OpenCASCADE_SP_VERSION @OpenCASCADE_SP_VERSION@) + SET(PYTHON_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/python_test_driver.py") SET(COMPONENT_NAME GEOM) SET(TIMEOUT 300) diff --git a/src/GEOMImpl/GEOMImpl_ICanonicalRecognition.cxx b/src/GEOMImpl/GEOMImpl_ICanonicalRecognition.cxx index 28b751278..73cead135 100644 --- a/src/GEOMImpl/GEOMImpl_ICanonicalRecognition.cxx +++ b/src/GEOMImpl/GEOMImpl_ICanonicalRecognition.cxx @@ -22,12 +22,17 @@ #include "GEOMImpl_ICanonicalRecognition.hxx" +#include + #include "GEOM_Function.hxx" #include "GEOM_Object.hxx" #include "GEOM_PythonDump.hxx" -#include +#if OCC_VERSION_LARGE > 0x07050303 #include +#endif + +#include #include #include @@ -67,14 +72,19 @@ bool GEOMImpl_ICanonicalRecognition::isPlane(const Handle(GEOM_Object)& theShape return false; } TopoDS_Shape aShape = theShape->GetValue(); - if (aShape.IsNull()) - { + if (aShape.IsNull()) { + SetErrorCode("Error: NULL shape"); return false; } +#if OCC_VERSION_LARGE < 0x07050304 + SetErrorCode("Shape type detection aborted. Improper OCCT version: please, use OCCT 7.5.3p5 or newer."); + return false; +#else ShapeAnalysis_CanonicalRecognition aRecognition(aShape); SetErrorCode(OK); return aRecognition.GetStatus() == 0 && aRecognition.IsPlane(theTolerance, thePln); +#endif } //============================================================================= @@ -91,14 +101,19 @@ bool GEOMImpl_ICanonicalRecognition::isSphere(const Handle(GEOM_Object)& theShap return false; } TopoDS_Shape aShape = theShape->GetValue(); - if (aShape.IsNull()) - { + if (aShape.IsNull()) { + SetErrorCode("Error: NULL shape"); return false; } +#if OCC_VERSION_LARGE < 0x07050304 + SetErrorCode("Shape type detection aborted. Improper OCCT version: please, use OCCT 7.5.3p5 or newer."); + return false; +#else ShapeAnalysis_CanonicalRecognition aRecognition(aShape); SetErrorCode(OK); return aRecognition.GetStatus() == 0 && aRecognition.IsSphere(theTolerance, theSphere); +#endif } //============================================================================= @@ -115,14 +130,19 @@ bool GEOMImpl_ICanonicalRecognition::isCone(const Handle(GEOM_Object)& theShape, return false; } TopoDS_Shape aShape = theShape->GetValue(); - if (aShape.IsNull()) - { + if (aShape.IsNull()) { + SetErrorCode("Error: NULL shape"); return false; } +#if OCC_VERSION_LARGE < 0x07050304 + SetErrorCode("Shape type detection aborted. Improper OCCT version: please, use OCCT 7.5.3p5 or newer."); + return false; +#else ShapeAnalysis_CanonicalRecognition aRecognition(aShape); SetErrorCode(OK); return aRecognition.GetStatus() == 0 && aRecognition.IsCone(theTolerance, theCone); +#endif } //============================================================================= @@ -139,14 +159,19 @@ bool GEOMImpl_ICanonicalRecognition::isCylinder(const Handle(GEOM_Object)& theSh return false; } TopoDS_Shape aShape = theShape->GetValue(); - if (aShape.IsNull()) - { + if (aShape.IsNull()) { + SetErrorCode("Error: NULL shape"); return false; } +#if OCC_VERSION_LARGE < 0x07050304 + SetErrorCode("Shape type detection aborted. Improper OCCT version: please, use OCCT 7.5.3p5 or newer."); + return false; +#else ShapeAnalysis_CanonicalRecognition aRecognition(aShape); SetErrorCode(OK); return aRecognition.GetStatus() == 0 && aRecognition.IsCylinder(theTolerance, theCylinder); +#endif } //============================================================================= @@ -163,14 +188,19 @@ bool GEOMImpl_ICanonicalRecognition::isLine(const Handle(GEOM_Object)& theEdge, return false; } TopoDS_Shape aShape = theEdge->GetValue(); - if (aShape.IsNull()) - { + if (aShape.IsNull()) { + SetErrorCode("Error: NULL shape"); return false; } +#if OCC_VERSION_LARGE < 0x07050304 + SetErrorCode("Shape type detection aborted. Improper OCCT version: please, use OCCT 7.5.3p5 or newer."); + return false; +#else ShapeAnalysis_CanonicalRecognition aRecognition(aShape); SetErrorCode(OK); return aRecognition.GetStatus() == 0 && aRecognition.IsLine(theTolerance, theLine); +#endif } //============================================================================= @@ -187,14 +217,19 @@ bool GEOMImpl_ICanonicalRecognition::isCircle(const Handle(GEOM_Object)& theEdge return false; } TopoDS_Shape aShape = theEdge->GetValue(); - if (aShape.IsNull()) - { + if (aShape.IsNull()) { + SetErrorCode("Error: NULL shape"); return false; } +#if OCC_VERSION_LARGE < 0x07050304 + SetErrorCode("Shape type detection aborted. Improper OCCT version: please, use OCCT 7.5.3p5 or newer."); + return false; +#else ShapeAnalysis_CanonicalRecognition aRecognition(aShape); SetErrorCode(OK); return aRecognition.GetStatus() == 0 && aRecognition.IsCircle(theTolerance, theCircle); +#endif } //============================================================================= @@ -211,12 +246,17 @@ bool GEOMImpl_ICanonicalRecognition::isEllipse(const Handle(GEOM_Object)& theEdg return false; } TopoDS_Shape aShape = theEdge->GetValue(); - if (aShape.IsNull()) - { + if (aShape.IsNull()) { + SetErrorCode("Error: NULL shape"); return false; } +#if OCC_VERSION_LARGE < 0x07050304 + SetErrorCode("Shape type detection aborted. Improper OCCT version: please, use OCCT 7.5.3p5 or newer."); + return false; +#else ShapeAnalysis_CanonicalRecognition aRecognition(aShape); SetErrorCode(OK); return aRecognition.GetStatus() == 0 && aRecognition.IsEllipse(theTolerance, theElips); +#endif } diff --git a/test/test_CR.py b/test/test_CR.py index da959e8ff..cf58efed7 100644 --- a/test/test_CR.py +++ b/test/test_CR.py @@ -19,7 +19,7 @@ # import salome - +### salome.salome_init() import GEOM diff --git a/test/tests.set b/test/tests.set index 8b5c4e5a6..e1f8b2a09 100644 --- a/test/tests.set +++ b/test/tests.set @@ -19,5 +19,10 @@ SET(ALL_TESTS test_perf_01.py - test_CR.py ) + +IF(${OpenCASCADE_VERSION}.${OpenCASCADE_SP_VERSION} VERSION_GREATER "7.5.3.3") + LIST(APPEND ALL_TESTS + test_CR.py + ) +ENDIF() -- 2.39.2