Skip to content

Commit

Permalink
Part: TopoShape: add generalFuse method (GFA)
Browse files Browse the repository at this point in the history
OCC's Generaal Fuse Algorithm
  • Loading branch information
DeepSOIC committed Jul 4, 2016
1 parent ec20073 commit c8ebc7f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Mod/Part/App/TopoShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,42 @@ TopoDS_Compound TopoShape::slices(const Base::Vector3d& dir, const std::vector<d
return comp;
}

TopoDS_Shape TopoShape::generalFuse(const std::vector<TopoDS_Shape> &sOthers, Standard_Real tolerance, std::vector<TopTools_ListOfShape>* mapInOut) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
#if OCC_VERSION_HEX <= 0x060900
throw Base::Exception("GFA is available only in OCC 6.9.0 and up.");
#else
BRepAlgoAPI_BuilderAlgo mkGFA;
TopTools_ListOfShape GFAArguments;
GFAArguments.Append(this->_Shape);
for (const TopoDS_Shape &it: sOthers) {
if (it.IsNull())
throw Base::Exception("Tool shape is null");
if (tolerance > 0.0)
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
GFAArguments.Append(BRepBuilderAPI_Copy(it).Shape());
else
GFAArguments.Append(it);
}
mkGFA.SetArguments(GFAArguments);
if (tolerance > 0.0)
mkGFA.SetFuzzyValue(tolerance);
mkGFA.SetNonDestructive(Standard_True);
mkGFA.Build();
if (!mkGFA.IsDone())
throw Base::Exception("MultiFusion failed");
TopoDS_Shape resShape = mkGFA.Shape();
if (mapInOut){
for(TopTools_ListIteratorOfListOfShape it(GFAArguments); it.More(); it.Next()){
mapInOut->push_back(mkGFA.Modified(it.Value()));
}
}
return resShape;
#endif
}

TopoDS_Shape TopoShape::makePipe(const TopoDS_Shape& profile) const
{
if (this->_Shape.IsNull())
Expand Down
22 changes: 22 additions & 0 deletions src/Mod/Part/App/TopoShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,28 @@ class PartExport TopoShape : public Data::ComplexGeoData
TopoDS_Shape section(TopoDS_Shape) const;
std::list<TopoDS_Wire> slice(const Base::Vector3d&, double) const;
TopoDS_Compound slices(const Base::Vector3d&, const std::vector<double>&) const;
/**
* @brief generalFuse: run general fuse algorithm between this and shapes
* supplied as sOthers
*
* @param sOthers (input): list of shapes to run the algorithm between
* (this is automatically added to the list)
*
* @param tolerance (input): fuzzy value (pass zero to disable fuzzyness
* and use shape tolerances only)
*
* @param mapInOut (output): pointer to list of lists, to write the info
* which shapes in result came from which argument shape. The length of
* list is equal to length of sOthers+1. First element is a list of shapes
* that came from shape of this, and the rest are those that come from
* shapes in sOthers. If the info is not needed, nullptr can be passed.
*
* @return compound of slices that can be combined to reproduce results of
* cut, fuse, common. The shapes share edges and faces where they touch.
* For example, if input shapes are two intersecting spheres, GFA returns
* three solids: two cuts and common.
*/
TopoDS_Shape generalFuse(const std::vector<TopoDS_Shape> &sOthers, Standard_Real tolerance, std::vector<TopTools_ListOfShape>* mapInOut = nullptr) const;
//@}

/** Sweeping */
Expand Down

0 comments on commit c8ebc7f

Please sign in to comment.