0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / Geom / Geom_Ellipse.hxx
1 // Created on: 1993-03-10
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 _Geom_Ellipse_HeaderFile
18 #define _Geom_Ellipse_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Standard_Real.hxx>
24 #include <Geom_Conic.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Integer.hxx>
27 class Standard_ConstructionError;
28 class Standard_RangeError;
29 class gp_Elips;
30 class gp_Ax2;
31 class gp_Ax1;
32 class gp_Pnt;
33 class gp_Vec;
34 class gp_Trsf;
35 class Geom_Geometry;
36
37
38 class Geom_Ellipse;
39 DEFINE_STANDARD_HANDLE(Geom_Ellipse, Geom_Conic)
40
41 //! Describes an ellipse in 3D space.
42 //! An ellipse is defined by its major and minor radii and,
43 //! as with any conic curve, is positioned in space with a
44 //! right-handed coordinate system (gp_Ax2 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 //! The origin, "X Direction" and "Y Direction" of this
49 //! coordinate system define the plane of the ellipse. The
50 //! coordinate system is the local coordinate system of the ellipse.
51 //! The "main Direction" of this coordinate system is the
52 //! vector normal to the plane of the ellipse. The axis, of
53 //! which the origin and unit vector are respectively the
54 //! origin and "main Direction" of the local coordinate
55 //! system, is termed the "Axis" or "main Axis" of the ellipse.
56 //! The "main Direction" of the local coordinate system
57 //! gives an explicit orientation to the ellipse (definition of
58 //! the trigonometric sense), determining the direction in
59 //! which the parameter increases along the ellipse.
60 //! The Geom_Ellipse ellipse is parameterized by an angle:
61 //! P(U) = O + MajorRad*Cos(U)*XDir + MinorRad*Sin(U)*YDir
62 //! where:
63 //! - P is the point of parameter U,
64 //! - O, XDir and YDir are respectively the origin, "X
65 //! Direction" and "Y Direction" of its local coordinate system,
66 //! - MajorRad and MinorRad are the major and minor radii of the ellipse.
67 //! The "X Axis" of the local coordinate system therefore
68 //! defines the origin of the parameter of the ellipse.
69 //! An ellipse is a closed and periodic curve. The period
70 //! is 2.*Pi and the parameter range is [ 0, 2.*Pi [.
71 class Geom_Ellipse : public Geom_Conic
72 {
73
74 public:
75
76   
77   //! Constructs an ellipse by conversion of the gp_Elips ellipse E.
78   Standard_EXPORT Geom_Ellipse(const gp_Elips& E);
79   
80   //! Constructs an ellipse
81   //! defined by its major and minor radii, MajorRadius
82   //! and MinorRadius, where A2 locates the ellipse
83   //! and defines its orientation in 3D space such that:
84   //! - the center of the ellipse is the origin of A2,
85   //! - the "X Direction" of A2 defines the major axis
86   //! of the ellipse, i.e. the major radius
87   //! MajorRadius is measured along this axis,
88   //! - the "Y Direction" of A2 defines the minor axis
89   //! of the ellipse, i.e. the minor radius
90   //! MinorRadius is measured along this axis,
91   //! - A2 is the local coordinate system of the ellipse.
92   //! Exceptions
93   //! Standard_ConstructionError if:
94   //! - MajorRadius is less than MinorRadius, or
95   //! - MinorRadius is less than 0.
96   //! Warning The Geom package does not prevent the
97   //! construction of an ellipse where MajorRadius and
98   //! MinorRadius are equal.
99   Standard_EXPORT Geom_Ellipse(const gp_Ax2& A2, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
100   
101   //! Converts the gp_Elips ellipse E into this ellipse.
102   Standard_EXPORT void SetElips (const gp_Elips& E);
103   
104   //! Assigns a value to the major radius of this ellipse.
105   //! ConstructionError raised if MajorRadius < MinorRadius.
106   Standard_EXPORT void SetMajorRadius (const Standard_Real MajorRadius);
107   
108   //! Assigns a value to the minor radius of this ellipse.
109   //! ConstructionError raised if MajorRadius < MinorRadius or if MinorRadius < 0.
110   Standard_EXPORT void SetMinorRadius (const Standard_Real MinorRadius);
111   
112
113   //! returns the non transient ellipse from gp with the same
114   Standard_EXPORT gp_Elips Elips() const;
115   
116   //! Computes the parameter on the reversed ellipse for
117   //! the point of parameter U on this ellipse.
118   //! For an ellipse, the returned value is: 2.*Pi - U.
119   Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
120   
121
122   //! This directrix is the line normal to the XAxis of the ellipse
123   //! in the local plane (Z = 0) at a distance d = MajorRadius / e
124   //! from the center of the ellipse, where e is the eccentricity of
125   //! the ellipse.
126   //! This line is parallel to the "YAxis". The intersection point
127   //! between directrix1 and the "XAxis" is the "Location" point
128   //! of the directrix1. This point is on the positive side of
129   //! the "XAxis".
130   //! Raised if Eccentricity = 0.0. (The ellipse degenerates
131   //! into a circle)
132   Standard_EXPORT gp_Ax1 Directrix1() const;
133   
134
135   //! This line is obtained by the symmetrical transformation
136   //! of "Directrix1" with respect to the "YAxis" of the ellipse.
137   //!
138   //! Raised if Eccentricity = 0.0. (The ellipse degenerates into a
139   //! circle).
140   Standard_EXPORT gp_Ax1 Directrix2() const;
141   
142
143   //! Returns the eccentricity of the ellipse  between 0.0 and 1.0
144   //! If f is the distance between the center of the ellipse and
145   //! the Focus1 then the eccentricity e = f / MajorRadius.
146   //! Returns 0 if MajorRadius = 0
147   Standard_EXPORT Standard_Real Eccentricity() const Standard_OVERRIDE;
148   
149
150   //! Computes the focal distance. It is the distance between the
151   //! the two focus of the ellipse.
152   Standard_EXPORT Standard_Real Focal() const;
153   
154
155   //! Returns the first focus of the ellipse. This focus is on the
156   //! positive side of the "XAxis" of the ellipse.
157   Standard_EXPORT gp_Pnt Focus1() const;
158   
159
160   //! Returns the second focus of the ellipse. This focus is on
161   //! the negative side of the "XAxis" of the ellipse.
162   Standard_EXPORT gp_Pnt Focus2() const;
163   
164   //! Returns the major  radius of this ellipse.
165   Standard_EXPORT Standard_Real MajorRadius() const;
166   
167   //! Returns the minor radius of this ellipse.
168   Standard_EXPORT Standard_Real MinorRadius() const;
169   
170
171   //! Returns p = (1 - e * e) * MajorRadius where e is the eccentricity
172   //! of the ellipse.
173   //! Returns 0 if MajorRadius = 0
174   Standard_EXPORT Standard_Real Parameter() const;
175   
176   //! Returns the value of the first parameter of this
177   //! ellipse. This is respectively:
178   //! - 0.0, which gives the start point of this ellipse, or
179   //! The start point and end point of an ellipse are coincident.
180   Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
181   
182   //! Returns the value of the  last parameter of this
183   //! ellipse. This is respectively:
184   //! - 2.*Pi, which gives the end point of this ellipse.
185   //! The start point and end point of an ellipse are coincident.
186   Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
187   
188   //! return True.
189   Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
190   
191   //! return True.
192   Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
193   
194   //! Returns in P the point of parameter U.
195   //! P = C + MajorRadius * Cos (U) * XDir + MinorRadius * Sin (U) * YDir
196   //! where C is the center of the ellipse , XDir the direction of
197   //! the "XAxis" and "YDir" the "YAxis" of the ellipse.
198   Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
199   
200   Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const Standard_OVERRIDE;
201   
202
203   //! Returns the point P of parameter U. The vectors V1 and V2
204   //! are the first and second derivatives at this point.
205   Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE;
206   
207
208   //! Returns the point P of parameter U, the first second and
209   //! third derivatives V1 V2 and V3.
210   Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE;
211   
212   //! For the point of parameter U of this ellipse, computes
213   //! the vector corresponding to the Nth derivative.
214   //! Exceptions Standard_RangeError if N is less than 1.
215   Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
216   
217   //! Applies the transformation T to this ellipse.
218   Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE;
219   
220   //! Creates a new object which is a copy of this ellipse.
221   Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
222
223   //! Dumps the content of me into the stream
224   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
225
226
227
228
229   DEFINE_STANDARD_RTTIEXT(Geom_Ellipse,Geom_Conic)
230
231 protected:
232
233
234
235
236 private:
237
238
239   Standard_Real majorRadius;
240   Standard_Real minorRadius;
241
242
243 };
244
245
246
247
248
249
250
251 #endif // _Geom_Ellipse_HeaderFile