From 87bf261319f58f39dd54c2ef578e1011d94d55b3 Mon Sep 17 00:00:00 2001 From: Raphael Lefevre <rlefevre@laas.fr> Date: Wed, 21 Feb 2018 14:20:24 +0100 Subject: [PATCH] Initialization of the transition path validation --- include/hpp/manipulation/graph/graph-component.hh | 8 ++++---- include/hpp/manipulation/problem.hh | 6 +----- src/graph/graph-component.cc | 10 ++++++++++ src/problem.cc | 10 ++++++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/include/hpp/manipulation/graph/graph-component.hh b/include/hpp/manipulation/graph/graph-component.hh index 0c4e7696..9007b9e4 100644 --- a/include/hpp/manipulation/graph/graph-component.hh +++ b/include/hpp/manipulation/graph/graph-component.hh @@ -100,6 +100,9 @@ namespace hpp { /// Print the component in DOT language. virtual std::ostream& dotPrint (std::ostream& os, dot::DrawingAttributes da = dot::DrawingAttributes ()) const; + /// Declare a component as dirty + void setDirty(); + protected: /// Initialize the component void init (const GraphComponentWkPtr_t& weak); @@ -120,10 +123,7 @@ namespace hpp { bool isInit_; - void throwIfNotInitialized () const - { - if (!isInit_) throw std::logic_error ("The graph should have been initialized first."); - } + void throwIfNotInitialized () const; /// Print the object in a stream. virtual std::ostream& print (std::ostream& os) const; diff --git a/include/hpp/manipulation/problem.hh b/include/hpp/manipulation/problem.hh index c7c318b5..34bc9e48 100644 --- a/include/hpp/manipulation/problem.hh +++ b/include/hpp/manipulation/problem.hh @@ -74,11 +74,7 @@ namespace hpp { void setPathValidationFactory ( const core::PathValidationBuilder_t& factory, - const value_type& tol) - { - pvFactory_ = factory; - pvTol_ = tol; - } + const value_type& tol); private: /// The graph of constraints diff --git a/src/graph/graph-component.cc b/src/graph/graph-component.cc index b53bfd0a..b609ea8e 100644 --- a/src/graph/graph-component.cc +++ b/src/graph/graph-component.cc @@ -45,6 +45,11 @@ namespace hpp { return os; } + void GraphComponent::setDirty() + { + isInit_ = false; + } + void GraphComponent::addNumericalConstraint (const NumericalConstraintPtr_t& nm, const segments_t& passiveDofs) { @@ -132,6 +137,11 @@ namespace hpp { wkPtr_ = weak; } + void GraphComponent::throwIfNotInitialized () const + { + if (!isInit_ || (graph_.lock() && !graph_.lock()->isInit_)) throw std::logic_error ("The graph should have been initialized first."); + } + std::ostream& operator<< (std::ostream& os, const hpp::manipulation::graph::GraphComponent& graphComp) { diff --git a/src/problem.cc b/src/problem.cc index 78a1b72c..69a00b26 100644 --- a/src/problem.cc +++ b/src/problem.cc @@ -21,6 +21,7 @@ #include <hpp/manipulation/weighed-distance.hh> #include <hpp/manipulation/graph-steering-method.hh> #include <hpp/manipulation/graph-path-validation.hh> +#include <hpp/manipulation/graph/graph.hh> namespace hpp { namespace manipulation { @@ -73,5 +74,14 @@ namespace hpp { return HPP_DYNAMIC_PTR_CAST (SteeringMethod, Parent::steeringMethod()); } + + void Problem::setPathValidationFactory ( + const core::PathValidationBuilder_t& factory, + const value_type& tol) + { + pvFactory_ = factory; + pvTol_ = tol; + if (graph_) graph_->setDirty(); + } } // namespace manipulation } // namespace hpp -- GitLab