Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-19 08:28:16

0001 // Created by: Eugeny MALTCHIKOV
0002 // Copyright (c) 2017 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _BOPAlgo_Options_HeaderFile
0016 #define _BOPAlgo_Options_HeaderFile
0017 
0018 #include <Message_Report.hxx>
0019 #include <Standard_OStream.hxx>
0020 
0021 #include <NCollection_BaseAllocator.hxx>
0022 
0023 class Message_ProgressScope;
0024 
0025 //! The class provides the following options for the algorithms in Boolean Component:
0026 //! - *Memory allocation tool* - tool for memory allocations;
0027 //! - *Error and warning reporting* - allows recording warnings and errors occurred
0028 //!                              during the operation.
0029 //!                              Error means that the algorithm has failed.
0030 //! - *Parallel processing mode* - provides the possibility to perform operation in parallel mode;
0031 //! - *Fuzzy tolerance* - additional tolerance for the operation to detect
0032 //!                       touching or coinciding cases;
0033 //! - *Using the Oriented Bounding Boxes* - Allows using the Oriented Bounding Boxes of the shapes
0034 //!                          for filtering the intersections.
0035 //!
0036 class BOPAlgo_Options
0037 {
0038 public:
0039   DEFINE_STANDARD_ALLOC
0040 
0041   //! Empty constructor
0042   Standard_EXPORT BOPAlgo_Options();
0043 
0044   //! Constructor with allocator
0045   Standard_EXPORT BOPAlgo_Options(const Handle(NCollection_BaseAllocator)& theAllocator);
0046 
0047   //! Destructor
0048   Standard_EXPORT virtual ~BOPAlgo_Options();
0049 
0050   //! Returns allocator
0051   const Handle(NCollection_BaseAllocator)& Allocator() const { return myAllocator; }
0052 
0053   //! Clears all warnings and errors, and any data cached by the algorithm.
0054   //! User defined options are not cleared.
0055   virtual void Clear() { myReport->Clear(); }
0056 
0057 public:
0058   //!@name Error reporting mechanism
0059 
0060   //! Adds the alert as error (fail)
0061   void AddError(const Handle(Message_Alert)& theAlert)
0062   {
0063     myReport->AddAlert(Message_Fail, theAlert);
0064   }
0065 
0066   //! Adds the alert as warning
0067   void AddWarning(const Handle(Message_Alert)& theAlert)
0068   {
0069     myReport->AddAlert(Message_Warning, theAlert);
0070   }
0071 
0072   //! Returns true if algorithm has failed
0073   Standard_Boolean HasErrors() const { return !myReport->GetAlerts(Message_Fail).IsEmpty(); }
0074 
0075   //! Returns true if algorithm has generated error of specified type
0076   Standard_Boolean HasError(const Handle(Standard_Type)& theType) const
0077   {
0078     return myReport->HasAlert(theType, Message_Fail);
0079   }
0080 
0081   //! Returns true if algorithm has generated some warning alerts
0082   Standard_Boolean HasWarnings() const { return !myReport->GetAlerts(Message_Warning).IsEmpty(); }
0083 
0084   //! Returns true if algorithm has generated warning of specified type
0085   Standard_Boolean HasWarning(const Handle(Standard_Type)& theType) const
0086   {
0087     return myReport->HasAlert(theType, Message_Warning);
0088   }
0089 
0090   //! Returns report collecting all errors and warnings
0091   const Handle(Message_Report)& GetReport() const { return myReport; }
0092 
0093   //! Dumps the error status into the given stream
0094   Standard_EXPORT void DumpErrors(Standard_OStream& theOS) const;
0095 
0096   //! Dumps the warning statuses into the given stream
0097   Standard_EXPORT void DumpWarnings(Standard_OStream& theOS) const;
0098 
0099   //! Clears the warnings of the algorithm
0100   void ClearWarnings() { myReport->Clear(Message_Warning); }
0101 
0102 public:
0103   //!@name Parallel processing mode
0104 
0105   //! Gets the global parallel mode
0106   Standard_EXPORT static Standard_Boolean GetParallelMode();
0107 
0108   //! Sets the global parallel mode
0109   Standard_EXPORT static void SetParallelMode(const Standard_Boolean theNewMode);
0110 
0111   //! Set the flag of parallel processing
0112   //! if <theFlag> is true  the parallel processing is switched on
0113   //! if <theFlag> is false the parallel processing is switched off
0114   void SetRunParallel(const Standard_Boolean theFlag) { myRunParallel = theFlag; }
0115 
0116   //! Returns the flag of parallel processing
0117   Standard_Boolean RunParallel() const { return myRunParallel; }
0118 
0119 public:
0120   //!@name Fuzzy tolerance
0121 
0122   //! Sets the additional tolerance
0123   Standard_EXPORT void SetFuzzyValue(const Standard_Real theFuzz);
0124 
0125   //! Returns the additional tolerance
0126   Standard_Real FuzzyValue() const { return myFuzzyValue; }
0127 
0128 public:
0129   //!@name Usage of Oriented Bounding boxes
0130 
0131   //! Enables/Disables the usage of OBB
0132   void SetUseOBB(const Standard_Boolean theUseOBB) { myUseOBB = theUseOBB; }
0133 
0134   //! Returns the flag defining usage of OBB
0135   Standard_Boolean UseOBB() const { return myUseOBB; }
0136 
0137 protected:
0138   //! Adds error to the report if the break signal was caught. Returns true in this case, false
0139   //! otherwise.
0140   Standard_EXPORT Standard_Boolean UserBreak(const Message_ProgressScope& thePS);
0141 
0142 protected:
0143   Handle(NCollection_BaseAllocator) myAllocator;
0144   Handle(Message_Report)            myReport;
0145   Standard_Boolean                  myRunParallel;
0146   Standard_Real                     myFuzzyValue;
0147   Standard_Boolean                  myUseOBB;
0148 };
0149 
0150 #endif // _BOPAlgo_Options_HeaderFile