Part: Add OCCT progress support to Part boolean and shape builders

Introduce a `Build(const Message_ProgressRange&)` overload in
`FCBRepAlgoAPI_BooleanOperation` (guarded by `OCC_VERSION_HEX <
0x070600`) and route user-abort checks around the operation. Add a new
`OCCTProgressIndicator` adapter (`OCCTProgressIndicator.h`) that bridges
`Message_ProgressIndicator` to `Base::ProgressIndicator`. Include
`OCCTProgressIndicator.h` where needed and update all `Build()` calls in
`TopoShape` and `TopoShapeExpansion` to pass
`OCCTProgressIndicator().Start()`, enabling singleton-based progress
reporting and user-break handling.
This commit is contained in:
Joao Matos
2025-05-18 18:05:57 +01:00
parent db02e43ad3
commit 39efc8ec0f
6 changed files with 200 additions and 5 deletions

View File

@@ -189,7 +189,7 @@
#include "TopoShapeSolidPy.h"
#include "TopoShapeVertexPy.h"
#include "TopoShapeWirePy.h"
#include "OCCTProgressIndicator.h"
FC_LOG_LEVEL_INIT("TopoShape",true,true)
@@ -1695,7 +1695,11 @@ TopoDS_Shape TopoShape::cut(const std::vector<TopoDS_Shape>& shapes, Standard_Re
} else if (tolerance < 0.0) {
mkCut.setAutoFuzzy();
}
#if OCC_VERSION_HEX >= 0x070600
mkCut.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
mkCut.Build();
#endif
if (!mkCut.IsDone())
throw Base::RuntimeError("Multi cut failed");
@@ -1734,7 +1738,11 @@ TopoDS_Shape TopoShape::common(const std::vector<TopoDS_Shape>& shapes, Standard
} else if (tolerance < 0.0) {
mkCommon.setAutoFuzzy();
}
#if OCC_VERSION_HEX >= 0x070600
mkCommon.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
mkCommon.Build();
#endif
if (!mkCommon.IsDone())
throw Base::RuntimeError("Multi common failed");
@@ -1773,7 +1781,11 @@ TopoDS_Shape TopoShape::fuse(const std::vector<TopoDS_Shape>& shapes, Standard_R
} else if (tolerance < 0.0) {
mkFuse.setAutoFuzzy();
}
#if OCC_VERSION_HEX >= 0x070600
mkFuse.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
mkFuse.Build();
#endif
if (!mkFuse.IsDone())
throw Base::RuntimeError("Multi fuse failed");
@@ -1792,7 +1804,11 @@ TopoDS_Shape TopoShape::section(TopoDS_Shape shape, Standard_Boolean approximate
mkSection.Init1(this->_Shape);
mkSection.Init2(shape);
mkSection.Approximation(approximate);
#if OCC_VERSION_HEX >= 0x070600
mkSection.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
mkSection.Build();
#endif
if (!mkSection.IsDone())
throw Base::RuntimeError("Section failed");
return mkSection.Shape();
@@ -1823,7 +1839,11 @@ TopoDS_Shape TopoShape::section(const std::vector<TopoDS_Shape>& shapes,
} else if (tolerance < 0.0) {
mkSection.setAutoFuzzy();
}
#if OCC_VERSION_HEX >= 0x070600
mkSection.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
mkSection.Build();
#endif
if (!mkSection.IsDone())
throw Base::RuntimeError("Multi section failed");
@@ -1886,7 +1906,11 @@ TopoDS_Shape TopoShape::generalFuse(const std::vector<TopoDS_Shape> &sOthers, St
FCBRepAlgoAPIHelper::setAutoFuzzy(&mkGFA);
}
mkGFA.SetNonDestructive(Standard_True);
#if OCC_VERSION_HEX >= 0x070600
mkGFA.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
mkGFA.Build();
#endif
if (!mkGFA.IsDone())
throw BooleanException("MultiFusion failed");
TopoDS_Shape resShape = mkGFA.Shape();
@@ -1940,8 +1964,11 @@ TopoDS_Shape TopoShape::makePipeShell(const TopTools_ListOfShape& profiles,
if (!mkPipeShell.IsReady())
throw Standard_Failure("shape is not ready to build");
#if OCC_VERSION_HEX >= 0x070600
mkPipeShell.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
mkPipeShell.Build();
#endif
if (make_solid)
mkPipeShell.MakeSolid();
@@ -2431,7 +2458,11 @@ TopoDS_Shape TopoShape::makeLoft(const TopTools_ListOfShape& profiles,
Standard_Boolean anIsCheck = Standard_True;
aGenerator.CheckCompatibility (anIsCheck); // use BRepFill_CompatibleWires on profiles. force #edges, orientation, "origin" to match.
#if OCC_VERSION_HEX >= 0x070600
aGenerator.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
aGenerator.Build();
#endif
if (!aGenerator.IsDone())
Standard_Failure::Raise("Failed to create loft face");
@@ -2573,7 +2604,11 @@ TopoDS_Shape TopoShape::makeOffsetShape(double offset, double tol, bool intersec
BRepOffsetAPI_ThruSections aGenerator;
aGenerator.AddWire(originalWire);
aGenerator.AddWire(offsetWire);
#if OCC_VERSION_HEX >= 0x070600
aGenerator.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
aGenerator.Build();
#endif
if (!aGenerator.IsDone())
{
Standard_Failure::Raise("ThruSections failed");
@@ -2880,8 +2915,11 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
//add final joining edge
mkWire.Add(BRepBuilderAPI_MakeEdge(v3,v1).Edge());
#if OCC_VERSION_HEX >= 0x070600
mkWire.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
mkWire.Build();
#endif
wiresForMakingFaces.push_front(mkWire.Wire());
}
}
@@ -2893,7 +2931,11 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
for(TopoDS_Wire &w : wiresForMakingFaces){
mkFace.addWire(w);
}
#if OCC_VERSION_HEX >= 0x070600
mkFace.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
mkFace.Build();
#endif
if (mkFace.Shape().IsNull())
throw Base::CADKernelError("makeOffset2D: making face failed (null shape returned).");
TopoDS_Shape result = mkFace.Shape();
@@ -3633,7 +3675,11 @@ TopoDS_Shape TopoShape::defeaturing(const std::vector<TopoDS_Shape>& s) const
defeat.SetShape(this->_Shape);
for (const auto & it : s)
defeat.AddFaceToRemove(it);
#if OCC_VERSION_HEX >= 0x070600
defeat.Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
defeat.Build();
#endif
if (!defeat.IsDone()) {
// error treatment
Standard_SStream aSStream;
@@ -3854,7 +3900,11 @@ TopoShape &TopoShape::makeFace(const std::vector<TopoShape> &shapes, const char
else if (s.getShape().ShapeType() != TopAbs_VERTEX)
mkFace->addShape(s.getShape());
}
#if OCC_VERSION_HEX >= 0x070600
mkFace->Build(OCCTProgressIndicator::getAppIndicator().Start());
#else
mkFace->Build();
#endif
_Shape = mkFace->Shape();
return *this;
}