0025706: SIGSEGV after making existing BSplineCurve rational
[occt.git] / src / Geom2d / Geom2d_Circle.cxx
CommitLineData
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
17#include <Geom2d_Circle.ixx>
18#include <ElCLib.hxx>
19#include <gp_XY.hxx>
20#include <Standard_RangeError.hxx>
21#include <Standard_ConstructionError.hxx>
22
23
24typedef Geom2d_Circle Circle;
25typedef Handle(Geom2d_Circle) Handle(Circle);
26typedef gp_Ax2d Ax2d;
27typedef gp_Dir2d Dir2d;
28typedef gp_Pnt2d Pnt2d;
29typedef gp_Trsf2d Trsf2d;
30typedef gp_Vec2d Vec2d;
31typedef gp_XY XY;
32
33
34
35
36
37
38
39
40//=======================================================================
41//function : Copy
42//purpose :
43//=======================================================================
44
45Handle(Geom2d_Geometry) Geom2d_Circle::Copy() const
46{
47 Handle(Circle) C;
48 C = new Circle (pos, radius);
49 return C;
50}
51
52
53//=======================================================================
54//function : Geom2d_Circle
55//purpose :
56//=======================================================================
57
58Geom2d_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
69Geom2d_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
82Geom2d_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
95void 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
107void 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
118Standard_Real Geom2d_Circle::Radius () const
119{
120 return radius;
121}
122
123//=======================================================================
124//function : Circ2d
125//purpose :
126//=======================================================================
127
128gp_Circ2d Geom2d_Circle::Circ2d () const
129{
130 return gp_Circ2d (pos, radius);
131}
132
133//=======================================================================
134//function : ReversedParameter
135//purpose :
136//=======================================================================
137
138Standard_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
148Standard_Real Geom2d_Circle::Eccentricity () const
149{
150 return 0.0;
151}
152
153//=======================================================================
154//function : FirstParameter
155//purpose :
156//=======================================================================
157
158Standard_Real Geom2d_Circle::FirstParameter () const
159{
160 return 0.0;
161}
162
163//=======================================================================
164//function : LastParameter
165//purpose :
166//=======================================================================
167
168Standard_Real Geom2d_Circle::LastParameter () const
169{
c6541a0c 170 return 2.0 * M_PI;
7fd59977 171}
172
173//=======================================================================
174//function : IsClosed
175//purpose :
176//=======================================================================
177
178Standard_Boolean Geom2d_Circle::IsClosed () const
179{
180 return Standard_True;
181}
182
183//=======================================================================
184//function : IsPeriodic
185//purpose :
186//=======================================================================
187
188Standard_Boolean Geom2d_Circle::IsPeriodic () const
189{
190 return Standard_True;
191}
192
193//=======================================================================
194//function : D0
195//purpose :
196//=======================================================================
197
198void 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
210void 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
221void 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
234void 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
247Vec2d 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
259void Geom2d_Circle::Transform (const Trsf2d& T)
260{
261 radius = radius * Abs(T.ScaleFactor());
262 pos.Transform (T);
263}