| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// |
| 2 |
|
|
// Copyright (c) 2014 CNRS |
| 3 |
|
|
// Authors: Florent Lamiraux |
| 4 |
|
|
// |
| 5 |
|
|
|
| 6 |
|
|
// Redistribution and use in source and binary forms, with or without |
| 7 |
|
|
// modification, are permitted provided that the following conditions are |
| 8 |
|
|
// met: |
| 9 |
|
|
// |
| 10 |
|
|
// 1. Redistributions of source code must retain the above copyright |
| 11 |
|
|
// notice, this list of conditions and the following disclaimer. |
| 12 |
|
|
// |
| 13 |
|
|
// 2. Redistributions in binary form must reproduce the above copyright |
| 14 |
|
|
// notice, this list of conditions and the following disclaimer in the |
| 15 |
|
|
// documentation and/or other materials provided with the distribution. |
| 16 |
|
|
// |
| 17 |
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 |
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 |
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 |
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 |
|
|
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 |
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 |
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 |
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 |
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 |
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 |
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 28 |
|
|
// DAMAGE. |
| 29 |
|
|
|
| 30 |
|
|
#ifndef HPP_CORE_NEAREST_NEIGHBOR_HH |
| 31 |
|
|
#define HPP_CORE_NEAREST_NEIGHBOR_HH |
| 32 |
|
|
|
| 33 |
|
|
#include <hpp/core/fwd.hh> |
| 34 |
|
|
#include <hpp/util/serialization-fwd.hh> |
| 35 |
|
|
|
| 36 |
|
|
namespace hpp { |
| 37 |
|
|
namespace core { |
| 38 |
|
|
/// Optimization of the nearest neighbor search |
| 39 |
|
|
class NearestNeighbor { |
| 40 |
|
|
public: |
| 41 |
|
|
virtual void clear() = 0; |
| 42 |
|
|
virtual void addNode(const NodePtr_t& node) = 0; |
| 43 |
|
|
|
| 44 |
|
|
/** |
| 45 |
|
|
* @brief search Return the closest node of the given configuration |
| 46 |
|
|
* @param configuration |
| 47 |
|
|
* @param connectedComponent |
| 48 |
|
|
* @param distance |
| 49 |
|
|
* @param reverse if true, compute distance from given configuration to nodes |
| 50 |
|
|
* in roadmap, if false from nodes in roadmap to given configuration |
| 51 |
|
|
* @return |
| 52 |
|
|
*/ |
| 53 |
|
|
virtual NodePtr_t search(ConfigurationIn_t configuration, |
| 54 |
|
|
const ConnectedComponentPtr_t& connectedComponent, |
| 55 |
|
|
value_type& distance, bool reverse = false) = 0; |
| 56 |
|
|
|
| 57 |
|
|
virtual NodePtr_t search(const NodePtr_t& node, |
| 58 |
|
|
const ConnectedComponentPtr_t& connectedComponent, |
| 59 |
|
|
value_type& distance) = 0; |
| 60 |
|
|
|
| 61 |
|
|
/// \param[out] distance to the Kth closest neighbor |
| 62 |
|
|
/// \return the K nearest neighbors |
| 63 |
|
|
virtual Nodes_t KnearestSearch( |
| 64 |
|
|
ConfigurationIn_t configuration, |
| 65 |
|
|
const ConnectedComponentPtr_t& connectedComponent, const std::size_t K, |
| 66 |
|
|
value_type& distance) = 0; |
| 67 |
|
|
|
| 68 |
|
|
/// \param[out] distance to the Kth closest neighbor |
| 69 |
|
|
/// \return the K nearest neighbors |
| 70 |
|
|
virtual Nodes_t KnearestSearch( |
| 71 |
|
|
const NodePtr_t& node, const ConnectedComponentPtr_t& connectedComponent, |
| 72 |
|
|
const std::size_t K, value_type& distance) = 0; |
| 73 |
|
|
|
| 74 |
|
|
/// Return the K nearest nodes in the whole roadmap |
| 75 |
|
|
/// \param configuration, the configuration to which distance is computed, |
| 76 |
|
|
/// \param K the number of nearest neighbors to return |
| 77 |
|
|
/// \retval distance to the Kth closest neighbor |
| 78 |
|
|
/// \return the K nearest neighbors |
| 79 |
|
|
virtual Nodes_t KnearestSearch(ConfigurationIn_t configuration, |
| 80 |
|
|
const RoadmapPtr_t& roadmap, |
| 81 |
|
|
const std::size_t K, value_type& distance) = 0; |
| 82 |
|
|
|
| 83 |
|
|
/// \return all the nodes closer than \c maxDistance to \c configuration |
| 84 |
|
|
/// within \c connectedComponent. |
| 85 |
|
|
virtual NodeVector_t withinBall(ConfigurationIn_t configuration, |
| 86 |
|
|
const ConnectedComponentPtr_t& cc, |
| 87 |
|
|
value_type maxDistance) = 0; |
| 88 |
|
|
|
| 89 |
|
|
// merge two connected components in the whole tree |
| 90 |
|
|
virtual void merge(ConnectedComponentPtr_t cc1, |
| 91 |
|
|
ConnectedComponentPtr_t cc2) = 0; |
| 92 |
|
|
|
| 93 |
|
|
// Get distance function |
| 94 |
|
|
virtual DistancePtr_t distance() const = 0; |
| 95 |
|
|
|
| 96 |
|
28 |
virtual ~NearestNeighbor() {}; |
| 97 |
|
|
|
| 98 |
|
|
private: |
| 99 |
|
|
HPP_SERIALIZABLE(); |
| 100 |
|
|
}; // class NearestNeighbor |
| 101 |
|
|
} // namespace core |
| 102 |
|
|
} // namespace hpp |
| 103 |
|
|
|
| 104 |
|
|
#endif // HPP_CORE_NEAREST_NEIGHBOR_HH |
| 105 |
|
|
|