|
||||
File indexing completed on 2025-01-18 10:03:03
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 <TColStd_Array1OfReal.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.<br> 0032 class BOPAlgo_Algo : public BOPAlgo_Options 0033 { 0034 public: 0035 0036 DEFINE_STANDARD_ALLOC 0037 0038 //! The main method to implement the operation 0039 //! Providing the range allows to enable Progress indicator User break functionalities. 0040 Standard_EXPORT virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange()) = 0; 0041 0042 protected: 0043 0044 //! Default constructor 0045 Standard_EXPORT BOPAlgo_Algo(); 0046 Standard_EXPORT virtual ~BOPAlgo_Algo(); 0047 0048 Standard_EXPORT BOPAlgo_Algo(const Handle(NCollection_BaseAllocator)& theAllocator); 0049 0050 //! Checks input data 0051 Standard_EXPORT virtual void CheckData(); 0052 0053 //! Checks the obtained result 0054 Standard_EXPORT virtual void CheckResult(); 0055 0056 protected: //! @name Analyzing operations to fill progress indicator 0057 0058 //! Analyze progress steps of the whole operation. 0059 //! @param theWhole - sum of progress of all operations. 0060 //! @oaram theSteps - steps of the operations supported by PI 0061 //! 0062 //! To use this method, one has to override the following methods: 0063 //! * fillPIConstants - method filling values for constant operations. 0064 //! * fillPISteps - method filling steps for the rest of operations. 0065 Standard_EXPORT void analyzeProgress(const Standard_Real theWhole, 0066 BOPAlgo_PISteps& theSteps) const; 0067 0068 //! Fills the values for constant operations - the operations having constant relative running time. 0069 //! @param theWhole - sum of all operations supported by PI, i.e. the value to normalize the steps to, if necessary. 0070 //! @param theSteps - steps of the operations supported by PI 0071 Standard_EXPORT virtual void fillPIConstants(const Standard_Real theWhole, 0072 BOPAlgo_PISteps& theSteps) const; 0073 0074 //! Fills the values for the operations dependent on the inputs. 0075 //! Filled values may not be normalized to represent percentage of total running time. 0076 //! The values should just correlate to each other. 0077 //! E.g. if progress depends on the number of input shapes, the values may look like this: 0078 //! step1 = number_of_input_vertices; 0079 //! step2 = 2 * number_of_input_edges; 0080 //! step3 = 10 * number_of_input_faces. 0081 //! Normalization of these values will be done automatically in analyzeProgress() method. 0082 Standard_EXPORT virtual void fillPISteps(BOPAlgo_PISteps& theSteps) const; 0083 }; 0084 0085 //! Additional root class to provide interface to be launched from parallel vector. 0086 //! It already has the range as a field, and has to be used with caution to create 0087 //! scope from the range only once. 0088 class BOPAlgo_ParallelAlgo : public BOPAlgo_Algo 0089 { 0090 public: 0091 DEFINE_STANDARD_ALLOC 0092 0093 //! The main method to implement the operation 0094 Standard_EXPORT virtual void Perform() = 0; 0095 0096 public: 0097 //! Sets the range for a single run 0098 void SetProgressRange(const Message_ProgressRange& theRange) 0099 { 0100 myProgressRange = theRange; 0101 } 0102 0103 private: 0104 //! Disable the range enabled method 0105 virtual void Perform(const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) {}; 0106 0107 protected: 0108 Message_ProgressRange myProgressRange; 0109 }; 0110 0111 //! Class for representing the relative contribution of each step of 0112 //! the operation to the whole progress 0113 class BOPAlgo_PISteps 0114 { 0115 public: 0116 //! Constructor 0117 BOPAlgo_PISteps(const Standard_Integer theNbOp) 0118 : mySteps(0, theNbOp - 1) 0119 { 0120 mySteps.Init(0); 0121 } 0122 0123 //! Returns the steps 0124 const TColStd_Array1OfReal& Steps() const { return mySteps; } 0125 //! Returns modifiable steps 0126 TColStd_Array1OfReal& ChangeSteps() { return mySteps; } 0127 0128 //! Assign the value theStep to theOperation 0129 void SetStep(const Standard_Integer theOperation, const Standard_Real theStep) 0130 { 0131 if (theOperation >= mySteps.Lower() && theOperation <= mySteps.Upper()) 0132 { 0133 mySteps(theOperation) = theStep; 0134 } 0135 } 0136 0137 //! Returns the step assigned to the operation 0138 Standard_Real GetStep(const Standard_Integer theOperation) 0139 { 0140 if (theOperation < mySteps.Lower() || theOperation > mySteps.Upper()) 0141 { 0142 return 0.; 0143 } 0144 return mySteps(theOperation); 0145 } 0146 0147 protected: 0148 TColStd_Array1OfReal mySteps; 0149 }; 0150 0151 #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 |