diff --git a/include/hpp/manipulation/graph/graph.hh b/include/hpp/manipulation/graph/graph.hh index 0fc6144c6e506ba7df401ec07fd5b8dc1b039b6b..2fa1ee258eb3fac76f29d5d2c5642da7e3aefac0 100644 --- a/include/hpp/manipulation/graph/graph.hh +++ b/include/hpp/manipulation/graph/graph.hh @@ -45,27 +45,27 @@ namespace hpp { NodeSelectorPtr_t createNodeSelector(); /// Returns the states of a configuration. - virtual Nodes_t getNode(const Configuration_t config); + Nodes_t getNode(const Configuration_t config) const; /// Select randomly outgoing edges of the given nodes. - virtual Edges_t chooseEdge(const Nodes_t& node); + Edges_t chooseEdge(const Nodes_t& node) const; /// Constraint to project onto the Nodes_t. /// \param the Nodes_t on which to project. /// \return The initialized projector. - virtual ConstraintSetPtr_t configConstraint (const Nodes_t& nodes); + ConstraintSetPtr_t configConstraint (const Nodes_t& nodes); /// Constraint to project onto the same leaf as config. /// \param edges a list of edges defining the foliation. /// \param config Configuration that will initialize the projector. /// \return The initialized projector. - virtual ConstraintSetPtr_t configConstraint (const Edges_t& edges, ConfigurationIn_t config); + ConstraintSetPtr_t configConstraint (const Edges_t& edges, ConfigurationIn_t config); /// Constraint to project a path. /// \param edges a list of edges defining the foliation. /// \param config Configuration that will initialize the constraint. /// \return The initialized constraint. - virtual ConstraintSetPtr_t pathConstraint (const Edges_t& edges, ConfigurationIn_t config); + ConstraintSetPtr_t pathConstraint (const Edges_t& edges, ConfigurationIn_t config); /// Return the NodeSelector with the given name if any, /// NULL pointer if not found. diff --git a/include/hpp/manipulation/graph/node-selector.hh b/include/hpp/manipulation/graph/node-selector.hh index df4144c241ba7f625afdc88fae1c8be046c24cb0..bbe446235432ff4ca6bf9e37ea1f2593006efb55 100644 --- a/include/hpp/manipulation/graph/node-selector.hh +++ b/include/hpp/manipulation/graph/node-selector.hh @@ -37,22 +37,22 @@ namespace hpp { NodePtr_t createNode (); /// Returns the state of a configuration. - virtual NodePtr_t getNode(const Configuration_t config); + NodePtr_t getNode(const Configuration_t config) const; /// Select randomly an outgoing edge of the given node. - virtual EdgePtr_t chooseEdge(const NodePtr_t& node); + virtual EdgePtr_t chooseEdge(const NodePtr_t& node) const; /// Print the object in a stream. std::ostream& print (std::ostream& os) const; /// Should never be called. - virtual void addNumericalConstraint (const core::DifferentiableFunctionPtr_t& /* function */) + void addNumericalConstraint (const core::DifferentiableFunctionPtr_t& /* function */) { HPP_THROW_EXCEPTION (Bad_function_call, "This component does not have constraints."); } /// Should never be called. - virtual void addLockedDofConstraint (const core::LockedDof& /* constraint */) + void addLockedDofConstraint (const core::LockedDof& /* constraint */) { HPP_THROW_EXCEPTION (Bad_function_call, "This component does not have constraints."); } diff --git a/include/hpp/manipulation/graph/node.hh b/include/hpp/manipulation/graph/node.hh index 32784f41da02d9666e68b480e2ca69b8ae01658e..db5b24b501b76871969c4874c3e339c8d476fb06 100644 --- a/include/hpp/manipulation/graph/node.hh +++ b/include/hpp/manipulation/graph/node.hh @@ -52,7 +52,7 @@ namespace hpp { virtual bool contains (const Configuration_t config); /// Get the parent NodeSelector. - NodeSelectorWkPtr_t nodeSelector () + NodeSelectorWkPtr_t nodeSelector () const { return selector_; } diff --git a/src/graph/graph.cc b/src/graph/graph.cc index c64a4df216860b52488e58c1582f2ef0e19c2d8e..e61e28df8bcaf8a76f57e53d89f2d428eff4c941 100644 --- a/src/graph/graph.cc +++ b/src/graph/graph.cc @@ -73,16 +73,16 @@ namespace hpp { return robot_; } - Nodes_t Graph::getNode(const Configuration_t config) + Nodes_t Graph::getNode(const Configuration_t config) const { Nodes_t nodes; - for (NodeSelectors_t::iterator it = nodeSelectors_.begin(); + for (NodeSelectors_t::const_iterator it = nodeSelectors_.begin(); it != nodeSelectors_.end(); it++) nodes.push_back( (*it)->getNode(config) ); return nodes; } - Edges_t Graph::chooseEdge(const Nodes_t& nodes) + Edges_t Graph::chooseEdge(const Nodes_t& nodes) const { Edges_t edges; for (Nodes_t::const_iterator it = nodes.begin(); diff --git a/src/graph/node-selector.cc b/src/graph/node-selector.cc index 141bcd9189fa152b25e6b4ab239f0b95515dc46a..909ed6534221ce5f9794e93d3611ce5b2c00d3c1 100644 --- a/src/graph/node-selector.cc +++ b/src/graph/node-selector.cc @@ -44,16 +44,16 @@ namespace hpp { return newNode; } - NodePtr_t NodeSelector::getNode(const Configuration_t config) + NodePtr_t NodeSelector::getNode(const Configuration_t config) const { - for (Nodes_t::iterator it = orderedStates_.begin(); + for (Nodes_t::const_iterator it = orderedStates_.begin(); orderedStates_.end() != it; it++) if ((*it)->contains(config)) return *it; return NodePtr_t (); } - EdgePtr_t NodeSelector::chooseEdge(const NodePtr_t& node) + EdgePtr_t NodeSelector::chooseEdge(const NodePtr_t& node) const { const Edges_t neighbors = node->neighbors(); size_t n = rand() % neighbors.size();