Part: TopoShape: add generalFuse method (GFA)
OCC's Generaal Fuse Algorithm
This commit is contained in:
parent
ec20073563
commit
c8ebc7f9c2
|
@ -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())
|
||||
|
|
|
@ -153,6 +153,28 @@ public:
|
|||
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 */
|
||||
|
|
Loading…
Reference in New Issue
Block a user