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_SurfaceOfRevolution_HeaderFile
0015 #define _GeomGridEval_SurfaceOfRevolution_HeaderFile
0016 
0017 #include <GeomGridEval.hxx>
0018 #include <GeomGridEval_Curve.hxx>
0019 #include <Geom_Curve.hxx>
0020 #include <Geom_SurfaceOfRevolution.hxx>
0021 #include <gp_Ax1.hxx>
0022 #include <gp_Dir.hxx>
0023 #include <gp_Pnt.hxx>
0024 #include <gp_Pnt2d.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <NCollection_Array2.hxx>
0027 #include <Standard.hxx>
0028 #include <Standard_DefineAlloc.hxx>
0029 
0030 //! @brief Optimized batch evaluator for revolution surface grid points.
0031 //!
0032 //! Evaluates the revolution surface formula:
0033 //! S(u, v) = Rotation(u, Axis) * C(v)
0034 //!
0035 //! Where:
0036 //! - C(v) is the meridian (basis curve)
0037 //! - u is the rotation angle around the axis
0038 //! - Axis is the axis of revolution
0039 //!
0040 //! Optimization: Uses GeomGridEval_Curve for batch evaluation of the basis curve,
0041 //! then applies rotation transformations. Precomputes sin/cos values for each U parameter.
0042 //!
0043 //! Mathematical formulas for derivatives:
0044 //! - D1U = Axis Cross (P - AxisLocation), then rotated
0045 //! - D1V = C'(v), rotated
0046 //! - D2U = (Axis Dot (P - AxisLocation)) * Axis - (P - AxisLocation), then rotated
0047 //! - D2UV = Axis Cross C'(v), then rotated
0048 //! - D2V = C''(v), rotated
0049 //!
0050 //! Usage:
0051 //! @code
0052 //!   GeomGridEval_SurfaceOfRevolution anEvaluator(myRevolutionSurface);
0053 //!   NCollection_Array2<gp_Pnt> aGrid = anEvaluator.EvaluateGrid(myUParams, myVParams);
0054 //! @endcode
0055 class GeomGridEval_SurfaceOfRevolution
0056 {
0057 public:
0058   DEFINE_STANDARD_ALLOC
0059 
0060   //! Constructor with geometry.
0061   //! @param theRevolution the revolution surface geometry to evaluate
0062   Standard_EXPORT GeomGridEval_SurfaceOfRevolution(
0063     const occ::handle<Geom_SurfaceOfRevolution>& theRevolution);
0064 
0065   //! Non-copyable and non-movable.
0066   GeomGridEval_SurfaceOfRevolution(const GeomGridEval_SurfaceOfRevolution&)            = delete;
0067   GeomGridEval_SurfaceOfRevolution& operator=(const GeomGridEval_SurfaceOfRevolution&) = delete;
0068   GeomGridEval_SurfaceOfRevolution(GeomGridEval_SurfaceOfRevolution&&)                 = delete;
0069   GeomGridEval_SurfaceOfRevolution& operator=(GeomGridEval_SurfaceOfRevolution&&)      = delete;
0070 
0071   //! Returns the geometry handle.
0072   const occ::handle<Geom_SurfaceOfRevolution>& Geometry() const { return myGeom; }
0073 
0074   //! Evaluate all grid points.
0075   //! @param[in] theUParams array of U parameter values (rotation angle)
0076   //! @param[in] theVParams array of V parameter values (curve parameter)
0077   //! @return 2D array of evaluated points (1-based indexing),
0078   //!         or empty array if geometry is null or no parameters set
0079   Standard_EXPORT NCollection_Array2<gp_Pnt> EvaluateGrid(
0080     const NCollection_Array1<double>& theUParams,
0081     const NCollection_Array1<double>& theVParams) const;
0082 
0083   //! Evaluate all grid points with first partial derivatives.
0084   //! @param[in] theUParams array of U parameter values (rotation angle)
0085   //! @param[in] theVParams array of V parameter values (curve parameter)
0086   //! @return 2D array of SurfD1 (1-based indexing),
0087   //!         or empty array if geometry is null or no parameters set
0088   Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD1> EvaluateGridD1(
0089     const NCollection_Array1<double>& theUParams,
0090     const NCollection_Array1<double>& theVParams) const;
0091 
0092   //! Evaluate all grid points with first and second partial derivatives.
0093   //! @param[in] theUParams array of U parameter values (rotation angle)
0094   //! @param[in] theVParams array of V parameter values (curve parameter)
0095   //! @return 2D array of SurfD2 (1-based indexing),
0096   //!         or empty array if geometry is null or no parameters set
0097   Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD2> EvaluateGridD2(
0098     const NCollection_Array1<double>& theUParams,
0099     const NCollection_Array1<double>& theVParams) const;
0100 
0101   //! Evaluate all grid points with derivatives up to third order.
0102   //! @param[in] theUParams array of U parameter values (rotation angle)
0103   //! @param[in] theVParams array of V parameter values (curve parameter)
0104   //! @return 2D array of SurfD3 (1-based indexing),
0105   //!         or empty array if geometry is null or no parameters set
0106   Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD3> EvaluateGridD3(
0107     const NCollection_Array1<double>& theUParams,
0108     const NCollection_Array1<double>& theVParams) const;
0109 
0110   //! Evaluate partial derivative d^(NU+NV)S/(dU^NU dV^NV) at all grid points.
0111   //! @param[in] theUParams array of U parameter values (rotation angle)
0112   //! @param[in] theVParams array of V parameter values (curve parameter)
0113   //! @param[in] theNU derivative order in U direction
0114   //! @param[in] theNV derivative order in V direction
0115   //! @return 2D array of derivative vectors (1-based indexing)
0116   Standard_EXPORT NCollection_Array2<gp_Vec> EvaluateGridDN(
0117     const NCollection_Array1<double>& theUParams,
0118     const NCollection_Array1<double>& theVParams,
0119     int                               theNU,
0120     int                               theNV) const;
0121 
0122 private:
0123   occ::handle<Geom_SurfaceOfRevolution> myGeom;
0124   occ::handle<Geom_Curve>               myBasisCurve;
0125   gp_Ax1                                myAxis;
0126   gp_Pnt                                myAxisLocation;
0127   gp_Dir                                myAxisDirection;
0128 };
0129 
0130 #endif // _GeomGridEval_SurfaceOfRevolution_HeaderFile