1 // Created on: 1993-03-24
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
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>
28 #include <Standard_ConstructionError.hxx>
29 #include <Standard_RangeError.hxx>
30 #include <Standard_Type.hxx>
32 typedef Geom2d_Circle Circle;
34 typedef gp_Dir2d Dir2d;
35 typedef gp_Pnt2d Pnt2d;
36 typedef gp_Trsf2d Trsf2d;
37 typedef gp_Vec2d Vec2d;
40 //=======================================================================
43 //=======================================================================
45 Handle(Geom2d_Geometry) Geom2d_Circle::Copy() const
47 Handle(Geom2d_Circle) C;
48 C = new Circle (pos, radius);
53 //=======================================================================
54 //function : Geom2d_Circle
56 //=======================================================================
58 Geom2d_Circle::Geom2d_Circle (const gp_Circ2d& C) : radius (C.Radius()) {
64 //=======================================================================
65 //function : Geom2d_Circle
67 //=======================================================================
69 Geom2d_Circle::Geom2d_Circle (const Ax2d& A, const Standard_Real Radius,
70 const Standard_Boolean Sense)
73 if (Radius < 0.0) { Standard_ConstructionError::Raise(); }
74 pos = gp_Ax22d(A, Sense);
77 //=======================================================================
78 //function : Geom2d_Circle
80 //=======================================================================
82 Geom2d_Circle::Geom2d_Circle (const gp_Ax22d& A, const Standard_Real Radius)
86 if (Radius < 0.0) { Standard_ConstructionError::Raise(); }
90 //=======================================================================
91 //function : SetCirc2d
93 //=======================================================================
95 void Geom2d_Circle::SetCirc2d (const gp_Circ2d& C) {
102 //=======================================================================
103 //function : SetRadius
105 //=======================================================================
107 void Geom2d_Circle::SetRadius (const Standard_Real R)
109 if (R < 0.0) { Standard_ConstructionError::Raise(); }
113 //=======================================================================
116 //=======================================================================
118 Standard_Real Geom2d_Circle::Radius () const
123 //=======================================================================
126 //=======================================================================
128 gp_Circ2d Geom2d_Circle::Circ2d () const
130 return gp_Circ2d (pos, radius);
133 //=======================================================================
134 //function : ReversedParameter
136 //=======================================================================
138 Standard_Real Geom2d_Circle::ReversedParameter( const Standard_Real U) const
140 return (2. * M_PI - U);
143 //=======================================================================
144 //function : Eccentricity
146 //=======================================================================
148 Standard_Real Geom2d_Circle::Eccentricity () const
153 //=======================================================================
154 //function : FirstParameter
156 //=======================================================================
158 Standard_Real Geom2d_Circle::FirstParameter () const
163 //=======================================================================
164 //function : LastParameter
166 //=======================================================================
168 Standard_Real Geom2d_Circle::LastParameter () const
173 //=======================================================================
174 //function : IsClosed
176 //=======================================================================
178 Standard_Boolean Geom2d_Circle::IsClosed () const
180 return Standard_True;
183 //=======================================================================
184 //function : IsPeriodic
186 //=======================================================================
188 Standard_Boolean Geom2d_Circle::IsPeriodic () const
190 return Standard_True;
193 //=======================================================================
196 //=======================================================================
198 void Geom2d_Circle::D0 (const Standard_Real U,
201 P= ElCLib::CircleValue (U, pos, radius);
205 //=======================================================================
208 //=======================================================================
210 void Geom2d_Circle::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const
212 ElCLib::CircleD1 (U, pos, radius, P, V1);
216 //=======================================================================
219 //=======================================================================
221 void Geom2d_Circle::D2 (const Standard_Real U,
223 Vec2d& V1, Vec2d& V2) const
225 ElCLib::CircleD2 (U, pos, radius, P, V1, V2);
229 //=======================================================================
232 //=======================================================================
234 void Geom2d_Circle::D3 (const Standard_Real U,
236 Vec2d& V1, Vec2d& V2, Vec2d& V3) const
238 ElCLib::CircleD3 (U, pos, radius, P, V1, V2, V3);
242 //=======================================================================
245 //=======================================================================
247 Vec2d Geom2d_Circle::DN (const Standard_Real U, const Standard_Integer N) const
249 Standard_RangeError_Raise_if (N < 1," ");
250 return ElCLib::CircleDN (U, pos, radius, N);
254 //=======================================================================
255 //function : Transform
257 //=======================================================================
259 void Geom2d_Circle::Transform (const Trsf2d& T)
261 radius = radius * Abs(T.ScaleFactor());