| 166 | } |
| 167 | |
| 168 | float GridMap::atPosition(const std::string& layer, const Position& position, InterpolationMethods interpolationMethod) const { |
| 169 | |
| 170 | bool skipNextSwitchCase = false; |
| 171 | switch (interpolationMethod) { |
| 172 | case InterpolationMethods::INTER_CUBIC_CONVOLUTION: { |
| 173 | float value; |
| 174 | if (atPositionBicubicConvolutionInterpolated(layer, position, value)) { |
| 175 | return value; |
| 176 | } else { |
| 177 | interpolationMethod = InterpolationMethods::INTER_LINEAR; |
| 178 | skipNextSwitchCase = true; |
| 179 | } |
| 180 | } |
| 181 | case InterpolationMethods::INTER_CUBIC: { |
| 182 | if (!skipNextSwitchCase) { |
| 183 | float value; |
| 184 | if (atPositionBicubicInterpolated(layer, position, value)) { |
| 185 | return value; |
| 186 | } else { |
| 187 | interpolationMethod = InterpolationMethods::INTER_LINEAR; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | case InterpolationMethods::INTER_LINEAR: { |
| 192 | float value; |
| 193 | if (atPositionLinearInterpolated(layer, position, value)) |
| 194 | return value; |
| 195 | else |
| 196 | interpolationMethod = InterpolationMethods::INTER_NEAREST; |
| 197 | } |
| 198 | case InterpolationMethods::INTER_NEAREST: { |
| 199 | Index index; |
| 200 | if (getIndex(position, index)) { |
| 201 | return at(layer, index); |
| 202 | } else |
| 203 | throw std::out_of_range("GridMap::atPosition(...) : Position is out of range."); |
| 204 | break; |
| 205 | } |
| 206 | default: |
| 207 | throw std::runtime_error( |
| 208 | "GridMap::atPosition(...) : Specified " |
| 209 | "interpolation method not implemented."); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | float& GridMap::at(const std::string& layer, const Index& index) { |
| 214 | try { |
no outgoing calls