From: jfa Date: Thu, 8 Sep 2022 14:29:22 +0000 (+0300) Subject: Provide compatibility with older OCCT versions X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0610528e3f9346712386220bd5042f7badd3fa4f;p=modules%2Fgeom.git Provide compatibility with older OCCT versions --- 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 deleted file mode 100644 index cba60b0ca..000000000 --- a/CTestTestfileInstall.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) 2017-2022 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -SET(PYTHON_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/python_test_driver.py") -SET(COMPONENT_NAME GEOM) -SET(TIMEOUT 300) - -SUBDIRS(examples xao other) diff --git a/CTestTestfileInstall.cmake.in b/CTestTestfileInstall.cmake.in new file mode 100644 index 000000000..c47c8b151 --- /dev/null +++ b/CTestTestfileInstall.cmake.in @@ -0,0 +1,27 @@ +# Copyright (C) 2017-2022 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# 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) + +SUBDIRS(examples xao other) 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()