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