From f0e02d951124dc9be98819495d8281717079eacd Mon Sep 17 00:00:00 2001 From: Hugues Delorme Date: Wed, 10 Jan 2024 16:57:08 +0100 Subject: [PATCH] Port to OpenCascade 7.8.0 --- .github/workflows/ci_windows.yml | 2 ++ mayo.pro | 36 +++++++++++++++++++++++--------- src/app/widget_main_control.cpp | 1 - src/base/brep_utils.cpp | 8 +++++-- src/base/brep_utils.h | 2 +- src/base/caf_utils.h | 4 +++- src/base/tkernel_utils.h | 2 ++ tests/test_base.cpp | 5 +++-- 8 files changed, 43 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci_windows.yml b/.github/workflows/ci_windows.yml index 670f92d7..770d558f 100644 --- a/.github/workflows/ci_windows.yml +++ b/.github/workflows/ci_windows.yml @@ -17,6 +17,8 @@ jobs: occ_zip_sha256: '137788c7693f74fb98797adfd06c1b00f66dac59beca5c3073c1f62c98b7a80f' - occ_version: 7.7.0 occ_zip_sha256: '82afb7bd5fd7097189ee4e98bf3bc02b4030cae7a82967db68d5f2b556801779' + - occ_version: 7.8.0 + occ_zip_sha256: '3ae81d7f872ce60a62e40743e4af88abc0d1196aa0e7642faf15b94f087e3e4d' runs-on: windows-latest diff --git a/mayo.pro b/mayo.pro index a21b22d9..f2bd14ed 100644 --- a/mayo.pro +++ b/mayo.pro @@ -173,19 +173,36 @@ LIBS += \ -lTKXmlXCAF \ -lTKXSBase \ -versionAtLeast(OCC_VERSION_STR, 7.7.0) { - LIBS += -lTKXDE +versionAtLeast(OCC_VERSION_STR, 7.8.0) { + # -- IGES support + LIBS += -lTKDEIGES + # -- STEP support + LIBS += -lTKDESTEP + # -- STL support + LIBS += -lTKDESTL + # -- VRML support + LIBS += -lTKDEVRML +} else { + # -- IGES support + LIBS += -lTKIGES -lTKXDEIGES + # -- STEP support + LIBS += -lTKSTEP -lTKSTEP209 -lTKSTEPAttr -lTKSTEPBase -lTKXDESTEP + # -- STL support + LIBS += -lTKSTL + # -- VRML support + LIBS += -lTKVRML + + versionAtLeast(OCC_VERSION_STR, 7.7.0) { + LIBS += -lTKXDE + } } -# -- IGES support -LIBS += -lTKIGES -lTKXDEIGES -# -- STEP support -LIBS += -lTKSTEP -lTKSTEP209 -lTKSTEPAttr -lTKSTEPBase -lTKXDESTEP -# -- STL support -LIBS += -lTKSTL # -- OBJ/glTF support versionAtLeast(OCC_VERSION_STR, 7.4.0) { LIBS += -lTKRWMesh + versionAtLeast(OCC_VERSION_STR, 7.8.0) { + LIBS += -lTKDEOBJ -lTKDEGLTF + } } else { SOURCES -= \ src/io_occ/io_occ_base_mesh.cpp \ @@ -205,8 +222,7 @@ versionAtLeast(OCC_VERSION_STR, 7.4.0) { SOURCES -= src/io_occ/io_occ_obj_writer.cpp message(OBJ writer disabled because OpenCascade < v7.6) } -# -- VRML support -LIBS += -lTKVRML + !versionAtLeast(OCC_VERSION_STR, 7.7.0) { SOURCES -= src/io_occ/io_occ_vrml_reader.cpp message(VRML reader disabled because OpenCascade < v7.7) diff --git a/src/app/widget_main_control.cpp b/src/app/widget_main_control.cpp index 51eca635..3240e3ae 100644 --- a/src/app/widget_main_control.cpp +++ b/src/app/widget_main_control.cpp @@ -312,7 +312,6 @@ QWidget* WidgetMainControl::recreateLeftHeaderPlaceHolder() WidgetGuiDocument* WidgetMainControl::widgetGuiDocument(int idx) const { - assert(idx == -1 || (0 <= idx && idx < m_ui->stack_GuiDocuments->count())); return qobject_cast(m_ui->stack_GuiDocuments->widget(idx)); } diff --git a/src/base/brep_utils.cpp b/src/base/brep_utils.cpp index 1b2f1197..b694f5bc 100644 --- a/src/base/brep_utils.cpp +++ b/src/base/brep_utils.cpp @@ -59,9 +59,13 @@ bool BRepUtils::moreComplex(TopAbs_ShapeEnum lhs, TopAbs_ShapeEnum rhs) return lhs < rhs; } -int BRepUtils::hashCode(const TopoDS_Shape& shape) +size_t BRepUtils::hashCode(const TopoDS_Shape& shape) { - return !shape.IsNull() ? shape.HashCode(INT_MAX) : -1; +#if OCC_VERSION_HEX >= OCC_VERSION_CHECK(7, 8, 0) + return std::hash{}(shape); +#else + return shape.HashCode(INT_MAX); +#endif } std::string BRepUtils::shapeToString(const TopoDS_Shape& shape) diff --git a/src/base/brep_utils.h b/src/base/brep_utils.h index 76830e89..a98dd2e1 100644 --- a/src/base/brep_utils.h +++ b/src/base/brep_utils.h @@ -53,7 +53,7 @@ struct BRepUtils { // Returns hash code computed from 'shape' // Computation uses the internal TShape and Location, but Orientation is not considered // Returned hash code is in the range [1, max(int)] - static int hashCode(const TopoDS_Shape& shape); + static size_t hashCode(const TopoDS_Shape& shape); // Serializes 'shape' into a string representation static std::string shapeToString(const TopoDS_Shape& shape); diff --git a/src/base/caf_utils.h b/src/base/caf_utils.h index d849de53..8863aa59 100644 --- a/src/base/caf_utils.h +++ b/src/base/caf_utils.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include #include @@ -43,7 +44,7 @@ struct CafUtils { } // namespace Mayo - +#if OCC_VERSION_HEX < 0x070800 #include namespace std { @@ -55,6 +56,7 @@ template<> struct hash { }; } // namespace std +#endif // -- // -- Implementation diff --git a/src/base/tkernel_utils.h b/src/base/tkernel_utils.h index 3dd45009..4f1d97af 100644 --- a/src/base/tkernel_utils.h +++ b/src/base/tkernel_utils.h @@ -55,6 +55,7 @@ class TKernelUtils { } // namespace Mayo +#if OCC_VERSION_HEX < OCC_VERSION_CHECK(7, 8, 0) namespace std { // Specialization of C++11 std::hash<> functor for opencascade::handle<> objects @@ -65,3 +66,4 @@ template struct hash> { }; } // namespace std +#endif diff --git a/tests/test_base.cpp b/tests/test_base.cpp index e98f482f..b28040e5 100644 --- a/tests/test_base.cpp +++ b/tests/test_base.cpp @@ -653,9 +653,10 @@ void TestBase::BRepUtils_test() const TopoDS_Shape shapeNull; const TopoDS_Shape shapeBase = BRepPrimAPI_MakeBox(25, 25, 25); const TopoDS_Shape shapeCopy = shapeBase; - QCOMPARE(BRepUtils::hashCode(shapeNull), -1); - QVERIFY(BRepUtils::hashCode(shapeBase) >= 0); + const TopoDS_Shape shapeOther = BRepPrimAPI_MakeBox(40, 40, 40); + QCOMPARE(BRepUtils::hashCode(shapeNull), BRepUtils::hashCode(TopoDS_Shape{})); QCOMPARE(BRepUtils::hashCode(shapeBase), BRepUtils::hashCode(shapeCopy)); + QVERIFY(BRepUtils::hashCode(shapeBase) != BRepUtils::hashCode(shapeOther)); } }