work on #17497 - recursively cut shapes in a compound iindividually to work around OCCT limitation
This commit is contained in:
@@ -30,7 +30,9 @@
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRepCheck_Analyzer.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <FuzzyHelper.h>
|
||||
|
||||
@@ -78,3 +80,33 @@ void FCBRepAlgoAPIHelper::setAutoFuzzy(BRepAlgoAPI_BuilderAlgo* op) {
|
||||
BRepBndLib::Add(it.Value(), bounds);
|
||||
op->SetFuzzyValue(Part::FuzzyHelper::getBooleanFuzzy() * sqrt(bounds.SquareExtent()) * Precision::Confusion());
|
||||
}
|
||||
|
||||
void FCBRepAlgoAPI_BooleanOperation::Build(const Message_ProgressRange& theRange) {
|
||||
|
||||
if (myOperation==BOPAlgo_CUT && myArguments.Size()==1 && myArguments.First().ShapeType() == TopAbs_COMPOUND) {
|
||||
myOriginalArguments = myArguments;
|
||||
myShape = RecursiveCutCompound(myOriginalArguments.First(), theRange);
|
||||
} else {
|
||||
return BRepAlgoAPI_BooleanOperation::Build(theRange);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const TopoDS_Shape FCBRepAlgoAPI_BooleanOperation::RecursiveCutCompound(const TopoDS_Shape& theArgument, const Message_ProgressRange& theRange) {
|
||||
BRep_Builder builder;
|
||||
TopoDS_Compound comp;
|
||||
builder.MakeCompound(comp);
|
||||
TopoDS_Iterator it(theArgument);
|
||||
for (; it.More(); it.Next()) {
|
||||
TopTools_ListOfShape currentArguments;
|
||||
currentArguments.Append(it.Value());
|
||||
myArguments = currentArguments;
|
||||
Build(theRange);
|
||||
if (IsDone()) {
|
||||
builder.Add(comp, myShape);
|
||||
} else {
|
||||
return TopoDS_Shape();
|
||||
}
|
||||
}
|
||||
return comp;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ public:
|
||||
// set fuzzyness based on size
|
||||
void setAutoFuzzy();
|
||||
|
||||
Standard_EXPORT virtual void Build(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
protected: //! @name Constructors
|
||||
|
||||
//! Constructor to perform Boolean operation on only two arguments.
|
||||
@@ -57,5 +59,10 @@ protected: //! @name Constructors
|
||||
const TopoDS_Shape& theS2,
|
||||
const BOPAlgo_Operation theOperation);
|
||||
|
||||
|
||||
private:
|
||||
TopTools_ListOfShape myOriginalArguments;
|
||||
Standard_EXPORT const TopoDS_Shape RecursiveCutCompound(const TopoDS_Shape& theArgument, const Message_ProgressRange& theRange);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user