Provide suitable way of keeping the progress steps of operations.
Give meaningful names to progress scopes.
Propagate progress indicator into deeper methods of BOA.
Add progress indicator to BOPAlgo_BuilderFace and BOPAlgo_WireSplitter, BOPAlgo_BuilderSolid and BOPAlgo_ShellSplitter
#include <BOPAlgo_Algo.hxx>
+#include <TColStd_MapOfInteger.hxx>
+
//=======================================================================
// function:
// purpose:
{
GetReport()->Clear(Message_Fail);
}
+
+//=======================================================================
+// function: analyzeProgress
+// purpose:
+//=======================================================================
+void BOPAlgo_Algo::analyzeProgress(const Standard_Real theWhole,
+ BOPAlgo_PISteps& theSteps) const
+{
+ Standard_Real aWhole = theWhole;
+
+ // Fill progress steps for constant operations
+ fillPIConstants(theWhole, theSteps);
+
+ TColStd_Array1OfReal& aSteps = theSteps.ChangeSteps();
+ TColStd_MapOfInteger aMIConst;
+ for (Standard_Integer i = aSteps.Lower(); i <= aSteps.Upper(); ++i)
+ {
+ if (aSteps(i) > 0.)
+ {
+ aMIConst.Add(i);
+ aWhole -= aSteps(i);
+ }
+ }
+
+ // Fill progress steps for other operations
+ fillPISteps(theSteps);
+
+ Standard_Real aSum = 0.;
+ for (Standard_Integer i = aSteps.Lower(); i <= aSteps.Upper(); ++i)
+ {
+ if (!aMIConst.Contains(i))
+ {
+ aSum += aSteps(i);
+ }
+ }
+
+ // Normalize steps
+ if (aSum > 0.)
+ {
+ for (Standard_Integer i = aSteps.Lower(); i <= aSteps.Upper(); ++i)
+ {
+ if (!aMIConst.Contains(i))
+ {
+ aSteps(i) = aWhole * aSteps(i) / aSum;
+ }
+ }
+ }
+}
+
+//=======================================================================
+// function: fillPIConstants
+// purpose:
+//=======================================================================
+void BOPAlgo_Algo::fillPIConstants (const Standard_Real, BOPAlgo_PISteps&) const
+{
+}
+
+//=======================================================================
+// function: fillPISteps
+// purpose:
+//=======================================================================
+void BOPAlgo_Algo::fillPISteps(BOPAlgo_PISteps&) const
+{
+}
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Message_ProgressRange.hxx>
-#include <NCollection_Array1.hxx>
+#include <TColStd_Array1OfReal.hxx>
#include <BOPAlgo_Options.hxx>
+class BOPAlgo_PISteps;
+
//! The class provides the root interface for the algorithms in Boolean Component.<br>
class BOPAlgo_Algo : public BOPAlgo_Options
{
DEFINE_STANDARD_ALLOC
- Standard_EXPORT virtual void Perform(const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) {};
-
- Standard_EXPORT virtual void Perform() {};
+ //! The main method to implement the operation
+ //! Providing the range allows to enable Progress indicator User break functionalities.
+ Standard_EXPORT virtual void Perform(const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) = 0;
protected:
//! Checks the obtained result
Standard_EXPORT virtual void CheckResult();
- //! Analyze progress steps
- virtual NCollection_Array1<Standard_Real> AnalyzeProgress()
+protected: //! @name Analyzing operations to fill progress indicator
+
+ //! Analyze progress steps of the whole operation.
+ //! @param theWhole - sum of progress of all operations.
+ //! @oaram theSteps - steps of the operations supported by PI
+ //!
+ //! To use this method, one has to override the following methods:
+ //! * fillPIConstants - method filling values for constant operations.
+ //! * fillPISteps - method filling steps for the rest of operations.
+ Standard_EXPORT void analyzeProgress(const Standard_Real theWhole,
+ BOPAlgo_PISteps& theSteps) const;
+
+ //! Fills the values for constant operations - the operations having constant relative running time.
+ //! @param theWhole - sum of all operations supported by PI, i.e. the value to normalize the steps to, if necessary.
+ //! @param theSteps - steps of the operations supported by PI
+ Standard_EXPORT virtual void fillPIConstants(const Standard_Real theWhole,
+ BOPAlgo_PISteps& theSteps) const;
+
+ //! Fills the values for the operations dependent on the inputs.
+ //! Filled values may not be normalized to represent percentage of total running time.
+ //! The values should just correlate to each other.
+ //! E.g. if progress depends on the number of input shapes, the values may look like this:
+ //! step1 = number_of_input_vertices;
+ //! step2 = 2 * number_of_input_edges;
+ //! step3 = 10 * number_of_input_faces.
+ //! Normalization of this values will be done automatically in analyzeProgress() method.
+ Standard_EXPORT virtual void fillPISteps(BOPAlgo_PISteps& theSteps) const;
+};
+
+//! Additional root class to provide interface to be launched from parallel vector.
+//! It already has the range as a field, and has to be used with cautious to create
+//! scope from the range only once.
+class BOPAlgo_ParallelAlgo : public BOPAlgo_Algo
+{
+public:
+ DEFINE_STANDARD_ALLOC
+
+ //! The main method to implement the operation
+ Standard_EXPORT virtual void Perform() = 0;
+
+public:
+ //! Sets the range for a single run
+ void SetProgressRange(const Message_ProgressRange& theRange)
{
- return NCollection_Array1<Standard_Real>();
- };
+ myProgressRange = theRange;
+ }
+
+private:
+ //! Disable the range enabled method
+ virtual void Perform(const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) {};
+protected:
+ Message_ProgressRange myProgressRange;
+};
+
+//! Class for representing the relative contribution of each step of
+//! the operation to the whole progress
+class BOPAlgo_PISteps
+{
+public:
+ //! Constructor
+ BOPAlgo_PISteps(const Standard_Integer theNbOp)
+ : mySteps(0, theNbOp - 1)
+ {
+ for (Standard_Integer i = 0; i < theNbOp; ++i)
+ {
+ mySteps(i) = 0.;
+ }
+ }
+
+ //! Returns the steps
+ const TColStd_Array1OfReal& Steps() const { return mySteps; }
+ //! Returns modifiable steps
+ TColStd_Array1OfReal& ChangeSteps() { return mySteps; }
+
+ //! Returns the step assigned to the operation
+ void SetStep(const Standard_Integer theOperation, const Standard_Real theStep)
+ {
+ if (theOperation >= mySteps.Lower() && theOperation <= mySteps.Upper())
+ {
+ mySteps(theOperation) = theStep;
+ }
+ }
+
+ //! Returns the step assigned to the operation
+ Standard_Real GetStep(const Standard_Integer theOperation)
+ {
+ if (theOperation < mySteps.Lower() || theOperation > mySteps.Upper())
+ {
+ return 0.;
+ }
+ return mySteps(theOperation);
+ }
+
+protected:
+ TColStd_Array1OfReal mySteps;
};
#endif // _BOPAlgo_Algo_HeaderFile
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::Perform(const Message_ProgressRange& theRange)
{
- Message_ProgressScope aPS(theRange, "Analyze", 1);
+ Message_ProgressScope aPS(theRange, "Analyze shapes", 10);
try {
OCC_CATCH_SIGNALS
myResult.Clear();
//
// 3. Test self-interference
if(mySelfInterMode) {
- TestSelfInterferences();
+ TestSelfInterferences(aPS.Next(8));
if (UserBreak(aPS))
{
return;
//function : TestSelfInterferences
//purpose :
//=======================================================================
-void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences()
+void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS(theRange, NULL, (!myShape1.IsNull() && !myShape2.IsNull() ? 2 : 1));
Standard_Integer ii;
//
for(ii = 0; ii < 2; ii++) {
aChecker.SetRunParallel(myRunParallel);
aChecker.SetFuzzyValue(myFuzzyValue);
//
- aChecker.Perform();
+ aChecker.Perform(aPS.Next());
Standard_Boolean hasError = aChecker.HasErrors();
//
const BOPDS_DS& aDS=*(aChecker.PDS());
Standard_EXPORT void TestTypes();
- Standard_EXPORT void TestSelfInterferences();
+ Standard_EXPORT void TestSelfInterferences(const Message_ProgressRange& theRange);
Standard_EXPORT void TestSmallEdge();
pPF=new BOPAlgo_PaveFiller(aAllocator);
pPF->SetArguments(aLS);
pPF->SetRunParallel(myRunParallel);
- Message_ProgressScope aPS(theRange, "Performing result of BOP operation", 10);
+ Message_ProgressScope aPS(theRange, "Performing Boolean operation", 10);
pPF->SetFuzzyValue(myFuzzyValue);
pPF->SetNonDestructive(myNonDestructive);
PerformInternal(*pPF, aPS.Next(1));
}
+//=======================================================================
+// function: fillPIConstants
+// purpose:
+//=======================================================================
+void BOPAlgo_BOP::fillPIConstants (const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const
+{
+ theSteps.SetStep (PIOperation_BuildShape, (myOperation == BOPAlgo_FUSE ? 10. : 5.) * theWhole / 100.);
+}
+
//=======================================================================
//function : PerformInternal1
//purpose :
//=======================================================================
-void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Message_ProgressRange& theRange)
+void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller,
+ const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS (theRange, "Building the result of Boolean operation", 100);
+
myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
myDS=myPaveFiller->PDS();
myContext=myPaveFiller->Context();
{
Standard_Boolean bDone = TreatEmptyShape();
if (bDone) {
- PrepareHistory();
+ PrepareHistory (theRange);
return;
}
}
//
- Message_ProgressScope aPS(theRange, "PerformInternal", 100);
- NCollection_Array1<Standard_Real> aSteps = BOPAlgo_Builder::AnalyzeProgress();
+ BOPAlgo_PISteps aSteps (PIOperation_Last);
+ analyzeProgress (100, aSteps);
+
// 3. Fill Images
// 3.1 Vertices
- FillImagesVertices(aPS.Next(aSteps(0)));
+ FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
if (HasErrors()) {
return;
}
return;
}
// 3.2 Edges
- FillImagesEdges(aPS.Next(aSteps(1)));
+ FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
if (HasErrors()) {
return;
}
}
//
// 3.3 Wires
- FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps(2)));
+ FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps.GetStep(PIOperation_TreatWires)));
if (HasErrors()) {
return;
}
}
//
// 3.4 Faces
- FillImagesFaces(aPS.Next(aSteps(3)));
+ FillImagesFaces(aPS.Next(aSteps.GetStep(PIOperation_TreatFaces)));
if (HasErrors()) {
return;
}
}
//
// 3.5 Shells
- FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps(4)));
+ FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps.GetStep(PIOperation_TreatShells)));
if (HasErrors()) {
return;
}
}
//
// 3.6 Solids
- FillImagesSolids(aPS.Next(aSteps(5)));
+ FillImagesSolids(aPS.Next(aSteps.GetStep(PIOperation_TreatSolids)));
if (HasErrors()) {
return;
}
}
//
// 3.7 CompSolids
- FillImagesContainers(TopAbs_COMPSOLID, aPS.Next(aSteps(6)));
+ FillImagesContainers(TopAbs_COMPSOLID, aPS.Next(aSteps.GetStep(PIOperation_TreatCompsolids)));
if (HasErrors()) {
return;
}
}
//
// 3.8 Compounds
- FillImagesCompounds(aPS.Next(aSteps(7)));
+ FillImagesCompounds(aPS.Next(aSteps.GetStep(PIOperation_TreatCompounds)));
if (HasErrors()) {
return;
}
}
//
// 4.BuildShape;
- BuildShape();
+ BuildShape(aPS.Next(aSteps.GetStep(PIOperation_BuildShape)));
if (HasErrors()) {
return;
}
//
// 5.History
- PrepareHistory();
+ PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
+ if (HasErrors()) {
+ return;
+ }
//
// 6 Post-treatment
- PostTreat();
+ PostTreat(aPS.Next(aSteps.GetStep(PIOperation_PostTreat)));
}
//=======================================================================
//function : BuildRC
//purpose :
//=======================================================================
-void BOPAlgo_BOP::BuildRC()
+void BOPAlgo_BOP::BuildRC(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS(theRange, NULL, 1);
+
TopAbs_ShapeEnum aType;
TopoDS_Compound aC;
BRep_Builder aBB;
return;
}
//
+ if (UserBreak(aPS))
+ {
+ return;
+ }
// B. Common, Cut, Cut21
//
Standard_Integer i, j, aNb, iDim;
}
}
//
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+ //
bCheckEdges = Standard_False;
//
// get splits of building elements
return;
}
//
+ if (UserBreak(aPS))
+ {
+ return;
+ }
// The squats around degenerated edges
Standard_Integer nVD;
TopTools_IndexedMapOfShape aMVC;
//function : BuildShape
//purpose :
//=======================================================================
-void BOPAlgo_BOP::BuildShape()
+void BOPAlgo_BOP::BuildShape(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS(theRange, NULL, 10.);
+
if (myDims[0] == 3 && myDims[1] == 3)
{
// For the Boolean operation on solids we need to check first
}
// Build the result using splits of arguments.
-
- BuildRC();
+ BuildRC(aPS.Next(2.));
//
if ((myOperation == BOPAlgo_FUSE) && (myDims[0] == 3)) {
- BuildSolid();
+ BuildSolid(aPS.Next(8.));
+ return;
+ }
+
+ // Check for user break
+ if (UserBreak(aPS))
+ {
return;
}
//
CollectContainers(aS, aLSC);
}
}
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
// make containers
TopTools_ListOfShape aLCRes;
TopTools_MapOfShape aMInpFence;
}
//
RemoveDuplicates(aLCRes);
+
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
//
// add containers to result
TopoDS_Compound aResult;
//function : BuildSolid
//purpose :
//=======================================================================
-void BOPAlgo_BOP::BuildSolid()
+void BOPAlgo_BOP::BuildSolid(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS(theRange, NULL, 10.);
// Containers
TopTools_ListOfShape aLSC;
//
CollectContainers(aSA, aLSC);
}
}
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
//
// Find solids in input arguments sharing faces with other solids
TopTools_MapOfShape aMTSols;
}
}
}
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
//
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
// Fill the list of faces to build the result solids
aBS.SetContext(myContext);
aBS.SetShapes(aSFS);
aBS.SetAvoidInternalShapes (Standard_True);
- aBS.Perform();
+ aBS.Perform(aPS.Next(8.));
if (aBS.HasErrors()) {
AddError (new BOPAlgo_AlertSolidBuilderFailed); // SolidBuilder failed
return;
TopoDS_Shape aResult;
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aResult);
//
+
aIt.Initialize(aRC);
if (!aIt.More()) {
// no solids in the result
}
}
//
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
// build connexity blocks from new solids
TopTools_ListOfShape aLCBS;
BOPTools_AlgoTools::MakeConnexityBlocks(aRC, TopAbs_FACE, TopAbs_SOLID, aLCBS);
//! Performs calculations using prepared Filler
//! object <thePF>
- Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange) Standard_OVERRIDE;
-
+ Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF,
+ const Message_ProgressRange& theRange) Standard_OVERRIDE;
+
Standard_EXPORT virtual void BuildResult (const TopAbs_ShapeEnum theType) Standard_OVERRIDE;
- Standard_EXPORT void BuildShape();
+ Standard_EXPORT void BuildShape(const Message_ProgressRange& theRange);
- Standard_EXPORT void BuildRC();
+ Standard_EXPORT void BuildRC(const Message_ProgressRange& theRange);
- Standard_EXPORT void BuildSolid();
+ Standard_EXPORT void BuildSolid(const Message_ProgressRange& theRange);
//! Treatment of the cases with empty shapes.<br>
//! It returns TRUE if there is nothing to do, i.e.
//! for building the result shape.
Standard_EXPORT virtual Standard_Boolean CheckArgsForOpenSolid();
+protected:
+
+ //! Extend list of operations to be supported by the Progress Indicator
+ enum BOPAlgo_PIOperation
+ {
+ PIOperation_BuildShape = BOPAlgo_ToolsProvider::BOPAlgo_PIOperation::PIOperation_Last,
+ PIOperation_Last
+ };
+
+ //! Fill PI steps
+ Standard_EXPORT virtual void fillPIConstants(const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
protected:
BOPAlgo_Operation myOperation;
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_MapOfOrientedShape.hxx>
-
//=======================================================================
//function :
//purpose :
//
pPF->SetArguments(myArguments);
pPF->SetRunParallel(myRunParallel);
- Message_ProgressScope aPS(theRange, "BOPAlgo_Builder::Perform()", 10);
+ Message_ProgressScope aPS(theRange, "Performing General Fuse operation", 10);
pPF->SetFuzzyValue(myFuzzyValue);
pPF->SetNonDestructive(myNonDestructive);
pPF->SetGlue(myGlue);
myFuzzyValue = theFiller.FuzzyValue();
myGlue = theFiller.Glue();
myUseOBB = theFiller.UseOBB();
- Message_ProgressScope aPS(theRange, NULL, 1);
- PerformInternal(theFiller, aPS.Next());
+ PerformInternal(theFiller, theRange);
}
//=======================================================================
//function : PerformInternal
}
//=======================================================================
-//function : AnalyzeProgress
+//function : getNbShapes
//purpose :
//=======================================================================
-NCollection_Array1<Standard_Real> BOPAlgo_Builder::AnalyzeProgress()
+BOPAlgo_Builder::NbShapes BOPAlgo_Builder::getNbShapes() const
{
- Standard_Integer aSize = 8;
- NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
- for (Standard_Integer i = 0; i < aSize; i++)
- {
- aSteps(i) = 0;
- }
-
- Standard_Real aPart = 100.;
- Standard_Integer aNbV = myDS->ShapesSD().Size();
- Standard_Integer aNbE = 0;
- Standard_Integer aNbW = 0;
- Standard_Integer aNbF = 0;
- Standard_Integer aNbSh = 0;
- Standard_Integer aNbS = 0;
- Standard_Integer aNbCS = 0;
- Standard_Integer aNbC = 0;
- for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); i++)
+ NbShapes aCounter;
+ aCounter.NbVertices() = myDS->ShapesSD().Size();
+ for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); ++i)
{
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
switch (aSI.ShapeType())
{
- case TopAbs_EDGE:
- aNbE++;
- break;
- case TopAbs_WIRE:
- aNbW++;
- break;
- case TopAbs_FACE:
- aNbF++;
- break;
- case TopAbs_SHELL:
- aNbSh++;
- break;
- case TopAbs_SOLID:
- aNbS++;
- break;
- case TopAbs_COMPSOLID:
- aNbCS++;
- break;
- case TopAbs_COMPOUND:
- aNbC++;
- break;
- default:
- break;
+ case TopAbs_EDGE:
+ {
+ if (myDS->HasPaveBlocks(i))
+ {
+ aCounter.NbEdges()++;
+ }
+ break;
+ }
+ case TopAbs_WIRE:
+ aCounter.NbWires()++;
+ break;
+ case TopAbs_FACE:
+ {
+ if (myDS->HasFaceInfo(i))
+ {
+ aCounter.NbFaces()++;
+ }
+ break;
+ }
+ case TopAbs_SHELL:
+ aCounter.NbShells()++;
+ break;
+ case TopAbs_SOLID:
+ aCounter.NbSolids()++;
+ break;
+ case TopAbs_COMPSOLID:
+ aCounter.NbCompsolids()++;
+ break;
+ case TopAbs_COMPOUND:
+ aCounter.NbCompounds()++;
+ break;
+ default: break;
}
}
+ return aCounter;
+}
- aNbE = 5 * aNbE;
- aNbW = 10 * aNbW;
- aNbF = 20 * aNbF;
- aNbSh = 10 * aNbSh;
- aNbS = 10 * aNbS;
- aNbCS = 5 * aNbCS;
- aNbC = 5 * aNbC;
- Standard_Real aSum = aNbV + aNbE + aNbW + aNbF + aNbSh + aNbS + aNbCS + aNbC;
- if (aSum == 0)
+//=======================================================================
+// function: fillPIConstants
+// purpose:
+//=======================================================================
+void BOPAlgo_Builder::fillPIConstants (const Standard_Real theWhole,
+ BOPAlgo_PISteps& theSteps) const
+{
+ // Fill in the constants:
+ if (myFillHistory)
{
- return aSteps;
+ // for FillHistroty, which takes about 5% of the whole operation
+ theSteps.SetStep(PIOperation_FillHistory, 5. * theWhole / 100.);
}
-
- aSteps(0) = aPart * aNbV / aSum;
- aSteps(1) = aPart * aNbE / aSum;
- aSteps(2) = aPart * aNbW / aSum;
- aSteps(3) = aPart * aNbF / aSum;
- aSteps(4) = aPart * aNbSh / aSum;
- aSteps(5) = aPart * aNbS / aSum;
- aSteps(6) = aPart * aNbCS / aSum;
- aSteps(7) = aPart * aNbC / aSum;
-
- return aSteps;
+
+ // and for PostTreat, which takes about 3% of the whole operation
+ theSteps.SetStep(PIOperation_PostTreat, 3. * theWhole / 100.);
+}
+
+//=======================================================================
+// function: fillPISteps
+// purpose:
+//=======================================================================
+void BOPAlgo_Builder::fillPISteps (BOPAlgo_PISteps& theSteps) const
+{
+ // Compute the rest of the operations - all depend on the number of sub-shapes of certain type
+ NbShapes aNbShapes = getNbShapes();
+
+ theSteps.SetStep(PIOperation_TreatVertices, aNbShapes.NbVertices());
+ theSteps.SetStep(PIOperation_TreatEdges, aNbShapes.NbEdges());
+ theSteps.SetStep(PIOperation_TreatWires, aNbShapes.NbWires());
+ theSteps.SetStep(PIOperation_TreatFaces, 20 * aNbShapes.NbFaces());
+ theSteps.SetStep(PIOperation_TreatShells, aNbShapes.NbShells());
+ theSteps.SetStep(PIOperation_TreatSolids, 50 * aNbShapes.NbSolids());
+ theSteps.SetStep(PIOperation_TreatCompsolids, aNbShapes.NbCompsolids());
+ theSteps.SetStep(PIOperation_TreatCompounds, aNbShapes.NbCompounds());
}
//=======================================================================
myFuzzyValue = myPaveFiller->FuzzyValue();
myNonDestructive = myPaveFiller->NonDestructive();
//
- Message_ProgressScope aPS(theRange, "PerformInternal", 100);
+ Message_ProgressScope aPS(theRange, "Building the result of General Fuse operation", 100);
// 1. CheckData
CheckData();
if (HasErrors()) {
return;
}
//
- NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
+ BOPAlgo_PISteps aSteps(PIOperation_Last);
+ analyzeProgress(100., aSteps);
// 3. Fill Images
// 3.1 Vertice
- FillImagesVertices(aPS.Next(aSteps(0)));
+ FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
if (HasErrors()) {
return;
}
return;
}
// 3.2 Edges
- FillImagesEdges(aPS.Next(aSteps(1)));
+ FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
if (HasErrors()) {
return;
}
}
//
// 3.3 Wires
- FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps(2)));
+ FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps.GetStep(PIOperation_TreatWires)));
if (HasErrors()) {
return;
}
}
// 3.4 Faces
- FillImagesFaces(aPS.Next(aSteps(3)));
+ FillImagesFaces(aPS.Next(aSteps.GetStep(PIOperation_TreatFaces)));
if (HasErrors()) {
return;
}
return;
}
// 3.5 Shells
- FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps(4)));
+ FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps.GetStep(PIOperation_TreatShells)));
if (HasErrors()) {
return;
}
return;
}
// 3.6 Solids
- FillImagesSolids(aPS.Next(aSteps(5)));
+ FillImagesSolids(aPS.Next(aSteps.GetStep(PIOperation_TreatSolids)));
if (HasErrors()) {
return;
}
return;
}
// 3.7 CompSolids
- FillImagesContainers(TopAbs_COMPSOLID, aPS.Next(aSteps(6)));
+ FillImagesContainers(TopAbs_COMPSOLID, aPS.Next(aSteps.GetStep(PIOperation_TreatCompsolids)));
if (HasErrors()) {
return;
}
}
// 3.8 Compounds
- FillImagesCompounds(aPS.Next(aSteps(7)));
+ FillImagesCompounds(aPS.Next(aSteps.GetStep(PIOperation_TreatCompounds)));
if (HasErrors()) {
return;
}
return;
}
//
- // 4.History
- PrepareHistory();
- //
+ // 4 History
+ PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
+ if (HasErrors()) {
+ return;
+ }
//
// 5 Post-treatment
- PostTreat();
-
+ PostTreat(aPS.Next(aSteps.GetStep(PIOperation_PostTreat)));
}
+
//=======================================================================
//function : PostTreat
//purpose :
//=======================================================================
-void BOPAlgo_Builder::PostTreat()
+void BOPAlgo_Builder::PostTreat(const Message_ProgressRange& theRange)
{
Standard_Integer i, aNbS;
TopAbs_ShapeEnum aType;
}
}
//
+ Message_ProgressScope aPS(theRange, "Post treatment of result shape", 2);
BOPTools_AlgoTools::CorrectTolerances(myShape, aMA, 0.05, myRunParallel);
+ aPS.Next().Close();
BOPTools_AlgoTools::CorrectShapeTolerances(myShape, aMA, myRunParallel);
}
aBB.Add(aResult, itLS.Value());
myShape = aResult;
- PrepareHistory();
+ PrepareHistory(Message_ProgressRange());
}
protected: //! @name History methods
//! Prepare information for history support.
- Standard_EXPORT void PrepareHistory();
+ Standard_EXPORT void PrepareHistory(const Message_ProgressRange& theRange);
//! Prepare history information for the input shapes taking into account possible
//! operation-specific modifications.
//! obtaining Generated elements differently.
Standard_EXPORT virtual const TopTools_ListOfShape& LocGenerated(const TopoDS_Shape& theS);
- //! AnalyzeProgress
- Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-
public: //! @name Images/Origins
//! Returns the map of images.
return myShapesSD;
}
+protected://! @name Analyze progress of the operation
+
+ //! List of operations to be supported by the Progress Indicator
+ enum BOPAlgo_PIOperation
+ {
+ PIOperation_TreatVertices = 0,
+ PIOperation_TreatEdges,
+ PIOperation_TreatWires,
+ PIOperation_TreatFaces,
+ PIOperation_TreatShells,
+ PIOperation_TreatSolids,
+ PIOperation_TreatCompsolids,
+ PIOperation_TreatCompounds,
+ PIOperation_FillHistory,
+ PIOperation_PostTreat,
+ PIOperation_Last
+ };
+
+
+ //! Auxiliary structure to get information about number of shapes
+ //! of each type participated in operation.
+ class NbShapes
+ {
+ public:
+ NbShapes()
+ {
+ for (Standard_Integer i = 0; i < 8; ++i)
+ {
+ myNbShapesArr[i] = 0;
+ }
+ }
+
+ Standard_Integer NbVertices() const { return myNbShapesArr[0]; }
+ Standard_Integer NbEdges() const { return myNbShapesArr[1]; }
+ Standard_Integer NbWires() const { return myNbShapesArr[2]; }
+ Standard_Integer NbFaces() const { return myNbShapesArr[3]; }
+ Standard_Integer NbShells() const { return myNbShapesArr[4]; }
+ Standard_Integer NbSolids() const { return myNbShapesArr[5]; }
+ Standard_Integer NbCompsolids() const { return myNbShapesArr[6]; }
+ Standard_Integer NbCompounds() const { return myNbShapesArr[7]; }
+
+ Standard_Integer& NbVertices() { return myNbShapesArr[0]; }
+ Standard_Integer& NbEdges() { return myNbShapesArr[1]; }
+ Standard_Integer& NbWires() { return myNbShapesArr[2]; }
+ Standard_Integer& NbFaces() { return myNbShapesArr[3]; }
+ Standard_Integer& NbShells() { return myNbShapesArr[4]; }
+ Standard_Integer& NbSolids() { return myNbShapesArr[5]; }
+ Standard_Integer& NbCompsolids() { return myNbShapesArr[6]; }
+ Standard_Integer& NbCompounds() { return myNbShapesArr[7]; }
+
+ private:
+ Standard_Integer myNbShapesArr[8];
+ };
+
+protected:
+
+ //! Compute number of shapes of certain type participating in operation
+ Standard_EXPORT NbShapes getNbShapes() const;
+
+ //! Filling steps for constant operations
+ Standard_EXPORT void fillPIConstants(const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
+ //! Filling steps for all other operations
+ Standard_EXPORT void fillPISteps(BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
protected: //! @name Methods for building the result
//! Builds the splits of faces using the information from the
//! intersection stage stored in Data Structure.
- Standard_EXPORT virtual void BuildSplitFaces();
+ Standard_EXPORT virtual void BuildSplitFaces(const Message_ProgressRange& theRange);
//! Looks for the same domain faces among the splits of the faces.
//! Updates the map of images with SD faces.
- Standard_EXPORT void FillSameDomainFaces();
+ Standard_EXPORT void FillSameDomainFaces(const Message_ProgressRange& theRange);
//! Classifies the alone vertices on faces relatively its splits
//! and adds them as INTERNAL into the splits.
- Standard_EXPORT void FillInternalVertices();
+ Standard_EXPORT void FillInternalVertices(const Message_ProgressRange& theRange);
protected: //! @name Fill Images of SOLIDS
TopTools_ListOfShape& theLIF);
//! Finds faces located inside each solid.
- Standard_EXPORT virtual void FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids);
+ Standard_EXPORT virtual void FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids,
+ const Message_ProgressRange& theRange);
//! Builds the splits of the solids using their draft versions
//! and faces located inside.
- Standard_EXPORT void BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids);
+ Standard_EXPORT void BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids,
+ const Message_ProgressRange& theRange);
//! Classifies the vertices and edges from the arguments relatively
//! splits of solids and makes them INTERNAL for solids.
- Standard_EXPORT void FillInternalShapes();
+ Standard_EXPORT void FillInternalShapes(const Message_ProgressRange& theRange);
protected: //! @name Fill Images of COMPOUNDS
//! Post treatment of the result of the operation.
//! The method checks validity of the sub-shapes of the result
//! and updates the tolerances to make them valid.
- Standard_EXPORT virtual void PostTreat();
-
+ Standard_EXPORT virtual void PostTreat(const Message_ProgressRange& theRange);
protected: //! @name Fields
Standard_EXPORT BOPAlgo_BuilderArea(const Handle(NCollection_BaseAllocator)& theAllocator);
- virtual void PerformShapesToAvoid() = 0;
+ virtual void PerformShapesToAvoid(const Message_ProgressRange& theRange) = 0;
- virtual void PerformLoops() = 0;
+ virtual void PerformLoops(const Message_ProgressRange& theRange) = 0;
- virtual void PerformAreas() = 0;
+ virtual void PerformAreas(const Message_ProgressRange& theRange) = 0;
- virtual void PerformInternalShapes() = 0;
+ virtual void PerformInternalShapes(const Message_ProgressRange& theRange) = 0;
Handle(IntTools_Context) myContext;
//function : Perform
//purpose :
//=======================================================================
-void BOPAlgo_BuilderFace::Perform(const Message_ProgressRange& /*theRange*/)
+void BOPAlgo_BuilderFace::Perform(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS (theRange, "Building face", 100);
+
GetReport()->Clear();
//
CheckData();
return;
}
//
- PerformShapesToAvoid();
+ PerformShapesToAvoid (aPS.Next(1));
if (HasErrors()) {
return;
}
//
- PerformLoops();
+ PerformLoops (aPS.Next(10));
if (HasErrors()) {
return;
}
//
- PerformAreas();
+ PerformAreas (aPS.Next(80));
if (HasErrors()) {
return;
}
//
- PerformInternalShapes();
- if (HasErrors()) {
- return;
- }
+ PerformInternalShapes(aPS.Next(9));
}
//=======================================================================
//function :PerformShapesToAvoid
//purpose :
//=======================================================================
-void BOPAlgo_BuilderFace::PerformShapesToAvoid()
+void BOPAlgo_BuilderFace::PerformShapesToAvoid(const Message_ProgressRange& theRange)
{
Standard_Boolean bFound;
Standard_Integer i, iCnt, aNbV, aNbE;
//
myShapesToAvoid.Clear();
//
+ Message_ProgressScope aPS(theRange, NULL, 1);
+ //
iCnt=0;
for(;;) {
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+
++iCnt;
bFound=Standard_False;
//
if (!bFound) {
break;
}
- //
- }//while (1)
- //printf(" EdgesToAvoid=%d, iCnt=%d\n", EdgesToAvoid.Extent(), iCnt);
+ }
}
//=======================================================================
//function : PerformLoops
//purpose :
//=======================================================================
-void BOPAlgo_BuilderFace::PerformLoops()
+void BOPAlgo_BuilderFace::PerformLoops(const Message_ProgressRange& theRange)
{
Standard_Boolean bFlag;
Standard_Integer i, aNbEA;
BOPAlgo_WireEdgeSet aWES(myAllocator);
BOPAlgo_WireSplitter aWSp(myAllocator);
//
+ Message_ProgressScope aMainScope(theRange, "Making wires", 10);
+ //
// 1.
myLoops.Clear();
aWES.SetFace(myFace);
aWSp.SetWES(aWES);
aWSp.SetRunParallel(myRunParallel);
aWSp.SetContext(myContext);
- aWSp.Perform();
+ aWSp.Perform(aMainScope.Next(9));
if (aWSp.HasErrors()) {
return;
}
aMEP.Add(aE);
}
}
+ if (UserBreak (aMainScope)) {
+ return;
+ }
//
// b. collect all edges that are to avoid
aNbEA = myShapesToAvoid.Extent();
}
}
//
+ if (UserBreak (aMainScope)) {
+ return;
+ }
// 2. Internal Wires
myLoopsInternal.Clear();
//
aNbEA = myShapesToAvoid.Extent();
for (i = 1; i <= aNbEA; ++i) {
const TopoDS_Shape& aEE = myShapesToAvoid(i);
- TopExp::MapShapesAndAncestors(aEE,
- TopAbs_VERTEX,
- TopAbs_EDGE,
- aVEMap);
+ TopExp::MapShapesAndAncestors(aEE,
+ TopAbs_VERTEX,
+ TopAbs_EDGE,
+ aVEMap);
}
//
bFlag=Standard_True;
continue;
}
//
+ if (UserBreak (aMainScope)) {
+ return;
+ }
// make new wire
TopoDS_Wire aW;
aBB.MakeWire(aW);
//function : PerformAreas
//purpose :
//=======================================================================
-void BOPAlgo_BuilderFace::PerformAreas()
+void BOPAlgo_BuilderFace::PerformAreas(const Message_ProgressRange& theRange)
{
myAreas.Clear();
BRep_Builder aBB;
// Get tolerance of myFace
Standard_Real aTol = BRep_Tool::Tolerance(myFace);
+ Message_ProgressScope aMainScope (theRange, NULL, 10);
+
// Check if there are no loops at all
if (myLoops.IsEmpty())
{
TopTools_IndexedMapOfShape aMHE;
// Analyze the new wires - classify them to be the holes and growths
+ Message_ProgressScope aPSClass(aMainScope.Next(5), "Making faces", myLoops.Size());
TopTools_ListIteratorOfListOfShape aItLL(myLoops);
- for (; aItLL.More(); aItLL.Next())
+ for (; aItLL.More(); aItLL.Next(), aPSClass.Next())
{
+ if (UserBreak(aPSClass))
+ {
+ return;
+ }
+
const TopoDS_Shape& aWire = aItLL.Value();
TopoDS_Face aFace;
BOPTools_Box2dTreeSelector aSelector;
aSelector.SetBVHSet (&aBoxTree);
+ Message_ProgressScope aPSHoles(aMainScope.Next(4), "Adding holes", aNewFaces.Extent());
TopTools_ListIteratorOfListOfShape aItLS(aNewFaces);
- for (; aItLS.More(); aItLS.Next())
+ for (; aItLS.More(); aItLS.Next(), aPSHoles.Next())
{
+ if (UserBreak (aPSHoles))
+ {
+ return;
+ }
const TopoDS_Face& aFace = TopoDS::Face(aItLS.Value());
// Build box
}
// Add Holes to Faces and add them to myAreas
+ Message_ProgressScope aPSU (aMainScope.Next(), NULL, aNewFaces.Size());
aItLS.Initialize(aNewFaces);
- for ( ; aItLS.More(); aItLS.Next())
+ for ( ; aItLS.More(); aItLS.Next(), aPSU.Next())
{
+ if (UserBreak (aPSU))
+ {
+ return;
+ }
+
TopoDS_Face& aFace = *(TopoDS_Face*)&aItLS.Value();
const TopTools_ListOfShape* pLHoles = aFaceHolesMap.Seek(aFace);
if (pLHoles)
//function : PerformInternalShapes
//purpose :
//=======================================================================
-void BOPAlgo_BuilderFace::PerformInternalShapes()
+void BOPAlgo_BuilderFace::PerformInternalShapes(const Message_ProgressRange& theRange)
{
if (myAvoidInternalShapes)
// User-defined option to avoid internal edges
// Map of edges to classify
TopTools_IndexedMapOfShape anEdgesMap;
+ // Main progress scope
+ Message_ProgressScope aMainScope (theRange, "Adding internal shapes", 3);
+
// Fill the tree and the map
TopTools_ListIteratorOfListOfShape itLE(myLoopsInternal);
for (; itLE.More(); itLE.Next())
{
+ if (UserBreak (aMainScope))
+ {
+ return;
+ }
TopoDS_Iterator itE(itLE.Value());
for (; itE.More(); itE.Next())
{
// Build BVH
aBoxTree.Build();
+ aMainScope.Next().Close();
+
// Fence map
TColStd_MapOfInteger aMEDone;
// Classify edges relatively faces
+ Message_ProgressScope aPSClass(aMainScope.Next(), NULL, myAreas.Size());
TopTools_ListIteratorOfListOfShape itLF(myAreas);
- for (; itLF.More(); itLF.Next())
+ for (; itLF.More(); itLF.Next(), aPSClass.Next())
{
+ if (UserBreak(aPSClass))
+ {
+ return;
+ }
TopoDS_Face& aF = *(TopoDS_Face*)&itLF.Value();
// Build box
//! Collect the edges that
//! a) are internal
//! b) are the same and have different orientation
- Standard_EXPORT virtual void PerformShapesToAvoid() Standard_OVERRIDE;
+ Standard_EXPORT virtual void PerformShapesToAvoid(const Message_ProgressRange& theRange) Standard_OVERRIDE;
//! Build draft wires
//! a)myLoops - draft wires that consist of
//! boundary edges
//! b)myLoopsInternal - draft wires that contains
//! inner edges
- Standard_EXPORT virtual void PerformLoops() Standard_OVERRIDE;
+ Standard_EXPORT virtual void PerformLoops(const Message_ProgressRange& theRange) Standard_OVERRIDE;
//! Build draft faces that contains boundary edges
- Standard_EXPORT virtual void PerformAreas() Standard_OVERRIDE;
+ Standard_EXPORT virtual void PerformAreas(const Message_ProgressRange& theRange) Standard_OVERRIDE;
//! Build finalized faces with internals
- Standard_EXPORT virtual void PerformInternalShapes() Standard_OVERRIDE;
+ Standard_EXPORT virtual void PerformInternalShapes(const Message_ProgressRange& theRange) Standard_OVERRIDE;
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
+protected:
TopoDS_Face myFace;
TopAbs_Orientation myOrientation;
-
-
-private:
-
-
-
-
-
};
-
-
-
-
-
-
#endif // _BOPAlgo_BuilderFace_HeaderFile
//function : Perform
//purpose :
//=======================================================================
-void BOPAlgo_BuilderSolid::Perform(const Message_ProgressRange& /*theRange*/)
+void BOPAlgo_BuilderSolid::Perform(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS (theRange, "Building solids", 100);
+
GetReport()->Clear();
//
if (myShapes.IsEmpty())
aBB.Add(aC, aF);
}
//
- PerformShapesToAvoid();
+ PerformShapesToAvoid (aPS.Next(1));
if (HasErrors()) {
return;
}
//
- PerformLoops();
+ PerformLoops (aPS.Next(10));
if (HasErrors()) {
return;
}
//
- PerformAreas();
+ PerformAreas (aPS.Next(80));
if (HasErrors()) {
return;
}
//
- PerformInternalShapes();
- if (HasErrors()) {
- return;
- }
+ PerformInternalShapes (aPS.Next(9));
}
//=======================================================================
//function :PerformShapesToAvoid
//purpose :
//=======================================================================
-void BOPAlgo_BuilderSolid::PerformShapesToAvoid()
+void BOPAlgo_BuilderSolid::PerformShapesToAvoid(const Message_ProgressRange& theRange)
{
Standard_Boolean bFound;
Standard_Integer i, iCnt, aNbE, aNbF;
//
myShapesToAvoid.Clear();
//
+ Message_ProgressScope aPS(theRange, NULL, 1);
+ //
iCnt=0;
for(;;) {
+ if (UserBreak(aPS)) {
+ return;
+ }
++iCnt;
bFound=Standard_False;
//
//function : PerformLoops
//purpose :
//=======================================================================
-void BOPAlgo_BuilderSolid::PerformLoops()
+void BOPAlgo_BuilderSolid::PerformLoops(const Message_ProgressRange& theRange)
{
Standard_Integer i, aNbSh;
TopTools_ListIteratorOfListOfShape aIt;
NCollection_BaseAllocator::CommonBaseAllocator();
BOPAlgo_ShellSplitter aSSp(aAlr);
//
- // 1. Shells Usual
+ Message_ProgressScope aMainScope (theRange, "Building shells", 10);
+
+ // 1. Shells Usual
aIt.Initialize (myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Face& aF=*((TopoDS_Face*)&aIt.Value());
}
//
aSSp.SetRunParallel(myRunParallel);
- aSSp.Perform();
+ aSSp.Perform(aMainScope.Next(9));
if (aSSp.HasErrors()) {
// add warning status
+ if (aMainScope.More())
{
TopoDS_Compound aFacesSp;
BRep_Builder().MakeCompound(aFacesSp);
aMP.Add(aF);
}
}
+ if (UserBreak (aMainScope)) {
+ return;
+ }
//
// b. collect all edges that are to avoid
aNbSh = myShapesToAvoid.Extent();
}
}
//=================================================
+ if (UserBreak (aMainScope)) {
+ return;
+ }
//
// 3.Internal Shells
myLoopsInternal.Clear();
}
//
for (i = 1; i <= aNbSh; ++i) {
+ if (UserBreak(aMainScope)) {
+ return;
+ }
const TopoDS_Shape& aFF = myShapesToAvoid(i);
if (!AddedFacesMap.Add(aFF)) {
continue;
//function : PerformAreas
//purpose :
//=======================================================================
-void BOPAlgo_BuilderSolid::PerformAreas()
+void BOPAlgo_BuilderSolid::PerformAreas(const Message_ProgressRange& theRange)
{
myAreas.Clear();
BRep_Builder aBB;
// If the analyzed shell contains any of the hole faces, it is considered as growth.
TopTools_IndexedMapOfShape aMHF;
+ Message_ProgressScope aMainScope(theRange, "Building solids", 10);
+
// Analyze the shells
+ Message_ProgressScope aPSClass(aMainScope.Next(5), "Classify solids", myLoops.Size());
TopTools_ListIteratorOfListOfShape aItLL(myLoops);
- for (; aItLL.More(); aItLL.Next())
+ for (; aItLL.More(); aItLL.Next(), aPSClass.Next())
{
+ if (UserBreak (aPSClass))
+ {
+ return;
+ }
const TopoDS_Shape& aShell = aItLL.Value();
Standard_Boolean bIsGrowth = IsGrowthShell(aShell, aMHF);
// Find outer growth shell that is most close to each hole shell
TopTools_IndexedDataMapOfShapeShape aHoleSolidMap;
+ Message_ProgressScope aPSH(aMainScope.Next(4), "Adding holes", aNewSolids.Size());
TopTools_ListIteratorOfListOfShape aItLS(aNewSolids);
- for (; aItLS.More(); aItLS.Next())
+ for (; aItLS.More(); aItLS.Next(), aPSH.Next())
{
+ if (UserBreak (aPSH))
+ {
+ return;
+ }
const TopoDS_Shape& aSolid = aItLS.Value();
// Build box
}
// Add Holes to Solids and add them to myAreas
+ Message_ProgressScope aPSU (aMainScope.Next(), NULL, aNewSolids.Size());
aItLS.Initialize(aNewSolids);
- for ( ; aItLS.More(); aItLS.Next())
+ for ( ; aItLS.More(); aItLS.Next(), aPSU.Next())
{
+ if (UserBreak (aPSU))
+ {
+ return;
+ }
TopoDS_Solid& aSolid = *(TopoDS_Solid*)&aItLS.Value();
const TopTools_ListOfShape* pLHoles = aSolidHolesMap.Seek(aSolid);
if (pLHoles)
//function : PerformInternalShapes
//purpose :
//=======================================================================
-void BOPAlgo_BuilderSolid::PerformInternalShapes()
+void BOPAlgo_BuilderSolid::PerformInternalShapes(const Message_ProgressRange& theRange)
{
if (myAvoidInternalShapes)
// user-defined option to avoid internal parts is in force
// no internal parts
return;
+ Message_ProgressScope aMainScope (theRange, "Adding internal shapes", 2);
+
// Get all faces to classify
TopTools_IndexedMapOfShape aMFs;
TopTools_ListIteratorOfListOfShape aItLS(myLoopsInternal);
return;
}
+ if (UserBreak (aMainScope))
+ {
+ return;
+ }
+
// Classify faces relatively solids
// Prepare list of faces to classify
TopTools_IndexedDataMapOfShapeListOfShape aMSLF;
// Perform classification
- BOPAlgo_Tools::ClassifyFaces(aLFaces, myAreas, myRunParallel, myContext, aMSLF, myBoxes);
+ BOPAlgo_Tools::ClassifyFaces(aLFaces,
+ myAreas,
+ myRunParallel,
+ myContext,
+ aMSLF,
+ myBoxes,
+ TopTools_DataMapOfShapeListOfShape(),
+ aMainScope.Next());
// Update Solids by internal Faces
TopTools_MapOfShape aMFDone;
Standard_Integer aNbS = aMSLF.Extent();
- for (i = 1; i <= aNbS; ++i)
+ Message_ProgressScope aPSLoop(aMainScope.Next(), NULL, aNbS);
+ for (i = 1; i <= aNbS; ++i, aPSLoop.Next())
{
+ if (UserBreak (aPSLoop))
+ {
+ return;
+ }
const TopoDS_Shape& aSolid = aMSLF.FindKey(i);
TopoDS_Shape *pSolid = (TopoDS_Shape*)&aSolid;
//! - that are alone but given twice with different orientation.
//! These faces will be put into the map *myShapesToAvoid* and will be
//! avoided in shells construction, but will be classified later on.
- Standard_EXPORT virtual void PerformShapesToAvoid() Standard_OVERRIDE;
+ Standard_EXPORT virtual void PerformShapesToAvoid(const Message_ProgressRange& theRange) Standard_OVERRIDE;
//! Build all possible closed shells from the given faces.
//! The method fills the following maps:
//! - myLoops - Created closed shells;
//! - myLoopsInternal - The shells created from unused faces.
- Standard_EXPORT virtual void PerformLoops() Standard_OVERRIDE;
+ Standard_EXPORT virtual void PerformLoops(const Message_ProgressRange& theRange) Standard_OVERRIDE;
//! Classifies the created shells on the Holes and Growths.
//! Creates the solids from the Growths shells.
//! Puts the Hole shells into the closest Growths solids.
- Standard_EXPORT virtual void PerformAreas() Standard_OVERRIDE;
+ Standard_EXPORT virtual void PerformAreas(const Message_ProgressRange& theRange) Standard_OVERRIDE;
//! Classifies the unused faces relatively the created solids.
//! Puts the classified faces into the closest solids as internal shells.
//! Warns the user about unclassified faces if any.
- Standard_EXPORT virtual void PerformInternalShapes() Standard_OVERRIDE;
+ Standard_EXPORT virtual void PerformInternalShapes(const Message_ProgressRange& theRange) Standard_OVERRIDE;
private:
//=======================================================================
void BOPAlgo_Builder::FillImagesVertices(const Message_ProgressRange& theRange)
{
- Message_ProgressScope aPS(theRange, "Filling splits of vertices", 1);
+ Message_ProgressScope aPS(theRange, "Filling splits of vertices", myDS->ShapesSD().Size());
TColStd_DataMapIteratorOfDataMapOfIntegerInteger aIt(myDS->ShapesSD());
- for (; aIt.More(); aIt.Next())
+ for (; aIt.More(); aIt.Next(), aPS.Next())
{
if (UserBreak(aPS))
{
void BOPAlgo_Builder::FillImagesEdges(const Message_ProgressRange& theRange)
{
Standard_Integer i, aNbS = myDS->NbSourceShapes();
- Message_ProgressScope aPS(theRange, "Filling splits of edges", 1);
- for (i = 0; i < aNbS; ++i) {
+ Message_ProgressScope aPS(theRange, "Filling splits of edges", aNbS);
+ for (i = 0; i < aNbS; ++i, aPS.Next()) {
if (UserBreak(aPS))
{
return;
TopTools_MapOfShape aMFP(100, myAllocator);
//
aNbS=myDS->NbSourceShapes();
- Message_ProgressScope aPS(theRange, "Filling images containers", 1);
+ Message_ProgressScope aPS(theRange, "Building splits of containers", 1);
for (i=0; i<aNbS; ++i) {
if (UserBreak(aPS))
{
TopTools_MapOfShape aMFP(100, myAllocator);
//
aNbS=myDS->NbSourceShapes();
- Message_ProgressScope aPS(theRange, "Filling images compounds", aNbS);
+ Message_ProgressScope aPS(theRange, "Building splits of compounds", aNbS);
for (i=0; i<aNbS; ++i, aPS.Next()) {
if (UserBreak(aPS))
{
//class : BOPAlgo_PairOfShapeBoolean
//purpose :
//=======================================================================
-class BOPAlgo_PairOfShapeBoolean : public BOPAlgo_Algo {
+class BOPAlgo_PairOfShapeBoolean : public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_PairOfShapeBoolean() :
- BOPAlgo_Algo(),
+ BOPAlgo_ParallelAlgo(),
myFlag(Standard_False) {
}
//
}
//
virtual void Perform() {
- //
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+
const TopoDS_Face& aFj=*((TopoDS_Face*)&myShape1);
const TopoDS_Face& aFk=*((TopoDS_Face*)&myShape2);
myFlag=BOPTools_AlgoTools::AreFacesSameDomain(aFj, aFk, myContext, myFuzzyValue);
typedef NCollection_Vector<BOPAlgo_PairOfShapeBoolean> BOPAlgo_VectorOfPairOfShapeBoolean;
//=======================================================================
-// BuilderFace
-//
-typedef NCollection_Vector<BOPAlgo_BuilderFace> BOPAlgo_VectorOfBuilderFace;
+//class : BOPAlgo_SplitFace
+//purpose : Auxiliary class to extend BOPAlgo_BuilderSolid with progress support
+//=======================================================================
+class BOPAlgo_SplitFace : public BOPAlgo_BuilderFace
+{
+public:
+ //! Sets progress range
+ void SetProgressRange(const Message_ProgressRange& theRange)
+ {
+ myRange = theRange;
+ }
+
+ // New perform method, using own progress range
+ void Perform()
+ {
+ Message_ProgressScope aPS(myRange, NULL, 1);
+ if (!aPS.More())
+ {
+ return;
+ }
+ BOPAlgo_BuilderFace::Perform(aPS.Next());
+ }
+
+private:
+ //! Disable the range enabled method
+ virtual void Perform(const Message_ProgressRange& /*theRange*/) {};
+
+private:
+ TopoDS_Solid mySolid; //!< Solid to split
+ Message_ProgressRange myRange;
+};
+typedef NCollection_Vector<BOPAlgo_SplitFace> BOPAlgo_VectorOfBuilderFace;
//=======================================================================
//class : BOPAlgo_VFI
//purpose :
//=======================================================================
-class BOPAlgo_VFI : public BOPAlgo_Algo {
+class BOPAlgo_VFI : public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_VFI() :
- BOPAlgo_Algo(),
+ BOPAlgo_ParallelAlgo(),
myIsInternal(Standard_False) {
}
//
}
//
virtual void Perform() {
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+
Standard_Real aT1, aT2, dummy;
//
Standard_Integer iFlag =
//=======================================================================
void BOPAlgo_Builder::FillImagesFaces(const Message_ProgressRange& theRange)
{
- Message_ProgressScope aPS(theRange, "Building splits of faces", 1);
- BuildSplitFaces();
- FillSameDomainFaces();
- FillInternalVertices();
+ Message_ProgressScope aPS(theRange, "Building spligs of faces", 10);
+ BuildSplitFaces(aPS.Next(9));
+ if (HasErrors())
+ {
+ return;
+ }
+ FillSameDomainFaces(aPS.Next(0.5));
+ if (HasErrors())
+ {
+ return;
+ }
+ FillInternalVertices(aPS.Next(0.5));
}
//=======================================================================
//function : BuildSplitFaces
//purpose :
//=======================================================================
-void BOPAlgo_Builder::BuildSplitFaces()
+void BOPAlgo_Builder::BuildSplitFaces(const Message_ProgressRange& theRange)
{
Standard_Boolean bHasFaceInfo, bIsClosed, bIsDegenerated, bToReverse;
Standard_Integer i, j, k, aNbS, aNbPBIn, aNbPBOn, aNbPBSc, aNbAV, nSp;
TopTools_ListOfShape aLE(aAllocator);
TopTools_MapOfShape aMDE(100, aAllocator);
//
+ Message_ProgressScope aPSOuter(theRange, NULL, 10);
// Build temporary map of faces images to avoid rebuilding
// of the faces without any IN or section edges
NCollection_IndexedDataMap<Standard_Integer, TopTools_ListOfShape> aFacesIm;
if (aSI.ShapeType()!=TopAbs_FACE) {
continue;
}
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
//
const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
Standard_Boolean isUClosed = Standard_False,
BRepLib::BuildPCurveForEdgesOnPlane(aLE, aFF);
}
// 3 Build split faces
- BOPAlgo_BuilderFace& aBF=aVBF.Appended();
+ BOPAlgo_SplitFace& aBF=aVBF.Appended();
aBF.SetFace(aF);
aBF.SetShapes(aLE);
aBF.SetRunParallel(myRunParallel);
//
}// for (i=0; i<aNbS; ++i) {
+
+ // close preparation task
+ aPSOuter.Next().Close();
//
+ Standard_Integer aNbBF = aVBF.Length();
+ // Set progress range for each task to be run in parallel
+ Message_ProgressScope aPSParallel(aPSOuter.Next(9), "Splitting faces", aNbBF);
+ for (Standard_Integer iF = 0; iF < aNbBF; iF++)
+ {
+ BOPAlgo_SplitFace& aBF = aVBF.ChangeValue(iF);
+ aBF.SetProgressRange(aPSParallel.Next());
+ }
//===================================================
BOPTools_Parallel::Perform (myRunParallel, aVBF);
//===================================================
- //
- Standard_Integer aNbBF = aVBF.Length();
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
for (k = 0; k < aNbBF; ++k)
{
BOPAlgo_BuilderFace& aBF = aVBF(k);
//function : FillSameDomainFaces
//purpose :
//=======================================================================
-void BOPAlgo_Builder::FillSameDomainFaces()
+void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange)
{
// It is necessary to analyze all Face/Face intersections
// and find all faces with equal sets of edges
if (!aNbFFs)
return;
+ Message_ProgressScope aPSOuter(theRange, NULL, 10);
+
Handle(NCollection_BaseAllocator) aAllocator = new NCollection_IncAllocator;
// Vector to store the indices of faces for future sorting
// Fill the vector with indices of faces
for (Standard_Integer i = 0; i < aNbFFs; ++i)
{
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
const BOPDS_InterfFF& aFF = aFFs(i);
// get indices
Standard_Integer nF[2];
Standard_Integer aNbF = aFIVec.Length();
for (Standard_Integer i = 0; i < aNbF; ++i)
{
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
const Standard_Integer nF = aFIVec(i);
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nF);
const TopoDS_Shape& aF = aSI.Shape();
Standard_Integer aNbSets = anESetFaces.Extent();
for (Standard_Integer i = 1; i <= aNbSets; ++i)
{
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
const TopTools_ListOfShape& aLF = anESetFaces(i);
if (aLF.Extent() < 2)
continue;
}
}
+ aPSOuter.Next().Close();
+
+ // Set progress range for each task to be run in parallel
+ Message_ProgressScope aPSParallel(aPSOuter.Next(3), "Checking SD faces", aVPSB.Size());
+ for (Standard_Integer iPSB = 0; iPSB < aVPSB.Size(); ++iPSB)
+ {
+ aVPSB.ChangeValue(iPSB).SetProgressRange(aPSParallel.Next());
+ }
//================================================================
// Perform analysis
BOPTools_Parallel::Perform (myRunParallel, aVPSB, myContext);
//================================================================
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
NCollection_List<TopTools_ListOfShape> aMBlocks(aAllocator);
// Fill map with SD faces to make the blocks
// function: FillImagesFaces1
// purpose:
//=======================================================================
-void BOPAlgo_Builder::FillInternalVertices()
+void BOPAlgo_Builder::FillInternalVertices(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPSOuter(theRange, NULL, 1);
+
// Vector of pairs of Vertex/Face for classification of the vertices
// relatively faces, and adding them as internal into the faces
BOPAlgo_VectorOfVFI aVVFI;
if (aSI.ShapeType() != TopAbs_FACE)
continue;
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
+
const TopoDS_Shape& aF = aSI.Shape();
const TopTools_ListOfShape* pLFIm = myImages.Seek(aF);
if (!pLFIm)
}
}
+ // Set progress range for each task to be run in parallel
+ Message_ProgressScope aPSParallel(aPSOuter.Next(), "Looking for internal shapes", aVVFI.Size());
+ for (Standard_Integer iVFI = 0; iVFI< aVVFI.Size(); ++iVFI)
+ {
+ aVVFI.ChangeValue(iVFI).SetProgressRange(aPSParallel.Next());
+ }
// Perform classification
//================================================================
BOPTools_Parallel::Perform (myRunParallel, aVVFI, myContext);
//================================================================
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
Standard_Integer aNbVFI = aVVFI.Length();
for (Standard_Integer i = 0; i < aNbVFI; ++i)
//=======================================================================
void BOPAlgo_Builder::FillImagesSolids(const Message_ProgressRange& theRange)
{
- Message_ProgressScope aPS(theRange, "Filling images solids", 1);
- Standard_Boolean bHasSolids;
- Standard_Integer i, aNbS;
- //
- bHasSolids=Standard_False;
- aNbS=myDS->NbSourceShapes();
- for (i=0; i<aNbS; ++i) {
- if (UserBreak(aPS))
+ Standard_Integer i = 0, aNbS = myDS->NbSourceShapes();
+ for (i = 0; i < aNbS; ++i) {
+ const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
+ if (aSI.ShapeType() == TopAbs_SOLID)
{
- return;
- }
- const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
- if (aSI.ShapeType()==TopAbs_SOLID) {
- bHasSolids=!bHasSolids;
break;
}
}
- //
- if (!bHasSolids) {
+ if (i >= aNbS) {
return;
}
+ Message_ProgressScope aPS(theRange, "Building splits of solids", 10);
// Draft solids
TopTools_DataMapOfShapeShape aDraftSolids;
// Find all IN faces for all IN faces
- FillIn3DParts(aDraftSolids);
+ FillIn3DParts(aDraftSolids, aPS.Next(4));
+ if (HasErrors())
+ {
+ return;
+ }
// Build split of the solids
- BuildSplitSolids(aDraftSolids);
+ BuildSplitSolids(aDraftSolids, aPS.Next(5));
+ if (HasErrors())
+ {
+ return;
+ }
// Fill solids with internal parts
- FillInternalShapes();
+ FillInternalShapes(aPS.Next());
}
//=======================================================================
//function : FillIn3DParts
//purpose :
//=======================================================================
-void BOPAlgo_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids)
+void BOPAlgo_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids,
+ const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS(theRange, NULL, 2);
+
Handle(NCollection_BaseAllocator) anAlloc = new NCollection_IncAllocator;
// Find all faces that are IN solids
if (aSI.ShapeType() != TopAbs_FACE)
continue;
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+
const TopoDS_Shape& aS = aSI.Shape();
const TopTools_ListOfShape* pLSIm = myImages.Seek(aS);
{
BOPDS_ShapeInfo& aSI = myDS->ChangeShapeInfo(i);
if (aSI.ShapeType() != TopAbs_SOLID)
+ {
continue;
-
+ }
+ if (UserBreak(aPS))
+ {
+ return;
+ }
const TopoDS_Shape& aS = aSI.Shape();
const TopoDS_Solid& aSolid = (*(TopoDS_Solid*)(&aS));
//
TopTools_IndexedDataMapOfShapeListOfShape anInParts;
BOPAlgo_Tools::ClassifyFaces(aLFaces, aLSolids, myRunParallel,
- myContext, anInParts, aShapeBoxMap, aSolidsIF);
+ myContext, anInParts, aShapeBoxMap,
+ aSolidsIF, aPS.Next());
// Analyze the results of classification
Standard_Integer aNbSol = aDraftSolid.Extent();
for (i = 1; i <= aNbSol; ++i)
{
+ if (UserBreak(aPS))
+ {
+ return;
+ }
const TopoDS_Solid& aSolid = TopoDS::Solid(aDraftSolid.FindKey(i));
const TopoDS_Solid& aSDraft = TopoDS::Solid(aDraftSolid(i));
const TopTools_ListOfShape& aLInFaces = anInParts.FindFromKey(aSDraft);
//! Returns the solid
const TopoDS_Solid& Solid() const { return mySolid; }
+ //! Sets progress range
+ void SetProgressRange(const Message_ProgressRange& theRange)
+ {
+ myRange = theRange;
+ }
+
+ // New perform method, using own progress range
+ void Perform()
+ {
+ Message_ProgressScope aPS(myRange, NULL, 1);
+ if (!aPS.More())
+ {
+ return;
+ }
+ BOPAlgo_BuilderSolid::Perform(aPS.Next());
+ }
+
+private:
+ //! Disable the range enabled method
+ virtual void Perform(const Message_ProgressRange&/* theRange*/) {}
+
private:
TopoDS_Solid mySolid; //!< Solid to split
+ Message_ProgressRange myRange;
};
// Vector of Solid Builders
//function : BuildSplitSolids
//purpose :
//=======================================================================
-void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids)
+void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids,
+ const Message_ProgressRange& theRange)
{
Standard_Boolean bFlagSD;
Standard_Integer i, aNbS;
BOPTools_MapOfSet aMST(100, aAlr0);
BOPAlgo_VectorOfBuilderSolid aVBS;
//
+ Message_ProgressScope aPSOuter (theRange, NULL, 10);
// 0. Find same domain solids for non-interfered solids
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
if (aSI.ShapeType()!=TopAbs_SOLID) {
continue;
}
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
//
const TopoDS_Shape& aS=aSI.Shape();
if (!aMFence.Add(aS)) {
Standard_Integer k, aNbBS;
//
aNbBS=aVBS.Length();
+ // Set progress range for each task to be run in parallel
+ Message_ProgressScope aPSParallel(aPSOuter.Next(9), "Splitting solids", aNbBS);
+ for (Standard_Integer iS = 0; iS < aNbBS; iS++)
+ {
+ BOPAlgo_SplitSolid& aSplitSolid = aVBS.ChangeValue(iS);
+ aSplitSolid.SetProgressRange(aPSParallel.Next());
+ }
//
//===================================================
BOPTools_Parallel::Perform (myRunParallel, aVBS);
//===================================================
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
//
for (k = 0; k < aNbBS; ++k)
{
//function :FillInternalShapes
//purpose :
//=======================================================================
-void BOPAlgo_Builder::FillInternalShapes()
+void BOPAlgo_Builder::FillInternalShapes(const Message_ProgressRange& theRange)
{
Standard_Integer i, j, aNbS, aNbSI, aNbSx;
TopAbs_ShapeEnum aType;
TopTools_ListOfShape aLArgs(aAllocator);
TopTools_ListOfShape aLSC(aAllocator);
TopTools_ListOfShape aLSI(aAllocator);
+
+ Message_ProgressScope aPS(theRange, NULL, 10);
//
// 1. Shapes to process
//
}
}
}
-
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+
aNbSI=aMSI.Extent();
//
// 2. Internal vertices, edges from source solids
if (aSI.ShapeType()!=TopAbs_SOLID) {
continue;
}
+ if (UserBreak(aPS))
+ {
+ return;
+ }
//
const TopoDS_Shape& aS=aSI.Shape();
//
//
// 5 Settle internal vertices and edges into solids
aMx.Clear();
+
+ Message_ProgressScope aPSLoop(aPS.Next(), "Looking for internal shapes", aLSd.Size());
+
aIt.Initialize(aLSd);
- for (; aIt.More(); aIt.Next()) {
+ for (; aIt.More(); aIt.Next(), aPSLoop.Next()) {
TopoDS_Solid aSd=TopoDS::Solid(aIt.Value());
//
aIt1.Initialize(aLSI);
//function : PrepareHistory
//purpose :
//=======================================================================
-void BOPAlgo_Builder::PrepareHistory()
+void BOPAlgo_Builder::PrepareHistory(const Message_ProgressRange& theRange)
{
if (!HasHistory())
return;
// - Shapes that have no trace in the result shape. Add them as Deleted
// during the operation.
Standard_Integer aNbS = myDS->NbSourceShapes();
- for (Standard_Integer i = 0; i < aNbS; ++i)
+ Message_ProgressScope aPS(theRange, "Preparing history information", aNbS);
+ for (Standard_Integer i = 0; i < aNbS; ++i, aPS.Next())
{
+ if (UserBreak(aPS))
+ {
+ return;
+ }
const TopoDS_Shape& aS = myDS->Shape(i);
// Check if History information is available for this kind of shape.
Standard_Boolean isHistory = HasHistory();
SetToFillHistory(Standard_False);
// Perform splitting of the arguments
- Message_ProgressScope aPS(theRange, "Performing cells operation", 1);
+ Message_ProgressScope aPS(theRange, "Performing MakeCells operation", 1);
BOPAlgo_Builder::PerformInternal1(theFiller, aPS.Next());
if (HasErrors()) {
return;
//
if (!theUpdate) {
if (bChanged) {
- PrepareHistory();
+ PrepareHistory(Message_ProgressRange());
}
}
else {
}
//
if (!theUpdate) {
- PrepareHistory();
+ PrepareHistory(Message_ProgressRange());
}
else {
RemoveInternalBoundaries();
if (bChanged) {
myShape = aResult;
//
- PrepareHistory();
+ PrepareHistory(Message_ProgressRange());
}
}
myShapeMaterial.Clear();
myMapModified.Clear();
//
- PrepareHistory();
+ PrepareHistory(Message_ProgressRange());
}
//=======================================================================
//
myShape = aResult;
//
- PrepareHistory();
+ PrepareHistory(Message_ProgressRange());
}
}
//=======================================================================
class BOPAlgo_FaceSelfIntersect :
public IntTools_FaceFace,
- public BOPAlgo_Algo {
+ public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_FaceSelfIntersect() :
IntTools_FaceFace(),
- BOPAlgo_Algo(),
+ BOPAlgo_ParallelAlgo(),
myIF(-1), myTolF(1.e-7) {
}
//
return myTolF;
}
//
- virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange()) {
- Message_ProgressScope aPS(theRange, NULL, 1);
+ virtual void Perform() {
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
if (UserBreak(aPS))
{
return;
return;
}
//
- Message_ProgressScope aPS(theRange, NULL, 1);
+ Message_ProgressScope aPS(theRange, "Checking shape on self-intersection", 10);
// Perform intersection of sub shapes
- BOPAlgo_PaveFiller::Perform(aPS.Next());
+ BOPAlgo_PaveFiller::Perform(aPS.Next(8));
if (UserBreak(aPS))
{
return;
}
//
- CheckFaceSelfIntersection();
+ CheckFaceSelfIntersection(aPS.Next());
+ Message_ProgressScope aPSZZ(aPS.Next(), NULL, 4);
// Perform intersection with solids
if (!HasErrors())
- PerformVZ();
+ PerformVZ(aPSZZ.Next());
//
if (!HasErrors())
- PerformEZ();
+ PerformEZ(aPSZZ.Next());
//
if (!HasErrors())
- PerformFZ();
+ PerformFZ(aPSZZ.Next());
//
if (!HasErrors())
- PerformZZ();
+ PerformZZ(aPSZZ.Next());
//
+ if (HasErrors())
+ return;
+
// Treat the intersection results
PostTreat();
}
//function : CheckFaceSelfIntersection
//purpose :
//=======================================================================
-void BOPAlgo_CheckerSI::CheckFaceSelfIntersection()
+void BOPAlgo_CheckerSI::CheckFaceSelfIntersection(const Message_ProgressRange& theRange)
{
if (myLevelOfCheck < 5)
return;
BOPAlgo_VectorOfFaceSelfIntersect aVFace;
Standard_Integer aNbS=myDS->NbSourceShapes();
+
+ Message_ProgressScope aPSOuter(theRange, NULL, 1);
//
for (Standard_Integer i = 0; i < aNbS; i++)
}
Standard_Integer aNbFace = aVFace.Length();
+ Message_ProgressScope aPSParallel(aPSOuter.Next(), "Checking surface on self-intersection", aNbFace);
+ for (Standard_Integer iF = 0; iF < aVFace.Size(); ++iF)
+ {
+ aVFace.ChangeValue(iF).SetProgressRange(aPSParallel.Next());
+ }
//======================================================
BOPTools_Parallel::Perform (myRunParallel, aVFace);
//======================================================
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
//
for (Standard_Integer k = 0; k < aNbFace; k++)
{
//! Treats the intersection results
Standard_EXPORT void PostTreat();
- Standard_EXPORT void CheckFaceSelfIntersection();
+ Standard_EXPORT void CheckFaceSelfIntersection(const Message_ProgressRange& theRange);
//! Methods for intersection with solids
//! Vertex/Solid intersection
- Standard_EXPORT virtual void PerformVZ();
+ Standard_EXPORT virtual void PerformVZ(const Message_ProgressRange& theRange);
//! Edge/Solid intersection
- Standard_EXPORT virtual void PerformEZ();
+ Standard_EXPORT virtual void PerformEZ(const Message_ProgressRange& theRange);
//! Face/Solid intersection
- Standard_EXPORT virtual void PerformFZ();
+ Standard_EXPORT virtual void PerformFZ(const Message_ProgressRange& theRange);
//! Solid/Solid intersection
- Standard_EXPORT virtual void PerformZZ();
+ Standard_EXPORT virtual void PerformZZ(const Message_ProgressRange& theRange);
//! Used for intersection of edges and faces with solids
- Standard_EXPORT virtual void PerformSZ(const TopAbs_ShapeEnum aTS);
+ Standard_EXPORT virtual void PerformSZ(const TopAbs_ShapeEnum aTS, const Message_ProgressRange& theRange);
Standard_Integer myLevelOfCheck;
//class : BOPAlgo_VertexSolid
//purpose :
//=======================================================================
-class BOPAlgo_VertexSolid {
+class BOPAlgo_VertexSolid : public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
- BOPAlgo_VertexSolid()
- : myIV(-1), myIZ(-1), myState(TopAbs_UNKNOWN) {
+ BOPAlgo_VertexSolid() :
+ BOPAlgo_ParallelAlgo(),
+ myIV(-1), myIZ(-1), myState(TopAbs_UNKNOWN) {
};
//
virtual ~BOPAlgo_VertexSolid(){
return myState;
};
//
- void Perform() {
+ virtual void Perform() {
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+
Standard_Real aTol;
gp_Pnt aPV;
//
//class : BOPAlgo_ShapeSolid
//purpose :
//=======================================================================
-class BOPAlgo_ShapeSolid {
+class BOPAlgo_ShapeSolid: public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_ShapeSolid() :
+ BOPAlgo_ParallelAlgo(),
myIE(-1),
myIZ(-1),
myHasInterf(Standard_False),
};
//
virtual void Perform() {
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+
Standard_Boolean bHasInterf;
//
myHasInterf=Standard_False;
};
//
virtual void Perform() {
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+
Standard_Boolean bFlag;
//
bFlag=Standard_False;
//function : PerformVZ
//purpose :
//=======================================================================
-void BOPAlgo_CheckerSI::PerformVZ()
+void BOPAlgo_CheckerSI::PerformVZ(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPSOuter(theRange, NULL, 1);
+
Standard_Integer iSize, nV, nZ, k, aNbVVS;
TopAbs_State aState;
BOPDS_MapOfPair aMPK;
BOPAlgo_VectorOfVertexSolid aVVS;
//
for (; myIterator->More(); myIterator->Next()) {
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
myIterator->Value(nV, nZ);
//
if (myDS->HasInterfShapeSubShapes(nV, nZ)) {
}
//
aNbVVS=aVVS.Length();
+
+ Message_ProgressScope aPSParallel(aPSOuter.Next(), "Performing Vertex-Solid intersection", aNbVVS);
+ for (Standard_Integer iVS = 0; iVS < aNbVVS; ++iVS)
+ {
+ aVVS.ChangeValue(iVS).SetProgressRange(aPSParallel.Next());
+ }
//=============================================================
BOPTools_Parallel::Perform (myRunParallel, aVVS, myContext);
//=============================================================
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
for (k=0; k < aNbVVS; ++k) {
const BOPAlgo_VertexSolid& aVertexSolid=aVVS(k);
aState=aVertexSolid.State();
//function : PerformEZ
//purpose :
//=======================================================================
-void BOPAlgo_CheckerSI::PerformEZ()
+void BOPAlgo_CheckerSI::PerformEZ(const Message_ProgressRange& theRange)
{
- PerformSZ(TopAbs_EDGE);
+ PerformSZ(TopAbs_EDGE, theRange);
}
//=======================================================================
//function : PerformFZ
//purpose :
//=======================================================================
-void BOPAlgo_CheckerSI::PerformFZ()
+void BOPAlgo_CheckerSI::PerformFZ(const Message_ProgressRange& theRange)
{
- PerformSZ(TopAbs_FACE);
+ PerformSZ(TopAbs_FACE, theRange);
}
//=======================================================================
//function : PerformZZ
//purpose :
//=======================================================================
-void BOPAlgo_CheckerSI::PerformZZ()
+void BOPAlgo_CheckerSI::PerformZZ(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPSOuter(theRange, NULL, 1);
+
Standard_Boolean bHasInterf;
Standard_Integer iSize, nZ1, nZ, k, aNbSolidSolid;
//
}
//
aNbSolidSolid=aVSolidSolid.Length();
+
+ Message_ProgressScope aPSParallel(aPSOuter.Next(), "Performing Solid-Solid intersection", aNbSolidSolid);
+ for (Standard_Integer iSS = 0; iSS < aNbSolidSolid; ++iSS)
+ {
+ aVSolidSolid.ChangeValue(iSS).SetProgressRange(aPSParallel.Next());
+ }
//======================================================
BOPTools_Parallel::Perform (myRunParallel, aVSolidSolid);
//======================================================
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
//
BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ();
//
//function : PerformSZ
//purpose :
//=======================================================================
-void BOPAlgo_CheckerSI::PerformSZ(const TopAbs_ShapeEnum aTS)
+void BOPAlgo_CheckerSI::PerformSZ(const TopAbs_ShapeEnum theTS, const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPSOuter(theRange, NULL, 1);
+
Standard_Boolean bHasInterf;
Standard_Integer iSize, nS, nZ, k, aNbShapeSolid;
//
- myIterator->Initialize(aTS, TopAbs_SOLID);
+ myIterator->Initialize(theTS, TopAbs_SOLID);
iSize=myIterator->ExpectedLength();
if (!iSize) {
return;
BOPAlgo_VectorOfShapeSolid aVShapeSolid;
//
for (; myIterator->More(); myIterator->Next()) {
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
myIterator->Value(nS, nZ);
//
BOPAlgo_ShapeSolid& aShapeSolid=aVShapeSolid.Appended();
}
//
aNbShapeSolid=aVShapeSolid.Length();
+
+ Message_ProgressScope aPSParallel(aPSOuter.Next(),
+ theTS == TopAbs_EDGE ? "Performing Edge-Solid intersection" :
+ "Performing Face-Solid intersection",
+ aNbShapeSolid);
+ for (Standard_Integer iSS = 0; iSS < aNbShapeSolid; ++iSS)
+ {
+ aVShapeSolid.ChangeValue(iSS).SetProgressRange(aPSParallel.Next());
+ }
//======================================================
BOPTools_Parallel::Perform (myRunParallel, aVShapeSolid);
//======================================================
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
//
BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ();
BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ();
//
- if (aTS==TopAbs_EDGE) {
+ if (theTS==TopAbs_EDGE) {
aEZs.SetIncrement(iSize);
}
else {//if (aTS==TopAbs_FACE)
if (bHasInterf) {
aShapeSolid.Indices(nS, nZ);
//
- if (aTS==TopAbs_EDGE) {
+ if (theTS==TopAbs_EDGE) {
BOPDS_InterfEZ& aEZ=aEZs.Appended();
aEZ.SetIndices(nS, nZ);
}
//=======================================================================
void BOPAlgo_MakerVolume::Perform(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS(theRange, "Performing MakeVolume operation", 10);
+ Standard_Real anInterPart = myIntersect ? 9 : 0.5;
+ Standard_Real aBuildPart = 10. - anInterPart;
+
GetReport()->Clear();
//
if (myEntryPoint == 1) {
pPF->SetNonDestructive(myNonDestructive);
pPF->SetGlue(myGlue);
pPF->SetUseOBB(myUseOBB);
- Message_ProgressScope aPS(theRange, "MakerVolume", 10);
- pPF->Perform(aPS.Next(9));
+ pPF->Perform(aPS.Next(anInterPart));
if (HasErrors())
{
return;
}
//
myEntryPoint = 1;
- PerformInternal(*pPF, aPS.Next(1));
+ PerformInternal(*pPF, aPS.Next(aBuildPart));
}
//=======================================================================
void BOPAlgo_MakerVolume::PerformInternal1
(const BOPAlgo_PaveFiller& theFiller, const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS(theRange, "Building volumes", 100);
myPaveFiller = (BOPAlgo_PaveFiller*)&theFiller;
myDS = myPaveFiller->PDS();
myContext = myPaveFiller->Context();
return;
}
//
+ BOPAlgo_PISteps aSteps(PIOperation_Last);
+ analyzeProgress(100., aSteps);
+
// 3. Fill Images
- // 3.1. Vertice
if (myIntersect) {
- Message_ProgressScope aPS(theRange, "PerformInternal", 100);
- NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
-
- FillImagesVertices(aPS.Next(aSteps(0)));
+ // 3.1. Vertices
+ FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
if (HasErrors()) {
return;
}
// 3.2. Edges
- FillImagesEdges(aPS.Next(aSteps(1)));
+ FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
if (HasErrors()) {
return;
}
// 3.3. Wires
- FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps(2)));
+ FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps.GetStep(PIOperation_TreatWires)));
if (HasErrors()) {
return;
}
// 3.4. Faces
- FillImagesFaces(aPS.Next(aSteps(3)));
+ FillImagesFaces(aPS.Next(aSteps.GetStep(PIOperation_TreatFaces)));
if (HasErrors()) {
return;
}
MakeBox(aBoxFaces);
//
// 6. Make volumes
- BuildSolids(aLSR);
+ BuildSolids(aLSR, aPS.Next(aSteps.GetStep(PIOperation_BuildSolids)));
if (HasErrors()) {
return;
}
BuildShape(aLSR);
//
// 10. History
- PrepareHistory();
+ PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
+ if (HasErrors()) {
+ return;
+ }
//
// 11. Post-treatment
- PostTreat();
+ PostTreat(aPS.Next(aSteps.GetStep(PIOperation_PostTreat)));
}
//=======================================================================
-//function : AnalyzeProgress
+//function : fillPISteps
//purpose :
//=======================================================================
-NCollection_Array1<Standard_Real> BOPAlgo_MakerVolume::AnalyzeProgress()
+void BOPAlgo_MakerVolume::fillPISteps(BOPAlgo_PISteps& theSteps) const
{
- Standard_Integer aSize = 4;
- NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
- for (Standard_Integer i = 0; i < aSize; i++)
+ NbShapes aNbShapes = getNbShapes();
+ if (myIntersect)
{
- aSteps(i) = 0;
+ theSteps.SetStep(PIOperation_TreatVertices, aNbShapes.NbVertices());
+ theSteps.SetStep(PIOperation_TreatEdges, aNbShapes.NbEdges());
+ theSteps.SetStep(PIOperation_TreatWires, aNbShapes.NbWires());
+ theSteps.SetStep(PIOperation_TreatFaces, 50 * aNbShapes.NbFaces());
}
-
- Standard_Real aPart = 100.;
- Standard_Integer aNbV = myDS->ShapesSD().Size();
- Standard_Integer aNbE = 0;
- Standard_Integer aNbW = 0;
- Standard_Integer aNbF = 0;
-
- for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); i++)
- {
- const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
- switch (aSI.ShapeType())
- {
- case TopAbs_EDGE:
- aNbE++;
- break;
- case TopAbs_WIRE:
- aNbW++;
- break;
- case TopAbs_FACE:
- aNbF++;
- break;
- default:
- break;
- }
- }
-
- aNbE = 5 * aNbE;
- aNbW = 10 * aNbW;
- aNbF = 20 * aNbF;
- Standard_Real aSum = aNbV + aNbE + aNbW + aNbF;
- if (aSum == 0)
- {
- return aSteps;
- }
-
- aSteps(0) = aPart * aNbV / aSum;
- aSteps(1) = aPart * aNbE / aSum;
- aSteps(2) = aPart * aNbW / aSum;
- aSteps(3) = aPart * aNbF / aSum;
-
- return aSteps;
+ theSteps.SetStep(PIOperation_BuildSolids, 50 * aNbShapes.NbFaces());
}
//=======================================================================
//function : BuildSolids
//purpose :
//=======================================================================
-void BOPAlgo_MakerVolume::BuildSolids(TopTools_ListOfShape& theLSR)
+void BOPAlgo_MakerVolume::BuildSolids(TopTools_ListOfShape& theLSR,
+ const Message_ProgressRange& theRange)
{
- //
BOPAlgo_BuilderSolid aBS;
//
aBS.SetShapes(myFaces);
aBS.SetRunParallel(myRunParallel);
aBS.SetAvoidInternalShapes(myAvoidInternalShapes);
- aBS.Perform();
+ aBS.Perform(theRange);
if (aBS.HasErrors())
{
AddError (new BOPAlgo_AlertSolidBuilderFailed); // SolidBuilder failed
DEFINE_STANDARD_ALLOC
-
-
//! Empty constructor.
BOPAlgo_MakerVolume();
virtual ~BOPAlgo_MakerVolume();
//! Checks the data.
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
- //! Analyze progress steps
- Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-
//! Performs the operation.
Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
Standard_EXPORT void MakeBox (TopTools_MapOfShape& theBoxFaces);
//! Builds solids.
- Standard_EXPORT void BuildSolids (TopTools_ListOfShape& theLSR);
+ Standard_EXPORT void BuildSolids (TopTools_ListOfShape& theLSR,
+ const Message_ProgressRange& theRange);
//! Removes the covering box.
Standard_EXPORT void RemoveBox (TopTools_ListOfShape& theLSR, const TopTools_MapOfShape& theBoxFaces);
//! Builds the result.
Standard_EXPORT void BuildShape (const TopTools_ListOfShape& theLSR);
+protected:
+ //! List of operations to be supported by the Progress Indicator.
+ //! Enumeration is going to contain some extra operations from base class,
+ //! which are not going to be used here. So, the array of steps will also
+ //! contain some extra zero values. This is the only extra resource that is
+ //! going to be used, but it allows us not to override the methods that use
+ //! the values of the enumeration of base class.
+ //! Starting the enumeration from the middle of enumeration of base class is
+ //! not a good idea as the values in enumeration may be swapped.
+ enum BOPAlgo_PIOperation
+ {
+ PIOperation_BuildSolids = BOPAlgo_Builder::PIOperation_Last,
+ PIOperation_Last
+ };
+
+ //! Analyze progress steps
+ Standard_EXPORT void fillPISteps(BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
+protected:
Standard_Boolean myIntersect;
Bnd_Box myBBox;
#include <TopoDS_Vertex.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+namespace
+{
+ //=======================================================================
+ //function : BOPAlgo_PIOperation
+ //purpose : List of operations to be supported by the Progress Indicator
+ //=======================================================================
+ enum BOPAlgo_PIOperation
+ {
+ PIOperation_Prepare = 0,
+ PIOperation_PerformVV,
+ PIOperation_PerformVE,
+ PIOperation_PerformEE,
+ PIOperation_PerformVF,
+ PIOperation_PerformEF,
+ PIOperation_RepeatIntersection,
+ PIOperation_ForceInterfEE,
+ PIOperation_ForceInterfEF,
+ PIOperation_PerformFF,
+ PIOperation_MakeSplitEdges,
+ PIOperation_MakeBlocks,
+ PIOperation_MakePCurves,
+ PIOperation_ProcessDE,
+ PIOperation_Last
+ };
+}
+
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
-:
+ :
BOPAlgo_Algo()
{
myDS = NULL;
//purpose :
//=======================================================================
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller
- (const Handle(NCollection_BaseAllocator)& theAllocator)
-:
- BOPAlgo_Algo(theAllocator),
- myFPBDone(1, theAllocator),
- myIncreasedSS(1, theAllocator),
- myVertsToAvoidExtension(1, theAllocator),
- myDistances(1, theAllocator)
+(const Handle (NCollection_BaseAllocator)& theAllocator)
+ :
+ BOPAlgo_Algo (theAllocator),
+ myFPBDone (1, theAllocator),
+ myIncreasedSS (1, theAllocator),
+ myVertsToAvoidExtension (1, theAllocator),
+ myDistances (1, theAllocator)
{
myDS = NULL;
myIterator = NULL;
//function : SetNonDestructive
//purpose :
//=======================================================================
-void BOPAlgo_PaveFiller::SetNonDestructive(const Standard_Boolean bFlag)
+void BOPAlgo_PaveFiller::SetNonDestructive (const Standard_Boolean bFlag)
{
- myNonDestructive=bFlag;
+ myNonDestructive = bFlag;
}
//=======================================================================
//function : NonDestructive
//purpose :
//=======================================================================
-Standard_Boolean BOPAlgo_PaveFiller::NonDestructive()const
+Standard_Boolean BOPAlgo_PaveFiller::NonDestructive() const
{
return myNonDestructive;
}
//function : SetGlue
//purpose :
//=======================================================================
-void BOPAlgo_PaveFiller::SetGlue(const BOPAlgo_GlueEnum theGlue)
+void BOPAlgo_PaveFiller::SetGlue (const BOPAlgo_GlueEnum theGlue)
{
- myGlue=theGlue;
+ myGlue = theGlue;
}
//=======================================================================
//function : Glue
//purpose :
//=======================================================================
-BOPAlgo_GlueEnum BOPAlgo_PaveFiller::Glue() const
+BOPAlgo_GlueEnum BOPAlgo_PaveFiller::Glue() const
{
return myGlue;
}
//function : SetIsPrimary
//purpose :
//=======================================================================
-void BOPAlgo_PaveFiller::SetIsPrimary(const Standard_Boolean bFlag)
+void BOPAlgo_PaveFiller::SetIsPrimary (const Standard_Boolean bFlag)
{
- myIsPrimary=bFlag;
+ myIsPrimary = bFlag;
}
//=======================================================================
//function : IsPrimary
//purpose :
//=======================================================================
-Standard_Boolean BOPAlgo_PaveFiller::IsPrimary()const
+Standard_Boolean BOPAlgo_PaveFiller::IsPrimary() const
{
return myIsPrimary;
}
BOPAlgo_Algo::Clear();
if (myIterator) {
delete myIterator;
- myIterator=NULL;
+ myIterator = NULL;
}
if (myDS) {
delete myDS;
- myDS=NULL;
+ myDS = NULL;
}
myIncreasedSS.Clear();
}
//function : Context
//purpose :
//=======================================================================
-const Handle(IntTools_Context)& BOPAlgo_PaveFiller::Context()
+const Handle (IntTools_Context)& BOPAlgo_PaveFiller::Context()
{
return myContext;
}
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetSectionAttribute
- (const BOPAlgo_SectionAttribute& theSecAttr)
+(const BOPAlgo_SectionAttribute& theSecAttr)
{
mySectionAttribute = theSecAttr;
}
// function: Init
// purpose:
//=======================================================================
-void BOPAlgo_PaveFiller::Init(const Message_ProgressRange& theRange)
+void BOPAlgo_PaveFiller::Init (const Message_ProgressRange& theRange)
{
if (!myArguments.Extent()) {
AddError (new BOPAlgo_AlertTooFewArguments);
return;
}
//
- Message_ProgressScope aPS(theRange, "Init", myArguments.Size());
- TopTools_ListIteratorOfListOfShape aIt(myArguments);
+ Message_ProgressScope aPS (theRange, "Initialization of Intersection algorithm", 1);
+ TopTools_ListIteratorOfListOfShape aIt (myArguments);
for (; aIt.More(); aIt.Next(), aPS.Next()) {
if (aIt.Value().IsNull()) {
AddError (new BOPAlgo_AlertNullInputShapes);
Clear();
//
// 1.myDS
- myDS=new BOPDS_DS(myAllocator);
- myDS->SetArguments(myArguments);
- myDS->Init(myFuzzyValue);
+ myDS = new BOPDS_DS (myAllocator);
+ myDS->SetArguments (myArguments);
+ myDS->Init (myFuzzyValue);
//
// 2 myContext
- myContext=new IntTools_Context;
+ myContext = new IntTools_Context;
//
// 3.myIterator
- myIterator=new BOPDS_Iterator(myAllocator);
- myIterator->SetRunParallel(myRunParallel);
- myIterator->SetDS(myDS);
- myIterator->Prepare(myContext, myUseOBB, myFuzzyValue);
+ myIterator = new BOPDS_Iterator (myAllocator);
+ myIterator->SetRunParallel (myRunParallel);
+ myIterator->SetDS (myDS);
+ myIterator->Prepare (myContext, myUseOBB, myFuzzyValue);
//
// 4 NonDestructive flag
SetNonDestructive();
}
-NCollection_Array1<Standard_Real> BOPAlgo_PaveFiller::AnalyzeProgress()
-{
- Standard_Integer aSize = 13;
- NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
- for (Standard_Integer i = 0; i < aSize; i++)
- {
- aSteps(i) = 0;
- }
-
- Standard_Real aPart = 95.;
-
- myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
- Standard_Real aPerformVVSize = myIterator->ExpectedLength();
-
- myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE);
- Standard_Real aPerformVESize = myIterator->ExpectedLength();
-
- myIterator->Initialize(TopAbs_EDGE, TopAbs_EDGE);
- Standard_Real aPerformEESize = myIterator->ExpectedLength();
-
- myIterator->Initialize(TopAbs_VERTEX, TopAbs_FACE);
- Standard_Real aPerformVFSize = myIterator->ExpectedLength();
-
- myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE);
- Standard_Real aPerformEFSize = myIterator->ExpectedLength();
-
- myIterator->Initialize(TopAbs_FACE, TopAbs_FACE);
- Standard_Real aPerformFFSize = myIterator->ExpectedLength();
-
- Standard_Real aStep1 = aPerformVVSize;
- Standard_Real aStep2 = 2 * aPerformVESize;
- Standard_Real aStep3 = 5 * aPerformEESize;
- Standard_Real aStep4 = 5 * aPerformVFSize;
- Standard_Real aStep5 = 10 * aPerformEFSize;
- Standard_Real aStep6 = 0.1 * (aStep1 + aStep2 + aStep4);
- Standard_Real aStep7 = 2 * aPerformEESize;
- Standard_Real aStep8 = 2 * aPerformEFSize;
- Standard_Real aStep9 = 30 * aPerformFFSize;
- Standard_Real aStep10 = 0.2 * aStep3;
- Standard_Real aStep11 = 0.2 * aStep9;
- Standard_Real aStep12 = 0.2 * aStep3;
-
- Standard_Real aSum = aStep1 + aStep2 + aStep3 + aStep4 + aStep5 + aStep6 +
- aStep7 + aStep8 + aStep9 + aStep10 + aStep11 + aStep12;
-
- if (!myNonDestructive)
- {
- aPart -= 5;
- // step for init
- aSteps(0) = 5;
- }
- if (!myIsPrimary)
- {
- aSum -= aStep8;
- aStep8 = 0;
- }
- if (myGlue != BOPAlgo_GlueOff)
- {
- aSum -= aStep8;
- aStep11 = 0;
- }
- if (myAvoidBuildPCurve)
- {
- aSum -= aStep12;
- aStep12 = 0;
- }
-
- if (aSum == 0)
- {
- aSteps(0) = 95.;
- return aSteps;
- }
- // step for PerformVV()
- aSteps(1) = aPart * aStep1 / aSum;
- // step for PerformVE()
- aSteps(2) = aPart * aStep2 / aSum;
- // step for PerformEE()
- aSteps(3) = aPart * aStep3 / aSum;
- // step for PerformVF()
- aSteps(4) = aPart * aStep4 / aSum;
- // step for PerformEF()
- aSteps(5) = aPart * aStep5 / aSum;
- // step for RepeatIntersection()
- aSteps(6) = aPart * aStep6 / aSum;
- // step for ForceInterfEE()
- aSteps(7) = aPart * aStep7 / aSum;
- // step for ForceInterfEF()
- aSteps(8) = aPart * aStep8 / aSum;
- // step for PerformFF()
- aSteps(9) = aPart * aStep9 / aSum;
- // step for MakeSplitEdges()
- aSteps(10) = aPart * aStep10 / aSum;
- // step for MakeBloks()
- aSteps(11) = aPart * aStep11 / aSum;
- // step for MakePCurves()
- aSteps(12) = aPart * aStep12 / aSum;
-
- return aSteps;
-}
-
//=======================================================================
// function: Perform
// purpose:
//=======================================================================
-void BOPAlgo_PaveFiller::Perform(const Message_ProgressRange& theRange)
+void BOPAlgo_PaveFiller::Perform (const Message_ProgressRange& theRange)
{
try {
OCC_CATCH_SIGNALS
//
- PerformInternal(theRange);
+ PerformInternal (theRange);
}
//
catch (Standard_Failure const&) {
AddError (new BOPAlgo_AlertIntersectionFailed);
- }
+ }
}
+
//=======================================================================
// function: PerformInternal
// purpose:
//=======================================================================
-void BOPAlgo_PaveFiller::PerformInternal(const Message_ProgressRange& theRange)
+void BOPAlgo_PaveFiller::PerformInternal (const Message_ProgressRange& theRange)
{
- Message_ProgressScope aPS(theRange, "Performing intersections of shapes", 100);
+ Message_ProgressScope aPS (theRange, "Performing intersection of shapes", 100);
- Init(aPS.Next(5));
+ Init (aPS.Next (5));
if (HasErrors()) {
- return;
+ return;
}
- NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
+
+ // Compute steps of the PI
+ BOPAlgo_PISteps aSteps (PIOperation_Last);
+ analyzeProgress (95, aSteps);
//
- Prepare(aPS.Next(aSteps[0]));
+ Prepare (aPS.Next (aSteps.GetStep (PIOperation_Prepare)));
if (HasErrors()) {
- return;
+ return;
}
// 00
- PerformVV(aPS.Next(aSteps[1]));
+ PerformVV (aPS.Next (aSteps.GetStep (PIOperation_PerformVV)));
if (HasErrors()) {
- return;
+ return;
}
// 01
- PerformVE(aPS.Next(aSteps[2]));
+ PerformVE (aPS.Next (aSteps.GetStep (PIOperation_PerformVE)));
if (HasErrors()) {
- return;
+ return;
}
//
UpdatePaveBlocksWithSDVertices();
// 11
- PerformEE(aPS.Next(aSteps[3]));
+ PerformEE (aPS.Next (aSteps.GetStep (PIOperation_PerformEE)));
if (HasErrors()) {
- return;
+ return;
}
UpdatePaveBlocksWithSDVertices();
// 02
- PerformVF(aPS.Next(aSteps[4]));
+ PerformVF (aPS.Next (aSteps.GetStep (PIOperation_PerformVF)));
if (HasErrors()) {
- return;
+ return;
}
UpdatePaveBlocksWithSDVertices();
// 12
- PerformEF(aPS.Next(aSteps[5]));
+ PerformEF (aPS.Next (aSteps.GetStep (PIOperation_PerformEF)));
if (HasErrors()) {
- return;
+ return;
}
UpdatePaveBlocksWithSDVertices();
UpdateInterfsWithSDVertices();
// Repeat Intersection with increased vertices
- RepeatIntersection(aPS.Next(aSteps[6]));
+ RepeatIntersection (aPS.Next (aSteps.GetStep (PIOperation_RepeatIntersection)));
if (HasErrors())
return;
// Force intersection of edges after increase
// of the tolerance values of their vertices
- ForceInterfEE(aPS.Next(aSteps[7]));
+ ForceInterfEE (aPS.Next (aSteps.GetStep (PIOperation_ForceInterfEE)));
if (HasErrors())
{
return;
}
// Force Edge/Face intersection after increase
// of the tolerance values of their vertices
- ForceInterfEF(aPS.Next(aSteps[8]));
+ ForceInterfEF (aPS.Next (aSteps.GetStep (PIOperation_ForceInterfEF)));
if (HasErrors())
{
return;
}
//
// 22
- PerformFF(aPS.Next(aSteps[9]));
+ PerformFF (aPS.Next (aSteps.GetStep (PIOperation_PerformFF)));
if (HasErrors()) {
- return;
+ return;
}
//
UpdateBlocksWithSharedVertices();
//
myDS->RefineFaceInfoIn();
//
- MakeSplitEdges(aPS.Next(aSteps[10]));
+ MakeSplitEdges (aPS.Next (aSteps.GetStep (PIOperation_MakeSplitEdges)));
if (HasErrors()) {
return;
}
//
UpdatePaveBlocksWithSDVertices();
//
- MakeBlocks(aPS.Next(aSteps[11]));
+ MakeBlocks (aPS.Next (aSteps.GetStep (PIOperation_MakeBlocks)));
if (HasErrors()) {
- return;
+ return;
}
//
CheckSelfInterference();
//
RemoveMicroEdges();
//
- MakePCurves(aPS.Next(aSteps[12]));
+ MakePCurves (aPS.Next (aSteps.GetStep (PIOperation_MakePCurves)));
if (HasErrors()) {
- return;
+ return;
}
//
- ProcessDE();
+ ProcessDE (aPS.Next (aSteps.GetStep (PIOperation_ProcessDE)));
if (HasErrors()) {
- return;
+ return;
}
}
// function: RepeatIntersection
// purpose:
//=======================================================================
-void BOPAlgo_PaveFiller::RepeatIntersection(const Message_ProgressRange& theRange)
+void BOPAlgo_PaveFiller::RepeatIntersection (const Message_ProgressRange& theRange)
{
// Find all vertices with increased tolerance
TColStd_MapOfInteger anExtraInterfMap;
const Standard_Integer aNbS = myDS->NbSourceShapes();
- Message_ProgressScope aPS(theRange, "Repeat intersection", 3);
+ Message_ProgressScope aPS (theRange, "Repeat intersection", 3);
for (Standard_Integer i = 0; i < aNbS; ++i)
{
- if (UserBreak(aPS))
+ if (UserBreak (aPS))
{
return;
}
- const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
+ const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo (i);
if (aSI.ShapeType() != TopAbs_VERTEX)
continue;
// Check if the tolerance of the original vertex has been increased
- if (myIncreasedSS.Contains(i))
+ if (myIncreasedSS.Contains (i))
{
- anExtraInterfMap.Add(i);
+ anExtraInterfMap.Add (i);
continue;
}
// Check if the vertex created a new vertex with greater tolerance
Standard_Integer nVSD;
- if (!myDS->HasShapeSD(i, nVSD))
+ if (!myDS->HasShapeSD (i, nVSD))
continue;
- if (myIncreasedSS.Contains(nVSD))
- anExtraInterfMap.Add(i);
+ if (myIncreasedSS.Contains (nVSD))
+ anExtraInterfMap.Add (i);
}
if (anExtraInterfMap.IsEmpty())
return;
// Update iterator of pairs of shapes with interfering boxes
- myIterator->IntersectExt(anExtraInterfMap);
+ myIterator->IntersectExt (anExtraInterfMap);
// Perform intersections with vertices
- PerformVV(aPS.Next());
+ PerformVV (aPS.Next());
if (HasErrors())
return;
UpdatePaveBlocksWithSDVertices();
- PerformVE(aPS.Next());
+ PerformVE (aPS.Next());
if (HasErrors())
return;
UpdatePaveBlocksWithSDVertices();
- PerformVF(aPS.Next());
+ PerformVF (aPS.Next());
if (HasErrors())
return;
UpdatePaveBlocksWithSDVertices();
UpdateInterfsWithSDVertices();
}
+
+
+//=======================================================================
+// function: fillPISteps
+// purpose:
+//=======================================================================
+void BOPAlgo_PaveFiller::fillPIConstants (const Standard_Real theWhole,
+ BOPAlgo_PISteps& theSteps) const
+{
+ if (!myNonDestructive)
+ {
+ theSteps.SetStep (PIOperation_Prepare, 1 * theWhole / 100.);
+ }
+}
+
+//=======================================================================
+// function: fillPISteps
+// purpose:
+//=======================================================================
+void BOPAlgo_PaveFiller::fillPISteps (BOPAlgo_PISteps& theSteps) const
+{
+ // Get number of all intersecting pairs
+ Standard_Integer aVVSize = 0, aVESize = 0, aEESize = 0, aVFSize = 0, aEFSize = 0, aFFSize = 0;
+
+ myIterator->Initialize (TopAbs_VERTEX, TopAbs_VERTEX);
+ aVVSize = myIterator->ExpectedLength();
+
+ myIterator->Initialize (TopAbs_VERTEX, TopAbs_EDGE);
+ aVESize = myIterator->ExpectedLength();
+
+ myIterator->Initialize (TopAbs_EDGE, TopAbs_EDGE);
+ aEESize = myIterator->ExpectedLength();
+
+ myIterator->Initialize (TopAbs_VERTEX, TopAbs_FACE);
+ aVFSize = myIterator->ExpectedLength();
+
+ if (myGlue != BOPAlgo_GlueFull)
+ {
+ myIterator->Initialize (TopAbs_EDGE, TopAbs_FACE);
+ aEFSize = myIterator->ExpectedLength();
+ }
+
+ myIterator->Initialize (TopAbs_FACE, TopAbs_FACE);
+ aFFSize = myIterator->ExpectedLength();
+
+ theSteps.SetStep (PIOperation_PerformVV, aVVSize);
+ theSteps.SetStep (PIOperation_PerformVE, 2 * aVESize);
+ theSteps.SetStep (PIOperation_PerformEE, 5 * aEESize);
+ theSteps.SetStep (PIOperation_PerformVF, 5 * aVFSize);
+ theSteps.SetStep (PIOperation_PerformEF, 10 * aEFSize);
+ theSteps.SetStep (PIOperation_RepeatIntersection, 0.2 * (aVVSize + aVESize + aVFSize));
+ theSteps.SetStep (PIOperation_ForceInterfEE, 2 * aEESize);
+ theSteps.SetStep (PIOperation_ForceInterfEF, 2 * aEFSize);
+ theSteps.SetStep (PIOperation_PerformFF, (myGlue == BOPAlgo_GlueFull ? 1 : 30) * aFFSize);
+ theSteps.SetStep (PIOperation_MakeSplitEdges, aEESize);
+ theSteps.SetStep (PIOperation_MakeBlocks, (myGlue == BOPAlgo_GlueFull ? 0 : 5) * aFFSize);
+ theSteps.SetStep (PIOperation_MakePCurves, myAvoidBuildPCurve ? 0 : 0.2 * (aEESize + aEFSize));
+ theSteps.SetStep (PIOperation_ProcessDE, 0.1 * aEESize);
+}
Standard_EXPORT void SplitPaveBlocks(const TColStd_MapOfInteger& theMEdges,
const Standard_Boolean theAddInterfs);
- Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-
Standard_EXPORT virtual void PerformVF(const Message_ProgressRange& theRange);
Standard_EXPORT virtual void PerformEE(const Message_ProgressRange& theRange);
Standard_EXPORT Standard_Integer MakeSDVertices(const TColStd_ListOfInteger& theVertIndices,
const Standard_Boolean theAddInterfs = 1);
- Standard_EXPORT void ProcessDE();
+ Standard_EXPORT void ProcessDE(const Message_ProgressRange& theRange);
Standard_EXPORT void FillShrunkData (Handle(BOPDS_PaveBlock)& thePB);
TColStd_DataMapOfIntegerInteger& theDMNewSD,
const BOPDS_IndexedMapOfPaveBlock& theMicroPB,
const TopTools_IndexedMapOfShape& theVertsOnRejectedPB,
- const Handle(NCollection_BaseAllocator)& theAllocator);
+ const Handle(NCollection_BaseAllocator)& theAllocator,
+ const Message_ProgressRange& theRange);
Standard_EXPORT void FindPaveBlocks (const Standard_Integer theV,
const Standard_Integer theF,
{}
};
+protected: //! Analyzing Progress steps
+
+ //! Filling steps for constant operations
+ Standard_EXPORT void fillPIConstants(const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+ //! Filling steps for all other operations
+ Standard_EXPORT void fillPISteps(BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
protected: //! Fields
TopTools_ListOfShape myArguments;
//
myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
aSize=myIterator->ExpectedLength();
- Message_ProgressScope aPS(theRange, "PerformVV", 1);
+ Message_ProgressScope aPS(theRange, NULL, 2.);
if (!aSize) {
return;
}
NCollection_List<TColStd_ListOfInteger> aMBlocks(aAllocator);
//
// 1. Map V/LV
- for (; myIterator->More(); myIterator->Next()) {
+ // Split progress range on intersection stage and making blocks. Display only intersection stage.
+ Message_ProgressScope aPSLoop(aPS.Next(1.), "Performing Vertex-Vertex intersection", aSize);
+ for (; myIterator->More(); myIterator->Next(), aPSLoop.Next()) {
if (UserBreak(aPS))
{
return;
//class : BOPAlgo_VertexEdge
//purpose :
//=======================================================================
-class BOPAlgo_VertexEdge : public BOPAlgo_Algo {
+class BOPAlgo_VertexEdge : public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_VertexEdge() :
- BOPAlgo_Algo(),
+ BOPAlgo_ParallelAlgo(),
myIV(-1), myIE(-1), myFlag(-1), myT(-1.), myTolVNew(-1.) {
};
//
const Handle(BOPDS_PaveBlock)& PaveBlock() const {
return myPB;
}
- void SetRange(const Message_ProgressRange& theRange)
- {
- myRange = theRange;
- }
//
virtual void Perform() {
- Message_ProgressScope aPS(myRange, NULL, 1);
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
if (UserBreak(aPS))
{
return;
TopoDS_Edge myE;
Handle(IntTools_Context) myContext;
Handle(BOPDS_PaveBlock) myPB;
-private:
- Message_ProgressRange myRange;
};
//=======================================================================
typedef NCollection_Vector<BOPAlgo_VertexEdge> BOPAlgo_VectorOfVertexEdge;
//
myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE);
Message_ProgressScope aPS(theRange, NULL, 1);
+
Standard_Integer iSize = myIterator->ExpectedLength();
if (!iSize) {
return;
// intersection of the same SD vertex with edge
NCollection_DataMap<BOPDS_Pair, TColStd_ListOfInteger, BOPDS_PairMapHasher> aDMVSD;
//
- Message_ProgressScope aPSOuter(theRange, "Intersecting vertices with edges", 1);
+ Message_ProgressScope aPSOuter(theRange, NULL, 10);
for (i = 1; i <= aNbVE; ++i) {
if (UserBreak(aPSOuter))
{
//
aNbVE = aVVE.Length();
- Message_ProgressScope aPS(aPSOuter.Next(), "Intersecting vertices with edges", aNbVE);
+ Message_ProgressScope aPS(aPSOuter.Next(9), "Performing Vertex-Edge intersection", aNbVE);
for (i = 0; i < aVVE.Length(); i++)
{
BOPAlgo_VertexEdge& aVESolver = aVVE.ChangeValue(i);
- aVESolver.SetRange(aPS.Next());
+ aVESolver.SetProgressRange(aPS.Next());
}
// Perform intersection
//=============================================================
//=======================================================================
class BOPAlgo_EdgeEdge :
public IntTools_EdgeEdge,
- public BOPAlgo_Algo {
+ public BOPAlgo_ParallelAlgo {
public:
//
BOPAlgo_EdgeEdge():
IntTools_EdgeEdge(),
- BOPAlgo_Algo() {
+ BOPAlgo_ParallelAlgo() {
};
//
virtual ~BOPAlgo_EdgeEdge(){
IntTools_EdgeEdge::SetFuzzyValue(theFuzz);
}
//
- void SetRange(const Message_ProgressRange& theRange)
- {
- myRange = theRange;
- }
- //
virtual void Perform() {
- Message_ProgressScope aPS(myRange, NULL, 1);
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
if (UserBreak(aPS))
{
return;
Handle(BOPDS_PaveBlock) myPB2;
Bnd_Box myBox1;
Bnd_Box myBox2;
-private:
- Message_ProgressRange myRange;
};
//
//=======================================================================
//
myIterator->Initialize(TopAbs_EDGE, TopAbs_EDGE);
Standard_Integer iSize = myIterator->ExpectedLength();
- Message_ProgressScope aPSOuter(theRange, NULL, 100);
+ Message_ProgressScope aPSOuter(theRange, NULL, 10);
if (!iSize) {
return;
}
//
aNbEdgeEdge=aVEdgeEdge.Length();
- Message_ProgressScope aPS(aPSOuter.Next(90), "Edge-edge perform", aNbEdgeEdge);
+ Message_ProgressScope aPS(aPSOuter.Next(9), "Performing Edge-edge intersection", aNbEdgeEdge);
for (k = 0; k < aNbEdgeEdge; k++)
{
BOPAlgo_EdgeEdge& anEdgeEdge = aVEdgeEdge.ChangeValue(k);
- anEdgeEdge.SetRange(aPS.Next());
+ anEdgeEdge.SetProgressRange(aPS.Next());
}
//======================================================
BOPTools_Parallel::Perform (myRunParallel, aVEdgeEdge);
// Update vertices of common blocks with real CB tolerances
UpdateVerticesOfCB();
- PerformNewVertices(aMVCPB, aAllocator, aPSOuter.Next(10));
+ PerformNewVertices(aMVCPB, aAllocator, aPSOuter.Next());
if (HasErrors())
{
return;
// 4. Compute Extra Paves and split Pave blocks by the Extra paves
Message_ProgressScope aPS(theRange, NULL, 2);
Standard_Integer i, aNb = aImages.Extent();
- Message_ProgressScope aPS1(aPS.Next(), "Performing new vertices", aNb + aNbV);
+ Message_ProgressScope aPS1(aPS.Next(), NULL, aNb + aNbV);
for (i = 1; i <= aNb; ++i, aPS1.Next()) {
if (UserBreak(aPS))
{
// those pairs of pave blocks with the same bounding vertices.
Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
- Message_ProgressScope aPSOuter(theRange, NULL, 1);
+ Message_ProgressScope aPSOuter(theRange, NULL, 10);
// Initialize pave blocks for all vertices which participated in intersections
const Standard_Integer aNbS = myDS->NbSourceShapes();
for (Standard_Integer i = 0; i < aNbS; ++i)
if (!aNbPairs)
return;
+ // close preparation step
+ aPSOuter.Next(0.7).Close();
+
aPBMap.Clear();
aMPBFence.Clear();
anAlloc->Reset();
- Message_ProgressScope aPS(aPSOuter.Next(), "Intersection edge-edge", aNbPairs);
+ Message_ProgressScope aPS(aPSOuter.Next(9), "Checking for coinciding edges", aNbPairs);
for (Standard_Integer i = 0; i < aNbPairs; i++)
{
BOPAlgo_EdgeEdge& anEdgeEdge = aVEdgeEdge.ChangeValue(i);
- anEdgeEdge.SetRange(aPS.Next());
+ anEdgeEdge.SetProgressRange(aPS.Next());
}
// Perform intersection of the found pairs
//class : BOPAlgo_VertexFace
//purpose :
//=======================================================================
-class BOPAlgo_VertexFace : public BOPAlgo_Algo {
+class BOPAlgo_VertexFace : public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_VertexFace() :
- BOPAlgo_Algo(),
+ BOPAlgo_ParallelAlgo(),
myIV(-1), myIF(-1),
myFlag(-1), myT1(-1.), myT2(-1.), myTolVNew(-1.) {
}
return myContext;
}
//
- void SetRange(const Message_ProgressRange& theRange)
- {
- myRange = theRange;
- }
- //
virtual void Perform() {
- Message_ProgressScope aPS(myRange, NULL, 1);
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
if (UserBreak(aPS))
{
return;
TopoDS_Vertex myV;
TopoDS_Face myF;
Handle(IntTools_Context) myContext;
-private:
- Message_ProgressRange myRange;
};
//=======================================================================
typedef NCollection_Vector<BOPAlgo_VertexFace> BOPAlgo_VectorOfVertexFace;
//
Standard_Integer nV, nF;
//
- Message_ProgressScope aPSOuter(theRange, NULL, 1);
+ Message_ProgressScope aPSOuter(theRange, NULL, 10);
if (myGlue == BOPAlgo_GlueFull) {
// there is no need to intersect vertices with faces in this mode
// just initialize FaceInfo for all faces
}//for (; myIterator->More(); myIterator->Next()) {
//
aNbVF=aVVF.Length();
- Message_ProgressScope aPS(aPSOuter.Next(), "Vertex-face perform", aNbVF);
+ Message_ProgressScope aPS(aPSOuter.Next(9), "Performing Vertex-Face intersection", aNbVF);
for (k = 0; k < aNbVF; k++)
{
BOPAlgo_VertexFace& aVertexFace = aVVF.ChangeValue(k);
- aVertexFace.SetRange(aPS.Next());
+ aVertexFace.SetProgressRange(aPS.Next());
}
//================================================================
BOPTools_Parallel::Perform (myRunParallel, aVVF, myContext);
//=======================================================================
class BOPAlgo_EdgeFace :
public IntTools_EdgeFace,
- public BOPAlgo_Algo {
+ public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_EdgeFace() :
IntTools_EdgeFace(),
- BOPAlgo_Algo(),
+ BOPAlgo_ParallelAlgo(),
myIE(-1), myIF(-1) {
};
//
myBox2 = theBox2;
}
//
- void SetProgress (const Message_ProgressRange& theRange)
- {
- myRange = theRange;
- }
- //
virtual void Perform() {
- Message_ProgressScope aPS(myRange, NULL, 1);
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
if (UserBreak(aPS))
{
return;
Handle(BOPDS_PaveBlock) myPB;
Bnd_Box myBox1;
Bnd_Box myBox2;
-
-private:
- Message_ProgressRange myRange;
};
//
//=======================================================================
FillShrunkData(TopAbs_EDGE, TopAbs_FACE);
//
myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE);
- Message_ProgressScope aPSOuter(theRange, "Intersecting edges with faces", 100);
+ Message_ProgressScope aPSOuter(theRange, NULL, 10);
Standard_Integer iSize = myIterator->ExpectedLength();
if (!iSize) {
return;
}//for (; myIterator->More(); myIterator->Next()) {
//
aNbEdgeFace=aVEdgeFace.Length();
- Message_ProgressScope aPS(aPSOuter.Next(90), "Edge-face perform", aNbEdgeFace);
+ Message_ProgressScope aPS(aPSOuter.Next(9), "Performing Edge-Face intersection", aNbEdgeFace);
for (Standard_Integer index = 0; index < aNbEdgeFace; index++)
{
BOPAlgo_EdgeFace& aEdgeFace = aVEdgeFace.ChangeValue(index);
- aEdgeFace.SetProgress(aPS.Next());
+ aEdgeFace.SetProgressRange(aPS.Next());
}
//=================================================================
BOPTools_Parallel::Perform (myRunParallel, aVEdgeFace, myContext);
//=========================================
BOPAlgo_Tools::PerformCommonBlocks(aMPBLI, aAllocator, myDS, myContext);
UpdateVerticesOfCB();
- PerformNewVertices(aMVCPB, aAllocator, aPSOuter.Next(10), Standard_False);
+ PerformNewVertices(aMVCPB, aAllocator, aPSOuter.Next(1), Standard_False);
if (HasErrors())
{
return;
const Message_ProgressRange& theRange,
const Standard_Boolean theAddInterf)
{
- Message_ProgressScope aPSOuter(theRange, NULL, 1);
+ // Split progress on preparation, intersection and post-treatment stages
+ Message_ProgressScope aPSOuter(theRange, NULL, 10);
if (theMPB.IsEmpty())
return;
// Fill the tree with bounding boxes of the pave blocks
Standard_Integer aNbEFs = aVEdgeFace.Length();
if (!aNbEFs)
+ {
return;
+ }
+
+ // close preparation step
+ aPSOuter.Next(0.7).Close();
aPBMap.Clear();
anAlloc->Reset();
- Message_ProgressScope aPS(aPSOuter.Next(), "Checking for coinciding edges and faces", aNbEFs);
+ Message_ProgressScope aPS(aPSOuter.Next(9), "Checking for edges coinciding with faces", aNbEFs);
for (Standard_Integer i = 0; i < aNbEFs; i++)
{
BOPAlgo_EdgeFace& aEdgeFace = aVEdgeFace.ChangeValue(i);
- aEdgeFace.SetProgress(aPS.Next());
+ aEdgeFace.SetProgressRange(aPS.Next());
}
// Perform intersection of the found pairs
BOPTools_Parallel::Perform (myRunParallel, aVEdgeFace, myContext);
//=======================================================================
class BOPAlgo_FaceFace :
public IntTools_FaceFace,
- public BOPAlgo_Algo {
+ public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_FaceFace() :
IntTools_FaceFace(),
- BOPAlgo_Algo(),
+ BOPAlgo_ParallelAlgo(),
myIF1(-1), myIF2(-1), myTolFF(1.e-7) {
}
//
IntTools_FaceFace::SetFuzzyValue(theFuzz);
}
//
- void SetProgress(const Message_ProgressRange& theRange)
- {
- myRange = theRange;
- }
- //
const gp_Trsf& Trsf() const { return myTrsf; }
//
virtual void Perform() {
- Message_ProgressScope aPS(myRange, NULL, 1);
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
if (UserBreak(aPS))
{
return;
Bnd_Box myBox1;
Bnd_Box myBox2;
gp_Trsf myTrsf;
-
- private:
- Message_ProgressRange myRange;
};
//
//=======================================================================
}//for (; myIterator->More(); myIterator->Next()) {
//
Standard_Integer k, aNbFaceFace = aVFaceFace.Length();;
- Message_ProgressScope aPS(aPSOuter.Next(), "Intersecting faces", aNbFaceFace);
+ Message_ProgressScope aPS(aPSOuter.Next(), "Performing Face-Face intersection", aNbFaceFace);
for (k = 0; k < aVFaceFace.Size(); k++)
{
BOPAlgo_FaceFace& aFaceFace = aVFaceFace.ChangeValue(k);
- aFaceFace.SetProgress(aPS.Next());
+ aFaceFace.SetProgressRange(aPS.Next());
}
//======================================================
// Perform intersection
//=======================================================================
void BOPAlgo_PaveFiller::MakeBlocks(const Message_ProgressRange& theRange)
{
- Message_ProgressScope aPSOuter(theRange, NULL, 2);
+ Message_ProgressScope aPSOuter(theRange, NULL, 4);
if (myGlue != BOPAlgo_GlueOff) {
return;
}
//
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
Standard_Integer aNbFF = aFFs.Length();
- Message_ProgressScope aPS(aPSOuter.Next(), "Making blocks", aNbFF);
+ Message_ProgressScope aPS(aPSOuter.Next(), "Building section edges", aNbFF);
if (!aNbFF) {
return;
}
// post treatment
MakeSDVerticesFF(aDMVLV, aDMNewSD);
- PostTreatFF(aMSCPB, aDMExEdges, aDMNewSD, aMicroPB, aVertsOnRejectedPB, aAllocator);
+ PostTreatFF(aMSCPB, aDMExEdges, aDMNewSD, aMicroPB, aVertsOnRejectedPB, aAllocator, aPSOuter.Next(2));
if (HasErrors()) {
return;
}
TColStd_DataMapOfIntegerInteger& aDMNewSD,
const BOPDS_IndexedMapOfPaveBlock& theMicroPB,
const TopTools_IndexedMapOfShape& theVertsOnRejectedPB,
- const Handle(NCollection_BaseAllocator)& theAllocator)
+ const Handle(NCollection_BaseAllocator)& theAllocator,
+ const Message_ProgressRange& theRange)
{
Standard_Integer aNbS = theMSCPB.Extent();
if (!aNbS) {
}
}
//
+ Message_ProgressScope aPS(theRange, "Intersection of section edges", 1);
+
// 2 Fuse shapes
aPF.SetRunParallel(myRunParallel);
aPF.SetArguments(aLS);
- aPF.Perform();
+ aPF.Perform(aPS.Next());
if (aPF.HasErrors()) {
AddError (new BOPAlgo_AlertPostTreatFF);
return;
//class : BOPAlgo_SplitEdge
//purpose :
//=======================================================================
-class BOPAlgo_SplitEdge : public BOPAlgo_Algo {
+class BOPAlgo_SplitEdge : public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_SplitEdge() :
- BOPAlgo_Algo() {
+ BOPAlgo_ParallelAlgo() {
myT1=0.;
myT2=0.;
myTol = 0.;
myContext = aContext;
}
//
- void SetRange(const Message_ProgressRange& theRange)
- {
- myRange = theRange;
- }
- //
virtual void Perform () {
- Message_ProgressScope aPS(myRange, NULL, 1);
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
if (UserBreak(aPS))
{
return;
//
BOPDS_PDS myDS;
Handle(IntTools_Context) myContext;
-private:
- Message_ProgressRange myRange;
};
//
//=======================================================================
//class : BOPAlgo_MPC
//purpose :
//=======================================================================
-class BOPAlgo_MPC : public BOPAlgo_Algo {
+class BOPAlgo_MPC : public BOPAlgo_ParallelAlgo {
public:
DEFINE_STANDARD_ALLOC
BOPAlgo_MPC() :
- BOPAlgo_Algo(),
+ BOPAlgo_ParallelAlgo(),
myFlag(Standard_False) {
};
//
return myContext;
}
//
- void SetRange(const Message_ProgressRange& theRange)
- {
- myRange = theRange;
- }
- //
virtual void Perform() {
- Message_ProgressScope aPS(myRange, NULL, 1);
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
if (UserBreak(aPS))
{
return;
Standard_Real myNewTol;
//
Handle(IntTools_Context) myContext;
- private:
- Message_ProgressRange myRange;
};
//
//=======================================================================
} // for (i=0; i<aNbPBP; ++i) {
//
aNbVBSE=aVBSE.Length();
- Message_ProgressScope aPS(aPSOuter.Next(), "MakeSplitEdges", aNbVBSE);
+ Message_ProgressScope aPS(aPSOuter.Next(), "Splitting edges", aNbVBSE);
for (k = 0; k < aNbVBSE; k++)
{
BOPAlgo_SplitEdge& aBSE = aVBSE.ChangeValue(k);
- aBSE.SetRange(aPS.Next());
+ aBSE.SetProgressRange(aPS.Next());
}
//======================================================
BOPTools_Parallel::Perform (myRunParallel, aVBSE, myContext);
for (i = 0; i < aVMPC.Length(); i++)
{
BOPAlgo_MPC& aMPC = aVMPC.ChangeValue(i);
- aMPC.SetRange(aPS.Next());
+ aMPC.SetProgressRange(aPS.Next());
}
//======================================================
BOPTools_Parallel::Perform (myRunParallel, aVMPC, myContext);
//function : ProcessDE
//purpose :
//=======================================================================
-void BOPAlgo_PaveFiller::ProcessDE()
+void BOPAlgo_PaveFiller::ProcessDE(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPSOuter(theRange, NULL, 1);
+
Standard_Integer nF, aNb, nE, nV, nVSD, aNbPB;
Handle(NCollection_BaseAllocator) aAllocator;
Handle(BOPDS_PaveBlock) aPBD;
//
aNb=myDS->NbSourceShapes();
for (nE=0; nE<aNb; ++nE) {
+ if (UserBreak(aPSOuter))
+ {
+ return;
+ }
const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
if (aSIE.ShapeType()==TopAbs_EDGE) {
if (aSIE.HasFlag(nF)) {
//nV,nE,nF
//
if (aSIF.ShapeType() == TopAbs_FACE) {
- // 1. Find PaveBlocks that are go through nV for nF
+ // 1. Find PaveBlocks that go through nV for nF
FindPaveBlocks(nV, nF, aLPBOut);
aNbPB=aLPBOut.Extent();
if (aNbPB) {
}
//=======================================================================
-//function : AnalyzeProgress
-//purpose :
+// function: fillPIConstants
+// purpose:
//=======================================================================
-NCollection_Array1<Standard_Real> BOPAlgo_Section::AnalyzeProgress()
+void BOPAlgo_Section::fillPIConstants (const Standard_Real theWhole,
+ BOPAlgo_PISteps& theSteps) const
{
- Standard_Integer aSize = 3;
- NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
- for (Standard_Integer i = 0; i < aSize; i++)
- {
- aSteps(i) = 0;
- }
-
- Standard_Real aPart = 100.;
- Standard_Integer aNbV = myDS->ShapesSD().Size();
- Standard_Integer aNbE = 0;
- Standard_Integer aNbF = 0;
- for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); i++)
- {
- const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
- switch (aSI.ShapeType())
- {
- case TopAbs_EDGE:
- aNbE++;
- break;
- case TopAbs_FACE:
- aNbF++;
- break;
- default:
- break;
- }
- }
-
- aNbE = 5 * aNbE;
- aNbF = 20 * aNbF;
-
- Standard_Real aSum = aNbV + aNbE + aNbF;
- if (aSum == 0)
+ // Fill in the constants:
+ if (myFillHistory)
{
- return aSteps;
+ // for FillHistroty, which takes about 10% of the whole operation
+ theSteps.SetStep(PIOperation_FillHistory, 10. * theWhole / 100.);
}
- aSteps(0) = aPart * aNbV / aSum;
- aSteps(1) = aPart * aNbE / aSum;
- aSteps(2) = aPart * aNbF / aSum;
-
- return aSteps;
+ // and for PostTreat, which takes about 5% of the whole operation
+ theSteps.SetStep(PIOperation_PostTreat, 5. * theWhole / 100.);
}
+//=======================================================================
+// function: fillPISteps
+// purpose:
+//=======================================================================
+void BOPAlgo_Section::fillPISteps (BOPAlgo_PISteps& theSteps) const
+{
+ // Compute the rest of the operations - all depend on the number of sub-shapes of certain type
+ NbShapes aNbShapes = getNbShapes();
+ theSteps.SetStep(PIOperation_TreatVertices, aNbShapes.NbVertices());
+ theSteps.SetStep(PIOperation_TreatEdges, aNbShapes.NbEdges());
+ theSteps.SetStep(PIOperation_BuildSection, aNbShapes.NbEdges() + aNbShapes.NbFaces());
+}
//=======================================================================
//function : PerformInternal1
//purpose :
void BOPAlgo_Section::PerformInternal1
(const BOPAlgo_PaveFiller& theFiller, const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS(theRange, "Building result of SECTION operation", 100);
myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
myDS=myPaveFiller->PDS();
myContext=myPaveFiller->Context();
return;
}
//
- Message_ProgressScope aPS(theRange, "Building result of SECTION operation", 100);
- NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
+ BOPAlgo_PISteps aSteps (PIOperation_Last);
+ analyzeProgress(100., aSteps);
// 3. Fill Images
// 3.1 Vertices
- FillImagesVertices(aPS.Next(aSteps(0)));
+ FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
if (HasErrors()) {
return;
}
return;
}
// 3.2 Edges
- FillImagesEdges(aPS.Next(aSteps(1)));
+ FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
if (HasErrors()) {
return;
}
return;
}
// 4. Section
- BuildSection(aPS.Next(aSteps(2)));
- //
+ BuildSection(aPS.Next(aSteps.GetStep(PIOperation_BuildSection)));
if (HasErrors()) {
return;
}
// 5.History
- PrepareHistory();
- //
+ PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
if (HasErrors()) {
return;
}
// 6. Post-treatment
- PostTreat();
+ PostTreat(aPS.Next(aSteps.GetStep(PIOperation_PostTreat)));
}
//=======================================================================
//function : BuildSection
//=======================================================================
void BOPAlgo_Section::BuildSection(const Message_ProgressRange& theRange)
{
- Message_ProgressScope aPS(theRange, "BuildSection", 1);
+ Message_ProgressScope aPS(theRange, "Building the result of Section operation", 1);
Standard_Integer i, aNbMS, aNbLE;
Standard_Integer j, nE, nV, aNb, aNbF, aNbPBSc;
TopoDS_Shape aRC, aRC1;
//! Combine the result of section operation
Standard_EXPORT virtual void BuildSection(const Message_ProgressRange& theRange);
- //! AnalyzeProgress
- Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-
//! Performs calculations using prepared Filler object <thePF>
Standard_EXPORT virtual void PerformInternal1(const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange) Standard_OVERRIDE;
-private:
+protected:
+
+ //! List of operations to be supported by the Progress Indicator.
+ //! Override the whole enumeration here since the constant operations are also
+ //! going to be overridden.
+ enum BOPAlgo_PIOperation
+ {
+ PIOperation_TreatVertices = 0,
+ PIOperation_TreatEdges,
+ PIOperation_BuildSection,
+ PIOperation_FillHistory,
+ PIOperation_PostTreat,
+ PIOperation_Last
+ };
+
+ //! Filling steps for constant operations
+ Standard_EXPORT void fillPIConstants(const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
+ //! Filling steps for all other operations
+ Standard_EXPORT void fillPISteps(BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
};
return *myPCB;
}
//
+ void SetProgressRange(const Message_ProgressRange& theRange)
+ {
+ myProgressRange = theRange;
+ }
+ //
void Perform() {
+ Message_ProgressScope aPS(myProgressRange, NULL, 1);
+ if (!aPS.More())
+ {
+ return;
+ }
BOPAlgo_ShellSplitter::SplitBlock(*myPCB);
}
protected:
BOPTools_ConnexityBlock *myPCB;
+ Message_ProgressRange myProgressRange;
};
//=======================================================================
typedef NCollection_Vector<BOPAlgo_CBK> BOPAlgo_VectorOfCBK;
//function : Perform
//purpose :
//=======================================================================
-void BOPAlgo_ShellSplitter::Perform(const Message_ProgressRange& /*theRange*/)
+void BOPAlgo_ShellSplitter::Perform(const Message_ProgressRange& theRange)
{
GetReport()->Clear();
+ Message_ProgressScope aPS(theRange, "Building shells", 1);
//
BOPTools_AlgoTools::MakeConnexityBlocks
(myStartShapes, TopAbs_EDGE, TopAbs_FACE, myLCB);
- //
- MakeShells();
+ if (UserBreak (aPS))
+ {
+ return;
+ }
+
+ MakeShells(aPS.Next());
}
//=======================================================================
//function : MakeShells
//purpose :
//=======================================================================
-void BOPAlgo_ShellSplitter::MakeShells()
+void BOPAlgo_ShellSplitter::MakeShells(const Message_ProgressRange& theRange)
{
Standard_Boolean bIsRegular;
Standard_Integer aNbVCBK, k;
TopTools_ListIteratorOfListOfShape aIt;
BOPAlgo_VectorOfCBK aVCBK;
//
+ Message_ProgressScope aPSOuter(theRange, NULL, 1);
myShells.Clear();
//
aItCB.Initialize(myLCB);
for (; aItCB.More(); aItCB.Next()) {
+ if (UserBreak (aPSOuter))
+ {
+ return;
+ }
BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue();
bIsRegular=aCB.IsRegular();
if (bIsRegular) {
}
//
aNbVCBK=aVCBK.Length();
+ Message_ProgressScope aPSParallel(aPSOuter.Next(), NULL, aNbVCBK);
+ for (Standard_Integer iS = 0; iS < aNbVCBK; ++iS)
+ {
+ aVCBK.ChangeValue(iS).SetProgressRange(aPSParallel.Next());
+ }
//===================================================
BOPTools_Parallel::Perform (myRunParallel, aVCBK);
//===================================================
protected:
- Standard_EXPORT void MakeShells();
+ Standard_EXPORT void MakeShells(const Message_ProgressRange& theRange);
TopTools_ListOfShape myStartShapes;
pPF->SetGlue(myGlue);
pPF->SetUseOBB(myUseOBB);
//
- Message_ProgressScope aPS(theRange, "BOPAlgo_Splitter", 10);
+ Message_ProgressScope aPS(theRange, "Performing Split operation", 10);
pPF->Perform(aPS.Next(9));
if (HasErrors())
{
//class : BOPAlgo_FillIn3DParts
//purpose : Auxiliary class for faces classification in parallel mode
//=======================================================================
-class BOPAlgo_FillIn3DParts : public BOPAlgo_Algo
+class BOPAlgo_FillIn3DParts : public BOPAlgo_ParallelAlgo
{
public:
DEFINE_STANDARD_ALLOC
}
//! Performs the classification
- virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange());
+ virtual void Perform();
//! Returns the faces classified as IN for solid
const TopTools_ListOfShape& InFaces() const
//function : BOPAlgo_FillIn3DParts::Perform
//purpose :
//=======================================================================
-void BOPAlgo_FillIn3DParts::Perform(const Message_ProgressRange& theRange)
+void BOPAlgo_FillIn3DParts::Perform()
{
- Message_ProgressScope aPS(theRange, NULL, 1);
- if (UserBreak(aPS))
+ Message_ProgressScope aPSOuter(myProgressRange, NULL, 2);
+ if (UserBreak(aPSOuter))
{
return;
}
MapEdgesAndFaces(aVShapeBox(aIVec(k)).Shape(), aMEFP, anAlloc);
}
+ aPSOuter.Next().Close();
+
// Map of Edge-Face connection, necessary for solid classification.
// It will be filled when first classification is performed.
TopTools_IndexedDataMapOfShapeListOfShape aMEFDS(1, anAlloc);
// Fence map to avoid processing of the same faces twice
TopTools_MapOfShape aMFDone(1, anAlloc);
- for (k = 0; k < aNbFP; ++k)
+ Message_ProgressScope aPSLoop (aPSOuter.Next(), NULL, aNbFP);
+ for (k = 0; k < aNbFP; ++k, aPSLoop.Next())
{
+ if (UserBreak (aPSLoop))
+ {
+ return;
+ }
Standard_Integer nFP = aIVec(k);
const TopoDS_Face& aFP = (*(TopoDS_Face*)&aVShapeBox(nFP).Shape());
if (!aMFDone.Add(aFP))
Handle(IntTools_Context)& theContext,
TopTools_IndexedDataMapOfShapeListOfShape& theInParts,
const TopTools_DataMapOfShapeBox& theShapeBoxMap,
- const TopTools_DataMapOfShapeListOfShape& theSolidsIF)
+ const TopTools_DataMapOfShapeListOfShape& theSolidsIF,
+ const Message_ProgressRange& theRange)
{
Handle(NCollection_BaseAllocator) anAlloc = new NCollection_IncAllocator;
+ Message_ProgressScope aPSOuter(theRange, NULL, 10);
+
// Fill the vector of shape box with faces and its bounding boxes
BOPAlgo_VectorOfShapeBox aVSB(256, anAlloc);
TopTools_ListIteratorOfListOfShape aItLF(theFaces);
for (; aItLF.More(); aItLF.Next())
{
+ if (!aPSOuter.More())
+ {
+ return;
+ }
+
const TopoDS_Shape& aF = aItLF.Value();
// Append face to the vector of shape box
BOPAlgo_ShapeBox& aSB = aVSB.Appended();
aFIP.SetShapeBoxVector(aVSB);
}
+ // Close preparation task
+ aPSOuter.Next().Close();
+ // Set progress range for each task to be run in parallel
+ Standard_Integer aNbS = aVFIP.Length();
+ Message_ProgressScope aPSParallel(aPSOuter.Next(9), "Classification of faces relatively solids", aNbS);
+ for (Standard_Integer iFS = 0; iFS < aNbS; ++iFS)
+ {
+ aVFIP.ChangeValue(iFS).SetProgressRange(aPSParallel.Next());
+ }
// Perform classification
//================================================================
BOPTools_Parallel::Perform (theRunParallel, aVFIP, theContext);
//================================================================
-
// Analyze the results and fill the resulting map
-
- Standard_Integer aNbS = aVFIP.Length();
for (Standard_Integer i = 0; i < aNbS; ++i)
{
BOPAlgo_FillIn3DParts& aFIP = aVFIP(i);
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <Standard_Integer.hxx>
+#include <Message_ProgressRange.hxx>
class BOPDS_PaveBlock;
class BOPDS_CommonBlock;
Handle(IntTools_Context)& theContext,
TopTools_IndexedDataMapOfShapeListOfShape& theInParts,
const TopTools_DataMapOfShapeBox& theShapeBoxMap = TopTools_DataMapOfShapeBox(),
- const TopTools_DataMapOfShapeListOfShape& theSolidsIF = TopTools_DataMapOfShapeListOfShape());
+ const TopTools_DataMapOfShapeListOfShape& theSolidsIF = TopTools_DataMapOfShapeListOfShape(),
+ const Message_ProgressRange& theRange = Message_ProgressRange());
//! Classifies the given parts relatively the given solids and
//! fills the solids with the parts classified as INTERNAL.
//function : Perform
//purpose :
//=======================================================================
-void BOPAlgo_WireSplitter::Perform(const Message_ProgressRange& /*theRange*/)
+void BOPAlgo_WireSplitter::Perform(const Message_ProgressRange& theRange)
{
GetReport()->Clear();
+ Message_ProgressScope aPS(theRange, "Building wires", 1);
//
CheckData();
if (HasErrors()) {
//
BOPTools_AlgoTools::MakeConnexityBlocks
(myWES->StartElements(), TopAbs_VERTEX, TopAbs_EDGE, myLCB);
+ if (UserBreak (aPS))
+ {
+ return;
+ }
- MakeWires();
+ MakeWires(aPS.Next());
}
/////////////////////////////////////////////////////////////////////////
const Handle(IntTools_Context)& Context()const {
return myContext;
}
+ //
+ void SetProgressRange(const Message_ProgressRange& theRange) {
+ myRange = theRange;
+ }
void Perform() {
+ Message_ProgressScope aPS (myRange, NULL, 1);
+ if (!aPS.More())
+ {
+ return;
+ }
BOPAlgo_WireSplitter::SplitBlock(myFace, myCB, myContext);
}
TopoDS_Face myFace;
BOPTools_ConnexityBlock myCB;
Handle(IntTools_Context) myContext;
+ Message_ProgressRange myRange;
};
typedef NCollection_Vector<BOPAlgo_WS_ConnexityBlock> BOPAlgo_VectorOfConnexityBlock;
//function : MakeWires
//purpose :
//=======================================================================
-void BOPAlgo_WireSplitter::MakeWires()
+void BOPAlgo_WireSplitter::MakeWires(const Message_ProgressRange& theRange)
{
Standard_Boolean bIsRegular;
Standard_Integer aNbVCB, k;
TopTools_ListIteratorOfListOfShape aIt;
BOPAlgo_VectorOfConnexityBlock aVCB;
//
+ Message_ProgressScope aPSOuter(theRange, NULL, 1);
+ //
const TopoDS_Face& aF=myWES->Face();
//
aItCB.Initialize(myLCB);
for (; aItCB.More(); aItCB.Next()) {
+ if (UserBreak (aPSOuter))
+ {
+ return;
+ }
+
BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue();
bIsRegular=aCB.IsRegular();
if (bIsRegular) {
aWSCB.SetConnexityBlock(aCB);
}
}
+ aNbVCB=aVCB.Length();
+ Message_ProgressScope aPSParallel(aPSOuter.Next(), NULL, aNbVCB);
+ for (Standard_Integer iW = 0; iW < aNbVCB; ++iW)
+ {
+ aVCB.ChangeValue(iW).SetProgressRange(aPSParallel.Next());
+ }
//===================================================
BOPTools_Parallel::Perform (myRunParallel, aVCB, myContext);
//===================================================
- aNbVCB=aVCB.Length();
for (k=0; k<aNbVCB; ++k) {
const BOPAlgo_WS_ConnexityBlock& aCB=aVCB(k);
const TopTools_ListOfShape& aLW=aCB.ConnexityBlock().Loops();
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
- Standard_EXPORT void MakeWires();
+ Standard_EXPORT void MakeWires(const Message_ProgressRange& theRange);
BOPAlgo_PWireEdgeSet myWES;
BOPTools_ListOfConnexityBlock myLCB;
const char** a,
const BOPAlgo_Operation aOp)
{
- Standard_Boolean bRunParallel, bNonDestructive;
TopoDS_Shape aS1, aS2;
TopTools_ListOfShape aLC;
- Standard_Real aTol;
//
if (n != 4) {
di << " use bx r s1 s2\n";
}
aLC.Append(aS1);
aLC.Append(aS2);
- //
- aTol=BOPTest_Objects::FuzzyValue();
- bRunParallel = BOPTest_Objects::RunParallel();
- bNonDestructive = BOPTest_Objects::NonDestructive();
- BOPAlgo_GlueEnum aGlue = BOPTest_Objects::Glue();
//
Handle(NCollection_BaseAllocator)aAL=
NCollection_BaseAllocator::CommonBaseAllocator();
//
- //---------------------------------------------------------------
- BOPAlgo_PaveFiller aPF(aAL);
- //
- aPF.SetArguments(aLC);
- aPF.SetFuzzyValue(aTol);
- aPF.SetRunParallel(bRunParallel);
- aPF.SetNonDestructive(bNonDestructive);
- aPF.SetGlue(aGlue);
- aPF.SetUseOBB(BOPTest_Objects::UseOBB());
- //
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
- Message_ProgressScope aPS(aProgress->Start(), "BOP", 10);
- aPF.Perform(aPS.Next(9));
- BOPTest::ReportAlerts(aPF.GetReport());
- if (aPF.HasErrors()) {
- return 0;
- }
- //
- //---------------------------------------------------------------
BOPAlgo_BOP aBOP(aAL);
- //
aBOP.AddArgument(aS1);
aBOP.AddTool(aS2);
aBOP.SetOperation(aOp);
- aBOP.SetRunParallel(bRunParallel);
+ // set options
+ aBOP.SetGlue(BOPTest_Objects::Glue());
+ aBOP.SetFuzzyValue(BOPTest_Objects::FuzzyValue());
+ aBOP.SetNonDestructive(BOPTest_Objects::NonDestructive());
+ aBOP.SetRunParallel(BOPTest_Objects::RunParallel());
+ aBOP.SetUseOBB(BOPTest_Objects::UseOBB());
aBOP.SetCheckInverted(BOPTest_Objects::CheckInverted());
aBOP.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
- aBOP.PerformWithFiller(aPF, aPS.Next(1));
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
+ aBOP.Perform(aProgress->Start());
BOPTest::ReportAlerts(aBOP.GetReport());
// Store the history of Boolean operation into the session
if (BRepTest_Objects::IsHistoryNeeded())
- BRepTest_Objects::SetHistory(aPF.Arguments(), aBOP);
+ BRepTest_Objects::SetHistory(aBOP.PDS()->Arguments(), aBOP);
if (aBOP.HasErrors()) {
return 0;
aBuilder.SetCheckInverted(BOPTest_Objects::CheckInverted());
aBuilder.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
//
OSD_Timer aTimer;
aTimer.Start();
//
- aBuilder.PerformWithFiller(aPF);
+ aBuilder.PerformWithFiller(aPF, aProgress->Start());
BOPTest::ReportAlerts(aBuilder.GetReport());
// Set history of GF operation into the session
pBuilder->SetCheckInverted(BOPTest_Objects::CheckInverted());
pBuilder->SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
+ //
OSD_Timer aTimer;
aTimer.Start();
//
- pBuilder->PerformWithFiller(aPF);
+ pBuilder->PerformWithFiller(aPF, aProgress->Start());
BOPTest::ReportAlerts(pBuilder->GetReport());
// Set history of Boolean operation into the session
}
}
- Message_ProgressScope aPS(theRange, NULL, myIsIntersectionNeeded ? 100 : 30);
+ TCollection_AsciiString aPSName;
+ switch (myOperation)
+ {
+ case BOPAlgo_COMMON:
+ aPSName = "Performing COMMON operation";
+ break;
+ case BOPAlgo_FUSE:
+ aPSName = "Performing FUSE operation";
+ break;
+ case BOPAlgo_CUT:
+ case BOPAlgo_CUT21:
+ aPSName = "Performing CUT operation";
+ break;
+ case BOPAlgo_SECTION:
+ aPSName = "Performing SECTION operation";
+ break;
+ default:
+ return;
+ }
+
+ Message_ProgressScope aPS(theRange, aPSName, myIsIntersectionNeeded ? 100 : 30);
// If necessary perform intersection of the argument shapes
if (myIsIntersectionNeeded)
{
myBuilder->SetCheckInverted(myCheckInverted);
myBuilder->SetToFillHistory(myFillHistory);
// Perform building of the result with pre-calculated intersections
- Message_ProgressScope aPS(theRange, NULL, 1);
- myBuilder->PerformWithFiller(*myDSFiller, aPS.Next());
+ myBuilder->PerformWithFiller(*myDSFiller, theRange);
// Merge the warnings of the Building part
GetReport()->Merge(myBuilder->GetReport());
// Check for the errors
anAnalyzer.SetRunParallel(myRunParallel);
anAnalyzer.SetFuzzyValue(myFuzzyValue);
// Perform the check
- Message_ProgressScope aPS(theRange, "Performing CHECK operation", 1);
+ Message_ProgressScope aPS(theRange, "Checking shapes", 1);
anAnalyzer.Perform(aPS.Next());
if (UserBreak(aPS))
{
//purpose :
//=======================================================================
BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1,
- const TopoDS_Shape& S2)
+ const TopoDS_Shape& S2,
+ const Message_ProgressRange& theRange)
: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_COMMON)
{
- Build();
+ Build(theRange);
}
//=======================================================================
//function : BRepAlgoAPI_Common
//=======================================================================
BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1,
const TopoDS_Shape& S2,
- const BOPAlgo_PaveFiller& aDSF)
+ const BOPAlgo_PaveFiller& aDSF,
+ const Message_ProgressRange& theRange)
: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOPAlgo_COMMON)
{
- Build();
+ Build(theRange);
}
//! <S2> -tool
//! <anOperation> - the type of the operation
//! Obsolete
- Standard_EXPORT BRepAlgoAPI_Common(const TopoDS_Shape& S1, const TopoDS_Shape& S2);
+ Standard_EXPORT BRepAlgoAPI_Common(const TopoDS_Shape& S1,
+ const TopoDS_Shape& S2,
+ const Message_ProgressRange& theRange = Message_ProgressRange());
//! Constructor with two shapes
//! <S1> -argument
//! <anOperation> - the type of the operation
//! <PF> - PaveFiller object that is carried out
//! Obsolete
- Standard_EXPORT BRepAlgoAPI_Common(const TopoDS_Shape& S1, const TopoDS_Shape& S2, const BOPAlgo_PaveFiller& PF);
+ Standard_EXPORT BRepAlgoAPI_Common(const TopoDS_Shape& S1,
+ const TopoDS_Shape& S2,
+ const BOPAlgo_PaveFiller& PF,
+ const Message_ProgressRange& theRange = Message_ProgressRange());
:
BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_CUT)
{
- Message_ProgressScope aPS(theRange, "Performing CUT operation", 1);
- Build(aPS.Next());
+ Build(theRange);
}
//=======================================================================
//function : BRepAlgoAPI_Cut
BRepAlgoAPI_BooleanOperation(S1, S2, aDSF,
(bFWD) ? BOPAlgo_CUT : BOPAlgo_CUT21)
{
- Message_ProgressScope aPS(theRange, "Performing CUT operation", 1);
- Build(aPS.Next());
+ Build(theRange);
}
:
BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_FUSE)
{
- Message_ProgressScope aPS(theRange, "Performing FUSE operation", 1);
- Build(aPS.Next());
+ Build(theRange);
}
//=======================================================================
//function : BRepAlgoAPI_Fuse
:
BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOPAlgo_FUSE)
{
- Message_ProgressScope aPS(theRange, "Performing FUSE operation", 1);
- Build(aPS.Next());
+ Build(theRange);
}
//=======================================================================
void BRepAlgoAPI_Section::Build(const Message_ProgressRange& theRange)
{
- Message_ProgressScope aPS(theRange, "Performing SECTION operation", 1);
- BRepAlgoAPI_BooleanOperation::Build(aPS.Next());
+ BRepAlgoAPI_BooleanOperation::Build(theRange);
}
//=======================================================================
//function : HasAncestorFaceOn1
}
//=======================================================================
-//function : AnalyzeProgress
+//function : PerformResult
//purpose :
//=======================================================================
-NCollection_Array1<Standard_Real> BRepFeat_Builder::AnalyzeProgress()
+ void BRepFeat_Builder::PerformResult(const Message_ProgressRange& theRange)
{
- Standard_Integer aSize = 3;
- NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
- for (Standard_Integer i = 0; i < aSize; i++)
+ myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
+ if (myShapes.IsEmpty())
{
- aSteps(i) = 0;
+ BuildShape(theRange);
+ return;
}
-
- Standard_Real aPart = 100.;
- Standard_Integer aNbSh = 0;
- Standard_Integer aNbS = 0;
- Standard_Integer aNbC = 0;
- for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); i++)
+
+ Standard_Real aWhole = 100.;
+ Message_ProgressScope aPS(theRange, "BRepFeat_Builder", aWhole);
+ Standard_Real aBSPart = 15;
+ aWhole -= aBSPart;
+
+ // Compute PI steps
+ const Standard_Integer aSize = 4;
+ NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
{
- const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
- switch (aSI.ShapeType())
+ for (Standard_Integer i = 0; i < aSize; ++i)
+ aSteps(i) = 0.;
+
+ NbShapes aNbShapes = getNbShapes();
+ Standard_Real aTreatFaces = 5 * aNbShapes.NbFaces();
+ Standard_Real aTreatShells = aNbShapes.NbShells();
+ Standard_Real aTreatSolids = 20 * aNbShapes.NbSolids();
+ Standard_Real aTreatCompounds = aNbShapes.NbCompounds();
+
+ Standard_Real aSum = aTreatFaces + aTreatShells + aTreatSolids + aTreatCompounds;
+ if (aSum > 0)
{
- case TopAbs_SHELL:
- aNbSh++;
- break;
- case TopAbs_SOLID:
- aNbS++;
- break;
- case TopAbs_COMPOUND:
- aNbC++;
- break;
- default:
- break;
+ aSteps(0) = aTreatFaces * aWhole / aSum;
+ aSteps(1) = aTreatShells * aWhole / aSum;
+ aSteps(2) = aTreatSolids * aWhole / aSum;
+ aSteps(3) = aTreatCompounds * aWhole / aSum;
}
}
-
- aNbSh = 10 * aNbSh;
- aNbS = 10 * aNbS;
- aNbC = 5 * aNbC;
- Standard_Real aSum = aNbSh + aNbS + aNbC;
- if (aSum == 0)
- {
- return aSteps;
+ //
+ Prepare();
+ //
+ RebuildFaces();
+ aPS.Next(aSteps(0));
+ //
+ FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps(1)));
+ if (HasErrors()) {
+ return;
}
-
- aSteps(0) = aPart * aNbSh / aSum;
- aSteps(1) = aPart * aNbS / aSum;
- aSteps(2) = aPart * aNbC / aSum;
-
- return aSteps;
-}
-
-//=======================================================================
-//function : PerformResult
-//purpose :
-//=======================================================================
- void BRepFeat_Builder::PerformResult(const Message_ProgressRange& theRange)
-{
- myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
//
- if (!myShapes.IsEmpty()) {
- Message_ProgressScope aPS(theRange, "BRepFeat_Builder", 100);
- //
- NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
- Prepare();
- //
- RebuildFaces();
- //
- FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps(0)));
- if (HasErrors()) {
- return;
- }
- //
- FillImagesSolids(aPS.Next(aSteps(1)));
- if (HasErrors()) {
- return;
- }
- //
- CheckSolidImages();
- //
- BuildResult(TopAbs_SOLID);
- if (HasErrors()) {
- return;
- }
- //
- FillImagesCompounds(aPS.Next(aSteps(2)));
- if (HasErrors()) {
- return;
- }
- //
- BuildResult(TopAbs_COMPOUND);
- if (HasErrors()) {
- return;
- }
+ FillImagesSolids(aPS.Next(aSteps(2)));
+ if (HasErrors()) {
+ return;
+ }
+ //
+ CheckSolidImages();
+ //
+ BuildResult(TopAbs_SOLID);
+ if (HasErrors()) {
+ return;
+ }
+ //
+ FillImagesCompounds(aPS.Next(aSteps(3)));
+ if (HasErrors()) {
+ return;
+ }
+ //
+ BuildResult(TopAbs_COMPOUND);
+ if (HasErrors()) {
+ return;
}
//
- BuildShape();
+ BuildShape(aPS.Next(aBSPart));
}
//=======================================================================
//function : FillIn3DParts
//purpose :
//=======================================================================
- void BRepFeat_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids)
+ void BRepFeat_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids,
+ const Message_ProgressRange& theRange)
{
GetReport()->Clear();
- BOPAlgo_Builder::FillIn3DParts(theDraftSolids);
+ BOPAlgo_Builder::FillIn3DParts(theDraftSolids, theRange);
// Clear the IN parts of the solids from the removed faces
TopTools_DataMapOfShapeListOfShape::Iterator itM(myInParts);
protected:
- //! AnalyzeProgress
- Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-
//! Prepares builder of local operation.
Standard_EXPORT virtual void Prepare() Standard_OVERRIDE;
//! Function is redefined to avoid the usage of removed faces.
- Standard_EXPORT virtual void FillIn3DParts (TopTools_DataMapOfShapeShape& theDraftSolids) Standard_OVERRIDE;
+ Standard_EXPORT virtual void FillIn3DParts (TopTools_DataMapOfShapeShape& theDraftSolids,
+ const Message_ProgressRange& theRange) Standard_OVERRIDE;
//! Avoid the check for open solids and always use the splits
//! of solids for building the result shape.