42cf5bc1 |
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_Circ2d_HeaderFile |
16 | #define _gp_Circ2d_HeaderFile |
17 | |
18 | #include <Standard.hxx> |
19 | #include <Standard_DefineAlloc.hxx> |
20 | #include <Standard_Handle.hxx> |
21 | |
22 | #include <gp_Ax22d.hxx> |
23 | #include <Standard_Real.hxx> |
24 | #include <Standard_Boolean.hxx> |
25 | #include <gp_Ax2d.hxx> |
26 | class Standard_ConstructionError; |
27 | class gp_Ax2d; |
28 | class gp_Ax22d; |
29 | class gp_Pnt2d; |
30 | class gp_Trsf2d; |
31 | class gp_Vec2d; |
32 | |
33 | |
34 | //! Describes a circle in the plane (2D space). |
35 | //! A circle is defined by its radius and positioned in the |
36 | //! plane with a coordinate system (a gp_Ax22d object) as follows: |
37 | //! - the origin of the coordinate system is the center of the circle, and |
38 | //! - the orientation (direct or indirect) of the coordinate |
39 | //! system gives an implicit orientation to the circle (and |
40 | //! defines its trigonometric sense). |
41 | //! This positioning coordinate system is the "local |
42 | //! coordinate system" of the circle. |
43 | //! Note: when a gp_Circ2d circle is converted into a |
44 | //! Geom2d_Circle circle, some implicit properties of the |
45 | //! circle are used explicitly: |
46 | //! - the implicit orientation corresponds to the direction in |
47 | //! which parameter values increase, |
48 | //! - the starting point for parameterization is that of the "X |
49 | //! Axis" of the local coordinate system (i.e. the "X Axis" of the circle). |
50 | //! See Also |
51 | //! GccAna and Geom2dGcc packages which provide |
52 | //! functions for constructing circles defined by geometric constraints |
53 | //! gce_MakeCirc2d which provides functions for more |
54 | //! complex circle constructions |
55 | //! Geom2d_Circle which provides additional functions for |
56 | //! constructing circles and works, with the parametric |
57 | //! equations of circles in particular gp_Ax22d |
58 | class gp_Circ2d |
59 | { |
60 | public: |
61 | |
62 | DEFINE_STANDARD_ALLOC |
63 | |
64 | |
65 | //! creates an indefinite circle. |
66 | gp_Circ2d(); |
67 | |
68 | |
69 | //! The location point of XAxis is the center of the circle. |
70 | //! Warnings : |
71 | //! It is not forbidden to create a circle with Radius = 0.0 Raises ConstructionError if Radius < 0.0. |
72 | //! Raised if Radius < 0.0. |
73 | gp_Circ2d(const gp_Ax2d& XAxis, const Standard_Real Radius, const Standard_Boolean Sense = Standard_True); |
74 | |
75 | |
76 | //! Axis defines the Xaxis and Yaxis of the circle which defines |
77 | //! the origin and the sense of parametrization. |
78 | //! The location point of Axis is the center of the circle. |
79 | //! Warnings : |
80 | //! It is not forbidden to create a circle with Radius = 0.0 Raises ConstructionError if Radius < 0.0. |
81 | //! Raised if Radius < 0.0. |
82 | gp_Circ2d(const gp_Ax22d& Axis, const Standard_Real Radius); |
83 | |
84 | //! Changes the location point (center) of the circle. |
be5c3602 |
85 | void SetLocation (const gp_Pnt2d& P); |
42cf5bc1 |
86 | |
87 | //! Changes the X axis of the circle. |
88 | void SetXAxis (const gp_Ax2d& A); |
89 | |
90 | //! Changes the X axis of the circle. |
91 | void SetAxis (const gp_Ax22d& A); |
92 | |
93 | //! Changes the Y axis of the circle. |
94 | void SetYAxis (const gp_Ax2d& A); |
95 | |
96 | //! Modifies the radius of this circle. |
97 | //! This class does not prevent the creation of a circle where |
98 | //! Radius is null. |
99 | //! Exceptions |
100 | //! Standard_ConstructionError if Radius is negative. |
101 | void SetRadius (const Standard_Real Radius); |
102 | |
103 | //! Computes the area of the circle. |
104 | Standard_Real Area() const; |
105 | |
106 | |
107 | //! Returns the normalized coefficients from the implicit equation |
108 | //! of the circle : |
109 | //! A * (X**2) + B * (Y**2) + 2*C*(X*Y) + 2*D*X + 2*E*Y + F = 0.0 |
110 | void Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D, Standard_Real& E, Standard_Real& F) const; |
111 | |
112 | //! Does <me> contain P ? |
113 | //! Returns True if the distance between P and any point on |
114 | //! the circumference of the circle is lower of equal to |
115 | //! <LinearTolerance>. |
116 | Standard_Boolean Contains (const gp_Pnt2d& P, const Standard_Real LinearTolerance) const; |
117 | |
118 | |
119 | //! Computes the minimum of distance between the point P and any |
120 | //! point on the circumference of the circle. |
121 | Standard_Real Distance (const gp_Pnt2d& P) const; |
122 | |
123 | |
124 | //! Computes the square distance between <me> and the point P. |
125 | Standard_Real SquareDistance (const gp_Pnt2d& P) const; |
126 | |
127 | //! computes the circumference of the circle. |
128 | Standard_Real Length() const; |
129 | |
130 | //! Returns the location point (center) of the circle. |
131 | const gp_Pnt2d& Location() const; |
132 | |
133 | //! Returns the radius value of the circle. |
134 | Standard_Real Radius() const; |
135 | |
136 | //! returns the position of the circle. |
137 | const gp_Ax22d& Axis() const; |
138 | |
139 | //! returns the position of the circle. Idem Axis(me). |
140 | const gp_Ax22d& Position() const; |
141 | |
142 | //! returns the X axis of the circle. |
143 | gp_Ax2d XAxis() const; |
144 | |
145 | //! Returns the Y axis of the circle. |
146 | //! Reverses the direction of the circle. |
147 | gp_Ax2d YAxis() const; |
148 | |
149 | //! Reverses the orientation of the local coordinate system |
150 | //! of this circle (the "Y Direction" is reversed) and therefore |
151 | //! changes the implicit orientation of this circle. |
152 | //! Reverse assigns the result to this circle, |
153 | void Reverse(); |
154 | |
155 | //! Reverses the orientation of the local coordinate system |
156 | //! of this circle (the "Y Direction" is reversed) and therefore |
157 | //! changes the implicit orientation of this circle. |
158 | //! Reversed creates a new circle. |
0be7dbe1 |
159 | Standard_NODISCARD gp_Circ2d Reversed() const; |
42cf5bc1 |
160 | |
161 | //! Returns true if the local coordinate system is direct |
162 | //! and false in the other case. |
163 | Standard_Boolean IsDirect() const; |
164 | |
165 | Standard_EXPORT void Mirror (const gp_Pnt2d& P); |
166 | |
167 | |
168 | //! Performs the symmetrical transformation of a circle with respect |
169 | //! to the point P which is the center of the symmetry |
0be7dbe1 |
170 | Standard_EXPORT Standard_NODISCARD gp_Circ2d Mirrored (const gp_Pnt2d& P) const; |
42cf5bc1 |
171 | |
172 | Standard_EXPORT void Mirror (const gp_Ax2d& A); |
173 | |
174 | |
175 | //! Performs the symmetrical transformation of a circle with respect |
176 | //! to an axis placement which is the axis of the symmetry. |
0be7dbe1 |
177 | Standard_EXPORT Standard_NODISCARD gp_Circ2d Mirrored (const gp_Ax2d& A) const; |
42cf5bc1 |
178 | |
179 | void Rotate (const gp_Pnt2d& P, const Standard_Real Ang); |
180 | |
181 | |
182 | //! Rotates a circle. P is the center of the rotation. |
183 | //! Ang is the angular value of the rotation in radians. |
0be7dbe1 |
184 | Standard_NODISCARD gp_Circ2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const; |
42cf5bc1 |
185 | |
186 | void Scale (const gp_Pnt2d& P, const Standard_Real S); |
187 | |
188 | |
189 | //! Scales a circle. S is the scaling value. |
190 | //! Warnings : |
191 | //! If S is negative the radius stay positive but |
192 | //! the "XAxis" and the "YAxis" are reversed as for |
193 | //! an ellipse. |
0be7dbe1 |
194 | Standard_NODISCARD gp_Circ2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const; |
42cf5bc1 |
195 | |
196 | void Transform (const gp_Trsf2d& T); |
197 | |
198 | |
199 | //! Transforms a circle with the transformation T from class Trsf2d. |
0be7dbe1 |
200 | Standard_NODISCARD gp_Circ2d Transformed (const gp_Trsf2d& T) const; |
42cf5bc1 |
201 | |
202 | void Translate (const gp_Vec2d& V); |
203 | |
204 | |
205 | //! Translates a circle in the direction of the vector V. |
206 | //! The magnitude of the translation is the vector's magnitude. |
0be7dbe1 |
207 | Standard_NODISCARD gp_Circ2d Translated (const gp_Vec2d& V) const; |
42cf5bc1 |
208 | |
209 | void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2); |
210 | |
211 | |
212 | //! Translates a circle from the point P1 to the point P2. |
0be7dbe1 |
213 | Standard_NODISCARD gp_Circ2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const; |
42cf5bc1 |
214 | |
215 | |
216 | |
217 | |
218 | protected: |
219 | |
220 | |
221 | |
222 | |
223 | |
224 | private: |
225 | |
226 | |
227 | |
228 | gp_Ax22d pos; |
229 | Standard_Real radius; |
230 | |
231 | |
232 | }; |
233 | |
234 | |
235 | #include <gp_Circ2d.lxx> |
236 | |
237 | |
238 | |
239 | |
240 | |
241 | #endif // _gp_Circ2d_HeaderFile |