From bc6ac1cd05e82b628a03a19f8b1830714dcfb7fb Mon Sep 17 00:00:00 2001
From: Florent Lamiraux <florent@laas.fr>
Date: Thu, 21 Apr 2022 17:22:23 +0000
Subject: [PATCH] Use vector instead of list.

---
 include/hpp/manipulation/fwd.hh            |  1 +
 include/hpp/manipulation/graph/helper.hh   |  8 ++++----
 include/hpp/manipulation/problem-solver.hh |  8 ++++----
 src/graph/helper.cc                        |  6 +++---
 src/problem-solver.cc                      | 18 +++++++++---------
 5 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/include/hpp/manipulation/fwd.hh b/include/hpp/manipulation/fwd.hh
index 96d12d85..957ac715 100644
--- a/include/hpp/manipulation/fwd.hh
+++ b/include/hpp/manipulation/fwd.hh
@@ -144,6 +144,7 @@ namespace hpp {
     typedef core::JointAndShapes_t JointAndShapes_t;
 
     typedef std::list <std::string> StringList_t;
+    typedef std::vector <std::string> Strings_t;
 
     namespace pathOptimization {
       HPP_PREDEF_CLASS (SmallSteps);
diff --git a/include/hpp/manipulation/graph/helper.hh b/include/hpp/manipulation/graph/helper.hh
index f6a78e4d..cf01745a 100644
--- a/include/hpp/manipulation/graph/helper.hh
+++ b/include/hpp/manipulation/graph/helper.hh
@@ -191,15 +191,15 @@ namespace hpp {
 
         struct ObjectDef_t {
           std::string name;
-          StringList_t handles, shapes;
+          Strings_t handles, shapes;
         };
 
         GraphPtr_t graphBuilder (
             const ProblemSolverPtr_t& ps,
             const std::string& graphName,
-            const StringList_t& griNames,
-            const std::list <ObjectDef_t>& objs,
-            const StringList_t& envNames,
+            const Strings_t& griNames,
+            const std::vector <ObjectDef_t>& objs,
+            const Strings_t& envNames,
 	    const Rules_t& rules,
             const value_type& prePlaceWidth = 0.05);
         /// \}
diff --git a/include/hpp/manipulation/problem-solver.hh b/include/hpp/manipulation/problem-solver.hh
index 0fd9a121..dcca195c 100644
--- a/include/hpp/manipulation/problem-solver.hh
+++ b/include/hpp/manipulation/problem-solver.hh
@@ -91,8 +91,8 @@ namespace hpp {
         /// \param margin see hpp::constraints::ConvexShapeContact::setNormalMargin
 	/// 
 	void createPlacementConstraint (const std::string& name,
-					const StringList_t& surface1,
-					const StringList_t& surface2,
+					const Strings_t& surface1,
+					const Strings_t& surface2,
                                         const value_type& margin = 1e-4);
 
 	/// Create pre-placement constraint
@@ -103,8 +103,8 @@ namespace hpp {
         /// \param margin see hpp::constraints::ConvexShapeContact::setNormalMargin
 	/// 
 	void createPrePlacementConstraint (const std::string& name,
-					   const StringList_t& surface1,
-					   const StringList_t& surface2,
+					   const Strings_t& surface1,
+					   const Strings_t& surface2,
                                            const value_type& width,
                                            const value_type& margin = 1e-4);
 
diff --git a/src/graph/helper.cc b/src/graph/helper.cc
index 1a3ec310..e542b21e 100644
--- a/src/graph/helper.cc
+++ b/src/graph/helper.cc
@@ -1007,9 +1007,9 @@ namespace hpp {
         GraphPtr_t graphBuilder (
             const ProblemSolverPtr_t& ps,
             const std::string& graphName,
-            const StringList_t& griNames,
-            const std::list <ObjectDef_t>& objs,
-            const StringList_t& envNames,
+            const Strings_t& griNames,
+            const std::vector <ObjectDef_t>& objs,
+            const Strings_t& envNames,
 	    const std::vector <Rule>& rules,
             const value_type& prePlaceWidth)
         {
diff --git a/src/problem-solver.cc b/src/problem-solver.cc
index d5c5a291..0bf22ca0 100644
--- a/src/problem-solver.cc
+++ b/src/problem-solver.cc
@@ -239,17 +239,18 @@ namespace hpp {
     }
 
     void ProblemSolver::createPlacementConstraint
-    (const std::string& name, const StringList_t& surface1,
-     const StringList_t& surface2, const value_type& margin)
+    (const std::string& name, const Strings_t& surface1,
+     const Strings_t& surface2, const value_type& margin)
     {
       bool explicit_(true);
       if (!robot_) throw std::runtime_error ("No robot loaded");
       JointAndShapes_t floorSurfaces, objectSurfaces, l;
-      for (StringList_t::const_iterator it1 = surface1.begin ();
+      for (Strings_t::const_iterator it1 = surface1.begin ();
           it1 != surface1.end(); ++it1) {
         if (!robot_->jointAndShapes.has (*it1))
           throw std::runtime_error ("First list of triangles not found.");
         l = robot_->jointAndShapes.get (*it1);
+        objectSurfaces.insert(objectSurfaces.end(), l.begin(), l.end());
         for(auto js : l){
           JointPtr_t j(js.first);
           // If one robot contact surface is not on a freeflying object,
@@ -261,11 +262,10 @@ namespace hpp {
             {
               explicit_ = false;
             }
-          objectSurfaces.insert(objectSurfaces.end(), l.begin(), l.end());
         }
       }
 
-      for (StringList_t::const_iterator it2 = surface2.begin ();
+      for (Strings_t::const_iterator it2 = surface2.begin ();
           it2 != surface2.end(); ++it2) {
         // Search first robot triangles
         if (robot_->jointAndShapes.has (*it2))
@@ -319,13 +319,13 @@ namespace hpp {
     }
 
     void ProblemSolver::createPrePlacementConstraint
-    (const std::string& name, const StringList_t& surface1,
-     const StringList_t& surface2, const value_type& width,
+    (const std::string& name, const Strings_t& surface1,
+     const Strings_t& surface2, const value_type& width,
      const value_type& margin)
     {
       if (!robot_) throw std::runtime_error ("No robot loaded");
       JointAndShapes_t floorSurfaces, objectSurfaces, l;
-      for (StringList_t::const_iterator it1 = surface1.begin ();
+      for (Strings_t::const_iterator it1 = surface1.begin ();
           it1 != surface1.end(); ++it1) {
         if (!robot_->jointAndShapes.has (*it1))
           throw std::runtime_error ("First list of triangles not found.");
@@ -333,7 +333,7 @@ namespace hpp {
         objectSurfaces.insert(objectSurfaces.end(), l.begin(), l.end());
       }
 
-      for (StringList_t::const_iterator it2 = surface2.begin ();
+      for (Strings_t::const_iterator it2 = surface2.begin ();
           it2 != surface2.end(); ++it2) {
         // Search first robot triangles
         if (robot_->jointAndShapes.has (*it2))
-- 
GitLab