0026912: CLang 3.6.2 compiler warning [-Winconsistent-missing-override]
[occt.git] / src / Geom2d / Geom2d_Ellipse.hxx
1 // Created on: 1993-03-24
2 // Created by: JCV
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_Ellipse_HeaderFile
18 #define _Geom2d_Ellipse_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 Standard_ConstructionError;
28 class Standard_RangeError;
29 class gp_Elips2d;
30 class gp_Ax2d;
31 class gp_Ax22d;
32 class gp_Pnt2d;
33 class gp_Vec2d;
34 class gp_Trsf2d;
35 class Geom2d_Geometry;
36
37
38 class Geom2d_Ellipse;
39 DEFINE_STANDARD_HANDLE(Geom2d_Ellipse, Geom2d_Conic)
40
41 //! Describes an ellipse in the plane (2D space).
42 //! An ellipse is defined by its major and minor radii and,
43 //! as with any conic curve, is positioned in the plane
44 //! with a coordinate system (gp_Ax22d object) where:
45 //! - the origin is the center of the ellipse,
46 //! - the "X Direction" defines the major axis, and
47 //! - the "Y Direction" defines the minor axis.
48 //! This coordinate system is the local coordinate system of the ellipse.
49 //! The orientation (direct or indirect) of the local
50 //! coordinate system gives an explicit orientation to the
51 //! ellipse, determining the direction in which the
52 //! parameter increases along the ellipse.
53 //! The Geom2d_Ellipse ellipse is parameterized by an angle:
54 //! P(U) = O + MajorRad*Cos(U)*XDir + MinorRad*Sin(U)*YDir
55 //! where:
56 //! - P is the point of parameter U,
57 //! - O, XDir and YDir are respectively the origin, "X
58 //! Direction" and "Y Direction" of its local coordinate system,
59 //! - MajorRad and MinorRad are the major and
60 //! minor radii of the ellipse.
61 //! The "X Axis" of the local coordinate system therefore
62 //! defines the origin of the parameter of the ellipse.
63 //! An ellipse is a closed and periodic curve. The period
64 //! is 2.*Pi and the parameter range is [ 0,2.*Pi [.
65 //! See Also
66 //! GCE2d_MakeEllipse which provides functions for
67 //! more complex ellipse constructions
68 //! gp_Ax22d
69 //! gp_Elips2d for an equivalent, non-parameterized data structure
70 class Geom2d_Ellipse : public Geom2d_Conic
71 {
72
73 public:
74
75   
76
77   //! Creates an ellipse by conversion of the gp_Elips2d ellipse E.
78   Standard_EXPORT Geom2d_Ellipse(const gp_Elips2d& E);
79   
80   //! Creates an ellipse defined by its major and minor radii,
81   //! MajorRadius and MinorRadius, and positioned
82   //! in the plane by its major axis MajorAxis; the
83   //! center of the ellipse is the origin of MajorAxis
84   //! and the unit vector of MajorAxis is the "X
85   //! Direction" of the local coordinate system of the
86   //! ellipse; this coordinate system is direct if Sense
87   //! is true (default value) or indirect if Sense is false.
88   //! Warnings :
89   //! It is not forbidden to create an ellipse with MajorRadius =
90   //! MinorRadius.
91   //! Exceptions
92   //! Standard_ConstructionError if:
93   //! - MajorRadius is less than MinorRadius, or
94   //! - MinorRadius is less than 0.
95   Standard_EXPORT Geom2d_Ellipse(const gp_Ax2d& MajorAxis, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Boolean Sense = Standard_True);
96   
97   //! Creates an ellipse defined by its major and minor radii,
98   //! MajorRadius and MinorRadius, where the
99   //! coordinate system Axis locates the ellipse and
100   //! defines its orientation in the plane such that:
101   //! - the center of the ellipse is the origin of Axis,
102   //! - the "X Direction" of Axis defines the major
103   //! axis of the ellipse,
104   //! - the "Y Direction" of Axis defines the minor
105   //! axis of the ellipse,
106   //! - the orientation of Axis (direct or indirect)
107   //! gives the orientation of the ellipse.
108   //! Warnings :
109   //! It is not forbidden to create an ellipse with MajorRadius =
110   //! MinorRadius.
111   //! Exceptions
112   //! Standard_ConstructionError if:
113   //! - MajorRadius is less than MinorRadius, or
114   //! - MinorRadius is less than 0.
115   Standard_EXPORT Geom2d_Ellipse(const gp_Ax22d& Axis, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
116   
117   //! Converts the gp_Elips2d ellipse E into this ellipse.
118   Standard_EXPORT void SetElips2d (const gp_Elips2d& E);
119   
120   //! Assigns a value to the major radius of this ellipse.
121   //! Exceptions
122   //! Standard_ConstructionError if:
123   //! - the major radius of this ellipse becomes less than
124   //! the minor radius, or
125   //! - MinorRadius is less than 0.
126   Standard_EXPORT void SetMajorRadius (const Standard_Real MajorRadius);
127   
128   //! Assigns a value to the minor radius of this ellipse.
129   //! Exceptions
130   //! Standard_ConstructionError if:
131   //! - the major radius of this ellipse becomes less than
132   //! the minor radius, or
133   //! - MinorRadius is less than 0.
134   Standard_EXPORT void SetMinorRadius (const Standard_Real MinorRadius);
135   
136   //! Converts this ellipse into a gp_Elips2d ellipse.
137   Standard_EXPORT gp_Elips2d Elips2d() const;
138   
139   //! Computes the parameter on the reversed ellipse for
140   //! the point of parameter U on this ellipse.
141   //! For an ellipse, the returned value is: 2.*Pi - U.
142   Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
143   
144   //! Computes the directrices of this ellipse.
145   //! This directrix is the line normal to the XAxis of the ellipse
146   //! in the local plane (Z = 0) at a distance d = MajorRadius / e
147   //! from the center of the ellipse, where e is the eccentricity of
148   //! the ellipse.
149   //! This line is parallel to the "YAxis". The intersection point
150   //! between directrix1 and the "XAxis" is the "Location" point
151   //! of the directrix1. This point is on the positive side of
152   //! the "XAxis".
153   //! Raises ConstructionError if Eccentricity = 0.0. (The ellipse degenerates
154   //! into a circle)
155   Standard_EXPORT gp_Ax2d Directrix1() const;
156   
157
158   //! This line is obtained by the symmetrical transformation
159   //! of "Directrix1" with respect to the "YAxis" of the ellipse.
160   //! Raises ConstructionError if Eccentricity = 0.0. (The ellipse degenerates into a
161   //! circle).
162   Standard_EXPORT gp_Ax2d Directrix2() const;
163   
164
165   //! Returns the eccentricity of the ellipse  between 0.0 and 1.0
166   //! If f is the distance between the center of the ellipse and
167   //! the Focus1 then the eccentricity e = f / MajorRadius.
168   //! Returns 0 if MajorRadius = 0
169   Standard_EXPORT Standard_Real Eccentricity() const Standard_OVERRIDE;
170   
171
172   //! Computes the focal distance. The focal distance is the distance between the center
173   //! and a focus of the ellipse.
174   Standard_EXPORT Standard_Real Focal() const;
175   
176
177   //! Returns the first focus of the ellipse. This focus is on the
178   //! positive side of the "XAxis" of the ellipse.
179   Standard_EXPORT gp_Pnt2d Focus1() const;
180   
181
182   //! Returns the second focus of the ellipse. This focus is on
183   //! the negative side of the "XAxis" of the ellipse.
184   Standard_EXPORT gp_Pnt2d Focus2() const;
185   
186   //! Returns the major radius of this ellipse.
187   Standard_EXPORT Standard_Real MajorRadius() const;
188   
189   //! Returns the minor radius of this ellipse.
190   Standard_EXPORT Standard_Real MinorRadius() const;
191   
192
193   //! Computes the parameter of this ellipse. This value is
194   //! given by the formula p = (1 - e * e) * MajorRadius where e is the eccentricity
195   //! of the ellipse.
196   //! Returns 0 if MajorRadius = 0
197   Standard_EXPORT Standard_Real Parameter() const;
198   
199   //! Returns the value of the first parameter of this
200   //! ellipse. This is  0.0, which gives the start point of this ellipse.
201   //! The start point and end point of an ellipse are coincident.
202   Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
203   
204   //! Returns the value of the  last parameter of this
205   //! ellipse. This is  2.*Pi, which gives the end point of this ellipse.
206   //! The start point and end point of an ellipse are coincident.
207   Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
208   
209   //! return True.
210   Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
211   
212   //! return True.
213   Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
214   
215   //! Returns in P the point of parameter U.
216   //! P = C + MajorRadius * Cos (U) * XDir + MinorRadius * Sin (U) * YDir
217   //! where C is the center of the ellipse , XDir the direction of
218   //! the "XAxis" and "YDir" the "YAxis" of the ellipse.
219   Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
220   
221   Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE;
222   
223
224   //! Returns the point P of parameter U. The vectors V1 and V2
225   //! are the first and second derivatives at this point.
226   Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
227   
228
229   //! Returns the point P of parameter U, the first second and
230   //! third derivatives V1 V2 and V3.
231   Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
232   
233   //! For the point of parameter U of this ellipse,
234   //! computes the vector corresponding to the Nth derivative.
235   //! Exceptions Standard_RangeError if N is less than 1.
236   Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
237   
238   //! Applies the transformation T to this ellipse.
239   Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
240   
241   //! Creates a new object which is a copy of this ellipse.
242   Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
243
244
245
246
247   DEFINE_STANDARD_RTTI(Geom2d_Ellipse,Geom2d_Conic)
248
249 protected:
250
251
252
253
254 private:
255
256
257   Standard_Real majorRadius;
258   Standard_Real minorRadius;
259
260
261 };
262
263
264
265
266
267
268
269 #endif // _Geom2d_Ellipse_HeaderFile