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_BSplineSurface_HeaderFile
0015 #define _GeomGridEval_BSplineSurface_HeaderFile
0016 
0017 #include <BSplSLib_Cache.hxx>
0018 #include <Geom_BSplineSurface.hxx>
0019 #include <GeomGridEval.hxx>
0020 #include <NCollection_Array1.hxx>
0021 #include <NCollection_Array2.hxx>
0022 #include <Standard.hxx>
0023 #include <Standard_DefineAlloc.hxx>
0024 
0025 //! @brief Efficient batch evaluator for B-spline surface points.
0026 //!
0027 //! Stateless evaluator - constructor takes geometry, parameters passed to methods.
0028 //!
0029 //! Optimizes evaluation by:
0030 //! - Pre-computing span indices for U and V parameters separately (O(aNbU + aNbV))
0031 //! - Grouping evaluation by (USpan, VSpan) for cache-optimal iteration
0032 //! - Rebuilding cache only once per span group (not per point)
0033 //! - Writing results directly to 2D output grid (no intermediate buffers)
0034 //!
0035 //! Usage:
0036 //! @code
0037 //!   GeomGridEval_BSplineSurface anEvaluator(myBSplineSurface);
0038 //!   NCollection_Array2<gp_Pnt> aGrid = anEvaluator.EvaluateGrid(myUParams, myVParams);
0039 //! @endcode
0040 class GeomGridEval_BSplineSurface
0041 {
0042 public:
0043   DEFINE_STANDARD_ALLOC
0044 
0045   //! Constructor with geometry.
0046   //! @param theSurface the B-spline surface to evaluate
0047   GeomGridEval_BSplineSurface(const occ::handle<Geom_BSplineSurface>& theSurface)
0048       : myGeom(theSurface)
0049   {
0050   }
0051 
0052   //! Non-copyable and non-movable.
0053   GeomGridEval_BSplineSurface(const GeomGridEval_BSplineSurface&)            = delete;
0054   GeomGridEval_BSplineSurface& operator=(const GeomGridEval_BSplineSurface&) = delete;
0055   GeomGridEval_BSplineSurface(GeomGridEval_BSplineSurface&&)                 = delete;
0056   GeomGridEval_BSplineSurface& operator=(GeomGridEval_BSplineSurface&&)      = delete;
0057 
0058   //! Returns the geometry handle.
0059   const occ::handle<Geom_BSplineSurface>& Geometry() const { return myGeom; }
0060 
0061   //! Evaluate grid points at Cartesian product of U and V parameters.
0062   //! Points are evaluated in span-grouped order to minimize cache rebuilds.
0063   //! @param theUParams array of U parameter values
0064   //! @param theVParams array of V parameter values
0065   //! @return 2D array of evaluated points (1-based indexing),
0066   //!         or empty array if geometry is null or parameters empty
0067   Standard_EXPORT NCollection_Array2<gp_Pnt> EvaluateGrid(
0068     const NCollection_Array1<double>& theUParams,
0069     const NCollection_Array1<double>& theVParams) const;
0070 
0071   //! Evaluate grid points with first partial derivatives.
0072   //! @param theUParams array of U parameter values
0073   //! @param theVParams array of V parameter values
0074   //! @return 2D array of SurfD1 (1-based indexing),
0075   //!         or empty array if geometry is null or parameters empty
0076   Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD1> EvaluateGridD1(
0077     const NCollection_Array1<double>& theUParams,
0078     const NCollection_Array1<double>& theVParams) const;
0079 
0080   //! Evaluate grid points with first and second partial derivatives.
0081   //! @param theUParams array of U parameter values
0082   //! @param theVParams array of V parameter values
0083   //! @return 2D array of SurfD2 (1-based indexing),
0084   //!         or empty array if geometry is null or parameters empty
0085   Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD2> EvaluateGridD2(
0086     const NCollection_Array1<double>& theUParams,
0087     const NCollection_Array1<double>& theVParams) const;
0088 
0089   //! Evaluate grid points with derivatives up to third order.
0090   //! Uses direct BSplSLib::D3 evaluation (no caching for D3).
0091   //! @param theUParams array of U parameter values
0092   //! @param theVParams array of V parameter values
0093   //! @return 2D array of SurfD3 (1-based indexing),
0094   //!         or empty array if geometry is null or parameters empty
0095   Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD3> EvaluateGridD3(
0096     const NCollection_Array1<double>& theUParams,
0097     const NCollection_Array1<double>& theVParams) const;
0098 
0099   //! Evaluate partial derivative d^(NU+NV)S/(dU^NU dV^NV) at all grid points.
0100   //! For orders > degree in either direction, returns zero.
0101   //! Uses direct geometry DN method.
0102   //! @param theUParams array of U parameter values
0103   //! @param theVParams array of V parameter values
0104   //! @param theNU derivative order in U direction
0105   //! @param theNV derivative order in V direction
0106   //! @return 2D array of derivative vectors (1-based indexing)
0107   Standard_EXPORT NCollection_Array2<gp_Vec> EvaluateGridDN(
0108     const NCollection_Array1<double>& theUParams,
0109     const NCollection_Array1<double>& theVParams,
0110     int                               theNU,
0111     int                               theNV) const;
0112 
0113 private:
0114   occ::handle<Geom_BSplineSurface> myGeom;
0115 };
0116 
0117 #endif // _GeomGridEval_BSplineSurface_HeaderFile