1 // Created by: Eugeny MALTCHIKOV
2 // Copyright (c) 2017 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #include <BOPAlgo_Options.hxx>
17 #include <Message_MsgFile.hxx>
18 #include <Message_ProgressIndicator.hxx>
19 #include <NCollection_BaseAllocator.hxx>
20 #include <Precision.hxx>
21 #include <Standard_NotImplemented.hxx>
22 #include <Standard_ProgramError.hxx>
26 Standard_Boolean myGlobalRunParallel = Standard_False;
28 // Initialize textual messages for errors and warnings defined in BOPAlgo
29 #include "BOPAlgo_BOPAlgo_msg.pxx"
30 bool BOPAlgo_InitMessages = false;
31 void BOPAlgo_LoadMessages ()
33 if (BOPAlgo_InitMessages)
35 BOPAlgo_InitMessages = true;
37 if (! Message_MsgFile::HasMsg ("BOPAlgo_LOAD_CHECKER"))
39 Message_MsgFile::LoadFromString (BOPAlgo_BOPAlgo_msg);
44 //=======================================================================
47 //=======================================================================
48 BOPAlgo_Options::BOPAlgo_Options()
50 myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
51 myReport(new Message_Report),
52 myRunParallel(myGlobalRunParallel),
53 myFuzzyValue(Precision::Confusion()),
54 myUseOBB(Standard_False)
56 BOPAlgo_LoadMessages();
59 //=======================================================================
62 //=======================================================================
63 BOPAlgo_Options::BOPAlgo_Options
64 (const Handle(NCollection_BaseAllocator)& theAllocator)
66 myAllocator(theAllocator),
67 myReport(new Message_Report),
68 myRunParallel(myGlobalRunParallel),
69 myFuzzyValue(Precision::Confusion()),
70 myUseOBB(Standard_False)
72 BOPAlgo_LoadMessages();
75 //=======================================================================
78 //=======================================================================
79 BOPAlgo_Options::~BOPAlgo_Options()
83 //=======================================================================
84 //function : DumpErrors
86 //=======================================================================
87 void BOPAlgo_Options::DumpErrors(Standard_OStream& theOS) const
89 myReport->Dump (theOS, Message_Fail);
92 //=======================================================================
93 //function : DumpWarnings
95 //=======================================================================
96 void BOPAlgo_Options::DumpWarnings(Standard_OStream& theOS) const
98 myReport->Dump (theOS, Message_Warning);
101 //=======================================================================
104 //=======================================================================
105 void BOPAlgo_Options::SetParallelMode(Standard_Boolean theNewMode)
107 myGlobalRunParallel = theNewMode;
110 //=======================================================================
113 //=======================================================================
114 Standard_Boolean BOPAlgo_Options::GetParallelMode()
116 return myGlobalRunParallel;
120 //=======================================================================
121 //function : SetFuzzyValue
123 //=======================================================================
124 void BOPAlgo_Options::SetFuzzyValue(const Standard_Real theFuzz)
126 myFuzzyValue = Max(theFuzz, Precision::Confusion());
130 //=======================================================================
131 //function : SetProgressIndicator
133 //=======================================================================
134 void BOPAlgo_Options::SetProgressIndicator
135 (const Handle(Message_ProgressIndicator)& theObj)
137 if (!theObj.IsNull()) {
138 myProgressIndicator = theObj;
141 //=======================================================================
142 //function : UserBreak
144 //=======================================================================
145 void BOPAlgo_Options::UserBreak() const
147 if (myProgressIndicator.IsNull()) {
150 if (myProgressIndicator->UserBreak()) {
151 throw Standard_NotImplemented("BOPAlgo_Options::UserBreak(), method is not implemented");