Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 09:03:10

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_ConicalSurface_HeaderFile
0018 #define _Geom_ConicalSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Geom_ElementarySurface.hxx>
0024 
0025 class gp_Ax3;
0026 class gp_Cone;
0027 class gp_Trsf;
0028 class gp_GTrsf2d;
0029 class Geom_Geometry;
0030 
0031 //! Describes a cone.
0032 //! A cone is defined by the half-angle (can be negative) at its apex, and
0033 //! is positioned in space by a coordinate system (a
0034 //! gp_Ax3 object) and a reference radius as follows:
0035 //! - The "main Axis" of the coordinate system is the
0036 //! axis of revolution of the cone.
0037 //! - The plane defined by the origin, the "X Direction"
0038 //! and the "Y Direction" of the coordinate system is
0039 //! the reference plane of the cone. The intersection
0040 //! of the cone with this reference plane is a circle of
0041 //! radius equal to the reference radius.
0042 //! - The apex of the cone is on the negative side of
0043 //! the "main Axis" of the coordinate system if the
0044 //! half-angle is positive, and on the positive side if
0045 //! the half-angle is negative.
0046 //! This coordinate system is the "local coordinate
0047 //! system" of the cone. The following apply:
0048 //! - Rotation around its "main Axis", in the
0049 //! trigonometric sense given by the "X Direction"
0050 //! and the "Y Direction", defines the u parametric direction.
0051 //! - Its "X Axis" gives the origin for the u parameter.
0052 //! - Its "main Direction" is the v parametric direction of the cone.
0053 //! - Its origin is the origin of the v parameter.
0054 //! The parametric range of the two parameters is:
0055 //! @code
0056 //!  - [ 0, 2.*Pi ] for u, and
0057 //!  - ] -infinity, +infinity [ for v
0058 //! @endcode
0059 //! The parametric equation of the cone is:
0060 //! @code
0061 //! P(u, v) = O + (R + v*sin(Ang)) * (cos(u)*XDir + sin(u)*YDir) + v*cos(Ang)*ZDir
0062 //! @endcode
0063 //! where:
0064 //! - O, XDir, YDir and ZDir are respectively
0065 //! the origin, the "X Direction", the "Y Direction" and
0066 //! the "Z Direction" of the cone's local coordinate system,
0067 //! - Ang is the half-angle at the apex of the cone, and
0068 //! - R is the reference radius.
0069 class Geom_ConicalSurface : public Geom_ElementarySurface
0070 {
0071 
0072 public:
0073   //! A3 defines the local coordinate system of the conical surface.
0074   //! Ang is the conical surface semi-angle. Its absolute value is in range
0075   //! ]0, PI/2[.
0076   //! Radius is the radius of the circle Viso in the placement plane
0077   //! of the conical surface defined with "XAxis" and "YAxis".
0078   //! The "ZDirection" of A3 defines the direction of the surface's
0079   //! axis of symmetry.
0080   //! If the location point of A3 is the apex of the surface
0081   //! Radius = 0 .
0082   //! At the creation the parametrization of the surface is defined
0083   //! such that the normal Vector (N = D1U ^ D1V) is oriented towards
0084   //! the "outside region" of the surface.
0085   //!
0086   //! Raised if Radius < 0.0 or std::abs(Ang) < Resolution from gp or
0087   //! std::abs(Ang) >= PI/2 - Resolution
0088   Standard_EXPORT Geom_ConicalSurface(const gp_Ax3& A3, const double Ang, const double Radius);
0089 
0090   //! Creates a ConicalSurface from a non transient gp_Cone.
0091   Standard_EXPORT Geom_ConicalSurface(const gp_Cone& C);
0092 
0093   //! Set <me> so that <me> has the same geometric properties as C.
0094   Standard_EXPORT void SetCone(const gp_Cone& C);
0095 
0096   //! Changes the radius of the conical surface in the placement plane (Z = 0, V = 0).
0097   //! The local coordinate system is not modified.
0098   //! Raised if R < 0.0
0099   Standard_EXPORT void SetRadius(const double R);
0100 
0101   //! Changes the semi angle of the conical surface.
0102   //! Semi-angle can be negative. Its absolute value
0103   //! std::abs(Ang) is in range ]0,PI/2[.
0104   //! Raises ConstructionError if std::abs(Ang) < Resolution from gp or
0105   //! std::abs(Ang) >= PI/2 - Resolution
0106   Standard_EXPORT void SetSemiAngle(const double Ang);
0107 
0108   //! Returns a non transient cone with the same geometric properties as <me>.
0109   Standard_EXPORT gp_Cone Cone() const;
0110 
0111   //! Eeturn 2.PI - U.
0112   Standard_EXPORT double UReversedParameter(const double U) const final;
0113 
0114   //! Computes the u (or v) parameter on the modified surface,
0115   //! when reversing its u (or v) parametric direction,
0116   //! for any point of u parameter U (or of v parameter V) on this cone.
0117   //! In the case of a cone, these functions return respectively:
0118   //! - 2.*Pi - U, -V.
0119   Standard_EXPORT double VReversedParameter(const double V) const final;
0120 
0121   //! Changes the orientation of this cone in the v parametric direction.
0122   //! The bounds of the surface are not changed but the v parametric direction is reversed.
0123   //! As a consequence, for a cone:
0124   //! - the "main Direction" of the local coordinate system
0125   //! is reversed, and
0126   //! - the half-angle at the apex is inverted.
0127   Standard_EXPORT void VReverse() final;
0128 
0129   //! Computes the parameters on the transformed surface for
0130   //! the transform of the point of parameters U,V on <me>.
0131   //! @code
0132   //!   me->Transformed(T)->Value(U',V')
0133   //! @endcode
0134   //! is the same point as
0135   //! @code
0136   //!   me->Value(U,V).Transformed(T)
0137   //! @endcode
0138   //! Where U',V' are the new values of U,V after calling
0139   //! @code
0140   //!   me->TransformParameters(U,V,T)
0141   //! @endcode
0142   //! This method multiplies V by T.ScaleFactor()
0143   Standard_EXPORT void TransformParameters(double& U, double& V, const gp_Trsf& T) const final;
0144 
0145   //! Returns a 2d transformation used to find the new
0146   //! parameters of a point on the transformed surface.
0147   //! @code
0148   //!   me->Transformed(T)->Value(U',V')
0149   //! @endcode
0150   //! is the same point as
0151   //! @code
0152   //!   me->Value(U,V).Transformed(T)
0153   //! @endcode
0154   //! Where U',V' are obtained by transforming U,V with the 2d transformation returned by
0155   //! @code
0156   //!   me->ParametricTransformation(T)
0157   //! @endcode
0158   //! This method returns a scale centered on the U axis with T.ScaleFactor
0159   Standard_EXPORT gp_GTrsf2d ParametricTransformation(const gp_Trsf& T) const final;
0160 
0161   //! Computes the apex of this cone. It is on the negative
0162   //! side of the axis of revolution of this cone if the
0163   //! half-angle at the apex is positive, and on the positive
0164   //! side of the "main Axis" if the half-angle is negative.
0165   Standard_EXPORT gp_Pnt Apex() const;
0166 
0167   //! The conical surface is infinite in the V direction so
0168   //! V1 = Realfirst from Standard and V2 = RealLast.
0169   //! U1 = 0 and U2 = 2*PI.
0170   Standard_EXPORT void Bounds(double& U1, double& U2, double& V1, double& V2) const final;
0171 
0172   //! Returns the coefficients of the implicit equation of the
0173   //! quadric in the absolute cartesian coordinate system :
0174   //! These coefficients are normalized.
0175   //! @code
0176   //!   A1.X**2 + A2.Y**2 + A3.Z**2 + 2.(B1.X.Y + B2.X.Z + B3.Y.Z) + 2.(C1.X + C2.Y + C3.Z) + D =
0177   //!   0.0
0178   //! @endcode
0179   Standard_EXPORT void Coefficients(double& A1,
0180                                     double& A2,
0181                                     double& A3,
0182                                     double& B1,
0183                                     double& B2,
0184                                     double& B3,
0185                                     double& C1,
0186                                     double& C2,
0187                                     double& C3,
0188                                     double& D) const;
0189 
0190   //! Returns the reference radius of this cone.
0191   //! The reference radius is the radius of the circle formed
0192   //! by the intersection of this cone and its reference
0193   //! plane (i.e. the plane defined by the origin, "X
0194   //! Direction" and "Y Direction" of the local coordinate
0195   //! system of this cone).
0196   //! If the apex of this cone is on the origin of the local
0197   //! coordinate system of this cone, the returned value is 0.
0198   Standard_EXPORT double RefRadius() const;
0199 
0200   //! Returns the semi-angle at the apex of this cone.
0201   //! Attention! Semi-angle can be negative.
0202   Standard_EXPORT double SemiAngle() const;
0203 
0204   //! returns True.
0205   Standard_EXPORT bool IsUClosed() const final;
0206 
0207   //! returns False.
0208   Standard_EXPORT bool IsVClosed() const final;
0209 
0210   //! Returns True.
0211   Standard_EXPORT bool IsUPeriodic() const final;
0212 
0213   //! Returns False.
0214   Standard_EXPORT bool IsVPeriodic() const final;
0215 
0216   //! Builds the U isoparametric line of this cone.
0217   //! The origin of this line is on the reference plane of this cone
0218   //! (i.e. the plane defined by the origin, "X Direction"
0219   //! and "Y Direction" of the local coordinate system of this cone).
0220   Standard_EXPORT occ::handle<Geom_Curve> UIso(const double U) const final;
0221 
0222   //! Builds the V isoparametric circle of this cone.
0223   //! It is the circle on this cone, located in the plane of Z
0224   //! coordinate V*cos(Semi-Angle) in the local coordinate system of this cone.
0225   //! The "Axis" of this circle is the axis of revolution of this cone.
0226   //! Its starting point is defined by the "X Direction" of this cone.
0227   //! Warning
0228   //! If the V isoparametric circle is close to the apex of
0229   //! this cone, the radius of the circle becomes very small.
0230   //! It is possible to have a circle with radius equal to 0.0.
0231   Standard_EXPORT occ::handle<Geom_Curve> VIso(const double V) const final;
0232 
0233   //! Computes the point P (U, V) on the surface.
0234   //! @code
0235   //!   P (U, V) = Loc +
0236   //!              (RefRadius + V * sin (Semi-Angle)) * (cos (U) * XDir + sin (U) * YDir) +
0237   //!              V * cos (Semi-Angle) * ZDir
0238   //! @endcode
0239   //! where Loc is the origin of the placement plane (XAxis, YAxis)
0240   //! XDir is the direction of the XAxis and YDir the direction of the YAxis.
0241   Standard_EXPORT gp_Pnt EvalD0(const double U, const double V) const final;
0242 
0243   //! Computes the current point and the first derivatives in the directions U and V.
0244   Standard_EXPORT Geom_Surface::ResD1 EvalD1(const double U, const double V) const final;
0245 
0246   //! Computes the current point, the first and the second derivatives in the directions U and V.
0247   Standard_EXPORT Geom_Surface::ResD2 EvalD2(const double U, const double V) const final;
0248 
0249   //! Computes the current point, the first,the second and the third
0250   //! derivatives in the directions U and V.
0251   Standard_EXPORT Geom_Surface::ResD3 EvalD3(const double U, const double V) const final;
0252 
0253   //! Computes the derivative of order Nu in the u
0254   //! parametric direction, and Nv in the v parametric
0255   //! direction at the point of parameters (U, V) of this cone.
0256   //! Exceptions
0257   //! Standard_RangeError if:
0258   //! - Nu + Nv is less than 1,
0259   //! - Nu or Nv is negative.
0260   Standard_EXPORT gp_Vec EvalDN(const double U,
0261                                 const double V,
0262                                 const int    Nu,
0263                                 const int    Nv) const final;
0264 
0265   //! Applies the transformation T to this cone.
0266   Standard_EXPORT void Transform(const gp_Trsf& T) final;
0267 
0268   //! Creates a new object which is a copy of this cone.
0269   Standard_EXPORT occ::handle<Geom_Geometry> Copy() const final;
0270   //! Dumps the content of me into the stream
0271   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const final;
0272 
0273   DEFINE_STANDARD_RTTIEXT(Geom_ConicalSurface, Geom_ElementarySurface)
0274 
0275 private:
0276   double radius;
0277   double semiAngle;
0278 };
0279 
0280 #endif // _Geom_ConicalSurface_HeaderFile