// function: Perform
// purpose: Performs the removal of the requested faces from the input shape
//=======================================================================
-void BOPAlgo_RemoveFeatures::Perform(const Message_ProgressRange& /*theRange*/)
+void BOPAlgo_RemoveFeatures::Perform(const Message_ProgressRange& theRange)
{
try
{
if (HasErrors())
return;
+ Message_ProgressScope aPS(theRange, "Removing features", 100);
+
// Prepare the faces to remove.
- PrepareFeatures();
+ PrepareFeatures(aPS.Next(10));
if (HasErrors())
return;
// Remove the features and fill the created gaps
- RemoveFeatures();
+ RemoveFeatures(aPS.Next(70));
+ if (HasErrors())
+ return;
// Update history with the removed features
- UpdateHistory();
+ UpdateHistory(aPS.Next(10));
+ if (HasErrors())
+ return;
// Simplify the result
- SimplifyResult();
+ SimplifyResult(aPS.Next(10));
+ if (HasErrors())
+ return;
// Post treatment
PostTreat();
// function: PrepareFeatures
// purpose: Prepares the features to remove
//=======================================================================
-void BOPAlgo_RemoveFeatures::PrepareFeatures()
+void BOPAlgo_RemoveFeatures::PrepareFeatures(const Message_ProgressRange& theRange)
{
// Map all sub-shapes of the input solids
TopExp::MapShapes(myInputShape, myInputsMap);
// Collect all faces of the input shape requested for removal
TopTools_ListOfShape aFacesToRemove;
TopTools_ListIteratorOfListOfShape aIt(myFacesToRemove);
- for (; aIt.More(); aIt.Next())
+ Message_ProgressScope aPS(theRange, "Preparing the faces to remove", myFacesToRemove.Size());
+ for (; aIt.More(); aIt.Next(), aPS.Next())
{
+ if (UserBreak(aPS))
+ {
+ return;
+ }
const TopoDS_Shape& aS = aIt.Value();
TopExp_Explorer anExpF(aS, TopAbs_FACE);
for (; anExpF.More(); anExpF.Next())
myFSMap = (TopTools_IndexedDataMapOfShapeListOfShape*)&theFSMap;
}
+ void SetRange(const Message_ProgressRange& theRange)
+ {
+ myRange = theRange;
+ }
+
//! Defines the parallel processing mode
void SetRunParallel(const Standard_Boolean bRunParallel) { myRunParallel = bRunParallel; }
//! then trims the extended faces to fill the gaps
void Perform()
{
+ Message_ProgressScope aPS(myRange, NULL, 1);
+ if (!aPS.More())
+ {
+ return;
+ }
OCC_CATCH_SIGNALS
try
TopoDS_Shape myFeature; //!< Feature to remove
TopTools_IndexedDataMapOfShapeListOfShape* myEFMap; //!< EF Connection map to find adjacent faces
TopTools_IndexedDataMapOfShapeListOfShape* myFSMap; //!< FS Connection map to find solids participating in the feature removal
+ Message_ProgressRange myRange; //!< Indication of progress
// Results
TopTools_MapOfShape myFeatureFacesMap; //!< Faces of the feature
// purpose: Remove features by filling the gaps by extension of the
// adjacent faces
//=======================================================================
-void BOPAlgo_RemoveFeatures::RemoveFeatures()
+void BOPAlgo_RemoveFeatures::RemoveFeatures(const Message_ProgressRange& theRange)
{
// For each feature:
// - Find the faces adjacent to the feature;
// - Rebuild the solids with reconstructed adjacent faces
// and avoiding the feature faces.
+ Message_ProgressScope aPSOuter(theRange, "Removing features", 100);
+
// Make Edge-Face connection map of the input
// shape to find faces adjacent to the feature
TopTools_IndexedDataMapOfShapeListOfShape anEFMap;
aFG.SetRunParallel(myRunParallel);
}
+ const Standard_Integer aNbF = aVFG.Length();
+ Message_ProgressScope aPS(aPSOuter.Next(60), "Filling gaps", aNbF);
+ for (Standard_Integer i = 0; i < aNbF; ++i)
+ {
+ FillGap& aFG = aVFG.ChangeValue(i);
+ aFG.SetRange(aPS.Next());
+ }
+
// Perform the reconstruction of the adjacent faces
BOPTools_Parallel::Perform (myRunParallel, aVFG);
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
// Even if the history is not requested, it is necessary to track:
// - The solids modification after each feature removal to find
// Remove the features one by one.
// It will allow removing the features even if there were
// some problems with removal of the previous features.
- const Standard_Integer aNbF = aVFG.Length();
- for (Standard_Integer i = 0; i < aNbF; ++i)
+ Message_ProgressScope aPSLoop(aPSOuter.Next(40), "Removing features one by one", aNbF);
+ for (Standard_Integer i = 0; i < aNbF; ++i, aPSLoop.Next())
{
+ if (UserBreak(aPSLoop))
+ {
+ return;
+ }
FillGap& aFG = aVFG(i);
// No need to fill the history for solids if the history is not
// function: UpdateHistory
// purpose: Update history with the removed features
//=======================================================================
-void BOPAlgo_RemoveFeatures::UpdateHistory()
+void BOPAlgo_RemoveFeatures::UpdateHistory(const Message_ProgressRange& theRange)
{
if (!HasHistory())
return;
BRepTools_History aHistory;
const Standard_Integer aNbS = myInputsMap.Extent();
- for (Standard_Integer i = 1; i <= aNbS; ++i)
+ Message_ProgressScope aPS(theRange, "Updating history", aNbS);
+ for (Standard_Integer i = 1; i <= aNbS; ++i, aPS.Next())
{
+ if (UserBreak(aPS))
+ {
+ return;
+ }
const TopoDS_Shape& aS = myInputsMap(i);
if (!BRepTools_History::IsSupportedType(aS))
continue;
// purpose: Simplifies the result by removing extra edges and vertices
// created during operation
//=======================================================================
-void BOPAlgo_RemoveFeatures::SimplifyResult()
+void BOPAlgo_RemoveFeatures::SimplifyResult(const Message_ProgressRange& theRange)
{
if (myShape.IsSame(myInputShape))
return;
if (myMapShape.IsEmpty())
TopExp::MapShapes(myShape, myMapShape);
+ Message_ProgressScope aPSOuter(theRange, "Simplifyingthe result", 2);
+
const Standard_Integer aNbS = myInputsMap.Extent();
- for (Standard_Integer i = 1; i <= aNbS; ++i)
+ Message_ProgressScope aPS(aPSOuter.Next(), NULL, aNbS);
+ for (Standard_Integer i = 1; i <= aNbS; ++i, aPS.Next())
{
+ if (UserBreak(aPS))
+ {
+ return;
+ }
if (myMapShape.Contains(myInputsMap(i)))
aSDTool.KeepShape(myInputsMap(i));
}
// Perform unification
aSDTool.Build();
+ aPSOuter.Next();
myShape = aSDTool.Shape();
if (HasHistory())
myHistory->Merge(aSDTool.History());