Provide suitable way of keeping the progress steps of operations.
#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
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", 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)));
//
// 6 Post-treatment
- PostTreat();
+ PostTreat(aPS.Next(aSteps.GetStep(PIOperation_PostTreat)));
}
//=======================================================================
//function : BuildRC
//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.
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+ // Build the result using splits of arguments.
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;
+ }
+ aPS.Next(5.);
//
// add containers to result
TopoDS_Compound aResult;
}
}
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+
// put non-container shapes in the result
aItLS.Initialize(aLSNonCont);
for (; aItLS.More(); aItLS.Next())
//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;
+ }
//
// Possibly untouched solids - to be added to results as is
TopTools_IndexedMapOfShape aMUSols;
//
MapFacesToBuildSolids(aSx, aMFS);
} // for (; aIt.More(); aIt.Next()) {
+
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
//
// Process possibly untouched solids.
// Really untouched solids will be added into result as is.
}
}
}
+
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
//
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
// Fill the list of faces to build the result solids
}
}
//
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
+ aPS.Next(1.);
+ //
TopoDS_Shape aRC;
BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
if (aSFS.Extent()) {
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
return;
}
//
+ // Check for user break
+ if (UserBreak(aPS))
+ {
+ return;
+ }
// get splits of faces of the Compsolid arguments
TopTools_MapOfShape aMFCs;
aItLS.Initialize(aLSC);
}
}
//
+ // 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);
//!
class BOPAlgo_BOP : public BOPAlgo_ToolsProvider
{
+public:
+ //! Extend list of operations to be supported by the Progress Indicator
+ enum BOPAlgo_PIOperation
+ {
+ PIOperation_BuildShape = BOPAlgo_Builder::PIOperation_Last,
+ PIOperation_Last
+ };
+
public:
DEFINE_STANDARD_ALLOC
//! 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 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();
+ //! 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 :
}
//=======================================================================
-//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;
}
}
//
// 4.History
- PrepareHistory();
+ PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
//
//
// 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();
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;
}
+public: //! @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
//! 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
//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) {
}
//
//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) {
}
//
//function : PrepareHistory
//purpose :
//=======================================================================
-void BOPAlgo_Builder::PrepareHistory()
+void BOPAlgo_Builder::PrepareHistory(const Message_ProgressRange& theRange)
{
if (!HasHistory())
return;
+ Message_ProgressScope aPS(theRange, "Filling history information", 1);
+
// Initializing history tool
myHistory = new BRepTools_History;
//
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());
}
}
//=======================================================================
void BOPAlgo_MakerVolume::Perform(const Message_ProgressRange& theRange)
{
+ Message_ProgressScope aPS(theRange, "MakerVolume", 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 the volume", 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)));
//
// 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++)
- {
- 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;
-
- 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)
+ NbShapes aNbShapes = getNbShapes();
+ if (myIntersect)
{
- return aSteps;
+ 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());
}
-
- 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
class BOPAlgo_MakerVolume : public BOPAlgo_Builder
{
public:
+ //! 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
+ };
- DEFINE_STANDARD_ALLOC
+public:
-
+ DEFINE_STANDARD_ALLOC
//! Empty constructor.
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:
+
+ //! 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, "Init", myArguments.Size());
+ 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 intersections 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);
{}
};
+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;
//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;
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;
};
//
//=======================================================================
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);
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;
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;
};
//
//=======================================================================
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);
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 (k = 0; k < aVFaceFace.Size(); k++)
{
BOPAlgo_FaceFace& aFaceFace = aVFaceFace.ChangeValue(k);
- aFaceFace.SetProgress(aPS.Next());
+ aFaceFace.SetProgressRange(aPS.Next());
}
//======================================================
// Perform intersection
//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 (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, "Processing of degenerated edges", 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)) {
}
//=======================================================================
-//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++)
+ // Fill in the constants:
+ if (myFillHistory)
{
- aSteps(i) = 0;
+ // for FillHistroty, which takes about 10% of the whole operation
+ theSteps.SetStep(PIOperation_FillHistory, 10. * theWhole / 100.);
}
- 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)
- {
- return aSteps;
- }
-
- 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
//! 4. edges that are Common Blocks
class BOPAlgo_Section : public BOPAlgo_Builder
{
+public:
+ //! 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
+ };
+
public:
DEFINE_STANDARD_ALLOC
//! 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:
+
+ //! 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;
};
}
//=======================================================================
-//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);
}
-
- 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;
+ //
+ 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));
}
//=======================================================================
protected:
- //! AnalyzeProgress
- Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-
//! Prepares builder of local operation.
Standard_EXPORT virtual void Prepare() Standard_OVERRIDE;