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