Add support for OCCT 7.8.0 (#11909)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user