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())
55 BOPAlgo_LoadMessages();
58 //=======================================================================
61 //=======================================================================
62 BOPAlgo_Options::BOPAlgo_Options
63 (const Handle(NCollection_BaseAllocator)& theAllocator)
65 myAllocator(theAllocator),
66 myReport(new Message_Report),
67 myRunParallel(myGlobalRunParallel),
68 myFuzzyValue(Precision::Confusion())
70 BOPAlgo_LoadMessages();
73 //=======================================================================
76 //=======================================================================
77 BOPAlgo_Options::~BOPAlgo_Options()
81 //=======================================================================
82 //function : DumpErrors
84 //=======================================================================
85 void BOPAlgo_Options::DumpErrors(Standard_OStream& theOS) const
87 myReport->Dump (theOS, Message_Fail);
90 //=======================================================================
91 //function : DumpWarnings
93 //=======================================================================
94 void BOPAlgo_Options::DumpWarnings(Standard_OStream& theOS) const
96 myReport->Dump (theOS, Message_Warning);
99 //=======================================================================
102 //=======================================================================
103 void BOPAlgo_Options::SetParallelMode(Standard_Boolean theNewMode)
105 myGlobalRunParallel = theNewMode;
108 //=======================================================================
111 //=======================================================================
112 Standard_Boolean BOPAlgo_Options::GetParallelMode()
114 return myGlobalRunParallel;
118 //=======================================================================
119 //function : SetFuzzyValue
121 //=======================================================================
122 void BOPAlgo_Options::SetFuzzyValue(const Standard_Real theFuzz)
124 myFuzzyValue = Max(theFuzz, Precision::Confusion());
128 //=======================================================================
129 //function : SetProgressIndicator
131 //=======================================================================
132 void BOPAlgo_Options::SetProgressIndicator
133 (const Handle(Message_ProgressIndicator)& theObj)
135 if (!theObj.IsNull()) {
136 myProgressIndicator = theObj;
139 //=======================================================================
140 //function : UserBreak
142 //=======================================================================
143 void BOPAlgo_Options::UserBreak() const
145 if (myProgressIndicator.IsNull()) {
148 if (myProgressIndicator->UserBreak()) {
149 throw Standard_NotImplemented("BOPAlgo_Options::UserBreak(), method is not implemented");