From d61331b2526b4bbb1fc93ef9602efecf57a3375e Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 15 Jan 2024 13:37:48 +0000 Subject: [PATCH] Porting to OCCT 7.8.0 --- src/GEOMAlgo/GEOMAlgo_ClsfSolid.hxx | 6 +++++ .../GEOMAlgo_DataMapOfPassKeyInteger.hxx | 14 +++++++++++ .../GEOMAlgo_IndexedDataMapOfIntegerShape.hxx | 12 +++++++++ src/GEOMAlgo/GEOMAlgo_PassKey.cxx | 2 ++ src/GEOMAlgo/GEOMAlgo_PassKey.hxx | 25 +++++++++++++++++++ src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.cxx | 17 +++++++++++++ src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.hxx | 11 ++++++++ src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx | 12 +++++++++ src/GEOMAlgo/GEOMAlgo_PassKeyShape.hxx | 13 ++++++++++ .../GEOMAlgo_PassKeyShapeMapHasher.cxx | 17 +++++++++++++ .../GEOMAlgo_PassKeyShapeMapHasher.hxx | 11 ++++++++ src/GEOMGUI/GeometryGUI.cxx | 16 ++++++++++++ src/STEPPlugin/STEPPlugin_ExportDriver.cxx | 14 ++++++++++- 13 files changed, 169 insertions(+), 1 deletion(-) diff --git a/src/GEOMAlgo/GEOMAlgo_ClsfSolid.hxx b/src/GEOMAlgo/GEOMAlgo_ClsfSolid.hxx index 20a6e6033..039486cbe 100644 --- a/src/GEOMAlgo/GEOMAlgo_ClsfSolid.hxx +++ b/src/GEOMAlgo/GEOMAlgo_ClsfSolid.hxx @@ -25,10 +25,16 @@ #ifndef _GEOMAlgo_ClsfSolid_HeaderFile #define _GEOMAlgo_ClsfSolid_HeaderFile +#include + #include #include #include +#if OCC_VERSION_LARGE < 0x07080000 #include +#else +#include +#endif #include DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf) diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapOfPassKeyInteger.hxx b/src/GEOMAlgo/GEOMAlgo_DataMapOfPassKeyInteger.hxx index 2dbddd353..973834342 100644 --- a/src/GEOMAlgo/GEOMAlgo_DataMapOfPassKeyInteger.hxx +++ b/src/GEOMAlgo/GEOMAlgo_DataMapOfPassKeyInteger.hxx @@ -25,14 +25,28 @@ #ifndef GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile #define GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile +#include + #include #include + +#if OCC_VERSION_LARGE < 0x07080000 #include #define _NCollection_MapHasher #include typedef NCollection_DataMap GEOMAlgo_DataMapOfPassKeyInteger; + +#else + +#include + +typedef NCollection_DataMap GEOMAlgo_DataMapOfPassKeyInteger; + +#endif // OCC_VERSION_LARGE < 0x07080000 + + typedef GEOMAlgo_DataMapOfPassKeyInteger::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger; #undef _NCollection_MapHasher diff --git a/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx index c848ff86c..68ad864de 100644 --- a/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx +++ b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx @@ -29,6 +29,11 @@ #include #include + +#include + +#if OCC_VERSION_LARGE < 0x07080000 + #include #define _NCollection_MapHasher @@ -39,6 +44,13 @@ typedef NCollection_IndexedDataMap + +typedef NCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfIntegerShape; + +#endif // OCC_VERSION_LARGE < 0x07080000 #endif diff --git a/src/GEOMAlgo/GEOMAlgo_PassKey.cxx b/src/GEOMAlgo/GEOMAlgo_PassKey.cxx index 9f052c40f..2a031c2b0 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKey.cxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKey.cxx @@ -206,6 +206,7 @@ static } return !bRet; } +#if OCC_VERSION_LARGE < 0x07080000 //======================================================================= //function : HashCode //purpose : @@ -214,6 +215,7 @@ static { return ::HashCode(mySum, aUpper); } +#endif //======================================================================= //function : Dump //purpose : diff --git a/src/GEOMAlgo/GEOMAlgo_PassKey.hxx b/src/GEOMAlgo/GEOMAlgo_PassKey.hxx index 77a74f073..bb5185689 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKey.hxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKey.hxx @@ -28,6 +28,8 @@ #ifndef _GEOMAlgo_PassKey_HeaderFile #define _GEOMAlgo_PassKey_HeaderFile +#include + #include #include #include @@ -88,8 +90,19 @@ class GEOMAlgo_PassKey { Standard_EXPORT Standard_Boolean IsEqual(const GEOMAlgo_PassKey& aOther) const; +#if OCC_VERSION_LARGE < 0x07080000 Standard_EXPORT Standard_Integer HashCode(const Standard_Integer Upper) const; +#endif + + Standard_EXPORT + bool operator==(const GEOMAlgo_PassKey& theOther) const + { + return IsEqual(theOther); + } + + Standard_EXPORT + size_t GetSum() const { return (size_t)mySum; } Standard_EXPORT Standard_Integer Id(const Standard_Integer aIndex) const; @@ -102,4 +115,16 @@ class GEOMAlgo_PassKey { Standard_Integer mySum; TColStd_IndexedMapOfInteger myMap; }; + +namespace std +{ + template <> + struct hash + { + size_t operator()(const GEOMAlgo_PassKey& thePK) const noexcept + { + return thePK.GetSum(); + } + }; +} #endif diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.cxx b/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.cxx index 79d55846e..9918596b4 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.cxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.cxx @@ -27,6 +27,8 @@ // #include +#if OCC_VERSION_LARGE < 0x07080000 + //======================================================================= //function : HashCode //purpose : @@ -45,3 +47,18 @@ { return aPK1.IsEqual(aPK2); } + +#else + +size_t GEOMAlgo_PassKeyMapHasher::operator()(const GEOMAlgo_PassKey& aPKey) const +{ + return aPKey.GetSum(); +} + +bool GEOMAlgo_PassKeyMapHasher::operator()(const GEOMAlgo_PassKey& aPKey1, + const GEOMAlgo_PassKey& aPKey2) const +{ + return aPKey1.IsEqual(aPKey2); +} + +#endif // OCC_VERSION_LARGE < 0x07080000 diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.hxx b/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.hxx index a6ce772af..144d5d14c 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.hxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyMapHasher.hxx @@ -34,12 +34,15 @@ #include #include +#include + //======================================================================= //class : GEOMAlgo_PassKeyMapHasher //purpose : //======================================================================= class GEOMAlgo_PassKeyMapHasher { public: +#if OCC_VERSION_LARGE < 0x07080000 Standard_EXPORT static Standard_Integer HashCode(const GEOMAlgo_PassKey& aPKey, const Standard_Integer Upper) ; @@ -47,5 +50,13 @@ class GEOMAlgo_PassKeyMapHasher { Standard_EXPORT static Standard_Boolean IsEqual(const GEOMAlgo_PassKey& aPKey1, const GEOMAlgo_PassKey& aPKey2) ; +#else + Standard_EXPORT + size_t operator()(const GEOMAlgo_PassKey& aPKey) const; + + Standard_EXPORT + bool operator()(const GEOMAlgo_PassKey& aPKey1, + const GEOMAlgo_PassKey& aPKey2) const; +#endif // OCC_VERSION_LARGE < 0x07080000 }; #endif diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx b/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx index fa0c73ee7..e4ceeb154 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx @@ -27,6 +27,8 @@ // #include +#include + #include #include @@ -94,7 +96,11 @@ static Clear(); myNbIds=1; myMap.Add(aS1); +#if OCC_VERSION_LARGE < 0x07080000 aHC=aS1.HashCode(myUpper); +#else + aHC = std::hash{}(aS1); +#endif mySum=NormalizedId(aHC, myNbIds); } //======================================================================= @@ -160,7 +166,11 @@ static myNbIds=myMap.Extent(); for(i=1; i<=myNbIds; ++i) { const TopoDS_Shape& aS=myMap(i); +#if OCC_VERSION_LARGE < 0x07080000 aId=aS.HashCode(myUpper); +#else + aId = std::hash{}(aS); +#endif aIdN=NormalizedId(aId, myNbIds); mySum+=aIdN; } @@ -195,6 +205,7 @@ static } return !bRet; } +#if OCC_VERSION_LARGE < 0x07080000 //======================================================================= //function : HashCode //purpose : @@ -203,6 +214,7 @@ static { return ::HashCode(mySum, aUpper); } +#endif //======================================================================= //function : Dump //purpose : diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyShape.hxx b/src/GEOMAlgo/GEOMAlgo_PassKeyShape.hxx index f846bfbf7..4ea580317 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyShape.hxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyShape.hxx @@ -29,6 +29,8 @@ #ifndef _GEOMAlgo_PassKeyShape_HeaderFile #define _GEOMAlgo_PassKeyShape_HeaderFile +#include + #include #include #include @@ -90,8 +92,19 @@ class GEOMAlgo_PassKeyShape { Standard_EXPORT Standard_Boolean IsEqual(const GEOMAlgo_PassKeyShape& aOther) const; +#if OCC_VERSION_LARGE < 0x07080000 Standard_EXPORT Standard_Integer HashCode(const Standard_Integer Upper) const; +#endif + + Standard_EXPORT + bool operator==(const GEOMAlgo_PassKeyShape& theOther) const + { + return IsEqual(theOther); + } + + Standard_EXPORT + size_t GetSum() const { return (size_t)mySum; } Standard_EXPORT void Dump(const Standard_Integer aHex = 0) const; diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.cxx b/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.cxx index 7e1dccbc1..e926870f9 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.cxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.cxx @@ -27,6 +27,8 @@ // #include +#if OCC_VERSION_LARGE < 0x07080000 + //======================================================================= //function : HashCode //purpose : @@ -45,3 +47,18 @@ { return aPK1.IsEqual(aPK2); } + +#else + +size_t GEOMAlgo_PassKeyShapeMapHasher::operator()(const GEOMAlgo_PassKeyShape& aPKey) const +{ + return aPKey.GetSum(); +} + +bool GEOMAlgo_PassKeyShapeMapHasher::operator()(const GEOMAlgo_PassKeyShape& aPKey1, + const GEOMAlgo_PassKeyShape& aPKey2) const +{ + return aPKey1.IsEqual(aPKey2); +} + +#endif // OCC_VERSION_LARGE < 0x07080000 diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.hxx b/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.hxx index 921d53db2..c656c45a4 100644 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.hxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyShapeMapHasher.hxx @@ -34,6 +34,8 @@ #include #include +#include + //======================================================================= //class : GEOMAlgo_PassKeyShapeMapHasher //purpose : @@ -41,6 +43,7 @@ class GEOMAlgo_PassKeyShapeMapHasher { public: +#if OCC_VERSION_LARGE < 0x07080000 Standard_EXPORT static Standard_Integer HashCode(const GEOMAlgo_PassKeyShape& aPKey, const Standard_Integer Upper) ; @@ -48,5 +51,13 @@ class GEOMAlgo_PassKeyShapeMapHasher Standard_EXPORT static Standard_Boolean IsEqual(const GEOMAlgo_PassKeyShape& aPKey1, const GEOMAlgo_PassKeyShape& aPKey2) ; +#else + Standard_EXPORT + size_t operator()(const GEOMAlgo_PassKeyShape& aPKey) const; + + Standard_EXPORT + bool operator()(const GEOMAlgo_PassKeyShape& aPKey1, + const GEOMAlgo_PassKeyShape& aPKey2) const; +#endif // OCC_VERSION_LARGE < 0x07080000 }; #endif diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 6c0e11d75..348d1fcc5 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -22,7 +22,23 @@ // File : GeometryGUI.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +#include + +#if OCC_VERSION_LARGE < 0x07080000 + #include // E.A. must be included before Python.h to fix compilation on windows + +#else + +#ifdef _MSC_VER +#ifndef _USE_MATH_DEFINES +#define _USE_MATH_DEFINES +#endif +#include +#endif + +#endif + #ifdef HAVE_FINITE #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined #endif diff --git a/src/STEPPlugin/STEPPlugin_ExportDriver.cxx b/src/STEPPlugin/STEPPlugin_ExportDriver.cxx index 1ed99c516..fa7492ea1 100644 --- a/src/STEPPlugin/STEPPlugin_ExportDriver.cxx +++ b/src/STEPPlugin/STEPPlugin_ExportDriver.cxx @@ -33,6 +33,8 @@ // OOCT includes #include #include +#include +#include #include #include #include @@ -126,12 +128,22 @@ Standard_Integer STEPPlugin_ExportDriver::Execute(Handle(TFunction_Logbook)& /*l Interface_Static::SetCVal("xstep.cascade.unit","M"); Interface_Static::SetCVal("write.step.unit", aWriteUnit.ToCString()); Interface_Static::SetIVal("write.step.nonmanifold", 1); -#else +#elif OCC_VERSION_LARGE < 0x07080000 STEPControl_Writer aWriterTmp; Interface_Static::SetCVal("xstep.cascade.unit","M"); Interface_Static::SetCVal("write.step.unit", aWriteUnit.ToCString()); Interface_Static::SetIVal("write.step.nonmanifold", 1); STEPControl_Writer aWriter; +#else + STEPControl_Writer aWriter; + Interface_Static::SetCVal("xstep.cascade.unit","M"); + Interface_Static::SetCVal("write.step.unit", aWriteUnit.ToCString()); + Interface_Static::SetIVal("write.step.nonmanifold", 1); + Handle(StepData_StepModel) aModel = aWriter.Model(); + aModel->InternalParameters.InitFromStatic(); + Standard_Integer aWriteUnitInt = Interface_Static::IVal("write.step.unit"); + Standard_Real aWriteUnitReal = UnitsMethods::GetLengthFactorValue(aWriteUnitInt); + aModel->SetWriteLengthUnit(aWriteUnitReal); #endif IFSelect_ReturnStatus status = aWriter.Transfer( aShape, STEPControl_AsIs ); -- 2.39.2