0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / BOPAlgo / BOPAlgo_Options.hxx
1 // Created by: Eugeny MALTCHIKOV
2 // Copyright (c) 2017 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef _BOPAlgo_Options_HeaderFile
16 #define _BOPAlgo_Options_HeaderFile
17
18 #include <Message_Report.hxx>
19 #include <Standard_OStream.hxx>
20
21 #include <NCollection_BaseAllocator.hxx>
22
23 class Message_ProgressIndicator;
24
25 //! The class provides the following options for the algorithms in Boolean Component:
26 //! - *Memory allocation tool* - tool for memory allocations;
27 //! - *Error and warning reporting* - allows recording warnings and errors occurred 
28 //!                              during the operation.
29 //!                              Error means that the algorithm has failed.
30 //! - *Parallel processing mode* - provides the possibility to perform operation in parallel mode;
31 //! - *Fuzzy tolerance* - additional tolerance for the operation to detect
32 //!                       touching or coinciding cases;
33 //! - *Progress indicator* - provides interface to track the progress of
34 //!                          operation and stop the operation by user's break.
35 //! - *Using the Oriented Bounding Boxes* - Allows using the Oriented Bounding Boxes of the shapes
36 //!                          for filtering the intersections.
37 //!
38 class BOPAlgo_Options
39 {
40 public:
41
42   DEFINE_STANDARD_ALLOC
43
44   //! Empty constructor
45   Standard_EXPORT BOPAlgo_Options();
46
47   //! Constructor with allocator
48   Standard_EXPORT BOPAlgo_Options(const Handle(NCollection_BaseAllocator)& theAllocator);
49
50   //! Destructor
51   Standard_EXPORT virtual ~BOPAlgo_Options();
52
53   //! Returns allocator
54   const Handle(NCollection_BaseAllocator)& Allocator() const
55   {
56     return myAllocator;
57   }
58
59   //! Clears all warnings and errors, and any data cached by the algorithm.
60   //! User defined options are not cleared.
61   virtual void Clear()
62   {
63     myReport->Clear();
64   }
65
66 public:
67   //!@name Error reporting mechanism
68
69   //! Adds the alert as error (fail)
70   void AddError (const Handle(Message_Alert)& theAlert)
71   {
72     myReport->AddAlert (Message_Fail, theAlert);
73   }
74
75   //! Adds the alert as warning
76   void AddWarning (const Handle(Message_Alert)& theAlert)
77   {
78     myReport->AddAlert (Message_Warning, theAlert);
79   }
80
81   //! Returns true if algorithm has failed
82   Standard_Boolean HasErrors() const
83   {
84     return ! myReport->GetAlerts(Message_Fail).IsEmpty();
85   }
86
87   //! Returns true if algorithm has generated error of specified type
88   Standard_Boolean HasError (const Handle(Standard_Type)& theType) const
89   {
90     return myReport->HasAlert(theType, Message_Fail);
91   }
92
93   //! Returns true if algorithm has generated some warning alerts
94   Standard_Boolean HasWarnings() const
95   {
96     return ! myReport->GetAlerts(Message_Warning).IsEmpty();
97   }
98
99   //! Returns true if algorithm has generated warning of specified type
100   Standard_Boolean HasWarning (const Handle(Standard_Type)& theType) const
101   {
102     return myReport->HasAlert(theType, Message_Warning);
103   }
104
105   //! Returns report collecting all errors and warnings
106   const Handle(Message_Report)& GetReport () const { return myReport; }
107
108   //! Dumps the error status into the given stream
109   Standard_EXPORT void DumpErrors(Standard_OStream& theOS) const;
110
111   //! Dumps the warning statuses into the given stream
112   Standard_EXPORT void DumpWarnings(Standard_OStream& theOS) const;
113
114   //! Clears the warnings of the algorithm
115   void ClearWarnings()
116   {
117     myReport->Clear (Message_Warning);
118   }
119
120 public:
121   //!@name Parallel processing mode
122
123   //! Gets the global parallel mode
124   Standard_EXPORT static Standard_Boolean GetParallelMode();
125
126   //! Sets the global parallel mode
127   Standard_EXPORT static void SetParallelMode(const Standard_Boolean theNewMode);
128
129   //! Set the flag of parallel processing
130   //! if <theFlag> is true  the parallel processing is switched on
131   //! if <theFlag> is false the parallel processing is switched off
132   void SetRunParallel(const Standard_Boolean theFlag)
133   {
134     myRunParallel = theFlag;
135   }
136
137   //! Returns the flag of parallel processing
138   Standard_Boolean RunParallel() const
139   {
140     return myRunParallel;
141   }
142
143 public:
144   //!@name Fuzzy tolerance
145
146   //! Sets the additional tolerance
147   Standard_EXPORT void SetFuzzyValue(const Standard_Real theFuzz);
148
149   //! Returns the additional tolerance
150   Standard_Real FuzzyValue() const
151   {
152     return myFuzzyValue;
153   }
154
155 public:
156   //!@name Progress indicator
157
158   //! Set the Progress Indicator object.
159   Standard_EXPORT void SetProgressIndicator(const Handle(Message_ProgressIndicator)& theObj);
160
161 public:
162   //!@name Usage of Oriented Bounding boxes
163
164   //! Enables/Disables the usage of OBB
165   void SetUseOBB(const Standard_Boolean theUseOBB)
166   {
167     myUseOBB = theUseOBB;
168   }
169
170   //! Returns the flag defining usage of OBB
171   Standard_Boolean UseOBB() const
172   {
173     return myUseOBB;
174   }
175
176 protected:
177
178   //! Breaks the execution if the break signal
179   //! is indicated by myProgressIndicator.
180   Standard_EXPORT void UserBreak() const;
181
182 protected:
183
184   Handle(NCollection_BaseAllocator) myAllocator;
185   Handle(Message_Report) myReport;
186   Standard_Boolean myRunParallel;
187   Standard_Real myFuzzyValue;
188   Handle(Message_ProgressIndicator) myProgressIndicator;
189   Standard_Boolean myUseOBB;
190
191 };
192
193 #endif // _BOPAlgo_Options_HeaderFile