|
13 | 13 |
|
14 | 14 | namespace grid_map {
|
15 | 15 |
|
16 |
| -unsigned int bindIndexToRange(int idReq, unsigned int nElem) |
| 16 | +unsigned int bindIndexToRange(unsigned int idReq, unsigned int nElem) |
17 | 17 | {
|
18 |
| - if (idReq < 0) { |
19 |
| - return 0; |
| 18 | + if (idReq >= nElem) { |
| 19 | + return (nElem - 1); |
20 | 20 | }
|
21 |
| - if (static_cast<unsigned int>(idReq) >= nElem) { |
22 |
| - return static_cast<unsigned int>(nElem - 1); |
23 |
| - } |
24 |
| - return static_cast<unsigned int>(idReq); |
| 21 | + return idReq; |
25 | 22 | }
|
26 | 23 |
|
27 |
| -double getLayerValue(const Matrix &layerMat, int rowReq, int colReq) |
| 24 | +double getLayerValue(const Matrix &layerMat, unsigned int rowReq, unsigned int colReq) |
28 | 25 | {
|
29 | 26 | const auto numCol = layerMat.cols();
|
30 | 27 | const auto numRow = layerMat.rows();
|
@@ -92,7 +89,7 @@ bool assembleFunctionValueMatrix(const GridMap &gridMap, const std::string &laye
|
92 | 89 | }
|
93 | 90 |
|
94 | 91 | const Matrix &layerMatrix = gridMap.get(layer);
|
95 |
| - auto f = [&layerMatrix](int rowReq, int colReq) { |
| 92 | + auto f = [&layerMatrix](unsigned int rowReq, unsigned int colReq) { |
96 | 93 | double retVal = getLayerValue(layerMatrix, rowReq, colReq);
|
97 | 94 | return retVal;
|
98 | 95 | };
|
@@ -135,11 +132,7 @@ bool getNormalizedCoordinates(const GridMap &gridMap, const Position &queriedPos
|
135 | 132 |
|
136 | 133 | bool getIndicesOfMiddleKnot(const GridMap &gridMap, const Position &queriedPosition, Index *index)
|
137 | 134 | {
|
138 |
| - |
139 |
| - if (!gridMap.getIndex(queriedPosition, *index)) { |
140 |
| - return false; |
141 |
| - } |
142 |
| - return true; |
| 135 | + return gridMap.getIndex(queriedPosition, *index); |
143 | 136 | }
|
144 | 137 |
|
145 | 138 | } /* namespace bicubic_conv */
|
@@ -264,11 +257,7 @@ bool getUnitSquareCornerIndices(const GridMap &gridMap, const Position &queriedP
|
264 | 257 |
|
265 | 258 | bool getClosestPointIndices(const GridMap &gridMap, const Position &queriedPosition, Index *index)
|
266 | 259 | {
|
267 |
| - |
268 |
| - if (!gridMap.getIndex(queriedPosition, *index)) { |
269 |
| - return false; |
270 |
| - } |
271 |
| - return true; |
| 260 | + return gridMap.getIndex(queriedPosition, *index); |
272 | 261 | }
|
273 | 262 |
|
274 | 263 | bool computeNormalizedCoordinates(const GridMap &gridMap, const Index &originIndex,
|
@@ -298,8 +287,8 @@ bool getFunctionValues(const Matrix &layerData, const IndicesMatrix &indices, Da
|
298 | 287 |
|
299 | 288 | void bindIndicesToRange(const GridMap &gridMap, IndicesMatrix *indices)
|
300 | 289 | {
|
301 |
| - const int numCol = gridMap.getSize().y(); |
302 |
| - const int numRow = gridMap.getSize().x(); |
| 290 | + const unsigned int numCol = gridMap.getSize().y(); |
| 291 | + const unsigned int numRow = gridMap.getSize().x(); |
303 | 292 |
|
304 | 293 | //top left
|
305 | 294 | {
|
@@ -346,10 +335,11 @@ bool getFirstOrderDerivatives(const Matrix &layerData, const IndicesMatrix &indi
|
346 | 335 | double firstOrderDerivativeAt(const Matrix &layerData, const Index &index, Dim2D dim,
|
347 | 336 | double resolution)
|
348 | 337 | {
|
349 |
| - const int numCol = layerData.cols(); |
350 |
| - const int numRow = layerData.rows(); |
| 338 | + const auto numCol{static_cast<unsigned int>(layerData.cols())}; |
| 339 | + const auto numRow{static_cast<unsigned int>(layerData.rows())}; |
351 | 340 |
|
352 |
| - double left, right; |
| 341 | + double left; |
| 342 | + double right; |
353 | 343 | switch (dim) {
|
354 | 344 | case Dim2D::X: {
|
355 | 345 | left = layerData(bindIndexToRange(index.x() + 1, numRow), index.y());
|
@@ -380,9 +370,8 @@ double mixedSecondOrderDerivativeAt(const Matrix &layerData, const Index &index,
|
380 | 370 | * the order doesn't matter. Derivative values are the same.
|
381 | 371 | * Taken from https://www.mathematik.uni-dortmund.de/~kuzmin/cfdintro/lecture4.pdf
|
382 | 372 | */
|
383 |
| - |
384 |
| - const int numCol = layerData.cols(); |
385 |
| - const int numRow = layerData.rows(); |
| 373 | + const auto numCol{static_cast<unsigned int>(layerData.cols())}; |
| 374 | + const auto numRow{static_cast<unsigned int>(layerData.rows())}; |
386 | 375 |
|
387 | 376 | const double f11 = layerData(bindIndexToRange(index.x() - 1, numRow),
|
388 | 377 | bindIndexToRange(index.y() - 1, numCol));
|
|
0 commit comments