|
|
|||
File indexing completed on 2026-09-28 09:20:12
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_Torus_HeaderFile 0015 #define _GeomGridEval_Torus_HeaderFile 0016 0017 #include <Geom_ToroidalSurface.hxx> 0018 #include <GeomGridEval.hxx> 0019 #include <gp_Pnt2d.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 torus grid points. 0026 //! 0027 //! Uses analytical formula: 0028 //! P(u,v) = Location + (MajorRadius + MinorRadius * cos(v)) * (cos(u) * XDir + sin(u) * YDir) + 0029 //! MinorRadius * sin(v) * ZDir 0030 //! 0031 //! Where U is major angle (0 to 2*PI) and V is minor angle (0 to 2*PI). 0032 //! 0033 //! Usage: 0034 //! @code 0035 //! GeomGridEval_Torus anEvaluator(myGeomTorus); 0036 //! NCollection_Array2<gp_Pnt> aGrid = anEvaluator.EvaluateGrid(myUParams, myVParams); 0037 //! @endcode 0038 class GeomGridEval_Torus 0039 { 0040 public: 0041 DEFINE_STANDARD_ALLOC 0042 0043 //! Constructor with geometry. 0044 //! @param theTorus the toroidal surface geometry to evaluate 0045 GeomGridEval_Torus(const occ::handle<Geom_ToroidalSurface>& theTorus) 0046 : myGeom(theTorus) 0047 { 0048 } 0049 0050 //! Non-copyable and non-movable. 0051 GeomGridEval_Torus(const GeomGridEval_Torus&) = delete; 0052 GeomGridEval_Torus& operator=(const GeomGridEval_Torus&) = delete; 0053 GeomGridEval_Torus(GeomGridEval_Torus&&) = delete; 0054 GeomGridEval_Torus& operator=(GeomGridEval_Torus&&) = delete; 0055 0056 //! Returns the geometry handle. 0057 const occ::handle<Geom_ToroidalSurface>& Geometry() const { return myGeom; } 0058 0059 //! Evaluate grid points at Cartesian product of U and V parameters. 0060 //! @param theUParams array of U parameter values (major angle) 0061 //! @param theVParams array of V parameter values (minor angle) 0062 //! @return 2D array of evaluated points (1-based indexing) 0063 Standard_EXPORT NCollection_Array2<gp_Pnt> EvaluateGrid( 0064 const NCollection_Array1<double>& theUParams, 0065 const NCollection_Array1<double>& theVParams) const; 0066 0067 //! Evaluate grid points with first partial derivatives. 0068 //! @param theUParams array of U parameter values (major angle) 0069 //! @param theVParams array of V parameter values (minor angle) 0070 //! @return 2D array of SurfD1 (1-based indexing) 0071 Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD1> EvaluateGridD1( 0072 const NCollection_Array1<double>& theUParams, 0073 const NCollection_Array1<double>& theVParams) const; 0074 0075 //! Evaluate grid points with first and second partial derivatives. 0076 //! @param theUParams array of U parameter values (major angle) 0077 //! @param theVParams array of V parameter values (minor angle) 0078 //! @return 2D array of SurfD2 (1-based indexing) 0079 Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD2> EvaluateGridD2( 0080 const NCollection_Array1<double>& theUParams, 0081 const NCollection_Array1<double>& theVParams) const; 0082 0083 //! Evaluate grid points with derivatives up to third order. 0084 //! @param theUParams array of U parameter values (major angle) 0085 //! @param theVParams array of V parameter values (minor angle) 0086 //! @return 2D array of SurfD3 (1-based indexing) 0087 Standard_EXPORT NCollection_Array2<GeomGridEval::SurfD3> EvaluateGridD3( 0088 const NCollection_Array1<double>& theUParams, 0089 const NCollection_Array1<double>& theVParams) const; 0090 0091 //! Evaluate partial derivative d^(NU+NV)S/(dU^NU dV^NV) at all grid points. 0092 //! For orders 1-3, reuses EvaluateGridD1/D2/D3. 0093 //! For orders > 3, uses geometry DN method. 0094 //! @param theUParams array of U parameter values (major angle) 0095 //! @param theVParams array of V parameter values (minor angle) 0096 //! @param theNU derivative order in U direction 0097 //! @param theNV derivative order in V direction 0098 //! @return 2D array of derivative vectors (1-based indexing) 0099 Standard_EXPORT NCollection_Array2<gp_Vec> EvaluateGridDN( 0100 const NCollection_Array1<double>& theUParams, 0101 const NCollection_Array1<double>& theVParams, 0102 int theNU, 0103 int theNV) const; 0104 0105 private: 0106 //! Pre-extracted torus data for efficient evaluation. 0107 struct Data 0108 { 0109 double CX, CY, CZ; //!< Center coordinates 0110 double XX, XY, XZ; //!< XDir coordinates 0111 double YX, YY, YZ; //!< YDir coordinates 0112 double ZX, ZY, ZZ; //!< ZDir coordinates 0113 double MajorRadius; //!< Major radius 0114 double MinorRadius; //!< Minor radius 0115 }; 0116 0117 //! Pre-computed U-dependent values for optimized grid evaluation. 0118 struct UContext 0119 { 0120 double cosU, sinU; 0121 double dirUX, dirUY, dirUZ; //!< DirU = cosU*XDir + sinU*YDir 0122 double dDirUX, dDirUY, dDirUZ; //!< DerivDirU = -sinU*XDir + cosU*YDir 0123 }; 0124 0125 //! Extract torus data for evaluation. 0126 Data extractData() const; 0127 0128 //! Pre-compute U-dependent values. 0129 static UContext computeUContext(const Data& theData, double theU); 0130 0131 //! Compute point with pre-computed U context. 0132 static gp_Pnt computeD0(const Data& theData, const UContext& theUCtx, double theV); 0133 0134 //! Compute point with D1 with pre-computed U context. 0135 static GeomGridEval::SurfD1 computeD1(const Data& theData, const UContext& theUCtx, double theV); 0136 0137 //! Compute point with D2 with pre-computed U context. 0138 static GeomGridEval::SurfD2 computeD2(const Data& theData, const UContext& theUCtx, double theV); 0139 0140 //! Compute point with D3 with pre-computed U context. 0141 static GeomGridEval::SurfD3 computeD3(const Data& theData, const UContext& theUCtx, double theV); 0142 0143 //! Compute DN with pre-computed U context. 0144 static gp_Vec computeDN(const Data& theData, 0145 const UContext& theUCtx, 0146 double theV, 0147 int theNU, 0148 int theNV); 0149 0150 occ::handle<Geom_ToroidalSurface> myGeom; 0151 }; 0152 0153 #endif // _GeomGridEval_Torus_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|