0022488: Typo in Geom2d_BSplineCurve::LocateU() - which uses a value not adjusted...
[occt.git] / src / Geom2d / Geom2d_Circle.cxx
1 // File:        Geom2d_Circle.cxx
2 // Created:     Wed Mar 24 19:20:00 1993
3 // Author:      JCV
4 //              <fid@sdsun2>
5 // Copyright:   Matra Datavision 1993
6
7 //File Geom2d_Circle.cxx, JCV 12/07/91
8
9
10 #include <Geom2d_Circle.ixx>
11 #include <ElCLib.hxx>
12 #include <gp_XY.hxx>
13 #include <Standard_RangeError.hxx>
14 #include <Standard_ConstructionError.hxx> 
15
16
17 typedef Geom2d_Circle         Circle;
18 typedef Handle(Geom2d_Circle) Handle(Circle);
19 typedef gp_Ax2d   Ax2d;
20 typedef gp_Dir2d  Dir2d;
21 typedef gp_Pnt2d  Pnt2d;
22 typedef gp_Trsf2d Trsf2d;
23 typedef gp_Vec2d  Vec2d;
24 typedef gp_XY     XY;
25
26
27
28
29
30
31
32
33 //=======================================================================
34 //function : Copy
35 //purpose  : 
36 //=======================================================================
37
38 Handle(Geom2d_Geometry) Geom2d_Circle::Copy() const 
39 {
40   Handle(Circle) C;
41   C = new Circle (pos, radius);
42   return C;
43 }
44
45
46 //=======================================================================
47 //function : Geom2d_Circle
48 //purpose  : 
49 //=======================================================================
50
51 Geom2d_Circle::Geom2d_Circle (const gp_Circ2d& C) : radius (C.Radius()) { 
52
53   pos = C.Axis();
54 }
55
56
57 //=======================================================================
58 //function : Geom2d_Circle
59 //purpose  : 
60 //=======================================================================
61
62 Geom2d_Circle::Geom2d_Circle (const Ax2d& A, const Standard_Real Radius,
63                               const Standard_Boolean Sense)
64 : radius(Radius) {
65   
66    if (Radius < 0.0) { Standard_ConstructionError::Raise(); }
67    pos = gp_Ax22d(A, Sense);
68 }
69
70 //=======================================================================
71 //function : Geom2d_Circle
72 //purpose  : 
73 //=======================================================================
74
75 Geom2d_Circle::Geom2d_Circle (const gp_Ax22d& A, const Standard_Real Radius)
76
77 : radius (Radius) {
78
79    if (Radius < 0.0) { Standard_ConstructionError::Raise(); }
80    pos = A;
81 }
82
83 //=======================================================================
84 //function : SetCirc2d
85 //purpose  : 
86 //=======================================================================
87
88 void Geom2d_Circle::SetCirc2d (const gp_Circ2d& C) {
89
90    radius = C.Radius();
91    pos    = C.Axis();
92 }
93
94
95 //=======================================================================
96 //function : SetRadius
97 //purpose  : 
98 //=======================================================================
99
100 void Geom2d_Circle::SetRadius (const Standard_Real R) 
101
102   if (R < 0.0) { Standard_ConstructionError::Raise(); }
103   radius = R;
104 }
105
106 //=======================================================================
107 //function : Radius
108 //purpose  : 
109 //=======================================================================
110
111 Standard_Real Geom2d_Circle::Radius () const
112
113   return radius;
114 }
115
116 //=======================================================================
117 //function : Circ2d
118 //purpose  : 
119 //=======================================================================
120
121 gp_Circ2d Geom2d_Circle::Circ2d () const    
122 {
123   return gp_Circ2d (pos, radius); 
124 }
125
126 //=======================================================================
127 //function : ReversedParameter
128 //purpose  : 
129 //=======================================================================
130
131 Standard_Real Geom2d_Circle::ReversedParameter( const Standard_Real U) const 
132 {
133   return (2. * M_PI - U);
134 }
135
136 //=======================================================================
137 //function : Eccentricity
138 //purpose  : 
139 //=======================================================================
140
141 Standard_Real Geom2d_Circle::Eccentricity () const       
142 {
143   return 0.0; 
144 }
145
146 //=======================================================================
147 //function : FirstParameter
148 //purpose  : 
149 //=======================================================================
150
151 Standard_Real Geom2d_Circle::FirstParameter () const     
152 {
153   return 0.0; 
154 }
155
156 //=======================================================================
157 //function : LastParameter
158 //purpose  : 
159 //=======================================================================
160
161 Standard_Real Geom2d_Circle::LastParameter () const      
162 {
163   return 2.0 * M_PI; 
164 }
165
166 //=======================================================================
167 //function : IsClosed
168 //purpose  : 
169 //=======================================================================
170
171 Standard_Boolean Geom2d_Circle::IsClosed () const        
172 {
173   return Standard_True; 
174 }
175
176 //=======================================================================
177 //function : IsPeriodic
178 //purpose  : 
179 //=======================================================================
180
181 Standard_Boolean Geom2d_Circle::IsPeriodic () const      
182 {
183   return Standard_True; 
184 }
185
186 //=======================================================================
187 //function : D0
188 //purpose  : 
189 //=======================================================================
190
191 void Geom2d_Circle::D0 (const Standard_Real   U, 
192                               Pnt2d& P) const 
193 {
194   P= ElCLib::CircleValue (U, pos, radius);
195 }
196
197
198 //=======================================================================
199 //function : D1
200 //purpose  : 
201 //=======================================================================
202
203 void Geom2d_Circle::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const 
204 {
205   ElCLib::CircleD1 (U, pos, radius, P, V1);
206 }
207
208
209 //=======================================================================
210 //function : D2
211 //purpose  : 
212 //=======================================================================
213
214 void Geom2d_Circle::D2 (const Standard_Real U, 
215                               Pnt2d& P, 
216                               Vec2d& V1, Vec2d& V2) const 
217 {
218   ElCLib::CircleD2 (U, pos, radius, P, V1, V2);
219 }
220
221
222 //=======================================================================
223 //function : D3
224 //purpose  : 
225 //=======================================================================
226
227 void Geom2d_Circle::D3 (const Standard_Real U, 
228                               Pnt2d& P, 
229                               Vec2d& V1, Vec2d& V2, Vec2d& V3) const 
230 {
231   ElCLib::CircleD3 (U, pos, radius, P, V1, V2, V3);
232 }
233
234
235 //=======================================================================
236 //function : DN
237 //purpose  : 
238 //=======================================================================
239
240 Vec2d Geom2d_Circle::DN (const Standard_Real U, const Standard_Integer N) const 
241 {
242   Standard_RangeError_Raise_if (N < 1," ");
243   return ElCLib::CircleDN (U, pos, radius, N);
244 }
245
246
247 //=======================================================================
248 //function : Transform
249 //purpose  : 
250 //=======================================================================
251
252 void Geom2d_Circle::Transform (const Trsf2d& T) 
253 {
254    radius = radius * Abs(T.ScaleFactor());
255    pos.Transform (T);
256 }