Back to home page

EIC code displayed by LXR

 
 

    


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

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