| 276 | } |
| 277 | |
| 278 | void |
| 279 | NeighborhoodSearch::query() |
| 280 | { |
| 281 | for (PointSet& d : m_point_sets) |
| 282 | { |
| 283 | if (d.is_neighborsearch_enabled()) |
| 284 | { |
| 285 | for (auto& n : d.m_neighbors) |
| 286 | { |
| 287 | n.clear(); |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | std::vector<std::pair<HashKey const, unsigned int> const*> kvps(m_map.size()); |
| 293 | std::transform(m_map.begin(), m_map.end(), kvps.begin(), |
| 294 | [](std::pair<HashKey const, unsigned int> const& kvp) |
| 295 | { |
| 296 | return &kvp; |
| 297 | }); |
| 298 | |
| 299 | // Perform neighborhood search. |
| 300 | #ifdef _MSC_VER |
| 301 | concurrency::parallel_for_each |
| 302 | #else |
| 303 | __gnu_parallel::for_each |
| 304 | #endif |
| 305 | (kvps.begin(), kvps.end(), [&](std::pair<HashKey const, unsigned int> const* kvp_) |
| 306 | { |
| 307 | auto const& kvp = *kvp_; |
| 308 | HashEntry const& entry = m_entries[kvp.second]; |
| 309 | HashKey const& key = kvp.first; |
| 310 | |
| 311 | for (unsigned int a = 0; a < entry.n_indices(); ++a) |
| 312 | { |
| 313 | PointID const& va = entry.indices[a]; |
| 314 | PointSet& da = m_point_sets[va.point_set_id]; |
| 315 | for (unsigned int b = a + 1; b < entry.n_indices(); ++b) |
| 316 | { |
| 317 | PointID const& vb = entry.indices[b]; |
| 318 | PointSet& db = m_point_sets[vb.point_set_id]; |
| 319 | |
| 320 | if (!da.is_neighborsearch_enabled() && |
| 321 | !db.is_neighborsearch_enabled()) |
| 322 | { |
| 323 | continue; |
| 324 | } |
| 325 | |
| 326 | Real const* xa = da.point(va.point_id); |
| 327 | Real const* xb = db.point(vb.point_id); |
| 328 | Real tmp = xa[0] - xb[0]; |
| 329 | Real l2 = tmp * tmp; |
| 330 | tmp = xa[1] - xb[1]; |
| 331 | l2 += tmp * tmp; |
| 332 | tmp = xa[2] - xb[2]; |
| 333 | l2 += tmp * tmp; |
| 334 | |
| 335 | if (l2 < m_r2) |
nothing calls this directly
no test coverage detected