1 // Created on: 1993-03-10
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 <Geom_Circle.hxx>
20 #include <Geom_Geometry.hxx>
22 #include <gp_Circ.hxx>
24 #include <gp_Trsf.hxx>
27 #include <Standard_ConstructionError.hxx>
28 #include <Standard_RangeError.hxx>
29 #include <Standard_Type.hxx>
31 IMPLEMENT_STANDARD_RTTIEXT(Geom_Circle,Geom_Conic)
33 typedef Geom_Circle Circle;
43 //=======================================================================
46 //=======================================================================
48 Handle(Geom_Geometry) Geom_Circle::Copy() const {
50 Handle(Geom_Circle) C;
51 C = new Circle (pos, radius);
56 //=======================================================================
57 //function : Geom_Circle
59 //=======================================================================
61 Geom_Circle::Geom_Circle (const gp_Circ& C) : radius (C.Radius()) {
67 //=======================================================================
68 //function : Geom_Circle
70 //=======================================================================
72 Geom_Circle::Geom_Circle (const Ax2& A2, const Standard_Real R) : radius (R) {
74 if (R < 0.0) throw Standard_ConstructionError();
79 //=======================================================================
82 //=======================================================================
84 Standard_Boolean Geom_Circle::IsClosed () const { return Standard_True; }
87 //=======================================================================
88 //function : IsPeriodic
90 //=======================================================================
92 Standard_Boolean Geom_Circle::IsPeriodic () const { return Standard_True; }
95 //=======================================================================
96 //function : ReversedParameter
98 //=======================================================================
100 Standard_Real Geom_Circle::ReversedParameter( const Standard_Real U) const
102 return ( 2. * M_PI - U);
105 //=======================================================================
106 //function : Eccentricity
108 //=======================================================================
110 Standard_Real Geom_Circle::Eccentricity () const { return 0.0; }
113 //=======================================================================
114 //function : FirstParameter
116 //=======================================================================
118 Standard_Real Geom_Circle::FirstParameter () const { return 0.0; }
121 //=======================================================================
122 //function : LastParameter
124 //=======================================================================
126 Standard_Real Geom_Circle::LastParameter () const { return 2.0 * M_PI; }
129 //=======================================================================
132 //=======================================================================
134 gp_Circ Geom_Circle::Circ () const { return gp_Circ (pos, radius); }
137 //=======================================================================
140 //=======================================================================
142 void Geom_Circle::SetCirc (const gp_Circ& C) {
149 //=======================================================================
150 //function : SetRadius
152 //=======================================================================
154 void Geom_Circle::SetRadius (const Standard_Real R) {
156 if (R < 0.0) throw Standard_ConstructionError();
160 //=======================================================================
163 //=======================================================================
165 Standard_Real Geom_Circle::Radius() const
170 //=======================================================================
173 //=======================================================================
175 void Geom_Circle::D0 (const Standard_Real U, Pnt& P) const {
177 P = ElCLib::CircleValue (U, pos, radius);
181 //=======================================================================
184 //=======================================================================
186 void Geom_Circle::D1 (const Standard_Real U, Pnt& P, Vec& V1) const {
188 ElCLib::CircleD1 (U, pos, radius, P, V1);
192 //=======================================================================
195 //=======================================================================
197 void Geom_Circle::D2 (const Standard_Real U, Pnt& P, Vec& V1, Vec& V2) const {
199 ElCLib::CircleD2 (U, pos, radius, P, V1, V2);
203 //=======================================================================
206 //=======================================================================
208 void Geom_Circle::D3 (
209 const Standard_Real U, Pnt& P, Vec& V1, Vec& V2, Vec& V3) const {
211 ElCLib::CircleD3 (U, pos, radius, P, V1, V2, V3);
215 //=======================================================================
218 //=======================================================================
220 Vec Geom_Circle::DN (const Standard_Real U, const Standard_Integer N) const {
222 Standard_RangeError_Raise_if (N < 1, " ");
223 return ElCLib::CircleDN (U, pos, radius, N);
227 //=======================================================================
228 //function : Transform
230 //=======================================================================
232 void Geom_Circle::Transform (const Trsf& T) {
234 radius = radius * Abs(T.ScaleFactor());
238 //=======================================================================
239 //function : DumpJson
241 //=======================================================================
242 void Geom_Circle::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
244 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
246 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Geom_Conic)
248 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, radius)