Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/Geom2d_Ellipse.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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