File indexing completed on 2026-09-28 09:20:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _GeomGridEval_HeaderFile
0015 #define _GeomGridEval_HeaderFile
0016
0017 #include <Geom_Curve.hxx>
0018 #include <Geom_Surface.hxx>
0019 #include <gp_Pnt2d.hxx>
0020 #include <NCollection_Array1.hxx>
0021 #include <NCollection_Array2.hxx>
0022
0023
0024
0025
0026
0027 namespace GeomGridEval
0028 {
0029
0030 using CurveD1 = Geom_Curve::ResD1;
0031 using CurveD2 = Geom_Curve::ResD2;
0032 using CurveD3 = Geom_Curve::ResD3;
0033 using SurfD1 = Geom_Surface::ResD1;
0034 using SurfD2 = Geom_Surface::ResD2;
0035 using SurfD3 = Geom_Surface::ResD3;
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 template <typename Evaluator>
0049 NCollection_Array2<gp_Pnt> EvaluateGridHelper(const NCollection_Array1<double>& theUParams,
0050 const NCollection_Array1<double>& theVParams,
0051 Evaluator theEval)
0052 {
0053 const int aNbU = theUParams.Length();
0054 const int aNbV = theVParams.Length();
0055 if (aNbU == 0 || aNbV == 0)
0056 {
0057 return NCollection_Array2<gp_Pnt>();
0058 }
0059
0060 NCollection_Array2<gp_Pnt> aResult(1, aNbU, 1, aNbV);
0061 for (int iU = 1; iU <= aNbU; ++iU)
0062 {
0063 const double aU = theUParams.Value(theUParams.Lower() + iU - 1);
0064 for (int iV = 1; iV <= aNbV; ++iV)
0065 {
0066 const double aV = theVParams.Value(theVParams.Lower() + iV - 1);
0067 aResult.SetValue(iU, iV, theEval(aU, aV));
0068 }
0069 }
0070 return aResult;
0071 }
0072
0073
0074
0075 template <typename Evaluator>
0076 NCollection_Array2<SurfD1> EvaluateGridD1Helper(const NCollection_Array1<double>& theUParams,
0077 const NCollection_Array1<double>& theVParams,
0078 Evaluator theEval)
0079 {
0080 const int aNbU = theUParams.Length();
0081 const int aNbV = theVParams.Length();
0082 if (aNbU == 0 || aNbV == 0)
0083 {
0084 return NCollection_Array2<SurfD1>();
0085 }
0086
0087 NCollection_Array2<SurfD1> aResult(1, aNbU, 1, aNbV);
0088 for (int iU = 1; iU <= aNbU; ++iU)
0089 {
0090 const double aU = theUParams.Value(theUParams.Lower() + iU - 1);
0091 for (int iV = 1; iV <= aNbV; ++iV)
0092 {
0093 const double aV = theVParams.Value(theVParams.Lower() + iV - 1);
0094 aResult.ChangeValue(iU, iV) = theEval(aU, aV);
0095 }
0096 }
0097 return aResult;
0098 }
0099
0100
0101
0102 template <typename Evaluator>
0103 NCollection_Array2<SurfD2> EvaluateGridD2Helper(const NCollection_Array1<double>& theUParams,
0104 const NCollection_Array1<double>& theVParams,
0105 Evaluator theEval)
0106 {
0107 const int aNbU = theUParams.Length();
0108 const int aNbV = theVParams.Length();
0109 if (aNbU == 0 || aNbV == 0)
0110 {
0111 return NCollection_Array2<SurfD2>();
0112 }
0113
0114 NCollection_Array2<SurfD2> aResult(1, aNbU, 1, aNbV);
0115 for (int iU = 1; iU <= aNbU; ++iU)
0116 {
0117 const double aU = theUParams.Value(theUParams.Lower() + iU - 1);
0118 for (int iV = 1; iV <= aNbV; ++iV)
0119 {
0120 const double aV = theVParams.Value(theVParams.Lower() + iV - 1);
0121 aResult.ChangeValue(iU, iV) = theEval(aU, aV);
0122 }
0123 }
0124 return aResult;
0125 }
0126
0127
0128
0129 template <typename Evaluator>
0130 NCollection_Array2<SurfD3> EvaluateGridD3Helper(const NCollection_Array1<double>& theUParams,
0131 const NCollection_Array1<double>& theVParams,
0132 Evaluator theEval)
0133 {
0134 const int aNbU = theUParams.Length();
0135 const int aNbV = theVParams.Length();
0136 if (aNbU == 0 || aNbV == 0)
0137 {
0138 return NCollection_Array2<SurfD3>();
0139 }
0140
0141 NCollection_Array2<SurfD3> aResult(1, aNbU, 1, aNbV);
0142 for (int iU = 1; iU <= aNbU; ++iU)
0143 {
0144 const double aU = theUParams.Value(theUParams.Lower() + iU - 1);
0145 for (int iV = 1; iV <= aNbV; ++iV)
0146 {
0147 const double aV = theVParams.Value(theVParams.Lower() + iV - 1);
0148 aResult.ChangeValue(iU, iV) = theEval(aU, aV);
0149 }
0150 }
0151 return aResult;
0152 }
0153
0154
0155
0156 template <typename Evaluator>
0157 NCollection_Array2<gp_Vec> EvaluateGridDNHelper(const NCollection_Array1<double>& theUParams,
0158 const NCollection_Array1<double>& theVParams,
0159 Evaluator theEval)
0160 {
0161 const int aNbU = theUParams.Length();
0162 const int aNbV = theVParams.Length();
0163 if (aNbU == 0 || aNbV == 0)
0164 {
0165 return NCollection_Array2<gp_Vec>();
0166 }
0167
0168 NCollection_Array2<gp_Vec> aResult(1, aNbU, 1, aNbV);
0169 for (int iU = 1; iU <= aNbU; ++iU)
0170 {
0171 const double aU = theUParams.Value(theUParams.Lower() + iU - 1);
0172 for (int iV = 1; iV <= aNbV; ++iV)
0173 {
0174 const double aV = theVParams.Value(theVParams.Lower() + iV - 1);
0175 aResult.SetValue(iU, iV, theEval(aU, aV));
0176 }
0177 }
0178 return aResult;
0179 }
0180
0181 }
0182
0183 #endif