Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-28 09:18:20

0001 // Created on: 1993-03-10
0002 // Created by: JCV
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Geom_Ellipse_HeaderFile
0018 #define _Geom_Ellipse_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Geom_Conic.hxx>
0024 #include <Standard_Integer.hxx>
0025 class gp_Elips;
0026 class gp_Ax2;
0027 class gp_Ax1;
0028 class gp_Pnt;
0029 class gp_Vec;
0030 class gp_Trsf;
0031 class Geom_Geometry;
0032 
0033 class Geom_Ellipse;
0034 DEFINE_STANDARD_HANDLE(Geom_Ellipse, Geom_Conic)
0035 
0036 //! Describes an ellipse in 3D space.
0037 //! An ellipse is defined by its major and minor radii and,
0038 //! as with any conic curve, is positioned in space with a
0039 //! right-handed coordinate system (gp_Ax2 object) where:
0040 //! - the origin is the center of the ellipse,
0041 //! - the "X Direction" defines the major axis, and
0042 //! - the "Y Direction" defines the minor axis.
0043 //! The origin, "X Direction" and "Y Direction" of this
0044 //! coordinate system define the plane of the ellipse. The
0045 //! coordinate system is the local coordinate system of the ellipse.
0046 //! The "main Direction" of this coordinate system is the
0047 //! vector normal to the plane of the ellipse. The axis, of
0048 //! which the origin and unit vector are respectively the
0049 //! origin and "main Direction" of the local coordinate
0050 //! system, is termed the "Axis" or "main Axis" of the ellipse.
0051 //! The "main Direction" of the local coordinate system
0052 //! gives an explicit orientation to the ellipse (definition of
0053 //! the trigonometric sense), determining the direction in
0054 //! which the parameter increases along the ellipse.
0055 //! The Geom_Ellipse ellipse is parameterized by an angle:
0056 //! P(U) = O + MajorRad*Cos(U)*XDir + MinorRad*Sin(U)*YDir
0057 //! where:
0058 //! - P is the point of parameter U,
0059 //! - O, XDir and YDir are respectively the origin, "X
0060 //! Direction" and "Y Direction" of its local coordinate system,
0061 //! - MajorRad and MinorRad are the major and minor radii of the ellipse.
0062 //! The "X Axis" of the local coordinate system therefore
0063 //! defines the origin of the parameter of the ellipse.
0064 //! An ellipse is a closed and periodic curve. The period
0065 //! is 2.*Pi and the parameter range is [ 0, 2.*Pi [.
0066 class Geom_Ellipse : public Geom_Conic
0067 {
0068 
0069 public:
0070   //! Constructs an ellipse by conversion of the gp_Elips ellipse E.
0071   Standard_EXPORT Geom_Ellipse(const gp_Elips& E);
0072 
0073   //! Constructs an ellipse
0074   //! defined by its major and minor radii, MajorRadius
0075   //! and MinorRadius, where A2 locates the ellipse
0076   //! and defines its orientation in 3D space such that:
0077   //! - the center of the ellipse is the origin of A2,
0078   //! - the "X Direction" of A2 defines the major axis
0079   //! of the ellipse, i.e. the major radius
0080   //! MajorRadius is measured along this axis,
0081   //! - the "Y Direction" of A2 defines the minor axis
0082   //! of the ellipse, i.e. the minor radius
0083   //! MinorRadius is measured along this axis,
0084   //! - A2 is the local coordinate system of the ellipse.
0085   //! Exceptions
0086   //! Standard_ConstructionError if:
0087   //! - MajorRadius is less than MinorRadius, or
0088   //! - MinorRadius is less than 0.
0089   //! Warning The Geom package does not prevent the
0090   //! construction of an ellipse where MajorRadius and
0091   //! MinorRadius are equal.
0092   Standard_EXPORT Geom_Ellipse(const gp_Ax2&       A2,
0093                                const Standard_Real MajorRadius,
0094                                const Standard_Real MinorRadius);
0095 
0096   //! Converts the gp_Elips ellipse E into this ellipse.
0097   Standard_EXPORT void SetElips(const gp_Elips& E);
0098 
0099   //! Assigns a value to the major radius of this ellipse.
0100   //! ConstructionError raised if MajorRadius < MinorRadius.
0101   Standard_EXPORT void SetMajorRadius(const Standard_Real MajorRadius);
0102 
0103   //! Assigns a value to the minor radius of this ellipse.
0104   //! ConstructionError raised if MajorRadius < MinorRadius or if MinorRadius < 0.
0105   Standard_EXPORT void SetMinorRadius(const Standard_Real MinorRadius);
0106 
0107   //! returns the non transient ellipse from gp with the same
0108   Standard_EXPORT gp_Elips Elips() const;
0109 
0110   //! Computes the parameter on the reversed ellipse for
0111   //! the point of parameter U on this ellipse.
0112   //! For an ellipse, the returned value is: 2.*Pi - U.
0113   Standard_EXPORT Standard_Real ReversedParameter(const Standard_Real U) const Standard_OVERRIDE;
0114 
0115   //! This directrix is the line normal to the XAxis of the ellipse
0116   //! in the local plane (Z = 0) at a distance d = MajorRadius / e
0117   //! from the center of the ellipse, where e is the eccentricity of
0118   //! the ellipse.
0119   //! This line is parallel to the "YAxis". The intersection point
0120   //! between directrix1 and the "XAxis" is the "Location" point
0121   //! of the directrix1. This point is on the positive side of
0122   //! the "XAxis".
0123   //! Raised if Eccentricity = 0.0. (The ellipse degenerates
0124   //! into a circle)
0125   Standard_EXPORT gp_Ax1 Directrix1() const;
0126 
0127   //! This line is obtained by the symmetrical transformation
0128   //! of "Directrix1" with respect to the "YAxis" of the ellipse.
0129   //!
0130   //! Raised if Eccentricity = 0.0. (The ellipse degenerates into a
0131   //! circle).
0132   Standard_EXPORT gp_Ax1 Directrix2() const;
0133 
0134   //! Returns the eccentricity of the ellipse  between 0.0 and 1.0
0135   //! If f is the distance between the center of the ellipse and
0136   //! the Focus1 then the eccentricity e = f / MajorRadius.
0137   //! Returns 0 if MajorRadius = 0
0138   Standard_EXPORT Standard_Real Eccentricity() const Standard_OVERRIDE;
0139 
0140   //! Computes the focal distance. It is the distance between the
0141   //! the two focus of the ellipse.
0142   Standard_EXPORT Standard_Real Focal() const;
0143 
0144   //! Returns the first focus of the ellipse. This focus is on the
0145   //! positive side of the "XAxis" of the ellipse.
0146   Standard_EXPORT gp_Pnt Focus1() const;
0147 
0148   //! Returns the second focus of the ellipse. This focus is on
0149   //! the negative side of the "XAxis" of the ellipse.
0150   Standard_EXPORT gp_Pnt Focus2() const;
0151 
0152   //! Returns the major  radius of this ellipse.
0153   Standard_EXPORT Standard_Real MajorRadius() const;
0154 
0155   //! Returns the minor radius of this ellipse.
0156   Standard_EXPORT Standard_Real MinorRadius() const;
0157 
0158   //! Returns p = (1 - e * e) * MajorRadius where e is the eccentricity
0159   //! of the ellipse.
0160   //! Returns 0 if MajorRadius = 0
0161   Standard_EXPORT Standard_Real Parameter() const;
0162 
0163   //! Returns the value of the first parameter of this
0164   //! ellipse. This is respectively:
0165   //! - 0.0, which gives the start point of this ellipse, or
0166   //! The start point and end point of an ellipse are coincident.
0167   Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
0168 
0169   //! Returns the value of the  last parameter of this
0170   //! ellipse. This is respectively:
0171   //! - 2.*Pi, which gives the end point of this ellipse.
0172   //! The start point and end point of an ellipse are coincident.
0173   Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
0174 
0175   //! return True.
0176   Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
0177 
0178   //! return True.
0179   Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
0180 
0181   //! Returns in P the point of parameter U.
0182   //! P = C + MajorRadius * Cos (U) * XDir + MinorRadius * Sin (U) * YDir
0183   //! where C is the center of the ellipse , XDir the direction of
0184   //! the "XAxis" and "YDir" the "YAxis" of the ellipse.
0185   Standard_EXPORT void D0(const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
0186 
0187   Standard_EXPORT void D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const Standard_OVERRIDE;
0188 
0189   //! Returns the point P of parameter U. The vectors V1 and V2
0190   //! are the first and second derivatives at this point.
0191   Standard_EXPORT void D2(const Standard_Real U,
0192                           gp_Pnt&             P,
0193                           gp_Vec&             V1,
0194                           gp_Vec&             V2) const Standard_OVERRIDE;
0195 
0196   //! Returns the point P of parameter U, the first second and
0197   //! third derivatives V1 V2 and V3.
0198   Standard_EXPORT void D3(const Standard_Real U,
0199                           gp_Pnt&             P,
0200                           gp_Vec&             V1,
0201                           gp_Vec&             V2,
0202                           gp_Vec&             V3) const Standard_OVERRIDE;
0203 
0204   //! For the point of parameter U of this ellipse, computes
0205   //! the vector corresponding to the Nth derivative.
0206   //! Exceptions Standard_RangeError if N is less than 1.
0207   Standard_EXPORT gp_Vec DN(const Standard_Real    U,
0208                             const Standard_Integer N) const Standard_OVERRIDE;
0209 
0210   //! Applies the transformation T to this ellipse.
0211   Standard_EXPORT void Transform(const gp_Trsf& T) Standard_OVERRIDE;
0212 
0213   //! Creates a new object which is a copy of this ellipse.
0214   Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
0215 
0216   //! Dumps the content of me into the stream
0217   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0218                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0219 
0220   DEFINE_STANDARD_RTTIEXT(Geom_Ellipse, Geom_Conic)
0221 
0222 protected:
0223 private:
0224   Standard_Real majorRadius;
0225   Standard_Real minorRadius;
0226 };
0227 
0228 #endif // _Geom_Ellipse_HeaderFile