Porting to OCCT 7.8.0

This commit is contained in:
jfa 2024-01-15 13:37:48 +00:00
parent e3ce834889
commit d61331b252
13 changed files with 169 additions and 1 deletions

View File

@ -25,10 +25,16 @@
#ifndef _GEOMAlgo_ClsfSolid_HeaderFile
#define _GEOMAlgo_ClsfSolid_HeaderFile
#include <Basics_OCCTVersion.hxx>
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <TopoDS_Shape.hxx>
#if OCC_VERSION_LARGE < 0x07080000
#include <Standard_Address.hxx>
#else
#include <Standard_TypeDef.hxx>
#endif
#include <GEOMAlgo_Clsf.hxx>
DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf)

View File

@ -25,14 +25,28 @@
#ifndef GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile
#define GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile
#include <Basics_OCCTVersion.hxx>
#include <GEOMAlgo_PassKey.hxx>
#include <Standard_Integer.hxx>
#if OCC_VERSION_LARGE < 0x07080000
#include <GEOMAlgo_PassKeyMapHasher.hxx>
#define _NCollection_MapHasher
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<GEOMAlgo_PassKey, Standard_Integer, GEOMAlgo_PassKeyMapHasher> GEOMAlgo_DataMapOfPassKeyInteger;
#else
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<GEOMAlgo_PassKey, Standard_Integer> GEOMAlgo_DataMapOfPassKeyInteger;
#endif // OCC_VERSION_LARGE < 0x07080000
typedef GEOMAlgo_DataMapOfPassKeyInteger::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger;
#undef _NCollection_MapHasher

View File

@ -29,6 +29,11 @@
#include <TopoDS_Shape.hxx>
#include <Standard_Integer.hxx>
#include <Basics_OCCTVersion.hxx>
#if OCC_VERSION_LARGE < 0x07080000
#include <TColStd_MapIntegerHasher.hxx>
#define _NCollection_MapHasher
@ -39,6 +44,13 @@ typedef NCollection_IndexedDataMap<Standard_Integer, TopoDS_Shape, TColStd_MapIn
#undef _NCollection_MapHasher
#else
#include <NCollection_IndexedDataMap.hxx>
typedef NCollection_IndexedDataMap<Standard_Integer, TopoDS_Shape> GEOMAlgo_IndexedDataMapOfIntegerShape;
#endif // OCC_VERSION_LARGE < 0x07080000
#endif

View File

@ -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 :

View File

@ -28,6 +28,8 @@
#ifndef _GEOMAlgo_PassKey_HeaderFile
#define _GEOMAlgo_PassKey_HeaderFile
#include <Basics_OCCTVersion.hxx>
#include <Standard.hxx>
#include <Standard_Macro.hxx>
#include <Standard_Integer.hxx>
@ -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<GEOMAlgo_PassKey>
{
size_t operator()(const GEOMAlgo_PassKey& thePK) const noexcept
{
return thePK.GetSum();
}
};
}
#endif

View File

@ -27,6 +27,8 @@
//
#include <GEOMAlgo_PassKeyMapHasher.hxx>
#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

View File

@ -34,12 +34,15 @@
#include <Standard_Boolean.hxx>
#include <GEOMAlgo_PassKey.hxx>
#include <Basics_OCCTVersion.hxx>
//=======================================================================
//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

View File

@ -27,6 +27,8 @@
//
#include <GEOMAlgo_PassKeyShape.hxx>
#include <Basics_OCCTVersion.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
@ -94,7 +96,11 @@ static
Clear();
myNbIds=1;
myMap.Add(aS1);
#if OCC_VERSION_LARGE < 0x07080000
aHC=aS1.HashCode(myUpper);
#else
aHC = std::hash<TopoDS_Shape>{}(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<TopoDS_Shape>{}(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 :

View File

@ -29,6 +29,8 @@
#ifndef _GEOMAlgo_PassKeyShape_HeaderFile
#define _GEOMAlgo_PassKeyShape_HeaderFile
#include <Basics_OCCTVersion.hxx>
#include <Standard.hxx>
#include <Standard_Macro.hxx>
#include <Standard_Integer.hxx>
@ -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;

View File

@ -27,6 +27,8 @@
//
#include <GEOMAlgo_PassKeyShapeMapHasher.hxx>
#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

View File

@ -34,6 +34,8 @@
#include <Standard_Boolean.hxx>
#include <GEOMAlgo_PassKeyShape.hxx>
#include <Basics_OCCTVersion.hxx>
//=======================================================================
//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

View File

@ -22,7 +22,23 @@
// File : GeometryGUI.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
#include <Basics_OCCTVersion.hxx>
#if OCC_VERSION_LARGE < 0x07080000
#include <Standard_math.hxx> // 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 <math.h>
#endif
#endif
#ifdef HAVE_FINITE
#undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
#endif

View File

@ -33,6 +33,8 @@
// OOCT includes
#include <IFSelect_ReturnStatus.hxx>
#include <STEPControl_Writer.hxx>
#include <StepData_StepModel.hxx>
#include <UnitsMethods.hxx>
#include <Interface_Static.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Shape.hxx>
@ -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 );