
https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Improve the robustness of psites on graphs. * mln/core/graph_psite.hh, mln/core/line_graph_psite.hh (to_psite): New method. (operator=): Don't copy the point set from the argument. Instead, ensure that that point set in compatible with the point set of the psite. graph_psite.hh | 19 ++++++++++++++++--- line_graph_psite.hh | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) Index: mln/core/graph_psite.hh --- mln/core/graph_psite.hh (revision 1725) +++ mln/core/graph_psite.hh (working copy) @@ -58,10 +58,14 @@ /// \{ graph_psite(const p_graph<P>& pg_, unsigned id); graph_psite(const self_& rhs); + /// \pre This psite must have the same graph point set as \a rhs. self_& operator= (const self_& rhs); /// \} - /// Access to point/psite. + /// Access to psite. + const self_& to_psite() const; + + /// Access to point. /// \{ operator P() const; const point& to_point() const; @@ -107,14 +111,23 @@ { if (&rhs == this) return *this; - // FIXME: Could we get rid of this cast? - const_cast< p_graph<P>& >(pg_) = rhs.pg_; + // Assigning a psite from a graph point set to a psite from + // another graph point set is meaningless. + mln_assertion(&pg_ == &rhs.pg_); id_ = rhs.id_; return *this; } template<typename P> inline + const graph_psite<P>& + graph_psite<P>::to_psite() const + { + return *this; + } + + template<typename P> + inline graph_psite<P>::operator P() const { return pg_.gr_.node_data(id_); Index: mln/core/line_graph_psite.hh --- mln/core/line_graph_psite.hh (revision 1725) +++ mln/core/line_graph_psite.hh (working copy) @@ -62,10 +62,14 @@ /// \{ line_graph_psite(const p_line_graph<P>& plg_, unsigned id); line_graph_psite(const self_& rhs); + /// \pre This psite must have the same graph point set as \a rhs. self_& operator= (const self_& rhs); /// \} - /// Access to point/psite. + /// Access to psite. + const self_& to_psite() const; + + /// Access to point. /// \{ operator point() const; const point& to_point() const; @@ -142,8 +146,9 @@ { if (&rhs == this) return *this; - // FIXME: Could we get rid of this cast? - const_cast< p_line_graph<P>& >(plg_) = rhs.plg_; + // Assigning a psite from a line graph point set to a psite from + // another line graph point set is meaningless. + mln_assertion(&plg_ == &rhs.plg_); id_ = rhs.id_; update_(); return *this; @@ -167,6 +172,14 @@ template<typename P> inline + const line_graph_psite<P>& + line_graph_psite<P>::to_psite() const + { + return *this; + } + + template<typename P> + inline const point_pair<P>& line_graph_psite<P>::to_point() const {