0025124: [Feature request] Removal of continuity checks for offset geometries
[occt.git] / src / Geom2d / Geom2d_Line.cxx
1 // Created on: 1993-03-24
2 // Created by: JCV
3 // Copyright (c) 1993-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 #include <Geom2d_Line.ixx>
18
19 #include <Precision.hxx>
20 #include <ElCLib.hxx>
21 #include <gp_XY.hxx>
22 #include <Standard_RangeError.hxx>
23
24
25 typedef Geom2d_Line         Line;
26 typedef Handle(Geom2d_Line) Handle(Line);
27 typedef gp_Ax2d   Ax2d;
28 typedef gp_Dir2d  Dir2d;
29 typedef gp_Pnt2d  Pnt2d;
30 typedef gp_Vec2d  Vec2d;
31 typedef gp_Trsf2d Trsf2d;
32 typedef gp_XY     XY;
33
34
35
36
37
38 //=======================================================================
39 //function : Copy
40 //purpose  : 
41 //=======================================================================
42
43 Handle(Geom2d_Geometry) Geom2d_Line::Copy() const 
44 {
45   Handle(Line) L;
46   L = new Line (pos);
47   return L;
48 }
49
50
51 //=======================================================================
52 //function : Geom2d_Line
53 //purpose  : 
54 //=======================================================================
55
56 Geom2d_Line::Geom2d_Line (const Ax2d& A)           : pos (A) { }
57
58 //=======================================================================
59 //function : Geom2d_Line
60 //purpose  : 
61 //=======================================================================
62
63 Geom2d_Line::Geom2d_Line (const gp_Lin2d& L)       : pos (L.Position()) { }
64
65 //=======================================================================
66 //function : Geom2d_Line
67 //purpose  : 
68 //=======================================================================
69
70 Geom2d_Line::Geom2d_Line (const Pnt2d& P, const Dir2d& V)  : pos (P, V) { }
71
72 //=======================================================================
73 //function : SetDirection
74 //purpose  : 
75 //=======================================================================
76
77 void Geom2d_Line::SetDirection (const Dir2d& V) { pos.SetDirection (V); }
78
79 //=======================================================================
80 //function : Direction
81 //purpose  : 
82 //=======================================================================
83
84 const gp_Dir2d& Geom2d_Line::Direction () const { return pos.Direction (); }
85
86 //=======================================================================
87 //function : SetLin2d
88 //purpose  : 
89 //=======================================================================
90
91 void Geom2d_Line::SetLin2d (const gp_Lin2d& L)  { pos = L.Position(); }
92
93 //=======================================================================
94 //function : SetLocation
95 //purpose  : 
96 //=======================================================================
97
98 void Geom2d_Line::SetLocation (const Pnt2d& P)  { pos.SetLocation (P); }
99
100 //=======================================================================
101 //function : Location
102 //purpose  : 
103 //=======================================================================
104
105 const gp_Pnt2d& Geom2d_Line::Location () const  { return pos.Location (); }
106
107 //=======================================================================
108 //function : SetPosition
109 //purpose  : 
110 //=======================================================================
111
112 void Geom2d_Line::SetPosition (const Ax2d& A)   { pos = A; }
113
114 //=======================================================================
115 //function : Position
116 //purpose  : 
117 //=======================================================================
118
119 const gp_Ax2d& Geom2d_Line::Position () const   { return pos; }
120
121 //=======================================================================
122 //function : Lin2d
123 //purpose  : 
124 //=======================================================================
125
126 gp_Lin2d Geom2d_Line::Lin2d () const            { return gp_Lin2d (pos); }
127
128 //=======================================================================
129 //function : Reverse
130 //purpose  : 
131 //=======================================================================
132
133 void Geom2d_Line::Reverse ()                    { pos.Reverse(); }
134
135 //=======================================================================
136 //function : ReversedParameter
137 //purpose  : 
138 //=======================================================================
139
140 Standard_Real Geom2d_Line::ReversedParameter( const Standard_Real U) const  { return (-U); }
141
142 //=======================================================================
143 //function : FirstParameter
144 //purpose  : 
145 //=======================================================================
146
147 Standard_Real Geom2d_Line::FirstParameter () const       
148 { return -Precision::Infinite(); }
149
150 //=======================================================================
151 //function : LastParameter
152 //purpose  : 
153 //=======================================================================
154
155 Standard_Real Geom2d_Line::LastParameter () const        
156 { return Precision::Infinite(); }
157
158 //=======================================================================
159 //function : IsClosed
160 //purpose  : 
161 //=======================================================================
162
163 Standard_Boolean Geom2d_Line::IsClosed () const          { return Standard_False; }
164
165 //=======================================================================
166 //function : IsPeriodic
167 //purpose  : 
168 //=======================================================================
169
170 Standard_Boolean Geom2d_Line::IsPeriodic () const        { return Standard_False;  }
171
172 //=======================================================================
173 //function : Continuity
174 //purpose  : 
175 //=======================================================================
176
177 GeomAbs_Shape Geom2d_Line::Continuity () const   { return GeomAbs_CN; }
178
179 //=======================================================================
180 //function : IsCN
181 //purpose  : 
182 //=======================================================================
183
184 Standard_Boolean Geom2d_Line::IsCN (const Standard_Integer ) const      { return Standard_True; }
185
186 //=======================================================================
187 //function : D0
188 //purpose  : 
189 //=======================================================================
190
191 void Geom2d_Line::D0 (const Standard_Real U, Pnt2d& P) const  
192 {
193   P = ElCLib::LineValue (U, pos);
194 }
195
196 //=======================================================================
197 //function : D1
198 //purpose  : 
199 //=======================================================================
200
201 void Geom2d_Line::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const 
202 {
203   ElCLib::LineD1 (U, pos, P, V1);
204 }
205
206 //=======================================================================
207 //function : D2
208 //purpose  : 
209 //=======================================================================
210
211 void Geom2d_Line::D2 (const Standard_Real U, 
212                             Pnt2d& P, 
213                             Vec2d& V1, Vec2d& V2) const 
214 {
215   ElCLib::LineD1 (U, pos, P, V1);
216   V2.SetCoord (0.0, 0.0);
217 }
218
219 //=======================================================================
220 //function : D3
221 //purpose  : 
222 //=======================================================================
223
224 void Geom2d_Line::D3 (const Standard_Real U, 
225                             Pnt2d& P, 
226                             Vec2d& V1, Vec2d& V2, Vec2d& V3) const
227 {
228   ElCLib::LineD1 (U, pos, P, V1);
229   V2.SetCoord (0.0, 0.0);
230   V3.SetCoord (0.0, 0.0);
231 }
232
233
234 //=======================================================================
235 //function : DN
236 //purpose  : 
237 //=======================================================================
238
239 Vec2d Geom2d_Line::DN
240   (const Standard_Real     ,
241    const Standard_Integer N ) const
242 {
243   Standard_RangeError_Raise_if (N <= 0, " ");
244   if (N == 1) 
245     return Vec2d (pos.Direction ());
246   else        
247     return Vec2d (0.0, 0.0);
248 }
249
250
251 //=======================================================================
252 //function : Transform
253 //purpose  : 
254 //=======================================================================
255
256 void Geom2d_Line::Transform (const Trsf2d& T)          { pos.Transform (T); }
257
258 //=======================================================================
259 //function : TransformedParameter
260 //purpose  : 
261 //=======================================================================
262
263 Standard_Real Geom2d_Line::TransformedParameter(const Standard_Real U,
264                                                 const gp_Trsf2d& T) const
265 {
266   if (Precision::IsInfinite(U)) return U;
267   return U * Abs(T.ScaleFactor());
268 }
269
270 //=======================================================================
271 //function : ParametricTransformation
272 //purpose  : 
273 //=======================================================================
274
275 Standard_Real Geom2d_Line::ParametricTransformation(const gp_Trsf2d& T) const
276 {
277   return Abs(T.ScaleFactor());
278 }
279
280
281 //=======================================================================
282 //function : Distance
283 //purpose  : 
284 //=======================================================================
285
286 Standard_Real Geom2d_Line::Distance (const gp_Pnt2d& P) const {
287
288   gp_Lin2d L (pos);   
289   return L.Distance (P);
290 }
291