add OCC defeaturing to TopoShape

This commit is contained in:
tomate44
2018-07-03 13:44:03 +02:00
committed by wmayer
parent e6658ed3f3
commit 4a0ea3c0ec
2 changed files with 33 additions and 0 deletions

View File

@@ -175,6 +175,10 @@
#include <BOPAlgo_ListOfCheckResult.hxx>
#endif
#if OCC_VERSION_HEX >= 0x070300
#include <BRepAlgoAPI_Defeaturing.hxx>
#endif
#include <Base/Builder3D.h>
#include <Base/FileInfo.h>
#include <Base/Exception.h>
@@ -3414,3 +3418,31 @@ void TopoShape::getFacesFromSubelement(const Data::Segment* element,
points.swap(meshPoints);
}
}
TopoDS_Shape TopoShape::defeaturing(const std::vector<TopoDS_Shape>& s) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
if (OCC_VERSION_HEX < 0x070300)
throw Base::RuntimeError("Defeaturing is not supported on OCC < 7.3.0.");
BRepAlgoAPI_Defeaturing defeat;
defeat.SetRunParallel(true);
defeat.SetShape(this->_Shape);
for (std::vector<TopoDS_Shape>::const_iterator it = s.begin(); it != s.end(); ++it)
defeat.AddFaceToRemove(*it);
defeat.Build();
if (!defeat.IsDone()) {
// error treatment
Standard_SStream aSStream;
defeat.DumpErrors(aSStream);
const std::string& resultstr = aSStream.str();
const char* cstr2 = resultstr.c_str();
throw Base::RuntimeError(cstr2);
}
// if (defeat.HasWarnings()) {
// // warnings treatment
// Standard_SStream aSStream;
// defeat.DumpWarnings(aSStream);
// }
return defeat.Shape();
}

View File

@@ -237,6 +237,7 @@ public:
bool fix(double, double, double);
bool removeInternalWires(double);
TopoDS_Shape removeSplitter() const;
TopoDS_Shape defeaturing(const std::vector<TopoDS_Shape>& s) const;
//@}
/** @name Getting basic geometric entities */