GCC Code Coverage Report


Directory: ./
File: src/nearest-neighbor/basic.hh
Date: 2024-08-10 11:29:48
Exec Total Coverage
Lines: 5 7 71.4%
Branches: 0 0 -%

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_BASIC_HH
31 #define HPP_CORE_NEAREST_NEIGHBOR_BASIC_HH
32
33 #include <hpp/core/fwd.hh>
34 #include <hpp/core/nearest-neighbor.hh>
35
36 namespace hpp {
37 namespace core {
38 namespace nearestNeighbor {
39 /// Optimization of the nearest neighbor search
40 class Basic : public NearestNeighbor {
41 public:
42 20 Basic(const DistancePtr_t& distance) : distance_(distance) {}
43
44 56 ~Basic() {}
45
46 14 virtual void clear() {}
47
48 82 void addNode(const NodePtr_t&) {}
49
50 virtual NodePtr_t search(const NodePtr_t& node,
51 const ConnectedComponentPtr_t& connectedComponent,
52 value_type& distance);
53
54 virtual NodePtr_t search(ConfigurationIn_t configuration,
55 const ConnectedComponentPtr_t& connectedComponent,
56 value_type& distance, bool reverse = false);
57
58 virtual Nodes_t KnearestSearch(
59 ConfigurationIn_t configuration,
60 const ConnectedComponentPtr_t& connectedComponent, const std::size_t K,
61 value_type& distance);
62
63 virtual Nodes_t KnearestSearch(
64 const NodePtr_t& node, const ConnectedComponentPtr_t& connectedComponent,
65 const std::size_t K, value_type& distance);
66
67 /// Return the K nearest nodes in the whole roadmap
68 /// \param configuration, the configuration to which distance is computed,
69 /// \param roadmap in which nodes are searched,
70 /// \param K the number of nearest neighbors to return
71 /// \retval distance to the Kth closest neighbor
72 /// \return the K nearest neighbors
73 virtual Nodes_t KnearestSearch(ConfigurationIn_t configuration,
74 const RoadmapPtr_t& roadmap,
75 const std::size_t K, value_type& distance);
76
77 NodeVector_t withinBall(ConfigurationIn_t configuration,
78 const ConnectedComponentPtr_t& cc,
79 value_type maxDistance);
80
81 virtual void merge(ConnectedComponentPtr_t, ConnectedComponentPtr_t) {}
82
83 // Get distance function
84 virtual DistancePtr_t distance() const { return distance_; }
85
86 private:
87 const DistancePtr_t distance_;
88
89 3 Basic() {}
90 HPP_SERIALIZABLE();
91 }; // class Basic
92 } // namespace nearestNeighbor
93 } // namespace core
94 } // namespace hpp
95
96 #endif // HPP_CORE_NEAREST_NEIGHBOR_BASIC_HH
97