Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:04

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 
0040   DEFINE_STANDARD_ALLOC
0041 
0042   //! Empty constructor
0043   Standard_EXPORT BOPAlgo_Options();
0044 
0045   //! Constructor with allocator
0046   Standard_EXPORT BOPAlgo_Options(const Handle(NCollection_BaseAllocator)& theAllocator);
0047 
0048   //! Destructor
0049   Standard_EXPORT virtual ~BOPAlgo_Options();
0050 
0051   //! Returns allocator
0052   const Handle(NCollection_BaseAllocator)& Allocator() const
0053   {
0054     return myAllocator;
0055   }
0056 
0057   //! Clears all warnings and errors, and any data cached by the algorithm.
0058   //! User defined options are not cleared.
0059   virtual void Clear()
0060   {
0061     myReport->Clear();
0062   }
0063 
0064 public:
0065   //!@name Error reporting mechanism
0066 
0067   //! Adds the alert as error (fail)
0068   void AddError (const Handle(Message_Alert)& theAlert)
0069   {
0070     myReport->AddAlert (Message_Fail, theAlert);
0071   }
0072 
0073   //! Adds the alert as warning
0074   void AddWarning (const Handle(Message_Alert)& theAlert)
0075   {
0076     myReport->AddAlert (Message_Warning, theAlert);
0077   }
0078 
0079   //! Returns true if algorithm has failed
0080   Standard_Boolean HasErrors() const
0081   {
0082     return ! myReport->GetAlerts(Message_Fail).IsEmpty();
0083   }
0084 
0085   //! Returns true if algorithm has generated error of specified type
0086   Standard_Boolean HasError (const Handle(Standard_Type)& theType) const
0087   {
0088     return myReport->HasAlert(theType, Message_Fail);
0089   }
0090 
0091   //! Returns true if algorithm has generated some warning alerts
0092   Standard_Boolean HasWarnings() const
0093   {
0094     return ! myReport->GetAlerts(Message_Warning).IsEmpty();
0095   }
0096 
0097   //! Returns true if algorithm has generated warning of specified type
0098   Standard_Boolean HasWarning (const Handle(Standard_Type)& theType) const
0099   {
0100     return myReport->HasAlert(theType, Message_Warning);
0101   }
0102 
0103   //! Returns report collecting all errors and warnings
0104   const Handle(Message_Report)& GetReport () const { return myReport; }
0105 
0106   //! Dumps the error status into the given stream
0107   Standard_EXPORT void DumpErrors(Standard_OStream& theOS) const;
0108 
0109   //! Dumps the warning statuses into the given stream
0110   Standard_EXPORT void DumpWarnings(Standard_OStream& theOS) const;
0111 
0112   //! Clears the warnings of the algorithm
0113   void ClearWarnings()
0114   {
0115     myReport->Clear (Message_Warning);
0116   }
0117 
0118 public:
0119   //!@name Parallel processing mode
0120 
0121   //! Gets the global parallel mode
0122   Standard_EXPORT static Standard_Boolean GetParallelMode();
0123 
0124   //! Sets the global parallel mode
0125   Standard_EXPORT static void SetParallelMode(const Standard_Boolean theNewMode);
0126 
0127   //! Set the flag of parallel processing
0128   //! if <theFlag> is true  the parallel processing is switched on
0129   //! if <theFlag> is false the parallel processing is switched off
0130   void SetRunParallel(const Standard_Boolean theFlag)
0131   {
0132     myRunParallel = theFlag;
0133   }
0134 
0135   //! Returns the flag of parallel processing
0136   Standard_Boolean RunParallel() const
0137   {
0138     return myRunParallel;
0139   }
0140 
0141 public:
0142   //!@name Fuzzy tolerance
0143 
0144   //! Sets the additional tolerance
0145   Standard_EXPORT void SetFuzzyValue(const Standard_Real theFuzz);
0146 
0147   //! Returns the additional tolerance
0148   Standard_Real FuzzyValue() const
0149   {
0150     return myFuzzyValue;
0151   }
0152 
0153 public:
0154   //!@name Usage of Oriented Bounding boxes
0155 
0156   //! Enables/Disables the usage of OBB
0157   void SetUseOBB(const Standard_Boolean theUseOBB)
0158   {
0159     myUseOBB = theUseOBB;
0160   }
0161 
0162   //! Returns the flag defining usage of OBB
0163   Standard_Boolean UseOBB() const
0164   {
0165     return myUseOBB;
0166   }
0167 
0168 protected:
0169 
0170   //! Adds error to the report if the break signal was caught. Returns true in this case, false otherwise.
0171   Standard_EXPORT Standard_Boolean UserBreak(const Message_ProgressScope& thePS);
0172 
0173 protected:
0174 
0175   Handle(NCollection_BaseAllocator) myAllocator;
0176   Handle(Message_Report) myReport;
0177   Standard_Boolean myRunParallel;
0178   Standard_Real myFuzzyValue;
0179   Standard_Boolean myUseOBB;
0180 
0181 };
0182 
0183 #endif // _BOPAlgo_Options_HeaderFile