From 8be2f91baf9a0933d8e9d8445cf507da6125eb11 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Thu, 10 Dec 2020 09:07:16 +0100
Subject: [PATCH] Rename methods in Roadmap to avoid masking parent class
 methods.

---
 include/hpp/manipulation/roadmap.hh |  4 ++--
 src/connected-component.cc          | 13 +++----------
 src/manipulation-planner.cc         |  2 +-
 src/roadmap.cc                      |  6 +++---
 4 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/include/hpp/manipulation/roadmap.hh b/include/hpp/manipulation/roadmap.hh
index de1aa61..2842f54 100644
--- a/include/hpp/manipulation/roadmap.hh
+++ b/include/hpp/manipulation/roadmap.hh
@@ -55,7 +55,7 @@ namespace hpp {
 
         /// Get the nearest neighbor in a given graph::Node and in a given
         /// ConnectedComponent.
-        RoadmapNodePtr_t nearestNode (const ConfigurationPtr_t& configuration,
+        RoadmapNodePtr_t nearestNodeInState (const ConfigurationPtr_t& configuration,
             const ConnectedComponentPtr_t& connectedComponent,
             const graph::StatePtr_t& state,
             value_type& minDistance) const;
@@ -105,7 +105,7 @@ namespace hpp {
 	  weak_ = shPtr;
 	}
 
-        virtual void addEdge (const core::EdgePtr_t& edge);
+        virtual void impl_addEdge (const core::EdgePtr_t& edge);
 
       private:
         typedef graph::Histograms_t Histograms_t;
diff --git a/src/connected-component.cc b/src/connected-component.cc
index 289dc7a..ce7e0fd 100644
--- a/src/connected-component.cc
+++ b/src/connected-component.cc
@@ -83,16 +83,9 @@ namespace hpp {
       core::ConnectedComponent::addNode(node);
       // Find right graph state in map and add roadmap node to corresponding vector
       const RoadmapNodePtr_t& n = static_cast <const RoadmapNodePtr_t> (node);
-      GraphStates_t::iterator mapIt = graphStateMap_.find(roadmap_->getState(n));
-      if (mapIt != graphStateMap_.end()) {
-        mapIt->second.push_back(n);
-      // if graph state not found, add new map element with one roadmap node
-      } else {
-	RoadmapNodes_t newRoadmapNodeVector;
-	newRoadmapNodeVector.push_back(n);
-	graphStateMap_.insert(std::pair<graph::StatePtr_t, RoadmapNodes_t>
-	  (roadmap_->getState(n), newRoadmapNodeVector));
-      }
+      RoadmapPtr_t roadmap = roadmap_.lock();
+      if (!roadmap) throw std::logic_error("The roadmap of this ConnectedComponent as been deleted.");
+      graphStateMap_[roadmap->getState(n)].push_back(n);
       assert (check ());
     }
 
diff --git a/src/manipulation-planner.cc b/src/manipulation-planner.cc
index 3e13a38..383cf7d 100644
--- a/src/manipulation-planner.cc
+++ b/src/manipulation-planner.cc
@@ -184,7 +184,7 @@ namespace hpp {
         core::value_type distance;
         for (itState = graphStates.begin (); itState != graphStates.end (); ++itState) {
           HPP_START_TIMECOUNTER(nearestNeighbor);
-          RoadmapNodePtr_t near = roadmap_->nearestNode (q_rand, HPP_STATIC_PTR_CAST(ConnectedComponent,*itcc), *itState, distance);
+          RoadmapNodePtr_t near = roadmap_->nearestNodeInState (q_rand, HPP_STATIC_PTR_CAST(ConnectedComponent,*itcc), *itState, distance);
           HPP_STOP_TIMECOUNTER(nearestNeighbor);
           HPP_DISPLAY_LAST_TIMECOUNTER(nearestNeighbor);
           if (!near) continue;
diff --git a/src/roadmap.cc b/src/roadmap.cc
index 175fa74..029dac5 100644
--- a/src/roadmap.cc
+++ b/src/roadmap.cc
@@ -91,7 +91,7 @@ namespace hpp {
       // graph->histograms() and this class will not know it.
     }
 
-    RoadmapNodePtr_t Roadmap::nearestNode (const ConfigurationPtr_t& configuration,
+    RoadmapNodePtr_t Roadmap::nearestNodeInState (const ConfigurationPtr_t& configuration,
         const ConnectedComponentPtr_t& connectedComponent,
         const graph::StatePtr_t& state,
         value_type& minDistance) const
@@ -159,9 +159,9 @@ namespace hpp {
       }
     }
 
-    void Roadmap::addEdge (const core::EdgePtr_t& edge)
+    void Roadmap::impl_addEdge (const core::EdgePtr_t& edge)
     {
-      Parent::addEdge(edge);
+      Parent::impl_addEdge(edge);
       const RoadmapNodePtr_t& f = static_cast <const RoadmapNodePtr_t> (edge->from());
       const RoadmapNodePtr_t& t = static_cast <const RoadmapNodePtr_t> (edge->to());
       if (f->graphState () == t->graphState ()) {
-- 
GitLab