Skip to content

Commit 83f4e2f

Browse files
committed
Coding - Refactor code for improved readability and consistency in Geom2dGridEval classes
1 parent a4c4b6c commit 83f4e2f

File tree

7 files changed

+84
-113
lines changed

7 files changed

+84
-113
lines changed

src/ModelingData/TKG2d/GTests/Geom2dGridEval_Curve_Test.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ TEST(Geom2dGridEval_CurveTest, BezierCurveDispatch)
538538
aPoles.SetValue(3, gp_Pnt2d(3, 2));
539539
aPoles.SetValue(4, gp_Pnt2d(4, 0));
540540
occ::handle<Geom2d_BezierCurve> aBezier = new Geom2d_BezierCurve(aPoles);
541-
Geom2dAdaptor_Curve anAdaptor(aBezier);
541+
Geom2dAdaptor_Curve anAdaptor(aBezier);
542542

543543
Geom2dGridEval_Curve anEval;
544544
anEval.Initialize(anAdaptor);

src/ModelingData/TKG2d/Geom2dGridEval/Geom2dGridEval_BSplineCurve.cxx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ NCollection_Array1<Geom2dGridEval::CurveD1> Geom2dGridEval_BSplineCurve::Evaluat
228228
Geom2dGridEval::CurveD1& theResult) {
229229
theCache->D1Local(theLocalParam, theResult.Point, theResult.D1);
230230
},
231-
[](const CurveData& theData,
232-
double theParam,
233-
int theSpanIdx,
234-
Geom2dGridEval::CurveD1& theResult) {
231+
[](const CurveData& theData,
232+
double theParam,
233+
int theSpanIdx,
234+
Geom2dGridEval::CurveD1& theResult) {
235235
BSplCLib::D1(theParam,
236236
theSpanIdx,
237237
theData.Degree,
@@ -264,10 +264,10 @@ NCollection_Array1<Geom2dGridEval::CurveD2> Geom2dGridEval_BSplineCurve::Evaluat
264264
Geom2dGridEval::CurveD2& theResult) {
265265
theCache->D2Local(theLocalParam, theResult.Point, theResult.D1, theResult.D2);
266266
},
267-
[](const CurveData& theData,
268-
double theParam,
269-
int theSpanIdx,
270-
Geom2dGridEval::CurveD2& theResult) {
267+
[](const CurveData& theData,
268+
double theParam,
269+
int theSpanIdx,
270+
Geom2dGridEval::CurveD2& theResult) {
271271
BSplCLib::D2(theParam,
272272
theSpanIdx,
273273
theData.Degree,
@@ -301,10 +301,10 @@ NCollection_Array1<Geom2dGridEval::CurveD3> Geom2dGridEval_BSplineCurve::Evaluat
301301
Geom2dGridEval::CurveD3& theResult) {
302302
theCache->D3Local(theLocalParam, theResult.Point, theResult.D1, theResult.D2, theResult.D3);
303303
},
304-
[](const CurveData& theData,
305-
double theParam,
306-
int theSpanIdx,
307-
Geom2dGridEval::CurveD3& theResult) {
304+
[](const CurveData& theData,
305+
double theParam,
306+
int theSpanIdx,
307+
Geom2dGridEval::CurveD3& theResult) {
308308
BSplCLib::D3(theParam,
309309
theSpanIdx,
310310
theData.Degree,

src/ModelingData/TKG2d/Geom2dGridEval/Geom2dGridEval_Circle.cxx

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ NCollection_Array1<Geom2dGridEval::CurveD1> Geom2dGridEval_Circle::EvaluateGridD
6868
return NCollection_Array1<Geom2dGridEval::CurveD1>();
6969
}
7070

71-
const int aNb = theParams.Size();
71+
const int aNb = theParams.Size();
7272
NCollection_Array1<Geom2dGridEval::CurveD1> aResult(1, aNb);
7373

7474
const gp_Circ2d& aCirc = myGeom->Circ2d();
@@ -92,11 +92,10 @@ NCollection_Array1<Geom2dGridEval::CurveD1> Geom2dGridEval_Circle::EvaluateGridD
9292

9393
// P = C + R * (cos(u) * X + sin(u) * Y)
9494
// D1 = R * (-sin(u) * X + cos(u) * Y)
95-
aResult.ChangeValue(i - theParams.Lower()
96-
+ 1) = {gp_Pnt2d(aCX + aRadius * (cosU * aXX + sinU * aYX),
97-
aCY + aRadius * (cosU * aXY + sinU * aYY)),
98-
gp_Vec2d(aRadius * (-sinU * aXX + cosU * aYX),
99-
aRadius * (-sinU * aXY + cosU * aYY))};
95+
aResult.ChangeValue(i - theParams.Lower() + 1) = {
96+
gp_Pnt2d(aCX + aRadius * (cosU * aXX + sinU * aYX),
97+
aCY + aRadius * (cosU * aXY + sinU * aYY)),
98+
gp_Vec2d(aRadius * (-sinU * aXX + cosU * aYX), aRadius * (-sinU * aXY + cosU * aYY))};
10099
}
101100
return aResult;
102101
}
@@ -111,7 +110,7 @@ NCollection_Array1<Geom2dGridEval::CurveD2> Geom2dGridEval_Circle::EvaluateGridD
111110
return NCollection_Array1<Geom2dGridEval::CurveD2>();
112111
}
113112

114-
const int aNb = theParams.Size();
113+
const int aNb = theParams.Size();
115114
NCollection_Array1<Geom2dGridEval::CurveD2> aResult(1, aNb);
116115

117116
const gp_Circ2d& aCirc = myGeom->Circ2d();
@@ -136,13 +135,11 @@ NCollection_Array1<Geom2dGridEval::CurveD2> Geom2dGridEval_Circle::EvaluateGridD
136135
// P = C + R * (cos(u) * X + sin(u) * Y)
137136
// D1 = R * (-sin(u) * X + cos(u) * Y)
138137
// D2 = R * (-cos(u) * X - sin(u) * Y)
139-
aResult.ChangeValue(i - theParams.Lower()
140-
+ 1) = {gp_Pnt2d(aCX + aRadius * (cosU * aXX + sinU * aYX),
141-
aCY + aRadius * (cosU * aXY + sinU * aYY)),
142-
gp_Vec2d(aRadius * (-sinU * aXX + cosU * aYX),
143-
aRadius * (-sinU * aXY + cosU * aYY)),
144-
gp_Vec2d(aRadius * (-cosU * aXX - sinU * aYX),
145-
aRadius * (-cosU * aXY - sinU * aYY))};
138+
aResult.ChangeValue(i - theParams.Lower() + 1) = {
139+
gp_Pnt2d(aCX + aRadius * (cosU * aXX + sinU * aYX),
140+
aCY + aRadius * (cosU * aXY + sinU * aYY)),
141+
gp_Vec2d(aRadius * (-sinU * aXX + cosU * aYX), aRadius * (-sinU * aXY + cosU * aYY)),
142+
gp_Vec2d(aRadius * (-cosU * aXX - sinU * aYX), aRadius * (-cosU * aXY - sinU * aYY))};
146143
}
147144
return aResult;
148145
}
@@ -157,7 +154,7 @@ NCollection_Array1<Geom2dGridEval::CurveD3> Geom2dGridEval_Circle::EvaluateGridD
157154
return NCollection_Array1<Geom2dGridEval::CurveD3>();
158155
}
159156

160-
const int aNb = theParams.Size();
157+
const int aNb = theParams.Size();
161158
NCollection_Array1<Geom2dGridEval::CurveD3> aResult(1, aNb);
162159

163160
const gp_Circ2d& aCirc = myGeom->Circ2d();
@@ -183,15 +180,12 @@ NCollection_Array1<Geom2dGridEval::CurveD3> Geom2dGridEval_Circle::EvaluateGridD
183180
// D1 = R * (-sin(u) * X + cos(u) * Y)
184181
// D2 = R * (-cos(u) * X - sin(u) * Y)
185182
// D3 = R * (sin(u) * X - cos(u) * Y)
186-
aResult.ChangeValue(i - theParams.Lower()
187-
+ 1) = {gp_Pnt2d(aCX + aRadius * (cosU * aXX + sinU * aYX),
188-
aCY + aRadius * (cosU * aXY + sinU * aYY)),
189-
gp_Vec2d(aRadius * (-sinU * aXX + cosU * aYX),
190-
aRadius * (-sinU * aXY + cosU * aYY)),
191-
gp_Vec2d(aRadius * (-cosU * aXX - sinU * aYX),
192-
aRadius * (-cosU * aXY - sinU * aYY)),
193-
gp_Vec2d(aRadius * (sinU * aXX - cosU * aYX),
194-
aRadius * (sinU * aXY - cosU * aYY))};
183+
aResult.ChangeValue(i - theParams.Lower() + 1) = {
184+
gp_Pnt2d(aCX + aRadius * (cosU * aXX + sinU * aYX),
185+
aCY + aRadius * (cosU * aXY + sinU * aYY)),
186+
gp_Vec2d(aRadius * (-sinU * aXX + cosU * aYX), aRadius * (-sinU * aXY + cosU * aYY)),
187+
gp_Vec2d(aRadius * (-cosU * aXX - sinU * aYX), aRadius * (-cosU * aXY - sinU * aYY)),
188+
gp_Vec2d(aRadius * (sinU * aXX - cosU * aYX), aRadius * (sinU * aXY - cosU * aYY))};
195189
}
196190
return aResult;
197191
}

src/ModelingData/TKG2d/Geom2dGridEval/Geom2dGridEval_Ellipse.cxx

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ NCollection_Array1<Geom2dGridEval::CurveD1> Geom2dGridEval_Ellipse::EvaluateGrid
6868
return NCollection_Array1<Geom2dGridEval::CurveD1>();
6969
}
7070

71-
const int aNb = theParams.Size();
71+
const int aNb = theParams.Size();
7272
NCollection_Array1<Geom2dGridEval::CurveD1> aResult(1, aNb);
7373

7474
const gp_Elips2d& anElips = myGeom->Elips2d();
@@ -94,11 +94,10 @@ NCollection_Array1<Geom2dGridEval::CurveD1> Geom2dGridEval_Ellipse::EvaluateGrid
9494
// P = Center + MajorR * cos(u) * XDir + MinorR * sin(u) * YDir
9595
// D1 = -MajorR * sin(u) * XDir + MinorR * cos(u) * YDir
9696

97-
aResult.ChangeValue(i - theParams.Lower()
98-
+ 1) = {gp_Pnt2d(aCX + aMajR * cosU * aXX + aMinR * sinU * aYX,
99-
aCY + aMajR * cosU * aXY + aMinR * sinU * aYY),
100-
gp_Vec2d(-aMajR * sinU * aXX + aMinR * cosU * aYX,
101-
-aMajR * sinU * aXY + aMinR * cosU * aYY)};
97+
aResult.ChangeValue(i - theParams.Lower() + 1) = {
98+
gp_Pnt2d(aCX + aMajR * cosU * aXX + aMinR * sinU * aYX,
99+
aCY + aMajR * cosU * aXY + aMinR * sinU * aYY),
100+
gp_Vec2d(-aMajR * sinU * aXX + aMinR * cosU * aYX, -aMajR * sinU * aXY + aMinR * cosU * aYY)};
102101
}
103102
return aResult;
104103
}
@@ -113,7 +112,7 @@ NCollection_Array1<Geom2dGridEval::CurveD2> Geom2dGridEval_Ellipse::EvaluateGrid
113112
return NCollection_Array1<Geom2dGridEval::CurveD2>();
114113
}
115114

116-
const int aNb = theParams.Size();
115+
const int aNb = theParams.Size();
117116
NCollection_Array1<Geom2dGridEval::CurveD2> aResult(1, aNb);
118117

119118
const gp_Elips2d& anElips = myGeom->Elips2d();
@@ -140,13 +139,11 @@ NCollection_Array1<Geom2dGridEval::CurveD2> Geom2dGridEval_Ellipse::EvaluateGrid
140139
// D1 = -MajorR * sin(u) * XDir + MinorR * cos(u) * YDir
141140
// D2 = -MajorR * cos(u) * XDir - MinorR * sin(u) * YDir = -(P - Center)
142141

143-
aResult.ChangeValue(i - theParams.Lower()
144-
+ 1) = {gp_Pnt2d(aCX + aMajR * cosU * aXX + aMinR * sinU * aYX,
145-
aCY + aMajR * cosU * aXY + aMinR * sinU * aYY),
146-
gp_Vec2d(-aMajR * sinU * aXX + aMinR * cosU * aYX,
147-
-aMajR * sinU * aXY + aMinR * cosU * aYY),
148-
gp_Vec2d(-aMajR * cosU * aXX - aMinR * sinU * aYX,
149-
-aMajR * cosU * aXY - aMinR * sinU * aYY)};
142+
aResult.ChangeValue(i - theParams.Lower() + 1) = {
143+
gp_Pnt2d(aCX + aMajR * cosU * aXX + aMinR * sinU * aYX,
144+
aCY + aMajR * cosU * aXY + aMinR * sinU * aYY),
145+
gp_Vec2d(-aMajR * sinU * aXX + aMinR * cosU * aYX, -aMajR * sinU * aXY + aMinR * cosU * aYY),
146+
gp_Vec2d(-aMajR * cosU * aXX - aMinR * sinU * aYX, -aMajR * cosU * aXY - aMinR * sinU * aYY)};
150147
}
151148
return aResult;
152149
}
@@ -161,7 +158,7 @@ NCollection_Array1<Geom2dGridEval::CurveD3> Geom2dGridEval_Ellipse::EvaluateGrid
161158
return NCollection_Array1<Geom2dGridEval::CurveD3>();
162159
}
163160

164-
const int aNb = theParams.Size();
161+
const int aNb = theParams.Size();
165162
NCollection_Array1<Geom2dGridEval::CurveD3> aResult(1, aNb);
166163

167164
const gp_Elips2d& anElips = myGeom->Elips2d();
@@ -189,15 +186,12 @@ NCollection_Array1<Geom2dGridEval::CurveD3> Geom2dGridEval_Ellipse::EvaluateGrid
189186
// D2 = -MajorR * cos(u) * XDir - MinorR * sin(u) * YDir
190187
// D3 = MajorR * sin(u) * XDir - MinorR * cos(u) * YDir = -D1
191188

192-
aResult.ChangeValue(i - theParams.Lower()
193-
+ 1) = {gp_Pnt2d(aCX + aMajR * cosU * aXX + aMinR * sinU * aYX,
194-
aCY + aMajR * cosU * aXY + aMinR * sinU * aYY),
195-
gp_Vec2d(-aMajR * sinU * aXX + aMinR * cosU * aYX,
196-
-aMajR * sinU * aXY + aMinR * cosU * aYY),
197-
gp_Vec2d(-aMajR * cosU * aXX - aMinR * sinU * aYX,
198-
-aMajR * cosU * aXY - aMinR * sinU * aYY),
199-
gp_Vec2d(aMajR * sinU * aXX - aMinR * cosU * aYX,
200-
aMajR * sinU * aXY - aMinR * cosU * aYY)};
189+
aResult.ChangeValue(i - theParams.Lower() + 1) = {
190+
gp_Pnt2d(aCX + aMajR * cosU * aXX + aMinR * sinU * aYX,
191+
aCY + aMajR * cosU * aXY + aMinR * sinU * aYY),
192+
gp_Vec2d(-aMajR * sinU * aXX + aMinR * cosU * aYX, -aMajR * sinU * aXY + aMinR * cosU * aYY),
193+
gp_Vec2d(-aMajR * cosU * aXX - aMinR * sinU * aYX, -aMajR * cosU * aXY - aMinR * sinU * aYY),
194+
gp_Vec2d(aMajR * sinU * aXX - aMinR * cosU * aYX, aMajR * sinU * aXY - aMinR * cosU * aYY)};
201195
}
202196
return aResult;
203197
}

src/ModelingData/TKG2d/Geom2dGridEval/Geom2dGridEval_Line.hxx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public:
7474
for (int i = theParams.Lower(); i <= theParams.Upper(); ++i)
7575
{
7676
const double t = theParams.Value(i);
77-
aResult.SetValue(i - theParams.Lower() + 1,
78-
gp_Pnt2d(aLocX + t * aDirX, aLocY + t * aDirY));
77+
aResult.SetValue(i - theParams.Lower() + 1, gp_Pnt2d(aLocX + t * aDirX, aLocY + t * aDirY));
7978
}
8079
return aResult;
8180
}
@@ -108,10 +107,9 @@ public:
108107

109108
for (int i = theParams.Lower(); i <= theParams.Upper(); ++i)
110109
{
111-
const double t = theParams.Value(i);
112-
aResult.ChangeValue(i - theParams.Lower() + 1) = {
113-
gp_Pnt2d(aLocX + t * aDirX, aLocY + t * aDirY),
114-
aD1};
110+
const double t = theParams.Value(i);
111+
aResult.ChangeValue(i - theParams.Lower()
112+
+ 1) = {gp_Pnt2d(aLocX + t * aDirX, aLocY + t * aDirY), aD1};
115113
}
116114
return aResult;
117115
}
@@ -145,11 +143,9 @@ public:
145143

146144
for (int i = theParams.Lower(); i <= theParams.Upper(); ++i)
147145
{
148-
const double t = theParams.Value(i);
149-
aResult.ChangeValue(i - theParams.Lower() + 1) = {
150-
gp_Pnt2d(aLocX + t * aDirX, aLocY + t * aDirY),
151-
aD1,
152-
aD2};
146+
const double t = theParams.Value(i);
147+
aResult.ChangeValue(i - theParams.Lower()
148+
+ 1) = {gp_Pnt2d(aLocX + t * aDirX, aLocY + t * aDirY), aD1, aD2};
153149
}
154150
return aResult;
155151
}
@@ -184,11 +180,9 @@ public:
184180
for (int i = theParams.Lower(); i <= theParams.Upper(); ++i)
185181
{
186182
const double t = theParams.Value(i);
187-
aResult.ChangeValue(i - theParams.Lower() + 1) = {
188-
gp_Pnt2d(aLocX + t * aDirX, aLocY + t * aDirY),
189-
aD1,
190-
aZero,
191-
aZero};
183+
aResult.ChangeValue(
184+
i - theParams.Lower()
185+
+ 1) = {gp_Pnt2d(aLocX + t * aDirX, aLocY + t * aDirY), aD1, aZero, aZero};
192186
}
193187
return aResult;
194188
}

src/ModelingData/TKG2d/Geom2dGridEval/Geom2dGridEval_OffsetCurve.cxx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ NCollection_Array1<Geom2dGridEval::CurveD2> Geom2dGridEval_OffsetCurve::Evaluate
123123
gp_Vec2d aDummyD4;
124124
isDirectionChange =
125125
Geom2d_OffsetCurveUtils::AdjustDerivative(*myBasis,
126-
3,
127-
theParams.Value(theParams.Lower() + i - 1),
128-
aD1,
129-
aD2,
130-
aD3,
131-
aDummyD4);
126+
3,
127+
theParams.Value(theParams.Lower() + i - 1),
128+
aD1,
129+
aD2,
130+
aD3,
131+
aDummyD4);
132132
}
133133

134134
Geom2d_OffsetCurveUtils::CalculateD2(aP, aD1, aD2, aD3, isDirectionChange, myOffset);
@@ -180,13 +180,7 @@ NCollection_Array1<Geom2dGridEval::CurveD3> Geom2dGridEval_OffsetCurve::Evaluate
180180
Geom2d_OffsetCurveUtils::AdjustDerivative(*myBasis, 4, aParam, aD1, aD2, aD3, aD4);
181181
}
182182

183-
Geom2d_OffsetCurveUtils::CalculateD3(aP,
184-
aD1,
185-
aD2,
186-
aD3,
187-
aD4,
188-
isDirectionChange,
189-
myOffset);
183+
Geom2d_OffsetCurveUtils::CalculateD3(aP, aD1, aD2, aD3, aD4, isDirectionChange, myOffset);
190184
aResult.ChangeValue(i) = {aP, aD1, aD2, aD3};
191185
}
192186

0 commit comments

Comments
 (0)