| 82 | } |
| 83 | |
| 84 | void SpiralIterator::generateRing() |
| 85 | { |
| 86 | distance_++; |
| 87 | Index point(distance_, 0); |
| 88 | Index pointInMap; |
| 89 | Index normal; |
| 90 | do { |
| 91 | pointInMap.x() = point.x() + indexCenter_.x(); |
| 92 | pointInMap.y() = point.y() + indexCenter_.y(); |
| 93 | if (checkIfIndexInRange(pointInMap, bufferSize_)) { |
| 94 | if (distance_ == nRings_ || distance_ == nRings_ - 1) { |
| 95 | if (isInside(pointInMap)) |
| 96 | pointsRing_.push_back(pointInMap); |
| 97 | } else { |
| 98 | pointsRing_.push_back(pointInMap); |
| 99 | } |
| 100 | } |
| 101 | normal.x() = -signum(point.y()); |
| 102 | normal.y() = signum(point.x()); |
| 103 | if (normal.x() != 0 |
| 104 | && (int) Vector(point.x() + normal.x(), point.y()).norm() == distance_) |
| 105 | point.x() += normal.x(); |
| 106 | else if (normal.y() != 0 |
| 107 | && (int) Vector(point.x(), point.y() + normal.y()).norm() == distance_) |
| 108 | point.y() += normal.y(); |
| 109 | else { |
| 110 | point.x() += normal.x(); |
| 111 | point.y() += normal.y(); |
| 112 | } |
| 113 | } while (point.x() != distance_ || point.y() != 0); |
| 114 | } |
| 115 | |
| 116 | double SpiralIterator::getCurrentRadius() const |
| 117 | { |
nothing calls this directly
no test coverage detected