Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:20:11

0001 // Copyright (c) 2025 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _GeomGridEval_Cylinder_HeaderFile
0015 #define _GeomGridEval_Cylinder_HeaderFile
0016 
0017 #include <Geom_CylindricalSurface.hxx>
0018 #include <GeomGridEval.hxx>
0019 #include <NCollection_Array1.hxx>
0020 #include <NCollection_Array2.hxx>
0021 #include <Standard.hxx>
0022 #include <Standard_DefineAlloc.hxx>
0023 
0024 //! @brief Efficient batch evaluator for cylinder grid points.
0025 //!
0026 //! Uses analytical formula:
0027 //! P(u,v) = Location + R * (cos(u) * XDir + sin(u) * YDir) + v * ZDir
0028 //!
0029 //! Where U is angle (0 to 2*PI) and V is height.
0030 //!
0031 //! Usage:
0032 //! @code
0033 //!   GeomGridEval_Cylinder anEvaluator(myGeomCylinder);
0034 //!   NCollection_Array2<gp_Pnt> aGrid = anEvaluator.EvaluateGrid(myUParams, myVParams);
0035 //! @endcode
0036 class GeomGridEval_Cylinder
0037 {
0038 public:
0039   DEFINE_STANDARD_ALLOC
0040 
0041   //! Constructor with geometry.
0042   //! @param theCylinder the cylindrical surface geometry to evaluate
0043   GeomGridEval_Cylinder(const occ::handle<Geom_CylindricalSurface>& theCylinder)
0044       : myGeom(theCylinder)
0045   {
0046   }
0047 
0048   //! Non-copyable and non-movable.
0049   GeomGridEval_Cylinder(const GeomGridEval_Cylinder&)            = delete;
0050   GeomGridEval_Cylinder& operator=(const GeomGridEval_Cylinder&) = delete;
0051   GeomGridEval_Cylinder(GeomGridEval_Cylinder&&)                 = delete;
0052   GeomGridEval_Cylinder& operator=(GeomGridEval_Cylinder&&)      = delete;
0053 
0054   //! Returns the geometry handle.
0055   const occ::handle<Geom_CylindricalSurface>& Geometry() const { return myGeom; }
0056 
0057   //! Evaluate grid points at Cartesian product of U and V parameters.
0058   //! @param theUParams array of U parameter values (angle)
0059   //! @param theVParams array of V parameter values (height)
0060   //! @return 2D array of evaluated points (1-based indexing)
0061   Standard_EXPORT NCollection_Array2<gp_Pnt> EvaluateGrid(
0062     const NCollection_Array1<double>& theUParams,
0063     const NCollection_Array1<double>& theVParams) const;
0064 
0065   //! Evaluate grid points with first partial derivatives.
0066   //! @param theUParams array of U parameter values (angle)
0067   //! @param theVParams array of V parameter values (height)
0068   //! @return 2D array of SurfD1 (1-based indexing)
0069   Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD1> EvaluateGridD1(
0070     const NCollection_Array1<double>& theUParams,
0071     const NCollection_Array1<double>& theVParams) const;
0072 
0073   //! Evaluate grid points with first and second partial derivatives.
0074   //! @param theUParams array of U parameter values (angle)
0075   //! @param theVParams array of V parameter values (height)
0076   //! @return 2D array of SurfD2 (1-based indexing)
0077   Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD2> EvaluateGridD2(
0078     const NCollection_Array1<double>& theUParams,
0079     const NCollection_Array1<double>& theVParams) const;
0080 
0081   //! Evaluate grid points with derivatives up to third order.
0082   //! @param theUParams array of U parameter values (angle)
0083   //! @param theVParams array of V parameter values (height)
0084   //! @return 2D array of SurfD3 (1-based indexing)
0085   Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD3> EvaluateGridD3(
0086     const NCollection_Array1<double>& theUParams,
0087     const NCollection_Array1<double>& theVParams) const;
0088 
0089   //! Evaluate partial derivative d^(NU+NV)S/(dU^NU dV^NV) at all grid points.
0090   //! For a cylinder:
0091   //! - U derivatives are cyclic (period 4): D_nU = R * (cyclic trig)
0092   //! - V derivatives: D1V = ZDir, higher = 0
0093   //! - Mixed: D_{nu,nv} = 0 for nv > 1
0094   //! @param theUParams array of U parameter values (angle)
0095   //! @param theVParams array of V parameter values (height)
0096   //! @param theNU derivative order in U direction
0097   //! @param theNV derivative order in V direction
0098   //! @return 2D array of derivative vectors (1-based indexing)
0099   Standard_EXPORT NCollection_Array2<gp_Vec> EvaluateGridDN(
0100     const NCollection_Array1<double>& theUParams,
0101     const NCollection_Array1<double>& theVParams,
0102     int                               theNU,
0103     int                               theNV) const;
0104 
0105 private:
0106   //! Pre-extracted cylinder data for efficient evaluation.
0107   struct Data
0108   {
0109     double CX, CY, CZ; //!< Center coordinates
0110     double XX, XY, XZ; //!< XDir coordinates
0111     double YX, YY, YZ; //!< YDir coordinates
0112     double ZX, ZY, ZZ; //!< ZDir coordinates
0113     double Radius;
0114   };
0115 
0116   //! Pre-computed U-dependent values for optimized grid evaluation.
0117   struct UContext
0118   {
0119     double cosU, sinU;
0120     double dirUX, dirUY, dirUZ;    //!< DirU = cosU*XDir + sinU*YDir (circle point direction)
0121     double dDirUX, dDirUY, dDirUZ; //!< DerivDirU = -sinU*XDir + cosU*YDir
0122   };
0123 
0124   //! Extract cylinder data for evaluation.
0125   Data extractData() const;
0126 
0127   //! Pre-compute U-dependent values.
0128   static UContext computeUContext(const Data& theData, double theU);
0129 
0130   //! Compute point with pre-computed U context.
0131   static gp_Pnt computeD0(const Data& theData, const UContext& theUCtx, double theV);
0132 
0133   //! Compute point with D1 with pre-computed U context.
0134   static GeomGridEval::SurfD1 computeD1(const Data& theData, const UContext& theUCtx, double theV);
0135 
0136   //! Compute point with D2 with pre-computed U context.
0137   static GeomGridEval::SurfD2 computeD2(const Data& theData, const UContext& theUCtx, double theV);
0138 
0139   //! Compute point with D3 with pre-computed U context.
0140   static GeomGridEval::SurfD3 computeD3(const Data& theData, const UContext& theUCtx, double theV);
0141 
0142   //! Compute DN with pre-computed U context.
0143   static gp_Vec computeDN(const Data&     theData,
0144                           const UContext& theUCtx,
0145                           double          theV,
0146                           int             theNU,
0147                           int             theNV);
0148 
0149   occ::handle<Geom_CylindricalSurface> myGeom;
0150 };
0151 
0152 #endif // _GeomGridEval_Cylinder_HeaderFile