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