1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13 
14 
15 #include <Message_Msg.hxx>
16 #include <ShapeBuild_ReShape.hxx>
17 #include <ShapeExtend_BasicMsgRegistrator.hxx>
18 #include <ShapeFix_Root.hxx>
19 #include <Standard_Type.hxx>
20 #include <TopoDS_Shape.hxx>
21 
IMPLEMENT_STANDARD_RTTIEXT(ShapeFix_Root,Standard_Transient)22 IMPLEMENT_STANDARD_RTTIEXT(ShapeFix_Root,Standard_Transient)
23 
24 //=======================================================================
25 //function : ShapeFix_Root
26 //purpose  :
27 //=======================================================================
28 ShapeFix_Root::ShapeFix_Root()
29 {
30   myPrecision = myMinTol = myMaxTol = Precision::Confusion();
31   myMsgReg = new ShapeExtend_BasicMsgRegistrator;
32 }
33 
34 //=======================================================================
35 //function : Set
36 //purpose  :
37 //=======================================================================
38 
Set(const Handle (ShapeFix_Root)& Root)39 void ShapeFix_Root::Set (const Handle(ShapeFix_Root)& Root)
40 {
41   myContext   = Root->myContext;
42   myMsgReg    = Root->myMsgReg;
43   myPrecision = Root->myPrecision;
44   myMinTol    = Root->myMinTol;
45   myMaxTol    = Root->myMaxTol;
46   myShape     = Root->myShape;
47 }
48 
49 //=======================================================================
50 //function : SetContext
51 //purpose  :
52 //=======================================================================
53 
SetContext(const Handle (ShapeBuild_ReShape)& context)54 void ShapeFix_Root::SetContext (const Handle(ShapeBuild_ReShape)& context)
55 {
56   myContext = context;
57 }
58 
59 //=======================================================================
60 //function : SetMsgRegistrator
61 //purpose  :
62 //=======================================================================
63 
SetMsgRegistrator(const Handle (ShapeExtend_BasicMsgRegistrator)& msgreg)64  void ShapeFix_Root::SetMsgRegistrator(const Handle(ShapeExtend_BasicMsgRegistrator)& msgreg)
65 {
66   myMsgReg = msgreg;
67 }
68 
69 //=======================================================================
70 //function : SetPrecision
71 //purpose  :
72 //=======================================================================
73 
SetPrecision(const Standard_Real preci)74 void ShapeFix_Root::SetPrecision (const Standard_Real preci)
75 {
76   myPrecision = preci;
77   if(myMaxTol < myPrecision) myMaxTol = myPrecision;
78   if(myMinTol > myPrecision) myMinTol = myPrecision;
79 }
80 
81 //=======================================================================
82 //function : SetMinTolerance
83 //purpose  :
84 //=======================================================================
85 
SetMinTolerance(const Standard_Real mintol)86 void ShapeFix_Root::SetMinTolerance (const Standard_Real mintol)
87 {
88   myMinTol = mintol;
89 }
90 
91 //=======================================================================
92 //function : SetMaxTolerance
93 //purpose  :
94 //=======================================================================
95 
SetMaxTolerance(const Standard_Real maxtol)96 void ShapeFix_Root::SetMaxTolerance (const Standard_Real maxtol)
97 {
98   myMaxTol = maxtol;
99 }
100 
101 //=======================================================================
102 //function : SendMsg
103 //purpose  :
104 //=======================================================================
105 
SendMsg(const TopoDS_Shape & shape,const Message_Msg & message,const Message_Gravity gravity) const106  void ShapeFix_Root::SendMsg(const TopoDS_Shape& shape,
107 			     const Message_Msg& message,
108 			     const Message_Gravity gravity) const
109 {
110   if ( !myMsgReg.IsNull() )
111     myMsgReg->Send (shape, message, gravity);
112 }
113