diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index c80cd98989..b80559c59e 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -175,6 +175,10 @@ #include #endif +#if OCC_VERSION_HEX >= 0x070300 +#include +#endif + #include #include #include @@ -3414,3 +3418,31 @@ void TopoShape::getFacesFromSubelement(const Data::Segment* element, points.swap(meshPoints); } } + +TopoDS_Shape TopoShape::defeaturing(const std::vector& 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::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(); +} diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index e6af8faee6..30d0174ca5 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -237,6 +237,7 @@ public: bool fix(double, double, double); bool removeInternalWires(double); TopoDS_Shape removeSplitter() const; + TopoDS_Shape defeaturing(const std::vector& s) const; //@} /** @name Getting basic geometric entities */