Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1991-09-09
0002 // Created by: Michel Chauvat
0003 // Copyright (c) 1991-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 _ElSLib_HeaderFile
0018 #define _ElSLib_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <gp_Pnt.hxx>
0025 #include <gp_Vec.hxx>
0026 class gp_Pnt;
0027 class gp_Pln;
0028 class gp_Cone;
0029 class gp_Cylinder;
0030 class gp_Sphere;
0031 class gp_Torus;
0032 class gp_Vec;
0033 class gp_Ax3;
0034 class gp_Lin;
0035 class gp_Circ;
0036 
0037 
0038 //! Provides functions for basic geometric computation on
0039 //! elementary surfaces.
0040 //! This includes:
0041 //! -   calculation of a point or derived vector on a surface
0042 //! where the surface is provided by the gp package, or
0043 //! defined in canonical form (as in the gp package), and
0044 //! the point is defined with a parameter,
0045 //! -   evaluation of the parameters corresponding to a
0046 //! point on an elementary surface from gp,
0047 //! -   calculation of isoparametric curves on an elementary
0048 //! surface defined in canonical form (as in the gp package).
0049 //! Notes:
0050 //! -   ElSLib stands for Elementary Surfaces Library.
0051 //! -   If the surfaces provided by the gp package are not
0052 //! explicitly parameterized, they still have an implicit
0053 //! parameterization, similar to that which they infer on
0054 //! the equivalent Geom surfaces.
0055 //! Note: ElSLib stands for Elementary Surfaces Library.
0056 class ElSLib 
0057 {
0058 public:
0059 
0060   DEFINE_STANDARD_ALLOC
0061 
0062   
0063   //! For elementary surfaces from the gp package (planes,
0064   //! cones, cylinders, spheres and tori), computes the point
0065   //! of parameters (U, V).
0066     static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl);
0067   
0068     static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Cone& C);
0069   
0070     static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C);
0071   
0072     static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Sphere& S);
0073   
0074     static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Torus& T);
0075   
0076   //! For elementary surfaces from the gp package (planes,
0077   //! cones, cylinders, spheres and tori), computes the
0078   //! derivative vector of order Nu and Nv in the u and v
0079   //! parametric directions respectively, at the point of
0080   //! parameters (U, V).
0081     static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl, const Standard_Integer Nu, const Standard_Integer Nv);
0082   
0083     static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Cone& C, const Standard_Integer Nu, const Standard_Integer Nv);
0084   
0085     static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, const Standard_Integer Nu, const Standard_Integer Nv);
0086   
0087     static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, const Standard_Integer Nu, const Standard_Integer Nv);
0088   
0089     static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Torus& T, const Standard_Integer Nu, const Standard_Integer Nv);
0090   
0091   //! For elementary surfaces from the gp package (planes,
0092   //! cones, cylinders, spheres and tori), computes the point P
0093   //! of parameters (U, V).inline
0094     static void D0 (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl, gp_Pnt& P);
0095   
0096     static void D0 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P);
0097   
0098     static void D0 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, gp_Pnt& P);
0099   
0100     static void D0 (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, gp_Pnt& P);
0101   
0102     static void D0 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P);
0103   
0104 
0105   //! For elementary surfaces from the gp package (planes,
0106   //! cones, cylinders, spheres and tori), computes:
0107   //! -   the point P of parameters (U, V), and
0108   //! -   the first derivative vectors Vu and Vv at this point in
0109   //! the u and v parametric directions respectively.
0110     static void D1 (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
0111   
0112     static void D1 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
0113   
0114     static void D1 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
0115   
0116     static void D1 (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
0117   
0118     static void D1 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
0119   
0120 
0121   //! For elementary surfaces from the gp package (cones,
0122   //! cylinders, spheres and tori), computes:
0123   //! -   the point P of parameters (U, V), and
0124   //! -   the first derivative vectors Vu and Vv at this point in
0125   //! the u and v parametric directions respectively, and
0126   //! -   the second derivative vectors Vuu, Vvv and Vuv at this point.
0127     static void D2 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
0128   
0129     static void D2 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
0130   
0131     static void D2 (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
0132   
0133     static void D2 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
0134   
0135 
0136   //! For elementary surfaces from the gp package (cones,
0137   //! cylinders, spheres and tori), computes:
0138   //! -   the point P of parameters (U,V), and
0139   //! -   the first derivative vectors Vu and Vv at this point in
0140   //! the u and v parametric directions respectively, and
0141   //! -   the second derivative vectors Vuu, Vvv and Vuv at
0142   //! this point, and
0143   //! -   the third derivative vectors Vuuu, Vvvv, Vuuv and
0144   //! Vuvv at this point.
0145     static void D3 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
0146   
0147     static void D3 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
0148   
0149     static void D3 (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
0150   
0151   //! Surface evaluation
0152   //! The following functions compute the point and the
0153   //! derivatives on elementary surfaces defined with their
0154   //! geometric characteristics.
0155   //! You don't need to create the surface to use these functions.
0156   //! These functions are called by the previous  ones.
0157   //! Example :
0158   //! A cylinder is defined with its position and its radius.
0159     static void D3 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
0160   
0161   Standard_EXPORT static gp_Pnt PlaneValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos);
0162   
0163   Standard_EXPORT static gp_Pnt CylinderValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius);
0164   
0165   Standard_EXPORT static gp_Pnt ConeValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle);
0166   
0167   Standard_EXPORT static gp_Pnt SphereValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius);
0168   
0169   Standard_EXPORT static gp_Pnt TorusValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
0170   
0171   Standard_EXPORT static gp_Vec PlaneDN (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Integer Nu, const Standard_Integer Nv);
0172   
0173   Standard_EXPORT static gp_Vec CylinderDN (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Integer Nu, const Standard_Integer Nv);
0174   
0175   Standard_EXPORT static gp_Vec ConeDN (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, const Standard_Integer Nu, const Standard_Integer Nv);
0176   
0177   Standard_EXPORT static gp_Vec SphereDN (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Integer Nu, const Standard_Integer Nv);
0178   
0179   Standard_EXPORT static gp_Vec TorusDN (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Integer Nu, const Standard_Integer Nv);
0180   
0181   Standard_EXPORT static void PlaneD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, gp_Pnt& P);
0182   
0183   Standard_EXPORT static void ConeD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, gp_Pnt& P);
0184   
0185   Standard_EXPORT static void CylinderD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P);
0186   
0187   Standard_EXPORT static void SphereD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P);
0188   
0189   Standard_EXPORT static void TorusD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, gp_Pnt& P);
0190   
0191   Standard_EXPORT static void PlaneD1 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
0192   
0193   Standard_EXPORT static void ConeD1 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
0194   
0195   Standard_EXPORT static void CylinderD1 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
0196   
0197   Standard_EXPORT static void SphereD1 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
0198   
0199   Standard_EXPORT static void TorusD1 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
0200   
0201   Standard_EXPORT static void ConeD2 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
0202   
0203   Standard_EXPORT static void CylinderD2 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
0204   
0205   Standard_EXPORT static void SphereD2 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
0206   
0207   Standard_EXPORT static void TorusD2 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
0208   
0209   Standard_EXPORT static void ConeD3 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
0210   
0211   Standard_EXPORT static void CylinderD3 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
0212   
0213   Standard_EXPORT static void SphereD3 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
0214   
0215 
0216   //! The following functions compute the parametric values
0217   //! corresponding to a given point on a elementary surface.
0218   //! The point should be on the surface.
0219   Standard_EXPORT static void TorusD3 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
0220   
0221   //! parametrization
0222   //! P (U, V) =
0223   //! Pl.Location() + U * Pl.XDirection() + V * Pl.YDirection()
0224     static void Parameters (const gp_Pln& Pl, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
0225   
0226   //! parametrization
0227   //! P (U, V) = Location + V * ZDirection +
0228   //! Radius * (Cos(U) * XDirection + Sin (U) * YDirection)
0229     static void Parameters (const gp_Cylinder& C, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
0230   
0231   //! parametrization
0232   //! P (U, V) =  Location + V * ZDirection +
0233   //! (Radius + V * Tan (SemiAngle)) *
0234   //! (Cos(U) * XDirection + Sin(U) * YDirection)
0235     static void Parameters (const gp_Cone& C, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
0236   
0237   //! parametrization
0238   //! P (U, V) = Location +
0239   //! Radius * Cos (V) * (Cos (U) * XDirection + Sin (U) * YDirection) +
0240   //! Radius * Sin (V) * ZDirection
0241     static void Parameters (const gp_Sphere& S, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
0242   
0243   //! parametrization
0244   //! P (U, V) = Location +
0245   //! (MajorRadius + MinorRadius * Cos(U)) *
0246   //! (Cos(V) * XDirection - Sin(V) * YDirection) +
0247   //! MinorRadius * Sin(U) * ZDirection
0248     static void Parameters (const gp_Torus& T, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
0249   
0250   //! parametrization
0251   //! P (U, V) =
0252   //! Pl.Location() + U * Pl.XDirection() + V * Pl.YDirection()
0253   Standard_EXPORT static void PlaneParameters (const gp_Ax3& Pos, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
0254   
0255   //! parametrization
0256   //! P (U, V) = Location + V * ZDirection +
0257   //! Radius * (Cos(U) * XDirection + Sin (U) * YDirection)
0258   Standard_EXPORT static void CylinderParameters (const gp_Ax3& Pos, const Standard_Real Radius, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
0259   
0260   //! parametrization
0261   //! P (U, V) =  Location + V * ZDirection +
0262   //! (Radius + V * Tan (SemiAngle)) *
0263   //! (Cos(U) * XDirection + Sin(U) * YDirection)
0264   Standard_EXPORT static void ConeParameters (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
0265   
0266   //! parametrization
0267   //! P (U, V) = Location +
0268   //! Radius * Cos (V) * (Cos (U) * XDirection + Sin (U) * YDirection) +
0269   //! Radius * Sin (V) * ZDirection
0270   Standard_EXPORT static void SphereParameters (const gp_Ax3& Pos, const Standard_Real Radius, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
0271   
0272   //! parametrization
0273   //! P (U, V) = Location +
0274   //! (MajorRadius + MinorRadius * Cos(U)) *
0275   //! (Cos(V) * XDirection - Sin(V) * YDirection) +
0276   //! MinorRadius * Sin(U) * ZDirection
0277   Standard_EXPORT static void TorusParameters (const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
0278   
0279   //! compute the U Isoparametric gp_Lin of the plane.
0280   Standard_EXPORT static gp_Lin PlaneUIso (const gp_Ax3& Pos, const Standard_Real U);
0281   
0282   //! compute the U Isoparametric gp_Lin of the cylinder.
0283   Standard_EXPORT static gp_Lin CylinderUIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real U);
0284   
0285   //! compute the U Isoparametric gp_Lin of the cone.
0286   Standard_EXPORT static gp_Lin ConeUIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, const Standard_Real U);
0287   
0288   //! compute the U Isoparametric gp_Circ of the sphere,
0289   //! (the meridian is not trimmed).
0290   Standard_EXPORT static gp_Circ SphereUIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real U);
0291   
0292   //! compute the U Isoparametric gp_Circ of the torus.
0293   Standard_EXPORT static gp_Circ TorusUIso (const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Real U);
0294   
0295   //! compute the V Isoparametric gp_Lin of the plane.
0296   Standard_EXPORT static gp_Lin PlaneVIso (const gp_Ax3& Pos, const Standard_Real V);
0297   
0298   //! compute the V Isoparametric gp_Circ of the cylinder.
0299   Standard_EXPORT static gp_Circ CylinderVIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real V);
0300   
0301   //! compute the V Isoparametric gp_Circ of the cone.
0302   Standard_EXPORT static gp_Circ ConeVIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, const Standard_Real V);
0303   
0304   //! compute the V Isoparametric gp_Circ of the sphere,
0305   //! (the meridian is not trimmed).
0306   Standard_EXPORT static gp_Circ SphereVIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real V);
0307   
0308   //! compute the V Isoparametric gp_Circ of the torus.
0309   Standard_EXPORT static gp_Circ TorusVIso (const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Real V);
0310 
0311 
0312 
0313 
0314 protected:
0315 
0316 
0317 
0318 
0319 
0320 private:
0321 
0322 
0323 
0324 
0325 
0326 };
0327 
0328 
0329 #include <ElSLib.lxx>
0330 
0331 
0332 
0333 
0334 
0335 #endif // _ElSLib_HeaderFile