Skip to content

Commit

Permalink
add OCC defeaturing to TopoShape
Browse files Browse the repository at this point in the history
  • Loading branch information
tomate44 authored and wwmayer committed Jul 29, 2018
1 parent e6658ed commit 4a0ea3c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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();
}
1 change: 1 addition & 0 deletions src/Mod/Part/App/TopoShape.h
Expand Up @@ -237,6 +237,7 @@ class PartExport TopoShape : public Data::ComplexGeoData
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 */
Expand Down

0 comments on commit 4a0ea3c

Please sign in to comment.