Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:33

0001 // Created on: 1993-03-24
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 _Geom2d_Ellipse_HeaderFile
0018 #define _Geom2d_Ellipse_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Geom2d_Conic.hxx>
0024 #include <Standard_Integer.hxx>
0025 class gp_Elips2d;
0026 class gp_Ax2d;
0027 class gp_Ax22d;
0028 class gp_Pnt2d;
0029 class gp_Vec2d;
0030 class gp_Trsf2d;
0031 class Geom2d_Geometry;
0032 
0033 
0034 class Geom2d_Ellipse;
0035 DEFINE_STANDARD_HANDLE(Geom2d_Ellipse, Geom2d_Conic)
0036 
0037 //! Describes an ellipse in the plane (2D space).
0038 //! An ellipse is defined by its major and minor radii and,
0039 //! as with any conic curve, is positioned in the plane
0040 //! with a coordinate system (gp_Ax22d object) where:
0041 //! - the origin is the center of the ellipse,
0042 //! - the "X Direction" defines the major axis, and
0043 //! - the "Y Direction" defines the minor axis.
0044 //! This coordinate system is the local coordinate system of the ellipse.
0045 //! The orientation (direct or indirect) of the local
0046 //! coordinate system gives an explicit orientation to the
0047 //! ellipse, determining the direction in which the
0048 //! parameter increases along the ellipse.
0049 //! The Geom2d_Ellipse ellipse is parameterized by an angle:
0050 //! P(U) = O + MajorRad*Cos(U)*XDir + MinorRad*Sin(U)*YDir
0051 //! where:
0052 //! - P is the point of parameter U,
0053 //! - O, XDir and YDir are respectively the origin, "X
0054 //! Direction" and "Y Direction" of its local coordinate system,
0055 //! - MajorRad and MinorRad are the major and
0056 //! minor radii of the ellipse.
0057 //! The "X Axis" of the local coordinate system therefore
0058 //! defines the origin of the parameter of the ellipse.
0059 //! An ellipse is a closed and periodic curve. The period
0060 //! is 2.*Pi and the parameter range is [ 0,2.*Pi [.
0061 //! See Also
0062 //! GCE2d_MakeEllipse which provides functions for
0063 //! more complex ellipse constructions
0064 //! gp_Ax22d
0065 //! gp_Elips2d for an equivalent, non-parameterized data structure
0066 class Geom2d_Ellipse : public Geom2d_Conic
0067 {
0068 
0069 public:
0070 
0071   
0072 
0073   //! Creates an ellipse by conversion of the gp_Elips2d ellipse E.
0074   Standard_EXPORT Geom2d_Ellipse(const gp_Elips2d& E);
0075   
0076   //! Creates an ellipse defined by its major and minor radii,
0077   //! MajorRadius and MinorRadius, and positioned
0078   //! in the plane by its major axis MajorAxis; the
0079   //! center of the ellipse is the origin of MajorAxis
0080   //! and the unit vector of MajorAxis is the "X
0081   //! Direction" of the local coordinate system of the
0082   //! ellipse; this coordinate system is direct if Sense
0083   //! is true (default value) or indirect if Sense is false.
0084   //! Warnings :
0085   //! It is not forbidden to create an ellipse with MajorRadius =
0086   //! MinorRadius.
0087   //! Exceptions
0088   //! Standard_ConstructionError if:
0089   //! - MajorRadius is less than MinorRadius, or
0090   //! - MinorRadius is less than 0.
0091   Standard_EXPORT Geom2d_Ellipse(const gp_Ax2d& MajorAxis, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Boolean Sense = Standard_True);
0092   
0093   //! Creates an ellipse defined by its major and minor radii,
0094   //! MajorRadius and MinorRadius, where the
0095   //! coordinate system Axis locates the ellipse and
0096   //! defines its orientation in the plane such that:
0097   //! - the center of the ellipse is the origin of Axis,
0098   //! - the "X Direction" of Axis defines the major
0099   //! axis of the ellipse,
0100   //! - the "Y Direction" of Axis defines the minor
0101   //! axis of the ellipse,
0102   //! - the orientation of Axis (direct or indirect)
0103   //! gives the orientation of the ellipse.
0104   //! Warnings :
0105   //! It is not forbidden to create an ellipse with MajorRadius =
0106   //! MinorRadius.
0107   //! Exceptions
0108   //! Standard_ConstructionError if:
0109   //! - MajorRadius is less than MinorRadius, or
0110   //! - MinorRadius is less than 0.
0111   Standard_EXPORT Geom2d_Ellipse(const gp_Ax22d& Axis, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
0112   
0113   //! Converts the gp_Elips2d ellipse E into this ellipse.
0114   Standard_EXPORT void SetElips2d (const gp_Elips2d& E);
0115   
0116   //! Assigns a value to the major radius of this ellipse.
0117   //! Exceptions
0118   //! Standard_ConstructionError if:
0119   //! - the major radius of this ellipse becomes less than
0120   //! the minor radius, or
0121   //! - MinorRadius is less than 0.
0122   Standard_EXPORT void SetMajorRadius (const Standard_Real MajorRadius);
0123   
0124   //! Assigns a value to the minor radius of this ellipse.
0125   //! Exceptions
0126   //! Standard_ConstructionError if:
0127   //! - the major radius of this ellipse becomes less than
0128   //! the minor radius, or
0129   //! - MinorRadius is less than 0.
0130   Standard_EXPORT void SetMinorRadius (const Standard_Real MinorRadius);
0131   
0132   //! Converts this ellipse into a gp_Elips2d ellipse.
0133   Standard_EXPORT gp_Elips2d Elips2d() const;
0134   
0135   //! Computes the parameter on the reversed ellipse for
0136   //! the point of parameter U on this ellipse.
0137   //! For an ellipse, the returned value is: 2.*Pi - U.
0138   Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
0139   
0140   //! Computes the directrices of this ellipse.
0141   //! This directrix is the line normal to the XAxis of the ellipse
0142   //! in the local plane (Z = 0) at a distance d = MajorRadius / e
0143   //! from the center of the ellipse, where e is the eccentricity of
0144   //! the ellipse.
0145   //! This line is parallel to the "YAxis". The intersection point
0146   //! between directrix1 and the "XAxis" is the "Location" point
0147   //! of the directrix1. This point is on the positive side of
0148   //! the "XAxis".
0149   //! Raises ConstructionError if Eccentricity = 0.0. (The ellipse degenerates
0150   //! into a circle)
0151   Standard_EXPORT gp_Ax2d Directrix1() const;
0152   
0153 
0154   //! This line is obtained by the symmetrical transformation
0155   //! of "Directrix1" with respect to the "YAxis" of the ellipse.
0156   //! Raises ConstructionError if Eccentricity = 0.0. (The ellipse degenerates into a
0157   //! circle).
0158   Standard_EXPORT gp_Ax2d Directrix2() const;
0159   
0160 
0161   //! Returns the eccentricity of the ellipse  between 0.0 and 1.0
0162   //! If f is the distance between the center of the ellipse and
0163   //! the Focus1 then the eccentricity e = f / MajorRadius.
0164   //! Returns 0 if MajorRadius = 0
0165   Standard_EXPORT Standard_Real Eccentricity() const Standard_OVERRIDE;
0166   
0167 
0168   //! Computes the focal distance. The focal distance is the distance between the center
0169   //! and a focus of the ellipse.
0170   Standard_EXPORT Standard_Real Focal() const;
0171   
0172 
0173   //! Returns the first focus of the ellipse. This focus is on the
0174   //! positive side of the "XAxis" of the ellipse.
0175   Standard_EXPORT gp_Pnt2d Focus1() const;
0176   
0177 
0178   //! Returns the second focus of the ellipse. This focus is on
0179   //! the negative side of the "XAxis" of the ellipse.
0180   Standard_EXPORT gp_Pnt2d Focus2() const;
0181   
0182   //! Returns the major radius of this ellipse.
0183   Standard_EXPORT Standard_Real MajorRadius() const;
0184   
0185   //! Returns the minor radius of this ellipse.
0186   Standard_EXPORT Standard_Real MinorRadius() const;
0187   
0188 
0189   //! Computes the parameter of this ellipse. This value is
0190   //! given by the formula p = (1 - e * e) * MajorRadius where e is the eccentricity
0191   //! of the ellipse.
0192   //! Returns 0 if MajorRadius = 0
0193   Standard_EXPORT Standard_Real Parameter() const;
0194   
0195   //! Returns the value of the first parameter of this
0196   //! ellipse. This is  0.0, which gives the start point of this ellipse.
0197   //! The start point and end point of an ellipse are coincident.
0198   Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
0199   
0200   //! Returns the value of the  last parameter of this
0201   //! ellipse. This is  2.*Pi, which gives the end point of this ellipse.
0202   //! The start point and end point of an ellipse are coincident.
0203   Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
0204   
0205   //! return True.
0206   Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
0207   
0208   //! return True.
0209   Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
0210   
0211   //! Returns in P the point of parameter U.
0212   //! P = C + MajorRadius * Cos (U) * XDir + MinorRadius * Sin (U) * YDir
0213   //! where C is the center of the ellipse , XDir the direction of
0214   //! the "XAxis" and "YDir" the "YAxis" of the ellipse.
0215   Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
0216   
0217   Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE;
0218   
0219 
0220   //! Returns the point P of parameter U. The vectors V1 and V2
0221   //! are the first and second derivatives at this point.
0222   Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
0223   
0224 
0225   //! Returns the point P of parameter U, the first second and
0226   //! third derivatives V1 V2 and V3.
0227   Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
0228   
0229   //! For the point of parameter U of this ellipse,
0230   //! computes the vector corresponding to the Nth derivative.
0231   //! Exceptions Standard_RangeError if N is less than 1.
0232   Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
0233   
0234   //! Applies the transformation T to this ellipse.
0235   Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
0236   
0237   //! Creates a new object which is a copy of this ellipse.
0238   Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
0239 
0240   //! Dumps the content of me into the stream
0241   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0242 
0243 
0244 
0245 
0246   DEFINE_STANDARD_RTTIEXT(Geom2d_Ellipse,Geom2d_Conic)
0247 
0248 protected:
0249 
0250 
0251 
0252 
0253 private:
0254 
0255 
0256   Standard_Real majorRadius;
0257   Standard_Real minorRadius;
0258 
0259 
0260 };
0261 
0262 
0263 
0264 
0265 
0266 
0267 
0268 #endif // _Geom2d_Ellipse_HeaderFile