Skip to content

Commit

Permalink
Port to OpenCascade 7.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Jan 10, 2024
1 parent 1049e9c commit d1b3545
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: 'beb30920efe5e5384d500d43dcb8ba1f476a76bb65b268b1af32d807b697bdee'

runs-on: windows-latest

Expand Down
36 changes: 26 additions & 10 deletions mayo.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/app/widget_main_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<WidgetGuiDocument*>(m_ui->stack_GuiDocuments->widget(idx));
}

Expand Down
8 changes: 6 additions & 2 deletions src/base/brep_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TopoDS_Shape>{}(shape);
#else
return shape.HashCode(INT_MAX);
#endif
}

std::string BRepUtils::shapeToString(const TopoDS_Shape& shape)
Expand Down
2 changes: 1 addition & 1 deletion src/base/brep_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/base/caf_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#pragma once

#include <Standard_Version.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TDF_Label.hxx>
Expand Down Expand Up @@ -43,7 +44,7 @@ struct CafUtils {

} // namespace Mayo


#if OCC_VERSION_HEX < 0x070800
#include <TDF_LabelMapHasher.hxx>
namespace std {

Expand All @@ -55,6 +56,7 @@ template<> struct hash<TDF_Label> {
};

} // namespace std
#endif

// --
// -- Implementation
Expand Down
2 changes: 2 additions & 0 deletions src/base/tkernel_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -65,3 +66,4 @@ template<typename T> struct hash<opencascade::handle<T>> {
};

} // namespace std
#endif
5 changes: 3 additions & 2 deletions tests/test_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit d1b3545

Please sign in to comment.