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_OffsetCurve_HeaderFile
0015 #define _GeomGridEval_OffsetCurve_HeaderFile
0016 
0017 #include <Geom_Curve.hxx>
0018 #include <Geom_OffsetCurve.hxx>
0019 #include <GeomGridEval.hxx>
0020 #include <NCollection_Array1.hxx>
0021 #include <Standard.hxx>
0022 #include <Standard_DefineAlloc.hxx>
0023 
0024 //! @brief Batch evaluator for offset curve grid points.
0025 //!
0026 //! Evaluates the offset curve formula:
0027 //! P(u) = C(u) + Offset * (D1(u) ^ Direction) / |D1(u) ^ Direction|
0028 //!
0029 //! Uses GeomGridEval_Curve for batch evaluation of the basis curve,
0030 //! then applies offset transformation.
0031 //!
0032 //! Usage:
0033 //! @code
0034 //!   GeomGridEval_OffsetCurve anEvaluator(myGeomOffset);
0035 //!   NCollection_Array1<gp_Pnt> aGrid = anEvaluator.EvaluateGrid(myParams);
0036 //! @endcode
0037 class GeomGridEval_OffsetCurve
0038 {
0039 public:
0040   DEFINE_STANDARD_ALLOC
0041 
0042   //! Constructor with geometry.
0043   //! @param theOffset the offset curve geometry to evaluate
0044   GeomGridEval_OffsetCurve(const occ::handle<Geom_OffsetCurve>& theOffset)
0045       : myGeom(theOffset),
0046         myOffset(0.0)
0047   {
0048     if (!myGeom.IsNull())
0049     {
0050       myOffset    = myGeom->Offset();
0051       myBasis     = myGeom->BasisCurve();
0052       myDirection = myGeom->Direction();
0053     }
0054   }
0055 
0056   //! Non-copyable and non-movable.
0057   GeomGridEval_OffsetCurve(const GeomGridEval_OffsetCurve&)            = delete;
0058   GeomGridEval_OffsetCurve& operator=(const GeomGridEval_OffsetCurve&) = delete;
0059   GeomGridEval_OffsetCurve(GeomGridEval_OffsetCurve&&)                 = delete;
0060   GeomGridEval_OffsetCurve& operator=(GeomGridEval_OffsetCurve&&)      = delete;
0061 
0062   //! Returns the geometry handle.
0063   const occ::handle<Geom_OffsetCurve>& Geometry() const { return myGeom; }
0064 
0065   //! Evaluate all grid points.
0066   //! @param theParams array of parameter values
0067   //! @return array of evaluated points (1-based indexing),
0068   //!         or empty array if geometry is null or no parameters
0069   Standard_EXPORT NCollection_Array1<gp_Pnt> EvaluateGrid(
0070     const NCollection_Array1<double>& theParams) const;
0071 
0072   //! Evaluate all grid points with first derivative.
0073   //! @param theParams array of parameter values
0074   //! @return array of CurveD1 (1-based indexing),
0075   //!         or empty array if geometry is null or no parameters
0076   Standard_EXPORT NCollection_Array1<GeomGridEval::CurveD1> EvaluateGridD1(
0077     const NCollection_Array1<double>& theParams) const;
0078 
0079   //! Evaluate all grid points with first and second derivatives.
0080   //! @param theParams array of parameter values
0081   //! @return array of CurveD2 (1-based indexing),
0082   //!         or empty array if geometry is null or no parameters
0083   Standard_EXPORT NCollection_Array1<GeomGridEval::CurveD2> EvaluateGridD2(
0084     const NCollection_Array1<double>& theParams) const;
0085 
0086   //! Evaluate all grid points with derivatives up to third order.
0087   //! Uses GeomAdaptor_Curve::D3 for evaluation.
0088   //! @param theParams array of parameter values
0089   //! @return array of CurveD3 (1-based indexing),
0090   //!         or empty array if geometry is null or no parameters
0091   Standard_EXPORT NCollection_Array1<GeomGridEval::CurveD3> EvaluateGridD3(
0092     const NCollection_Array1<double>& theParams) const;
0093 
0094   //! Evaluate Nth derivative at all grid points.
0095   //! For orders 1-3, reuses EvaluateGridD1/D2/D3.
0096   //! For orders > 3, uses geometry DN method.
0097   //! @param theParams array of parameter values
0098   //! @param theN derivative order (N >= 1)
0099   //! @return array of derivative vectors (1-based indexing)
0100   Standard_EXPORT NCollection_Array1<gp_Vec> EvaluateGridDN(
0101     const NCollection_Array1<double>& theParams,
0102     int                               theN) const;
0103 
0104 private:
0105   occ::handle<Geom_OffsetCurve> myGeom;
0106   occ::handle<Geom_Curve>       myBasis;
0107   double                        myOffset;
0108   gp_Dir                        myDirection;
0109 };
0110 
0111 #endif // _GeomGridEval_OffsetCurve_HeaderFile