| 276 | |
| 277 | template <class RandomIt, typename T> |
| 278 | inline void Sort(RandomIt bitr, RandomIt eitr, BackToFront<T>& me) |
| 279 | { |
| 280 | auto start = bitr; |
| 281 | |
| 282 | // brute force for testing |
| 283 | |
| 284 | std::vector<typename RandomIt::value_type> working; |
| 285 | std::vector<typename RandomIt::value_type> result; |
| 286 | working.assign(bitr, eitr); |
| 287 | size_t numNodes = working.size(); |
| 288 | |
| 289 | #ifdef MB_DEBUG |
| 290 | // check for any short loops and debug |
| 291 | for (auto it = working.begin(); it != working.end(); ++it) |
| 292 | { |
| 293 | auto it2 = it; |
| 294 | it2++; |
| 295 | for (; it2 != working.end(); ++it2) |
| 296 | { |
| 297 | int comp1 = me.CompareOrderWithUncertainty(*it, *it2); |
| 298 | int comp2 = me.CompareOrderWithUncertainty(*it2, *it); |
| 299 | if (comp1 * comp2 > 0) |
| 300 | { |
| 301 | me.CompareOrderWithUncertainty(*it, *it2); |
| 302 | me.CompareOrderWithUncertainty(*it2, *it); |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | // build the graph |
| 308 | std::vector<gnode<RandomIt>> graph; |
| 309 | for (auto it = working.begin(); it != working.end(); ++it) |
| 310 | { |
| 311 | gnode<RandomIt> anode; |
| 312 | anode.Value = it; |
| 313 | graph.push_back(anode); |
| 314 | } |
| 315 | for (auto& git : graph) |
| 316 | { |
| 317 | for (auto& next : graph) |
| 318 | { |
| 319 | if (git.Value != next.Value && me.CompareOrderWithUncertainty(*git.Value, *next.Value) > 0) |
| 320 | { |
| 321 | git.Closer.push_back(&next); |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | // graph constructed, now look for a loop |
| 327 | std::vector<gnode<RandomIt>> active; |
| 328 | std::vector<gnode<RandomIt>> loop; |
| 329 | for (auto& gval : graph) |
| 330 | { |
| 331 | loop.clear(); |
| 332 | if (findCycle(gval, graph, active, loop)) |
| 333 | { |
| 334 | vtkVector3d dir = me.CameraViewDirection; |
| 335 | dir.Normalize(); |
no test coverage detected