Back to home page

EIC code displayed by LXR

 
 

    


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

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_ToroidalSurface_HeaderFile
0018 #define _Geom_ToroidalSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Geom_ElementarySurface.hxx>
0024 #include <TColStd_Array1OfReal.hxx>
0025 #include <Standard_Integer.hxx>
0026 class gp_Ax3;
0027 class gp_Torus;
0028 class Geom_Curve;
0029 class gp_Pnt;
0030 class gp_Vec;
0031 class gp_Trsf;
0032 class Geom_Geometry;
0033 
0034 class Geom_ToroidalSurface;
0035 DEFINE_STANDARD_HANDLE(Geom_ToroidalSurface, Geom_ElementarySurface)
0036 
0037 //! Describes a torus.
0038 //! A torus is defined by its major and minor radii, and
0039 //! positioned in space with a coordinate system (a
0040 //! gp_Ax3 object) as follows:
0041 //! - The origin is the center of the torus.
0042 //! - The surface is obtained by rotating a circle around
0043 //! the "main Direction". This circle has a radius equal
0044 //! to the minor radius, and is located in the plane
0045 //! defined by the origin, "X Direction" and "main
0046 //! Direction". It is centered on the "X Axis", on its
0047 //! positive side, and positioned at a distance from the
0048 //! origin equal to the major radius. This circle is the
0049 //! "reference circle" of the torus.
0050 //! - The plane defined by the origin, the "X Direction"
0051 //! and the "Y Direction" is called the "reference plane" of the torus.
0052 //! This coordinate system is the "local coordinate
0053 //! system" of the torus. The following apply:
0054 //! - Rotation around its "main Axis", in the trigonometric
0055 //! sense given by "X Direction" and "Y Direction",
0056 //! defines the u parametric direction.
0057 //! - The "X Axis" gives the origin for the u parameter.
0058 //! - Rotation around an axis parallel to the "Y Axis" and
0059 //! passing through the center of the "reference circle"
0060 //! gives the v parameter on the "reference circle".
0061 //! - The "X Axis" gives the origin of the v parameter on
0062 //! the "reference circle".
0063 //! - The v parametric direction is oriented by the
0064 //! inverse of the "main Direction", i.e. near 0, as v
0065 //! increases, the Z coordinate decreases. (This
0066 //! implies that the "Y Direction" orients the reference
0067 //! circle only when the local coordinate system is direct.)
0068 //! - The u isoparametric curve is a circle obtained by
0069 //! rotating the "reference circle" of the torus through
0070 //! an angle u about the "main Axis".
0071 //! The parametric equation of the torus is :
0072 //! P(u, v) = O + (R + r*cos(v)) * (cos(u)*XDir +
0073 //! sin(u)*YDir ) + r*sin(v)*ZDir, where:
0074 //! - O, XDir, YDir and ZDir are respectively the
0075 //! origin, the "X Direction", the "Y Direction" and the "Z
0076 //! Direction" of the local coordinate system,
0077 //! - r and R are, respectively, the minor and major radius.
0078 //! The parametric range of the two parameters is:
0079 //! - [ 0, 2.*Pi ] for u
0080 //! - [ 0, 2.*Pi ] for v
0081 class Geom_ToroidalSurface : public Geom_ElementarySurface
0082 {
0083 
0084 public:
0085   //! A3 is the local coordinate system of the surface.
0086   //! The orientation of increasing V parametric value is defined
0087   //! by the rotation around the main axis (ZAxis) in the
0088   //! trigonometric sense. The parametrization of the surface in the
0089   //! U direction is defined such as the normal Vector (N = D1U ^ D1V)
0090   //! is oriented towards the "outside region" of the surface.
0091   //! Warnings :
0092   //! It is not forbidden to create a toroidal surface with
0093   //! MajorRadius = MinorRadius = 0.0
0094   //!
0095   //! Raised if MinorRadius < 0.0 or if MajorRadius < 0.0
0096   Standard_EXPORT Geom_ToroidalSurface(const gp_Ax3&       A3,
0097                                        const Standard_Real MajorRadius,
0098                                        const Standard_Real MinorRadius);
0099 
0100   //! Creates a ToroidalSurface from a non transient Torus from
0101   //! package gp.
0102   Standard_EXPORT Geom_ToroidalSurface(const gp_Torus& T);
0103 
0104   //! Modifies this torus by changing its major radius.
0105   //! Exceptions
0106   //! Standard_ConstructionError if:
0107   //! - MajorRadius is negative, or
0108   //! - MajorRadius - r is less than or equal to
0109   //! gp::Resolution(), where r is the minor radius of this torus.
0110   Standard_EXPORT void SetMajorRadius(const Standard_Real MajorRadius);
0111 
0112   //! Modifies this torus by changing its minor radius.
0113   //! Exceptions
0114   //! Standard_ConstructionError if:
0115   //! - MinorRadius is negative, or
0116   //! - R - MinorRadius is less than or equal to
0117   //! gp::Resolution(), where R is the major radius of this torus.
0118   Standard_EXPORT void SetMinorRadius(const Standard_Real MinorRadius);
0119 
0120   //! Converts the gp_Torus torus T into this torus.
0121   Standard_EXPORT void SetTorus(const gp_Torus& T);
0122 
0123   //! Returns the non transient torus with the same geometric
0124   //! properties as <me>.
0125   Standard_EXPORT gp_Torus Torus() const;
0126 
0127   //! Return the  parameter on the  Ureversed surface for
0128   //! the point of parameter U on <me>.
0129   //! Return 2.PI - U.
0130   Standard_EXPORT Standard_Real UReversedParameter(const Standard_Real U) const Standard_OVERRIDE;
0131 
0132   //! Return the  parameter on the  Ureversed surface for
0133   //! the point of parameter U on <me>.
0134   //! Return 2.PI - U.
0135   Standard_EXPORT Standard_Real VReversedParameter(const Standard_Real U) const Standard_OVERRIDE;
0136 
0137   //! Computes the aera of the surface.
0138   Standard_EXPORT Standard_Real Area() const;
0139 
0140   //! Returns the parametric bounds U1, U2, V1 and V2 of this torus.
0141   //! For a torus: U1 = V1 = 0 and U2 = V2 = 2*PI .
0142   Standard_EXPORT void Bounds(Standard_Real& U1,
0143                               Standard_Real& U2,
0144                               Standard_Real& V1,
0145                               Standard_Real& V2) const Standard_OVERRIDE;
0146 
0147   //! Returns the coefficients of the implicit equation of the surface
0148   //! in the absolute cartesian coordinate system :
0149   //! Coef(1) * X**4 + Coef(2) * Y**4 + Coef(3) * Z**4 +
0150   //! Coef(4) * X**3 * Y + Coef(5) * X**3 * Z + Coef(6) * Y**3 * X +
0151   //! Coef(7) * Y**3 * Z + Coef(8) * Z**3 * X + Coef(9) * Z**3 * Y +
0152   //! Coef(10) * X**2 * Y**2 + Coef(11) * X**2 * Z**2 +
0153   //! Coef(12) * Y**2 * Z**2 + Coef(13) * X**3 + Coef(14) * Y**3 +
0154   //! Coef(15) * Z**3 + Coef(16) * X**2 * Y + Coef(17) * X**2 * Z +
0155   //! Coef(18) * Y**2 * X + Coef(19) * Y**2 * Z + Coef(20) * Z**2 * X +
0156   //! Coef(21) * Z**2 * Y + Coef(22) * X**2 + Coef(23) * Y**2 +
0157   //! Coef(24) * Z**2 + Coef(25) * X * Y + Coef(26) * X * Z +
0158   //! Coef(27) * Y * Z + Coef(28) * X + Coef(29) * Y + Coef(30) *  Z +
0159   //! Coef(31) = 0.0
0160   //! Raised if the length of Coef is lower than 31.
0161   Standard_EXPORT void Coefficients(TColStd_Array1OfReal& Coef) const;
0162 
0163   //! Returns the major radius, or the minor radius, of this torus.
0164   Standard_EXPORT Standard_Real MajorRadius() const;
0165 
0166   //! Returns the major radius, or the minor radius, of this torus.
0167   Standard_EXPORT Standard_Real MinorRadius() const;
0168 
0169   //! Computes the volume.
0170   Standard_EXPORT Standard_Real Volume() const;
0171 
0172   //! Returns True.
0173   Standard_EXPORT Standard_Boolean IsUClosed() const Standard_OVERRIDE;
0174 
0175   //! Returns True.
0176   Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE;
0177 
0178   //! Returns True.
0179   Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE;
0180 
0181   //! Returns True.
0182   Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE;
0183 
0184   //! Computes the U isoparametric curve.
0185   //!
0186   //! For a toroidal surface the UIso curve is a circle.
0187   //! The center of the Uiso circle is at the distance MajorRadius
0188   //! from the location point of the toroidal surface.
0189   //! Warnings :
0190   //! The radius of the circle can be zero if for the surface
0191   //! MinorRadius = 0.0
0192   Standard_EXPORT Handle(Geom_Curve) UIso(const Standard_Real U) const Standard_OVERRIDE;
0193 
0194   //! Computes the V isoparametric curve.
0195   //!
0196   //! For a ToroidalSurface the VIso curve is a circle.
0197   //! The axis of the circle is the main axis (ZAxis) of the
0198   //! toroidal  surface.
0199   //! Warnings :
0200   //! The radius of the circle can be zero if for the surface
0201   //! MajorRadius = MinorRadius
0202   Standard_EXPORT Handle(Geom_Curve) VIso(const Standard_Real V) const Standard_OVERRIDE;
0203 
0204   //! Computes the  point P (U, V) on the surface.
0205   //! P (U, V) = Loc + MinorRadius * Sin (V) * Zdir +
0206   //! (MajorRadius + MinorRadius * Cos(V)) *
0207   //! (cos (U) * XDir + sin (U) * YDir)
0208   //! where Loc is the origin of the placement plane (XAxis, YAxis)
0209   //! XDir is the direction of the XAxis and YDir the direction of
0210   //! the YAxis and ZDir the direction of the ZAxis.
0211   Standard_EXPORT void D0(const Standard_Real U,
0212                           const Standard_Real V,
0213                           gp_Pnt&             P) const Standard_OVERRIDE;
0214 
0215   //! Computes the current point and the first derivatives in
0216   //! the directions U and V.
0217   Standard_EXPORT void D1(const Standard_Real U,
0218                           const Standard_Real V,
0219                           gp_Pnt&             P,
0220                           gp_Vec&             D1U,
0221                           gp_Vec&             D1V) const Standard_OVERRIDE;
0222 
0223   //! Computes the current point, the first and the second derivatives
0224   //! in the directions U and V.
0225   Standard_EXPORT void D2(const Standard_Real U,
0226                           const Standard_Real V,
0227                           gp_Pnt&             P,
0228                           gp_Vec&             D1U,
0229                           gp_Vec&             D1V,
0230                           gp_Vec&             D2U,
0231                           gp_Vec&             D2V,
0232                           gp_Vec&             D2UV) const Standard_OVERRIDE;
0233 
0234   //! Computes the current point, the first,the second and the
0235   //! third derivatives in the directions U and V.
0236   Standard_EXPORT void D3(const Standard_Real U,
0237                           const Standard_Real V,
0238                           gp_Pnt&             P,
0239                           gp_Vec&             D1U,
0240                           gp_Vec&             D1V,
0241                           gp_Vec&             D2U,
0242                           gp_Vec&             D2V,
0243                           gp_Vec&             D2UV,
0244                           gp_Vec&             D3U,
0245                           gp_Vec&             D3V,
0246                           gp_Vec&             D3UUV,
0247                           gp_Vec&             D3UVV) const Standard_OVERRIDE;
0248 
0249   //! Computes the derivative of order Nu in the direction u and
0250   //! Nv in the direction v.
0251   //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
0252   Standard_EXPORT gp_Vec DN(const Standard_Real    U,
0253                             const Standard_Real    V,
0254                             const Standard_Integer Nu,
0255                             const Standard_Integer Nv) const Standard_OVERRIDE;
0256 
0257   //! Applies the transformation T to this torus.
0258   Standard_EXPORT void Transform(const gp_Trsf& T) Standard_OVERRIDE;
0259 
0260   //! Creates a new object which is a copy of this torus.
0261   Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
0262 
0263   //! Dumps the content of me into the stream
0264   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0265                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0266 
0267   DEFINE_STANDARD_RTTIEXT(Geom_ToroidalSurface, Geom_ElementarySurface)
0268 
0269 protected:
0270 private:
0271   Standard_Real majorRadius;
0272   Standard_Real minorRadius;
0273 };
0274 
0275 #endif // _Geom_ToroidalSurface_HeaderFile