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_Ellipse_HeaderFile
0015 #define _GeomGridEval_Ellipse_HeaderFile
0016 
0017 #include <Geom_Ellipse.hxx>
0018 #include <GeomGridEval.hxx>
0019 #include <NCollection_Array1.hxx>
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 //! @brief Efficient batch evaluator for ellipse grid points.
0024 //!
0025 //! Uses analytical formula:
0026 //! P(u) = Center + MajorRadius * cos(u) * XDir + MinorRadius * sin(u) * YDir
0027 //!
0028 //! Usage:
0029 //! @code
0030 //!   GeomGridEval_Ellipse anEvaluator(myGeomEllipse);
0031 //!   NCollection_Array1<gp_Pnt> aGrid = anEvaluator.EvaluateGrid(myParams);
0032 //! @endcode
0033 class GeomGridEval_Ellipse
0034 {
0035 public:
0036   DEFINE_STANDARD_ALLOC
0037 
0038   //! Constructor with geometry.
0039   //! @param theEllipse the ellipse geometry to evaluate
0040   GeomGridEval_Ellipse(const occ::handle<Geom_Ellipse>& theEllipse)
0041       : myGeom(theEllipse)
0042   {
0043   }
0044 
0045   //! Non-copyable and non-movable.
0046   GeomGridEval_Ellipse(const GeomGridEval_Ellipse&)            = delete;
0047   GeomGridEval_Ellipse& operator=(const GeomGridEval_Ellipse&) = delete;
0048   GeomGridEval_Ellipse(GeomGridEval_Ellipse&&)                 = delete;
0049   GeomGridEval_Ellipse& operator=(GeomGridEval_Ellipse&&)      = delete;
0050 
0051   //! Returns the geometry handle.
0052   const occ::handle<Geom_Ellipse>& Geometry() const { return myGeom; }
0053 
0054   //! Evaluate all grid points.
0055   //! @param theParams array of parameter values
0056   //! @return array of evaluated points (1-based indexing),
0057   //!         or empty array if geometry is null or no parameters
0058   Standard_EXPORT NCollection_Array1<gp_Pnt> EvaluateGrid(
0059     const NCollection_Array1<double>& theParams) const;
0060 
0061   //! Evaluate all grid points with first derivative.
0062   //! @param theParams array of parameter values
0063   //! @return array of CurveD1 (1-based indexing)
0064   Standard_EXPORT NCollection_Array1<GeomGridEval::CurveD1> EvaluateGridD1(
0065     const NCollection_Array1<double>& theParams) const;
0066 
0067   //! Evaluate all grid points with first and second derivatives.
0068   //! @param theParams array of parameter values
0069   //! @return array of CurveD2 (1-based indexing)
0070   Standard_EXPORT NCollection_Array1<GeomGridEval::CurveD2> EvaluateGridD2(
0071     const NCollection_Array1<double>& theParams) const;
0072 
0073   //! Evaluate all grid points with first, second, and third derivatives.
0074   //! @param theParams array of parameter values
0075   //! @return array of CurveD3 (1-based indexing)
0076   Standard_EXPORT NCollection_Array1<GeomGridEval::CurveD3> EvaluateGridD3(
0077     const NCollection_Array1<double>& theParams) const;
0078 
0079   //! Evaluate Nth derivative at all grid points.
0080   //! Ellipse has cyclic derivatives with period 4:
0081   //! D1 = -MajR * sin(u) * X + MinR * cos(u) * Y
0082   //! D2 = -MajR * cos(u) * X - MinR * sin(u) * Y
0083   //! D3 = MajR * sin(u) * X - MinR * cos(u) * Y
0084   //! D4 = MajR * cos(u) * X + MinR * sin(u) * Y = D0, then repeats
0085   //! @param theParams array of parameter values
0086   //! @param theN derivative order (N >= 1)
0087   //! @return array of derivative vectors (1-based indexing)
0088   Standard_EXPORT NCollection_Array1<gp_Vec> EvaluateGridDN(
0089     const NCollection_Array1<double>& theParams,
0090     int                               theN) const;
0091 
0092 private:
0093   occ::handle<Geom_Ellipse> myGeom;
0094 };
0095 
0096 #endif // _GeomGridEval_Ellipse_HeaderFile