b311480e |
1 | // Created on: 1993-03-24 |
2 | // Created by: JCV |
3 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
7fd59977 |
18 | #include <ElCLib.hxx> |
42cf5bc1 |
19 | #include <Geom2d_Circle.hxx> |
20 | #include <Geom2d_Geometry.hxx> |
21 | #include <gp_Ax2d.hxx> |
22 | #include <gp_Ax22d.hxx> |
23 | #include <gp_Circ2d.hxx> |
24 | #include <gp_Pnt2d.hxx> |
25 | #include <gp_Trsf2d.hxx> |
26 | #include <gp_Vec2d.hxx> |
7fd59977 |
27 | #include <gp_XY.hxx> |
42cf5bc1 |
28 | #include <Standard_ConstructionError.hxx> |
7fd59977 |
29 | #include <Standard_RangeError.hxx> |
42cf5bc1 |
30 | #include <Standard_Type.hxx> |
7fd59977 |
31 | |
92efcf78 |
32 | IMPLEMENT_STANDARD_RTTIEXT(Geom2d_Circle,Geom2d_Conic) |
33 | |
7fd59977 |
34 | typedef Geom2d_Circle Circle; |
7fd59977 |
35 | typedef gp_Ax2d Ax2d; |
36 | typedef gp_Dir2d Dir2d; |
37 | typedef gp_Pnt2d Pnt2d; |
38 | typedef gp_Trsf2d Trsf2d; |
39 | typedef gp_Vec2d Vec2d; |
40 | typedef gp_XY XY; |
41 | |
7fd59977 |
42 | //======================================================================= |
43 | //function : Copy |
44 | //purpose : |
45 | //======================================================================= |
46 | |
47 | Handle(Geom2d_Geometry) Geom2d_Circle::Copy() const |
48 | { |
c04c30b3 |
49 | Handle(Geom2d_Circle) C; |
7fd59977 |
50 | C = new Circle (pos, radius); |
51 | return C; |
52 | } |
53 | |
54 | |
55 | //======================================================================= |
56 | //function : Geom2d_Circle |
57 | //purpose : |
58 | //======================================================================= |
59 | |
60 | Geom2d_Circle::Geom2d_Circle (const gp_Circ2d& C) : radius (C.Radius()) { |
61 | |
62 | pos = C.Axis(); |
63 | } |
64 | |
65 | |
66 | //======================================================================= |
67 | //function : Geom2d_Circle |
68 | //purpose : |
69 | //======================================================================= |
70 | |
71 | Geom2d_Circle::Geom2d_Circle (const Ax2d& A, const Standard_Real Radius, |
72 | const Standard_Boolean Sense) |
73 | : radius(Radius) { |
74 | |
9775fa61 |
75 | if (Radius < 0.0) { throw Standard_ConstructionError(); } |
7fd59977 |
76 | pos = gp_Ax22d(A, Sense); |
77 | } |
78 | |
79 | //======================================================================= |
80 | //function : Geom2d_Circle |
81 | //purpose : |
82 | //======================================================================= |
83 | |
84 | Geom2d_Circle::Geom2d_Circle (const gp_Ax22d& A, const Standard_Real Radius) |
85 | |
86 | : radius (Radius) { |
87 | |
9775fa61 |
88 | if (Radius < 0.0) { throw Standard_ConstructionError(); } |
7fd59977 |
89 | pos = A; |
90 | } |
91 | |
92 | //======================================================================= |
93 | //function : SetCirc2d |
94 | //purpose : |
95 | //======================================================================= |
96 | |
97 | void Geom2d_Circle::SetCirc2d (const gp_Circ2d& C) { |
98 | |
99 | radius = C.Radius(); |
100 | pos = C.Axis(); |
101 | } |
102 | |
103 | |
104 | //======================================================================= |
105 | //function : SetRadius |
106 | //purpose : |
107 | //======================================================================= |
108 | |
109 | void Geom2d_Circle::SetRadius (const Standard_Real R) |
110 | { |
9775fa61 |
111 | if (R < 0.0) { throw Standard_ConstructionError(); } |
7fd59977 |
112 | radius = R; |
113 | } |
114 | |
115 | //======================================================================= |
116 | //function : Radius |
117 | //purpose : |
118 | //======================================================================= |
119 | |
120 | Standard_Real Geom2d_Circle::Radius () const |
121 | { |
122 | return radius; |
123 | } |
124 | |
125 | //======================================================================= |
126 | //function : Circ2d |
127 | //purpose : |
128 | //======================================================================= |
129 | |
130 | gp_Circ2d Geom2d_Circle::Circ2d () const |
131 | { |
132 | return gp_Circ2d (pos, radius); |
133 | } |
134 | |
135 | //======================================================================= |
136 | //function : ReversedParameter |
137 | //purpose : |
138 | //======================================================================= |
139 | |
140 | Standard_Real Geom2d_Circle::ReversedParameter( const Standard_Real U) const |
141 | { |
c6541a0c |
142 | return (2. * M_PI - U); |
7fd59977 |
143 | } |
144 | |
145 | //======================================================================= |
146 | //function : Eccentricity |
147 | //purpose : |
148 | //======================================================================= |
149 | |
150 | Standard_Real Geom2d_Circle::Eccentricity () const |
151 | { |
152 | return 0.0; |
153 | } |
154 | |
155 | //======================================================================= |
156 | //function : FirstParameter |
157 | //purpose : |
158 | //======================================================================= |
159 | |
160 | Standard_Real Geom2d_Circle::FirstParameter () const |
161 | { |
162 | return 0.0; |
163 | } |
164 | |
165 | //======================================================================= |
166 | //function : LastParameter |
167 | //purpose : |
168 | //======================================================================= |
169 | |
170 | Standard_Real Geom2d_Circle::LastParameter () const |
171 | { |
c6541a0c |
172 | return 2.0 * M_PI; |
7fd59977 |
173 | } |
174 | |
175 | //======================================================================= |
176 | //function : IsClosed |
177 | //purpose : |
178 | //======================================================================= |
179 | |
180 | Standard_Boolean Geom2d_Circle::IsClosed () const |
181 | { |
182 | return Standard_True; |
183 | } |
184 | |
185 | //======================================================================= |
186 | //function : IsPeriodic |
187 | //purpose : |
188 | //======================================================================= |
189 | |
190 | Standard_Boolean Geom2d_Circle::IsPeriodic () const |
191 | { |
192 | return Standard_True; |
193 | } |
194 | |
195 | //======================================================================= |
196 | //function : D0 |
197 | //purpose : |
198 | //======================================================================= |
199 | |
200 | void Geom2d_Circle::D0 (const Standard_Real U, |
201 | Pnt2d& P) const |
202 | { |
203 | P= ElCLib::CircleValue (U, pos, radius); |
204 | } |
205 | |
206 | |
207 | //======================================================================= |
208 | //function : D1 |
209 | //purpose : |
210 | //======================================================================= |
211 | |
212 | void Geom2d_Circle::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const |
213 | { |
214 | ElCLib::CircleD1 (U, pos, radius, P, V1); |
215 | } |
216 | |
217 | |
218 | //======================================================================= |
219 | //function : D2 |
220 | //purpose : |
221 | //======================================================================= |
222 | |
223 | void Geom2d_Circle::D2 (const Standard_Real U, |
224 | Pnt2d& P, |
225 | Vec2d& V1, Vec2d& V2) const |
226 | { |
227 | ElCLib::CircleD2 (U, pos, radius, P, V1, V2); |
228 | } |
229 | |
230 | |
231 | //======================================================================= |
232 | //function : D3 |
233 | //purpose : |
234 | //======================================================================= |
235 | |
236 | void Geom2d_Circle::D3 (const Standard_Real U, |
237 | Pnt2d& P, |
238 | Vec2d& V1, Vec2d& V2, Vec2d& V3) const |
239 | { |
240 | ElCLib::CircleD3 (U, pos, radius, P, V1, V2, V3); |
241 | } |
242 | |
243 | |
244 | //======================================================================= |
245 | //function : DN |
246 | //purpose : |
247 | //======================================================================= |
248 | |
249 | Vec2d Geom2d_Circle::DN (const Standard_Real U, const Standard_Integer N) const |
250 | { |
251 | Standard_RangeError_Raise_if (N < 1," "); |
252 | return ElCLib::CircleDN (U, pos, radius, N); |
253 | } |
254 | |
255 | |
256 | //======================================================================= |
257 | //function : Transform |
258 | //purpose : |
259 | //======================================================================= |
260 | |
261 | void Geom2d_Circle::Transform (const Trsf2d& T) |
262 | { |
263 | radius = radius * Abs(T.ScaleFactor()); |
264 | pos.Transform (T); |
265 | } |