Add support for OCCT 7.8.0 (#11909)

This commit is contained in:
bgbsww
2024-01-09 20:47:25 -05:00
committed by GitHub
parent b1ee268d98
commit bd1fc0fc03
29 changed files with 161 additions and 35 deletions

View File

@@ -127,8 +127,6 @@ if(OCC_FOUND)
TKG2d
TKG3d
TKMath
TKIGES
TKSTL
TKShHealing
TKXSBase
TKBool
@@ -139,10 +137,6 @@ if(OCC_FOUND)
TKGeomBase
TKOffset
TKPrim
TKSTEPBase
TKSTEPAttr
TKSTEP209
TKSTEP
TKHLR
TKFeat
)
@@ -154,8 +148,6 @@ if(OCC_FOUND)
TKLCAF
TKVCAF
TKCDF
TKXDESTEP
TKXDEIGES
TKMeshVS
TKService
TKV3d
@@ -164,6 +156,12 @@ if(OCC_FOUND)
if(NOT OCC_VERSION_STRING VERSION_LESS 7.5.0)
list(APPEND OCC_OCAF_LIBRARIES TKRWMesh)
endif(NOT OCC_VERSION_STRING VERSION_LESS 7.5.0)
if(OCC_VERSION_STRING VERSION_LESS 7.8.0)
list(APPEND OCC_LIBRARIES TKIGES TKSTL TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP)
list(APPEND OCC_OCAF_LIBRARIES TKXDESTEP TKXDEIGES)
else(OCC_VERSION_STRING VERSION_LESS 7.8.0)
list(APPEND OCC_LIBRARIES TKDESTEP TKDEIGES TKDEGLTF TKDESTL)
endif(OCC_VERSION_STRING VERSION_LESS 7.8.0)
message(STATUS "-- Found OCE/OpenCASCADE version: ${OCC_VERSION_STRING}")
message(STATUS "-- OCE/OpenCASCADE include directory: ${OCC_INCLUDE_DIR}")
message(STATUS "-- OCE/OpenCASCADE shared libraries directory: ${OCC_LIBRARY_DIR}")

View File

@@ -29,13 +29,26 @@
#include <TopoDS_Shape.hxx>
#include <Standard_Version.hxx>
/*
* This method needed for instance NCollection_DataMap with TopoDS_Shape as key
*/
#if OCC_VERSION_HEX >= 0x070800
struct SMESHDS_Hasher
{
size_t operator()(const TopoDS_Shape& S) const noexcept {
return std::hash<TopoDS_Shape>{}(S);
}
size_t operator()(const TopoDS_Shape& S1, const TopoDS_Shape& S2) const noexcept {
return S1.IsSame(S2);
}
};
#else
struct SMESHDS_Hasher
{
static inline Standard_Boolean IsEqual(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
const TopoDS_Shape& S2)
{
return S1.IsSame(S2);
}
@@ -45,6 +58,6 @@ struct SMESHDS_Hasher
return ::HashCode( S, Upper);
}
};
#endif
#endif

View File

@@ -57,9 +57,6 @@
#ifndef _MeshVS_EntityType_HeaderFile
#include <MeshVS_EntityType.hxx>
#endif
#ifndef _Standard_Address_HeaderFile
#include <Standard_Address.hxx>
#endif
#ifndef _TColStd_HArray1OfInteger_HeaderFile
#include <TColStd_HArray1OfInteger.hxx>
#endif

View File

@@ -37,4 +37,5 @@
#define SMESH_EXPORT
#endif
#include <Standard_Version.hxx>
#endif

View File

@@ -28,10 +28,11 @@
#include "SMESH_SMESH.hxx"
#include <NCollection_DefineSequence.hxx>
#if OCC_VERSION_HEX >= 0x060703
#include <NCollection_IncAllocator.hxx>
#include <NCollection_Sequence.hxx>
#else
#include <NCollection_DefineSequence.hxx>
#endif
typedef const SMDS_MeshNode* SMDS_MeshNodePtr;

View File

@@ -185,11 +185,18 @@ typedef std::vector< UVPtStruct > UVPtStructVec;
// --------------------------------------------------------------------------------
// class SMESH_SequenceOfElemPtr
#include <Standard_Version.hxx>
#if OCC_VERSION_HEX >= 0x060703
#include <NCollection_Sequence.hxx>
#else
#include <NCollection_DefineSequence.hxx>
#endif
class SMDS_MeshElement;
typedef const SMDS_MeshElement* SMDS_MeshElementPtr;
#define DEFINE_SEQUENCE(_ClassName_, _BaseCollection_, TheItemType) \
typedef NCollection_Sequence<TheItemType > _ClassName_;
DEFINE_SEQUENCE (SMESH_SequenceOfElemPtr, SMESH_BaseCollectionElemPtr, SMDS_MeshElementPtr)

View File

@@ -33,10 +33,33 @@
#include "SMDS_MeshNode.hxx"
#include "SMESH_File.hxx"
#include <Standard_Version.hxx>
namespace
{
struct Hasher
{
#if OCC_VERSION_HEX >= 0x070800
size_t operator()(const gp_Pnt& point) const noexcept
{
union
{
Standard_Real R[3];
Standard_Integer I[6];
} U;
point.Coord( U.R[0], U.R[1], U.R[2] );
return std::hash<Standard_Integer>{}(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7);
}
size_t operator()(const gp_Pnt& point1, const gp_Pnt& point2) const noexcept
{
static Standard_Real tab1[3], tab2[3];
point1.Coord(tab1[0],tab1[1],tab1[2]);
point2.Coord(tab2[0],tab2[1],tab2[2]);
return (memcmp(tab1,tab2,sizeof(tab1)) == 0);
}
#else
//=======================================================================
//function : HashCode
//purpose :
@@ -51,9 +74,9 @@ namespace
} U;
point.Coord( U.R[0], U.R[1], U.R[2] );
return ::HashCode(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7,Upper);
return std::hash<Standard_Integer>{}(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7);
}
//=======================================================================
//function : IsEqual
//purpose :
@@ -66,7 +89,9 @@ namespace
point2.Coord(tab2[0],tab2[1],tab2[2]);
return (memcmp(tab1,tab2,sizeof(tab1)) == 0);
}
#endif
};
typedef NCollection_DataMap<gp_Pnt,SMDS_MeshNode*,Hasher> TDataMapOfPntNodePtr;
const int HEADER_SIZE = 84;

View File

@@ -48,7 +48,6 @@
#include <Bnd_Box.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Geom_Surface.hxx>
#include <NCollection_DefineArray2.hxx>
#include <Precision.hxx>
#include <Standard_Real.hxx>
#include <TColStd_SequenceOfInteger.hxx>

View File

@@ -28,7 +28,6 @@
#include <SMESHDS_Mesh.hxx>
#include <SMESH_Mesh.hxx>
#include <Standard_math.hxx>
#endif
#include <Base/Console.h>

View File

@@ -151,7 +151,11 @@ void ImportOCAF::loadShapes(const TDF_Label& label,
std::vector<App::DocumentObject*> localValue;
if (aShapeTool->GetShape(label, aShape)) {
#if OCC_VERSION_HEX >= 0x070800
hash = std::hash<TopoDS_Shape> {}(aShape);
#else
hash = aShape.HashCode(HashUpper);
#endif
}
Handle(TDataStd_Name) name;
@@ -223,7 +227,11 @@ void ImportOCAF::loadShapes(const TDF_Label& label,
if (isRef || myRefShapes.find(hash) == myRefShapes.end()) {
TopoDS_Shape aShape;
if (isRef && aShapeTool->GetShape(label, aShape)) {
#if OCC_VERSION_HEX >= 0x070800
myRefShapes.insert(std::hash<TopoDS_Shape> {}(aShape));
#else
myRefShapes.insert(aShape.HashCode(HashUpper));
#endif
}
if (aShapeTool->IsSimpleShape(label) && (isRef || aShapeTool->IsFree(label))) {
@@ -550,7 +558,11 @@ void ImportXCAF::createShape(const TopoDS_Shape& shape, bool perface, bool setna
part->Label.setValue(default_name);
part->Shape.setValue(shape);
std::map<Standard_Integer, Quantity_ColorRGBA>::const_iterator jt;
#if OCC_VERSION_HEX >= 0x070800
jt = myColorMap.find(std::hash<TopoDS_Shape> {}(shape));
#else
jt = myColorMap.find(shape.HashCode(INT_MAX));
#endif
App::Color partColor(0.8f, 0.8f, 0.8f);
#if 0 // TODO
@@ -571,7 +583,11 @@ void ImportXCAF::createShape(const TopoDS_Shape& shape, bool perface, bool setna
// set label name if defined
if (setname && !myNameMap.empty()) {
std::map<Standard_Integer, std::string>::const_iterator jt;
#if OCC_VERSION_HEX >= 0x070800
jt = myNameMap.find(std::hash<TopoDS_Shape> {}(shape));
#else
jt = myNameMap.find(shape.HashCode(INT_MAX));
#endif
if (jt != myNameMap.end()) {
part->Label.setValue(jt->second);
}
@@ -591,7 +607,11 @@ void ImportXCAF::createShape(const TopoDS_Shape& shape, bool perface, bool setna
faceColors.resize(faces.Extent(), partColor);
xp.Init(shape, TopAbs_FACE);
while (xp.More()) {
#if OCC_VERSION_HEX >= 0x070800
jt = myColorMap.find(std::hash<TopoDS_Shape> {}(xp.Current()));
#else
jt = myColorMap.find(xp.Current().HashCode(INT_MAX));
#endif
if (jt != myColorMap.end()) {
int index = faces.FindIndex(xp.Current());
faceColors[index - 1] = convertColor(jt->second);
@@ -626,29 +646,57 @@ void ImportXCAF::loadShapes(const TDF_Label& label)
// add the shapes
TopExp_Explorer xp;
for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++) {
#if OCC_VERSION_HEX >= 0x070800
this->mySolids[std::hash<TopoDS_Shape> {}(xp.Current())] = (xp.Current());
#else
this->mySolids[xp.Current().HashCode(INT_MAX)] = (xp.Current());
#endif
}
for (xp.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); xp.More(); xp.Next(), ctShells++) {
#if OCC_VERSION_HEX >= 0x070800
this->myShells[std::hash<TopoDS_Shape> {}(xp.Current())] = (xp.Current());
#else
this->myShells[xp.Current().HashCode(INT_MAX)] = (xp.Current());
#endif
}
// if no solids and no shells were found then go for compounds
if (ctSolids == 0 && ctShells == 0) {
for (xp.Init(aShape, TopAbs_COMPOUND); xp.More(); xp.Next(), ctComps++) {
#if OCC_VERSION_HEX >= 0x070800
this->myCompds[std::hash<TopoDS_Shape> {}(xp.Current())] = (xp.Current());
#else
this->myCompds[xp.Current().HashCode(INT_MAX)] = (xp.Current());
#endif
}
}
if (ctComps == 0) {
for (xp.Init(aShape, TopAbs_FACE, TopAbs_SHELL); xp.More(); xp.Next()) {
#if OCC_VERSION_HEX >= 0x070800
this->myShapes[std::hash<TopoDS_Shape> {}(xp.Current())] = (xp.Current());
#else
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
#endif
}
for (xp.Init(aShape, TopAbs_WIRE, TopAbs_FACE); xp.More(); xp.Next()) {
#if OCC_VERSION_HEX >= 0x070800
this->myShapes[std::hash<TopoDS_Shape> {}(xp.Current())] = (xp.Current());
#else
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
#endif
}
for (xp.Init(aShape, TopAbs_EDGE, TopAbs_WIRE); xp.More(); xp.Next()) {
#if OCC_VERSION_HEX >= 0x070800
this->myShapes[std::hash<TopoDS_Shape> {}(xp.Current())] = (xp.Current());
#else
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
#endif
}
for (xp.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); xp.More(); xp.Next()) {
#if OCC_VERSION_HEX >= 0x070800
this->myShapes[std::hash<TopoDS_Shape> {}(xp.Current())] = (xp.Current());
#else
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
#endif
}
}
}
@@ -659,7 +707,11 @@ void ImportXCAF::loadShapes(const TDF_Label& label)
|| hColors->GetColor(label, XCAFDoc_ColorSurf, col)
|| hColors->GetColor(label, XCAFDoc_ColorCurv, col)) {
// add defined color
#if OCC_VERSION_HEX >= 0x070800
myColorMap[std::hash<TopoDS_Shape> {}(aShape)] = col;
#else
myColorMap[aShape.HashCode(INT_MAX)] = col;
#endif
}
else {
// http://www.opencascade.org/org/forum/thread_17107/
@@ -669,7 +721,11 @@ void ImportXCAF::loadShapes(const TDF_Label& label)
|| hColors->GetColor(it.Value(), XCAFDoc_ColorSurf, col)
|| hColors->GetColor(it.Value(), XCAFDoc_ColorCurv, col)) {
// add defined color
#if OCC_VERSION_HEX >= 0x070800
myColorMap[std::hash<TopoDS_Shape> {}(it.Value())] = col;
#else
myColorMap[it.Value().HashCode(INT_MAX)] = col;
#endif
}
}
}
@@ -682,7 +738,11 @@ void ImportXCAF::loadShapes(const TDF_Label& label)
extstr.ToUTF8CString(str);
std::string labelName(str);
if (!labelName.empty()) {
#if OCC_VERSION_HEX >= 0x070800
myNameMap[std::hash<TopoDS_Shape> {}(aShape)] = labelName;
#else
myNameMap[aShape.HashCode(INT_MAX)] = labelName;
#endif
}
delete[] str;
}

View File

@@ -30,7 +30,6 @@
#include <unordered_map>
#include <vector>
#include <TDF_LabelMapHasher.hxx>
#include <TDocStd_Document.hxx>
#include <TopoDS_Shape.hxx>
#include <XCAFDoc_ColorTool.hxx>

View File

@@ -24,12 +24,13 @@
#define IMPORT_TOOLS_H
#include <Quantity_ColorRGBA.hxx>
#include <TDF_LabelMapHasher.hxx>
#include <TopoDS_Shape.hxx>
#include <XCAFDoc_ColorTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <App/Color.h>
#include <Standard_Version.hxx>
namespace Import
{
@@ -37,7 +38,11 @@ struct ShapeHasher
{
std::size_t operator()(const TopoDS_Shape& shape) const
{
#if OCC_VERSION_HEX >= 0x070800
return std::hash<TopoDS_Shape> {}(shape);
#else
return shape.HashCode(INT_MAX);
#endif
}
};
@@ -45,7 +50,11 @@ struct LabelHasher
{
std::size_t operator()(const TDF_Label& label) const
{
#if OCC_VERSION_HEX >= 0x070800
return std::hash<TDF_Label> {}(label);
#else
return TDF_LabelMapHasher::HashCode(label, INT_MAX);
#endif
}
};

View File

@@ -32,6 +32,7 @@
#include <Mod/Mesh/App/Mesh.h>
#include <Mod/MeshPart/MeshPartGlobal.h>
#include <Standard_Version.hxx>
namespace MeshCore
{
@@ -65,7 +66,12 @@ public:
{
bool operator()(const T& x, const T& y) const
{
#if OCC_VERSION_HEX >= 0x070800
std::hash<T> hasher;
return hasher(x) < hasher(y);
#else
return x.HashCode(INT_MAX - 1) < y.HashCode(INT_MAX - 1);
#endif
}
};

View File

@@ -137,7 +137,12 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
// This is a trick to access the GUI via Python and set the color property
// of the associated view provider. If no GUI is up an exception is thrown
// and cleared immediately
#if OCC_VERSION_HEX >= 0x070800
std::hash<TopoDS_Solid> hasher;
std::map<int, Quantity_Color>::iterator it = hash_col.find(hasher(aSolid));
#else
std::map<int, Quantity_Color>::iterator it = hash_col.find(aSolid.HashCode(INT_MAX));
#endif
if (it != hash_col.end()) {
try {
Py::Object obj(pcFeature->getPyObject(), true);

View File

@@ -1306,7 +1306,11 @@ PyObject* TopoShapePy::ancestorsOfType(PyObject *args)
TopTools_ListIteratorOfListOfShape it(ancestors);
for (; it.More(); it.Next()) {
// make sure to avoid duplicates
#if OCC_VERSION_HEX >= 0x070800
const size_t code = std::hash<TopoDS_Shape>{}(static_cast<TopoDS_Shape>(it.Value()));
#else
Standard_Integer code = it.Value().HashCode(INT_MAX);
#endif
if (hashes.find(code) == hashes.end()) {
list.append(shape2pyshape(it.Value()));
hashes.insert(code);
@@ -1928,7 +1932,11 @@ PyObject* TopoShapePy::hashCode(PyObject *args)
if (!PyArg_ParseTuple(args, "|i",&upper))
return nullptr;
#if OCC_VERSION_HEX >= 0x070800
int hc = std::hash<TopoDS_Shape>{}(getTopoShapePtr()->getShape());
#else
int hc = getTopoShapePtr()->getShape().HashCode(upper);
#endif
return Py_BuildValue("i", hc);
}

View File

@@ -24,7 +24,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Standard_math.hxx>
#endif
#include <Base/Console.h>

View File

@@ -26,7 +26,6 @@
# include <QFileInfo>
# include <QPointer>
# include <QString>
# include <Standard_math.hxx>
# include <Standard_Version.hxx>
# include <TopExp_Explorer.hxx>
# include <TopoDS_Shape.hxx>

View File

@@ -23,7 +23,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Standard_math.hxx>
# include <QInputDialog>
#endif

View File

@@ -28,7 +28,6 @@
# include <QKeyEvent>
# include <BRep_Builder.hxx>
# include <Standard_math.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Compound.hxx>

View File

@@ -25,7 +25,6 @@
#ifndef _PreComp_
# include <cfloat>
# include <Standard_math.hxx>
# include <Inventor/nodes/SoAnnotation.h>
# include <Inventor/nodes/SoBaseColor.h>

View File

@@ -982,7 +982,11 @@ void ViewProviderPartExt::updateVisual()
TopExp_Explorer xp;
for (xp.Init(faceMap(i),TopAbs_EDGE);xp.More();xp.Next())
#if OCC_VERSION_HEX >= 0x070800
faceEdges.insert(std::hash<TopoDS_Shape>{}(xp.Current()));
#else
faceEdges.insert(xp.Current().HashCode(INT_MAX));
#endif
numFaces++;
}
@@ -1010,7 +1014,11 @@ void ViewProviderPartExt::updateVisual()
// So, we have to store the hashes of the edges associated to a face.
// If the hash of a given edge is not in this list we know it's really
// a free edge.
#if OCC_VERSION_HEX >= 0x070800
int hash = std::hash<TopoDS_Shape>{}(aEdge);
#else
int hash = aEdge.HashCode(INT_MAX);
#endif
if (faceEdges.find(hash) == faceEdges.end()) {
Handle(Poly_Polygon3D) aPoly = Part::Tools::polygonOfEdge(aEdge, aLoc);
if (!aPoly.IsNull()) {
@@ -1209,7 +1217,11 @@ void ViewProviderPartExt::updateVisual()
TopLoc_Location aLoc;
// handling of the free edge that are not associated to a face
#if OCC_VERSION_HEX >= 0x070800
int hash = std::hash<TopoDS_Shape>{}(aEdge);
#else
int hash = aEdge.HashCode(INT_MAX);
#endif
if (faceEdges.find(hash) == faceEdges.end()) {
Handle(Poly_Polygon3D) aPoly = Part::Tools::polygonOfEdge(aEdge, aLoc);
if (!aPoly.IsNull()) {

View File

@@ -24,7 +24,6 @@
#define PARTGUI_VIEWPROVIDERPARTEXT_H
#include <map>
#include <Standard_math.hxx>
#include <App/PropertyUnits.h>
#include <Gui/ViewProviderGeometryObject.h>

View File

@@ -27,7 +27,6 @@
# include <QMenu>
# include <QTimer>
# include <Standard_math.hxx>
# include <TopExp.hxx>
# include <TopTools_IndexedMapOfShape.hxx>

View File

@@ -22,7 +22,6 @@
#include "PreCompiled.h"
#include <Standard_math.hxx>
#ifndef _PreComp_
# include <Inventor/nodes/SoSeparator.h>
#endif

View File

@@ -24,7 +24,6 @@
#ifndef PARTGUI_ViewProviderPartReference_H
#define PARTGUI_ViewProviderPartReference_H
#include <Standard_math.hxx>
#include <Standard_Boolean.hxx>
#include <TopoDS_Shape.hxx>
#include <Gui/ViewProviderGeometryObject.h>

View File

@@ -22,7 +22,8 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Standard_math.hxx>
#define _USE_MATH_DEFINES
# include <math.h>
#endif
#include <Base/Vector3D.h>

View File

@@ -38,8 +38,6 @@
# define PathGuiExport
#endif
#include <Standard_math.hxx>
#ifdef _MSC_VER
# pragma warning( disable : 4273 )
#endif

View File

@@ -38,8 +38,6 @@
#define RobotGuiExport
#endif
#include <Standard_math.hxx>
#ifdef _MSC_VER
#pragma warning(disable : 4005)
#pragma warning(disable : 4273)

View File

@@ -23,7 +23,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <Standard_math.hxx>
/// Qt Include Files
#include <Inventor/sensors/SoSensor.h>
#include <QApplication>