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_Line_HeaderFile
0015 #define _GeomGridEval_Line_HeaderFile
0016
0017 #include <Geom_Line.hxx>
0018 #include <GeomGridEval.hxx>
0019 #include <NCollection_Array1.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 class GeomGridEval_Line
0032 {
0033 public:
0034 DEFINE_STANDARD_ALLOC
0035
0036
0037
0038 GeomGridEval_Line(const occ::handle<Geom_Line>& theLine)
0039 : myGeom(theLine)
0040 {
0041 }
0042
0043
0044 GeomGridEval_Line(const GeomGridEval_Line&) = delete;
0045 GeomGridEval_Line& operator=(const GeomGridEval_Line&) = delete;
0046 GeomGridEval_Line(GeomGridEval_Line&&) = delete;
0047 GeomGridEval_Line& operator=(GeomGridEval_Line&&) = delete;
0048
0049
0050 const occ::handle<Geom_Line>& Geometry() const { return myGeom; }
0051
0052
0053
0054
0055
0056 NCollection_Array1<gp_Pnt> EvaluateGrid(const NCollection_Array1<double>& theParams) const
0057 {
0058 if (myGeom.IsNull() || theParams.IsEmpty())
0059 {
0060 return NCollection_Array1<gp_Pnt>();
0061 }
0062
0063 NCollection_Array1<gp_Pnt> aResult(1, theParams.Length());
0064
0065
0066 const gp_Lin& aLin = myGeom->Lin();
0067 const gp_Pnt& aLoc = aLin.Location();
0068 const gp_Dir& aDir = aLin.Direction();
0069
0070
0071 const double aLocX = aLoc.X();
0072 const double aLocY = aLoc.Y();
0073 const double aLocZ = aLoc.Z();
0074 const double aDirX = aDir.X();
0075 const double aDirY = aDir.Y();
0076 const double aDirZ = aDir.Z();
0077
0078 for (int i = theParams.Lower(); i <= theParams.Upper(); ++i)
0079 {
0080 const double t = theParams.Value(i);
0081 aResult.SetValue(i - theParams.Lower() + 1,
0082 gp_Pnt(aLocX + t * aDirX, aLocY + t * aDirY, aLocZ + t * aDirZ));
0083 }
0084 return aResult;
0085 }
0086
0087
0088
0089
0090
0091
0092 NCollection_Array1<GeomGridEval::CurveD1> EvaluateGridD1(
0093 const NCollection_Array1<double>& theParams) const
0094 {
0095 if (myGeom.IsNull() || theParams.IsEmpty())
0096 {
0097 return NCollection_Array1<GeomGridEval::CurveD1>();
0098 }
0099
0100 NCollection_Array1<GeomGridEval::CurveD1> aResult(1, theParams.Length());
0101
0102 const gp_Lin& aLin = myGeom->Lin();
0103 const gp_Pnt& aLoc = aLin.Location();
0104 const gp_Dir& aDir = aLin.Direction();
0105
0106 const double aLocX = aLoc.X();
0107 const double aLocY = aLoc.Y();
0108 const double aLocZ = aLoc.Z();
0109 const double aDirX = aDir.X();
0110 const double aDirY = aDir.Y();
0111 const double aDirZ = aDir.Z();
0112
0113
0114 const gp_Vec aD1(aDirX, aDirY, aDirZ);
0115
0116 for (int i = theParams.Lower(); i <= theParams.Upper(); ++i)
0117 {
0118 const double t = theParams.Value(i);
0119 aResult.ChangeValue(i - theParams.Lower()
0120 + 1) = {gp_Pnt(aLocX + t * aDirX, aLocY + t * aDirY, aLocZ + t * aDirZ),
0121 aD1};
0122 }
0123 return aResult;
0124 }
0125
0126
0127
0128
0129
0130
0131 NCollection_Array1<GeomGridEval::CurveD2> EvaluateGridD2(
0132 const NCollection_Array1<double>& theParams) const
0133 {
0134 if (myGeom.IsNull() || theParams.IsEmpty())
0135 {
0136 return NCollection_Array1<GeomGridEval::CurveD2>();
0137 }
0138
0139 NCollection_Array1<GeomGridEval::CurveD2> aResult(1, theParams.Length());
0140
0141 const gp_Lin& aLin = myGeom->Lin();
0142 const gp_Pnt& aLoc = aLin.Location();
0143 const gp_Dir& aDir = aLin.Direction();
0144
0145 const double aLocX = aLoc.X();
0146 const double aLocY = aLoc.Y();
0147 const double aLocZ = aLoc.Z();
0148 const double aDirX = aDir.X();
0149 const double aDirY = aDir.Y();
0150 const double aDirZ = aDir.Z();
0151
0152 const gp_Vec aD1(aDirX, aDirY, aDirZ);
0153 const gp_Vec aD2(0, 0, 0);
0154
0155 for (int i = theParams.Lower(); i <= theParams.Upper(); ++i)
0156 {
0157 const double t = theParams.Value(i);
0158 aResult.ChangeValue(
0159 i - theParams.Lower()
0160 + 1) = {gp_Pnt(aLocX + t * aDirX, aLocY + t * aDirY, aLocZ + t * aDirZ), aD1, aD2};
0161 }
0162 return aResult;
0163 }
0164
0165
0166
0167
0168
0169
0170 NCollection_Array1<GeomGridEval::CurveD3> EvaluateGridD3(
0171 const NCollection_Array1<double>& theParams) const
0172 {
0173 if (myGeom.IsNull() || theParams.IsEmpty())
0174 {
0175 return NCollection_Array1<GeomGridEval::CurveD3>();
0176 }
0177
0178 NCollection_Array1<GeomGridEval::CurveD3> aResult(1, theParams.Length());
0179
0180 const gp_Lin& aLin = myGeom->Lin();
0181 const gp_Pnt& aLoc = aLin.Location();
0182 const gp_Dir& aDir = aLin.Direction();
0183
0184 const double aLocX = aLoc.X();
0185 const double aLocY = aLoc.Y();
0186 const double aLocZ = aLoc.Z();
0187 const double aDirX = aDir.X();
0188 const double aDirY = aDir.Y();
0189 const double aDirZ = aDir.Z();
0190
0191 const gp_Vec aD1(aDirX, aDirY, aDirZ);
0192 const gp_Vec aZero(0, 0, 0);
0193
0194 for (int i = theParams.Lower(); i <= theParams.Upper(); ++i)
0195 {
0196 const double t = theParams.Value(i);
0197 aResult.ChangeValue(
0198 i - theParams.Lower()
0199 + 1) = {gp_Pnt(aLocX + t * aDirX, aLocY + t * aDirY, aLocZ + t * aDirZ), aD1, aZero, aZero};
0200 }
0201 return aResult;
0202 }
0203
0204
0205
0206
0207
0208
0209
0210 NCollection_Array1<gp_Vec> EvaluateGridDN(const NCollection_Array1<double>& theParams,
0211 int theN) const
0212 {
0213 if (myGeom.IsNull() || theParams.IsEmpty() || theN < 1)
0214 {
0215 return NCollection_Array1<gp_Vec>();
0216 }
0217
0218 NCollection_Array1<gp_Vec> aResult(1, theParams.Length());
0219
0220 if (theN == 1)
0221 {
0222
0223 const gp_Dir aDir = myGeom->Lin().Direction();
0224 const gp_Vec aD1(aDir.X(), aDir.Y(), aDir.Z());
0225 for (int i = 1; i <= theParams.Length(); ++i)
0226 {
0227 aResult.SetValue(i, aD1);
0228 }
0229 }
0230 else
0231 {
0232
0233 const gp_Vec aZero(0, 0, 0);
0234 for (int i = 1; i <= theParams.Length(); ++i)
0235 {
0236 aResult.SetValue(i, aZero);
0237 }
0238 }
0239 return aResult;
0240 }
0241
0242 private:
0243 occ::handle<Geom_Line> myGeom;
0244 };
0245
0246 #endif