diff --git a/include/hpp/manipulation/graph/graph-component.hh b/include/hpp/manipulation/graph/graph-component.hh index 36cb8d5b29ecdb3094ca896b54f83c89ada53cb9..f0c9c45586c6e1ca87a99bb28d02aefb4738375a 100644 --- a/include/hpp/manipulation/graph/graph-component.hh +++ b/include/hpp/manipulation/graph/graph-component.hh @@ -109,8 +109,16 @@ namespace hpp { /// Print the component in DOT language. virtual std::ostream& dotPrint (std::ostream& os, dot::DrawingAttributes da = dot::DrawingAttributes ()) const; + /// Invalidate the component + /// The component needs to be initialized again. + virtual void invalidate() + { + isInit_ = false; + } + /// Declare a component as dirty - void setDirty(); + /// \deprecated call invalidate instead + void setDirty() HPP_MANIPULATION_DEPRECATED; protected: /// Initialize the component @@ -143,7 +151,7 @@ namespace hpp { /// Populate DrawingAttributes tooltip virtual void populateTooltip (dot::Tooltip& tp) const; - virtual void initialize () = 0; + virtual void initialize() = 0; private: /// Name of the component. diff --git a/include/hpp/manipulation/graph/graph.hh b/include/hpp/manipulation/graph/graph.hh index af5840675609ddf46ee14769a61c22ef944fd72f..0cef13e8902af148661826fd052da26cbdb3f192 100644 --- a/include/hpp/manipulation/graph/graph.hh +++ b/include/hpp/manipulation/graph/graph.hh @@ -238,8 +238,12 @@ namespace hpp { /// Print the component in DOT language. virtual std::ostream& dotPrint (std::ostream& os, dot::DrawingAttributes da = dot::DrawingAttributes ()) const; + /// Initialize all components of the graph (edges and states) virtual void initialize (); + /// Invalidate all states and edges of the graph + virtual void invalidate(); + protected: /// Initialization of the object. void init (const GraphWkPtr_t& weak, DevicePtr_t robot); diff --git a/include/hpp/manipulation/graph/state.hh b/include/hpp/manipulation/graph/state.hh index f5a9e0013886d16bc715ff5e64bfbb997ec0d21f..916326cc79b10aa6fcba100321d2a378b6c35b23 100644 --- a/include/hpp/manipulation/graph/state.hh +++ b/include/hpp/manipulation/graph/state.hh @@ -130,7 +130,7 @@ namespace hpp { virtual void addNumericalConstraintForPath (const ImplicitPtr_t& nm, const segments_t& passiveDofs = segments_t ()) { - isInit_ = false; + invalidate(); numericalConstraintsForPath_.push_back (nm); passiveDofsForPath_.push_back (passiveDofs); } diff --git a/src/graph/edge.cc b/src/graph/edge.cc index 548a26cc456959c022a198ff3f9c1cd958dcfde2..e026a1d5c6dd2e11c52c3df4be272ef9513cea3b 100644 --- a/src/graph/edge.cc +++ b/src/graph/edge.cc @@ -115,7 +115,7 @@ namespace hpp { if (securityMargins_(row, col) != margin) { securityMargins_(row, col) = margin; securityMargins_(col, row) = margin; - isInit_ = false; + invalidate (); } } @@ -839,7 +839,7 @@ namespace hpp { (const constraints::ImplicitPtr_t& nm, const segments_t& passiveDofs) { - isInit_ = false; + invalidate (); paramNumericalConstraints_.push_back (nm); paramPassiveDofs_.push_back (passiveDofs); } @@ -853,7 +853,7 @@ namespace hpp { (const constraints::ImplicitPtr_t& nm, const segments_t& passiveDofs) { - isInit_ = false; + invalidate (); condNumericalConstraints_.push_back (nm); condPassiveDofs_.push_back (passiveDofs); } diff --git a/src/graph/graph-component.cc b/src/graph/graph-component.cc index b9188b8fdd52cc8731a0b77f138d3fbf59330252..0900acc1a30a762fc4a8e7ebfa91583e50e75e01 100644 --- a/src/graph/graph-component.cc +++ b/src/graph/graph-component.cc @@ -48,26 +48,26 @@ namespace hpp { void GraphComponent::setDirty() { - isInit_ = false; + invalidate(); } void GraphComponent::addNumericalConstraint (const ImplicitPtr_t& nm, const segments_t& passiveDofs) { - isInit_ = false; + invalidate(); numericalConstraints_.push_back(nm); passiveDofs_.push_back (passiveDofs); } void GraphComponent::addNumericalCost (const ImplicitPtr_t& cost) { - isInit_ = false; + invalidate(); numericalCosts_.push_back(cost); } void GraphComponent::resetNumericalConstraints () { - isInit_ = false; + invalidate(); numericalConstraints_.clear(); passiveDofs_.clear(); numericalCosts_.clear(); diff --git a/src/graph/graph.cc b/src/graph/graph.cc index 3725672c605ce5b73b10b969a32dc5dd9d87ddf1..e98c0a6b368f512e1f06d2df8d5fdbee09936350 100644 --- a/src/graph/graph.cc +++ b/src/graph/graph.cc @@ -50,7 +50,7 @@ namespace hpp { ); } - void Graph::initialize () + void Graph::initialize() { hists_.clear (); assert(components_.size() >= 1 && components_[0].lock() == wkPtr_.lock()); @@ -60,9 +60,19 @@ namespace hpp { isInit_ = true; } - StateSelectorPtr_t Graph::createStateSelector (const std::string& name) + void Graph::invalidate () { + for (std::size_t i = 1; i < components_.size(); ++i) + { + assert(components_[i].lock()); + components_[i].lock()->invalidate(); + } isInit_ = false; + } + + StateSelectorPtr_t Graph::createStateSelector (const std::string& name) + { + invalidate (); stateSelector_ = StateSelector::create (name); stateSelector_->parentGraph (wkPtr_); return stateSelector_; @@ -70,14 +80,14 @@ namespace hpp { void Graph::stateSelector (StateSelectorPtr_t ns) { - isInit_ = false; + invalidate (); stateSelector_ = ns; stateSelector_->parentGraph (wkPtr_); } void Graph::maxIterations (size_type iterations) { - isInit_ = false; + invalidate (); maxIterations_ = iterations; } @@ -88,7 +98,7 @@ namespace hpp { void Graph::errorThreshold (const value_type& threshold) { - isInit_ = false; + invalidate (); errorThreshold_ = threshold; } @@ -106,7 +116,7 @@ namespace hpp { { if (problem_ != problem) { problem_ = problem; - setDirty(); + invalidate(); } }