|
|
|||
File indexing completed on 2026-09-23 09:16:47
0001 // Created by: Peter KURNEV 0002 // Copyright (c) 2010-2014 OPEN CASCADE SAS 0003 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE 0004 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, 0005 // EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 0006 // 0007 // This file is part of Open CASCADE Technology software library. 0008 // 0009 // This library is free software; you can redistribute it and/or modify it under 0010 // the terms of the GNU Lesser General Public License version 2.1 as published 0011 // by the Free Software Foundation, with special exception defined in the file 0012 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0013 // distribution for complete text of the license and disclaimer of any warranty. 0014 // 0015 // Alternatively, this file may be used under the terms of Open CASCADE 0016 // commercial license or contractual agreement. 0017 0018 #ifndef _BOPAlgo_Algo_HeaderFile 0019 #define _BOPAlgo_Algo_HeaderFile 0020 0021 #include <Standard.hxx> 0022 #include <Standard_DefineAlloc.hxx> 0023 #include <Standard_Handle.hxx> 0024 #include <Message_ProgressRange.hxx> 0025 #include <NCollection_Array1.hxx> 0026 0027 #include <BOPAlgo_Options.hxx> 0028 0029 class BOPAlgo_PISteps; 0030 0031 //! The class provides the root interface for the algorithms in Boolean Component. 0032 class BOPAlgo_Algo : public BOPAlgo_Options 0033 { 0034 public: 0035 DEFINE_STANDARD_ALLOC 0036 0037 //! The main method to implement the operation 0038 //! Providing the range allows to enable Progress indicator User break functionalities. 0039 Standard_EXPORT virtual void Perform( 0040 const Message_ProgressRange& theRange = Message_ProgressRange()) = 0; 0041 0042 protected: 0043 //! Default constructor 0044 Standard_EXPORT BOPAlgo_Algo(); 0045 Standard_EXPORT ~BOPAlgo_Algo() override; 0046 0047 Standard_EXPORT BOPAlgo_Algo(const occ::handle<NCollection_BaseAllocator>& theAllocator); 0048 0049 //! Checks input data 0050 Standard_EXPORT virtual void CheckData(); 0051 0052 //! Checks the obtained result 0053 Standard_EXPORT virtual void CheckResult(); 0054 0055 protected: //! @name Analyzing operations to fill progress indicator 0056 //! Analyze progress steps of the whole operation. 0057 //! @param theWhole - sum of progress of all operations. 0058 //! @param theSteps - steps of the operations supported by PI 0059 //! 0060 //! To use this method, one has to override the following methods: 0061 //! * fillPIConstants - method filling values for constant operations. 0062 //! * fillPISteps - method filling steps for the rest of operations. 0063 Standard_EXPORT void analyzeProgress(const double theWhole, BOPAlgo_PISteps& theSteps) const; 0064 0065 //! Fills the values for constant operations - the operations having constant relative running 0066 //! time. 0067 //! @param theWhole - sum of all operations supported by PI, i.e. the value to normalize the steps 0068 //! to, if necessary. 0069 //! @param theSteps - steps of the operations supported by PI 0070 Standard_EXPORT virtual void fillPIConstants(const double theWhole, 0071 BOPAlgo_PISteps& theSteps) const; 0072 0073 //! Fills the values for the operations dependent on the inputs. 0074 //! Filled values may not be normalized to represent percentage of total running time. 0075 //! The values should just correlate to each other. 0076 //! E.g. if progress depends on the number of input shapes, the values may look like this: 0077 //! step1 = number_of_input_vertices; 0078 //! step2 = 2 * number_of_input_edges; 0079 //! step3 = 10 * number_of_input_faces. 0080 //! Normalization of these values will be done automatically in analyzeProgress() method. 0081 Standard_EXPORT virtual void fillPISteps(BOPAlgo_PISteps& theSteps) const; 0082 }; 0083 0084 //! Additional root class to provide interface to be launched from parallel vector. 0085 //! It already has the range as a field, and has to be used with caution to create 0086 //! scope from the range only once. 0087 class BOPAlgo_ParallelAlgo : public BOPAlgo_Algo 0088 { 0089 public: 0090 DEFINE_STANDARD_ALLOC 0091 0092 //! The main method to implement the operation 0093 Standard_EXPORT virtual void Perform() = 0; 0094 0095 public: 0096 //! Sets the range for a single run 0097 void SetProgressRange(const Message_ProgressRange& theRange) { myProgressRange = theRange; } 0098 0099 private: 0100 //! Disable the range enabled method 0101 void Perform(const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) override {}; 0102 0103 protected: 0104 Message_ProgressRange myProgressRange; 0105 }; 0106 0107 //! Class for representing the relative contribution of each step of 0108 //! the operation to the whole progress 0109 class BOPAlgo_PISteps 0110 { 0111 public: 0112 //! Constructor 0113 BOPAlgo_PISteps(const int theNbOp) 0114 : mySteps(0, theNbOp - 1) 0115 { 0116 mySteps.Init(0); 0117 } 0118 0119 //! Returns the steps 0120 const NCollection_Array1<double>& Steps() const { return mySteps; } 0121 0122 //! Returns modifiable steps 0123 NCollection_Array1<double>& ChangeSteps() { return mySteps; } 0124 0125 //! Assign the value theStep to theOperation 0126 void SetStep(const int theOperation, const double theStep) 0127 { 0128 if (theOperation >= mySteps.Lower() && theOperation <= mySteps.Upper()) 0129 { 0130 mySteps(theOperation) = theStep; 0131 } 0132 } 0133 0134 //! Returns the step assigned to the operation 0135 double GetStep(const int theOperation) 0136 { 0137 if (theOperation < mySteps.Lower() || theOperation > mySteps.Upper()) 0138 { 0139 return 0.; 0140 } 0141 return mySteps(theOperation); 0142 } 0143 0144 protected: 0145 NCollection_Array1<double> mySteps; 0146 }; 0147 0148 #endif // _BOPAlgo_Algo_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|