1 // Created on: 1993-03-24 2 // Created by: Philippe DAUTRY 3 // Copyright (c) 1993-1999 Matra Datavision 4 // Copyright (c) 1999-2014 OPEN CASCADE SAS 5 // 6 // This file is part of Open CASCADE Technology software library. 7 // 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. 13 // 14 // Alternatively, this file may be used under the terms of Open CASCADE 15 // commercial license or contractual agreement. 16 17 #ifndef _Geom2d_Circle_HeaderFile 18 #define _Geom2d_Circle_HeaderFile 19 20 #include <Standard.hxx> 21 #include <Standard_Type.hxx> 22 23 #include <Standard_Real.hxx> 24 #include <Geom2d_Conic.hxx> 25 #include <Standard_Boolean.hxx> 26 #include <Standard_Integer.hxx> 27 class gp_Circ2d; 28 class gp_Ax2d; 29 class gp_Ax22d; 30 class gp_Pnt2d; 31 class gp_Vec2d; 32 class gp_Trsf2d; 33 class Geom2d_Geometry; 34 35 36 class Geom2d_Circle; 37 DEFINE_STANDARD_HANDLE(Geom2d_Circle, Geom2d_Conic) 38 39 //! Describes a circle in the plane (2D space). 40 //! A circle is defined by its radius and, as with any conic 41 //! curve, is positioned in the plane with a coordinate 42 //! system (gp_Ax22d object) where the origin is the 43 //! center of the circle. 44 //! The coordinate system is the local coordinate 45 //! system of the circle. 46 //! The orientation (direct or indirect) of the local 47 //! coordinate system gives an explicit orientation to the 48 //! circle, determining the direction in which the 49 //! parameter increases along the circle. 50 //! The Geom2d_Circle circle is parameterized by an angle: 51 //! P(U) = O + R*Cos(U)*XDir + R*Sin(U)*YDir 52 //! where: 53 //! - P is the point of parameter U, 54 //! - O, XDir and YDir are respectively the origin, "X 55 //! Direction" and "Y Direction" of its local coordinate system, 56 //! - R is the radius of the circle. 57 //! The "X Axis" of the local coordinate system therefore 58 //! defines the origin of the parameter of the circle. The 59 //! parameter is the angle with this "X Direction". 60 //! A circle is a closed and periodic curve. The period is 61 //! 2.*Pi and the parameter range is [ 0,2.*Pi [. 62 //! See Also 63 //! GCE2d_MakeCircle which provides functions for 64 //! more complex circle constructions 65 //! gp_Ax22d and gp_Circ2d for an equivalent, non-parameterized data structure. 66 class Geom2d_Circle : public Geom2d_Conic 67 { 68 69 public: 70 71 72 //! Constructs a circle by conversion of the gp_Circ2d circle C. 73 Standard_EXPORT Geom2d_Circle(const gp_Circ2d& C); 74 75 //! Constructs a circle of radius Radius, whose center is the origin of axis 76 //! A; A is the "X Axis" of the local coordinate system 77 //! of the circle; this coordinate system is direct if 78 //! Sense is true (default value) or indirect if Sense is false. 79 //! Note: It is possible to create a circle where Radius is equal to 0.0. 80 //! Exceptions Standard_ConstructionError if Radius is negative. 81 Standard_EXPORT Geom2d_Circle(const gp_Ax2d& A, const Standard_Real Radius, const Standard_Boolean Sense = Standard_True); 82 83 //! Constructs a circle 84 //! of radius Radius, where the coordinate system A 85 //! locates the circle and defines its orientation in the plane such that: 86 //! - the center of the circle is the origin of A, 87 //! - the orientation (direct or indirect) of A gives the 88 //! orientation of the circle. 89 Standard_EXPORT Geom2d_Circle(const gp_Ax22d& A, const Standard_Real Radius); 90 91 92 //! Converts the gp_Circ2d circle C into this circle. 93 Standard_EXPORT void SetCirc2d (const gp_Circ2d& C); 94 95 Standard_EXPORT void SetRadius (const Standard_Real R); 96 97 98 //! Returns the non persistent circle from gp with the same 99 //! geometric properties as <me>. 100 Standard_EXPORT gp_Circ2d Circ2d() const; 101 102 //! Returns the radius of this circle. 103 Standard_EXPORT Standard_Real Radius() const; 104 105 //! Computes the parameter on the reversed circle for 106 //! the point of parameter U on this circle. 107 //! For a circle, the returned value is: 2.*Pi - U. 108 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE; 109 110 //! Returns 0., which is the eccentricity of any circle. 111 Standard_EXPORT Standard_Real Eccentricity() const Standard_OVERRIDE; 112 113 //! Returns 0.0 114 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; 115 116 //! Returns 2*PI. 117 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; 118 119 //! returns True. 120 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; 121 122 //! returns True. The period of a circle is 2.*Pi. 123 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; 124 125 //! Returns in P the point of parameter U. 126 //! P = C + R * Cos (U) * XDir + R * Sin (U) * YDir 127 //! where C is the center of the circle , XDir the XDirection and 128 //! YDir the YDirection of the circle's local coordinate system. 129 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE; 130 131 132 //! Returns the point P of parameter U and the first derivative V1. 133 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE; 134 135 136 //! Returns the point P of parameter U, the first and second 137 //! derivatives V1 and V2. 138 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE; 139 140 141 //! Returns the point P of parameter u, the first second and third 142 //! derivatives V1 V2 and V3. 143 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE; 144 145 //! For the point of parameter U of this circle, computes 146 //! the vector corresponding to the Nth derivative. 147 //! Exceptions: Standard_RangeError if N is less than 1. 148 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; 149 150 //! Applies the transformation T to this circle. 151 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE; 152 153 //! Creates a new object which is a copy of this circle. 154 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE; 155 156 //! Dumps the content of me into the stream 157 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; 158 159 160 161 162 DEFINE_STANDARD_RTTIEXT(Geom2d_Circle,Geom2d_Conic) 163 164 protected: 165 166 167 168 169 private: 170 171 172 Standard_Real radius; 173 174 175 }; 176 177 178 179 180 181 182 183 #endif // _Geom2d_Circle_HeaderFile 184