1 // Created on: 1994-08-31
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 
18 #include <BRep_Tool.hxx>
19 #include <Draft_EdgeInfo.hxx>
20 #include <Geom2d_Curve.hxx>
21 #include <Geom_Curve.hxx>
22 #include <gp_Pnt.hxx>
23 #include <Standard_DomainError.hxx>
24 #include <TopoDS_Face.hxx>
25 
26 //=======================================================================
27 //function : Draft_EdgeInfo
28 //purpose  :
29 //=======================================================================
Draft_EdgeInfo()30 Draft_EdgeInfo::Draft_EdgeInfo():
31        myNewGeom(Standard_False),myTgt(Standard_False),myTol(0)
32 {}
33 
34 
35 //=======================================================================
36 //function : Draft_EdgeInfo
37 //purpose  :
38 //=======================================================================
39 
Draft_EdgeInfo(const Standard_Boolean HasNewGeometry)40 Draft_EdgeInfo::Draft_EdgeInfo(const Standard_Boolean HasNewGeometry):
41        myNewGeom(HasNewGeometry),myTgt(Standard_False),myTol(0)
42 {}
43 
44 
45 //=======================================================================
46 //function : Add
47 //purpose  :
48 //=======================================================================
49 
Add(const TopoDS_Face & F)50 void Draft_EdgeInfo::Add(const TopoDS_Face& F)
51 {
52   if (myFirstF.IsNull()) {
53     myFirstF = F;
54   }
55   else if (!myFirstF.IsSame(F) && mySeconF.IsNull()) {
56     mySeconF = F;
57   }
58   myTol=Max(myTol, BRep_Tool::Tolerance(F));
59 }
60 
61 //=======================================================================
62 //function : RootFace
63 //purpose  :
64 //=======================================================================
65 
RootFace(const TopoDS_Face & F)66 void Draft_EdgeInfo::RootFace(const TopoDS_Face& F)
67 {
68   myRootFace = F;
69 }
70 
71 
72 
73 //=======================================================================
74 //function : Tangent
75 //purpose  :
76 //=======================================================================
77 
Tangent(const gp_Pnt & P)78 void Draft_EdgeInfo::Tangent(const gp_Pnt& P)
79 {
80   myTgt = Standard_True;
81   myPt  = P;
82 }
83 
84 //=======================================================================
85 //function : IsTangent
86 //purpose  :
87 //=======================================================================
88 
IsTangent(gp_Pnt & P) const89 Standard_Boolean Draft_EdgeInfo::IsTangent(gp_Pnt& P) const
90 {
91   P = myPt;
92   return myTgt;
93 }
94 
95 //=======================================================================
96 //function : NewGeometry
97 //purpose  :
98 //=======================================================================
99 
NewGeometry() const100 Standard_Boolean Draft_EdgeInfo::NewGeometry() const
101 {
102   return myNewGeom;
103 }
104 
105 //=======================================================================
106 //function : SetNewGeometry
107 //purpose  :
108 //=======================================================================
109 
SetNewGeometry(const Standard_Boolean NewGeom)110 void Draft_EdgeInfo::SetNewGeometry( const Standard_Boolean NewGeom )
111 {
112   myNewGeom = NewGeom;
113 }
114 
115 //=======================================================================
116 //function : Geometry
117 //purpose  :
118 //=======================================================================
119 
Handle(Geom_Curve)120 const Handle(Geom_Curve)& Draft_EdgeInfo::Geometry() const
121 {
122   return myGeom;
123 }
124 
125 
126 //=======================================================================
127 //function : FirstFace
128 //purpose  :
129 //=======================================================================
130 
FirstFace() const131 const TopoDS_Face& Draft_EdgeInfo::FirstFace () const
132 {
133   return myFirstF;
134 }
135 
136 
137 //=======================================================================
138 //function : SecondFace
139 //purpose  :
140 //=======================================================================
141 
SecondFace() const142 const TopoDS_Face& Draft_EdgeInfo::SecondFace () const
143 {
144   return mySeconF;
145 }
146 
147 
148 //=======================================================================
149 //function : ChangeGeometry
150 //purpose  :
151 //=======================================================================
152 
Handle(Geom_Curve)153 Handle(Geom_Curve)& Draft_EdgeInfo::ChangeGeometry()
154 {
155   return myGeom;
156 }
157 
158 //=======================================================================
159 //function : Handle(Geom2d_Curve)&
160 //purpose  :
161 //=======================================================================
162 
Handle(Geom2d_Curve)163 const Handle(Geom2d_Curve)& Draft_EdgeInfo::FirstPC() const
164 {
165   return myFirstPC;
166 }
167 
168 
169 //=======================================================================
170 //function : Handle(Geom2d_Curve)&
171 //purpose  :
172 //=======================================================================
173 
Handle(Geom2d_Curve)174 const Handle(Geom2d_Curve)& Draft_EdgeInfo::SecondPC() const
175 {
176   return mySeconPC;
177 }
178 
179 //=======================================================================
180 //function : ChangeFirstPC
181 //purpose  :
182 //=======================================================================
183 
Handle(Geom2d_Curve)184 Handle(Geom2d_Curve)& Draft_EdgeInfo::ChangeFirstPC()
185 {
186   return myFirstPC;
187 }
188 
189 
190 //=======================================================================
191 //function : ChangeSecondPC
192 //purpose  :
193 //=======================================================================
194 
Handle(Geom2d_Curve)195 Handle(Geom2d_Curve)& Draft_EdgeInfo::ChangeSecondPC()
196 {
197   return mySeconPC;
198 }
199 
200 
201 //=======================================================================
202 //function : RootFace
203 //purpose  :
204 //=======================================================================
205 
RootFace() const206 const TopoDS_Face & Draft_EdgeInfo::RootFace() const
207 {
208   return myRootFace;
209 }
210 
211 //=======================================================================
212 //function : Tolerance
213 //purpose  :
214 //=======================================================================
215 
Tolerance(const Standard_Real tol)216 void  Draft_EdgeInfo::Tolerance(const Standard_Real tol)
217 {
218   myTol=tol;
219 }
Tolerance() const220 Standard_Real  Draft_EdgeInfo::Tolerance() const
221 {
222   return myTol;
223 }
224 
225 
226