Back to home page

EIC code displayed by LXR

 
 

    


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

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 _Geom2dGridEval_Ellipse_HeaderFile
0015 #define _Geom2dGridEval_Ellipse_HeaderFile
0016 
0017 #include <Geom2d_Ellipse.hxx>
0018 #include <Geom2dGridEval.hxx>
0019 #include <NCollection_Array1.hxx>
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 //! @brief Efficient batch evaluator for 2D 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 //!   Geom2dGridEval_Ellipse anEvaluator(myGeom2dEllipse);
0031 //!   NCollection_Array1<gp_Pnt2d> aGrid = anEvaluator.EvaluateGrid(myParams);
0032 //! @endcode
0033 class Geom2dGridEval_Ellipse
0034 {
0035 public:
0036   DEFINE_STANDARD_ALLOC
0037 
0038   //! Constructor with geometry.
0039   //! @param theEllipse the 2D ellipse geometry to evaluate
0040   Geom2dGridEval_Ellipse(const occ::handle<Geom2d_Ellipse>& theEllipse)
0041       : myGeom(theEllipse)
0042   {
0043   }
0044 
0045   //! Non-copyable and non-movable.
0046   Geom2dGridEval_Ellipse(const Geom2dGridEval_Ellipse&)            = delete;
0047   Geom2dGridEval_Ellipse& operator=(const Geom2dGridEval_Ellipse&) = delete;
0048   Geom2dGridEval_Ellipse(Geom2dGridEval_Ellipse&&)                 = delete;
0049   Geom2dGridEval_Ellipse& operator=(Geom2dGridEval_Ellipse&&)      = delete;
0050 
0051   //! Returns the geometry handle.
0052   const occ::handle<Geom2d_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_Pnt2d> 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   //!         or empty array if geometry is null or no parameters
0065   Standard_EXPORT NCollection_Array1<Geom2dGridEval::CurveD1> EvaluateGridD1(
0066     const NCollection_Array1<double>& theParams) const;
0067 
0068   //! Evaluate all grid points with first and second derivatives.
0069   //! @param theParams array of parameter values
0070   //! @return array of CurveD2 (1-based indexing),
0071   //!         or empty array if geometry is null or no parameters
0072   Standard_EXPORT NCollection_Array1<Geom2dGridEval::CurveD2> EvaluateGridD2(
0073     const NCollection_Array1<double>& theParams) const;
0074 
0075   //! Evaluate all grid points with first, second, and third derivatives.
0076   //! @param theParams array of parameter values
0077   //! @return array of CurveD3 (1-based indexing),
0078   //!         or empty array if geometry is null or no parameters
0079   Standard_EXPORT NCollection_Array1<Geom2dGridEval::CurveD3> EvaluateGridD3(
0080     const NCollection_Array1<double>& theParams) const;
0081 
0082   //! Evaluate Nth derivative at all grid points.
0083   //! Ellipse has cyclic derivatives with period 4:
0084   //! D1 = -MajR * sin(u) * X + MinR * cos(u) * Y
0085   //! D2 = -MajR * cos(u) * X - MinR * sin(u) * Y
0086   //! D3 = MajR * sin(u) * X - MinR * cos(u) * Y
0087   //! D4 = MajR * cos(u) * X + MinR * sin(u) * Y = D0, then repeats
0088   //! @param theParams array of parameter values
0089   //! @param theN derivative order (N >= 1)
0090   //! @return array of derivative vectors (1-based indexing),
0091   //!         or empty array if geometry is null or no parameters
0092   Standard_EXPORT NCollection_Array1<gp_Vec2d> EvaluateGridDN(
0093     const NCollection_Array1<double>& theParams,
0094     int                               theN) const;
0095 
0096 private:
0097   occ::handle<Geom2d_Ellipse> myGeom;
0098 };
0099 
0100 #endif // _Geom2dGridEval_Ellipse_HeaderFile