d2b58f1d32a5305539ea15bf7776b58aecb7d569
[occt.git] / src / gp / gp_Circ.hxx
1 // Copyright (c) 1991-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef _gp_Circ_HeaderFile
16 #define _gp_Circ_HeaderFile
17
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
21
22 #include <gp_Ax2.hxx>
23 #include <Standard_Real.hxx>
24 #include <gp_Ax1.hxx>
25 #include <Standard_Boolean.hxx>
26 class Standard_ConstructionError;
27 class gp_Ax2;
28 class gp_Ax1;
29 class gp_Pnt;
30 class gp_Trsf;
31 class gp_Vec;
32
33
34
35 //! Describes a circle in 3D space.
36 //! A circle is defined by its radius and positioned in space
37 //! with a coordinate system (a gp_Ax2 object) as follows:
38 //! -   the origin of the coordinate system is the center of the circle, and
39 //! -   the origin, "X Direction" and "Y Direction" of the
40 //! coordinate system define the plane of the circle.
41 //! This positioning coordinate system is the "local
42 //! coordinate system" of the circle. Its "main Direction"
43 //! gives the normal vector to the plane of the circle. The
44 //! "main Axis" of the coordinate system is referred to as
45 //! the "Axis" of the circle.
46 //! Note: when a gp_Circ circle is converted into a
47 //! Geom_Circle circle, some implicit properties of the
48 //! circle are used explicitly:
49 //! -   the "main Direction" of the local coordinate system
50 //! gives an implicit orientation to the circle (and defines
51 //! its trigonometric sense),
52 //! -   this orientation corresponds to the direction in
53 //! which parameter values increase,
54 //! -   the starting point for parameterization is that of the
55 //! "X Axis" of the local coordinate system (i.e. the "X Axis" of the circle).
56 //! See Also
57 //! gce_MakeCirc which provides functions for more complex circle constructions
58 //! Geom_Circle which provides additional functions for
59 //! constructing circles and works, in particular, with the
60 //! parametric equations of circles
61 class gp_Circ 
62 {
63 public:
64
65   DEFINE_STANDARD_ALLOC
66
67   
68   //! Creates an indefinite circle.
69     gp_Circ();
70   
71
72   //! A2 locates the circle and gives its orientation in 3D space.
73   //! Warnings :
74   //! It is not forbidden to create a circle with Radius = 0.0  Raises ConstructionError if Radius < 0.0
75     gp_Circ(const gp_Ax2& A2, const Standard_Real Radius);
76   
77
78   //! Changes the main axis of the circle. It is the axis
79   //! perpendicular to the plane of the circle.
80   //! Raises ConstructionError if the direction of A1
81   //! is parallel to the "XAxis" of the circle.
82     void SetAxis (const gp_Ax1& A1);
83   
84
85   //! Changes the "Location" point (center) of the circle.
86     void SetLocation (const gp_Pnt& P);
87   
88   //! Changes the position of the circle.
89     void SetPosition (const gp_Ax2& A2);
90   
91   //! Modifies the radius of this circle.
92   //! Warning. This class does not prevent the creation of a circle where Radius is null.
93   //! Exceptions
94   //! Standard_ConstructionError if Radius is negative.
95     void SetRadius (const Standard_Real Radius);
96   
97   //! Computes the area of the circle.
98     Standard_Real Area() const;
99   
100
101   //! Returns the main axis of the circle.
102   //! It is the axis perpendicular to the plane of the circle,
103   //! passing through the "Location" point (center) of the circle.
104     const gp_Ax1& Axis() const;
105   
106   //! Computes the circumference of the circle.
107     Standard_Real Length() const;
108   
109
110   //! Returns the center of the circle. It is the
111   //! "Location" point of the local coordinate system
112   //! of the circle
113     const gp_Pnt& Location() const;
114   
115
116   //! Returns the position of the circle.
117   //! It is the local coordinate system of the circle.
118     const gp_Ax2& Position() const;
119   
120   //! Returns the radius of this circle.
121     Standard_Real Radius() const;
122   
123
124   //! Returns the "XAxis" of the circle.
125   //! This axis is perpendicular to the axis of the conic.
126   //! This axis and the "Yaxis" define the plane of the conic.
127     gp_Ax1 XAxis() const;
128   
129
130   //! Returns the "YAxis" of the circle.
131   //! This axis and the "Xaxis" define the plane of the conic.
132   //! The "YAxis" is perpendicular to the "Xaxis".
133     gp_Ax1 YAxis() const;
134   
135
136   //! Computes the minimum of distance between the point P and
137   //! any point on the circumference of the circle.
138     Standard_Real Distance (const gp_Pnt& P) const;
139   
140
141   //! Computes the square distance between <me> and the point P.
142     Standard_Real SquareDistance (const gp_Pnt& P) const;
143   
144
145   //! Returns True if the point P is on the circumference.
146   //! The distance between <me> and <P> must be lower or
147   //! equal to LinearTolerance.
148     Standard_Boolean Contains (const gp_Pnt& P, const Standard_Real LinearTolerance) const;
149   
150   Standard_EXPORT void Mirror (const gp_Pnt& P);
151   
152
153   //! Performs the symmetrical transformation of a circle
154   //! with respect to the point P which is the center of the
155   //! symmetry.
156   Standard_EXPORT Standard_NODISCARD gp_Circ Mirrored (const gp_Pnt& P) const;
157   
158   Standard_EXPORT void Mirror (const gp_Ax1& A1);
159   
160
161   //! Performs the symmetrical transformation of a circle with
162   //! respect to an axis placement which is the axis of the
163   //! symmetry.
164   Standard_EXPORT Standard_NODISCARD gp_Circ Mirrored (const gp_Ax1& A1) const;
165   
166   Standard_EXPORT void Mirror (const gp_Ax2& A2);
167   
168
169   //! Performs the symmetrical transformation of a circle with respect
170   //! to a plane. The axis placement A2 locates the plane of the
171   //! of the symmetry : (Location, XDirection, YDirection).
172   Standard_EXPORT Standard_NODISCARD gp_Circ Mirrored (const gp_Ax2& A2) const;
173   
174     void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
175   
176
177   //! Rotates a circle. A1 is the axis of the rotation.
178   //! Ang is the angular value of the rotation in radians.
179     Standard_NODISCARD gp_Circ Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
180   
181     void Scale (const gp_Pnt& P, const Standard_Real S);
182   
183
184   //! Scales a circle. S is the scaling value.
185   //! Warnings :
186   //! If S is negative the radius stay positive but
187   //! the "XAxis" and the "YAxis" are  reversed as for
188   //! an ellipse.
189     Standard_NODISCARD gp_Circ Scaled (const gp_Pnt& P, const Standard_Real S) const;
190   
191     void Transform (const gp_Trsf& T);
192   
193
194   //! Transforms a circle with the transformation T from class Trsf.
195     Standard_NODISCARD gp_Circ Transformed (const gp_Trsf& T) const;
196   
197     void Translate (const gp_Vec& V);
198   
199
200   //! Translates a circle in the direction of the vector V.
201   //! The magnitude of the translation is the vector's magnitude.
202     Standard_NODISCARD gp_Circ Translated (const gp_Vec& V) const;
203   
204     void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
205   
206
207   //! Translates a circle from the point P1 to the point P2.
208     Standard_NODISCARD gp_Circ Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
209
210
211
212
213 protected:
214
215
216
217
218
219 private:
220
221
222
223   gp_Ax2 pos;
224   Standard_Real radius;
225
226
227 };
228
229
230 #include <gp_Circ.lxx>
231
232
233
234
235
236 #endif // _gp_Circ_HeaderFile