milena r3755: Fixes about aharpness attribute

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2009-05-05 Edwin Carlinet <carlinet@lrde.epita.fr> Fixes about aharpness attribute. * morpho/attribute/sharpness.hh: Sharpness attribute fixes. * morpho/tree/data.hh: Add leaves precondition. --- attribute/sharpness.hh | 8 ++++++-- tree/data.hh | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) Index: trunk/milena/mln/morpho/tree/data.hh =================================================================== --- trunk/milena/mln/morpho/tree/data.hh (revision 3754) +++ trunk/milena/mln/morpho/tree/data.hh (revision 3755) @@ -415,6 +415,7 @@ ++nroots_; } } + mln_assertion(leaves_.nsites() > 0); } template <typename I, typename S> Index: trunk/milena/mln/morpho/attribute/sharpness.hh =================================================================== --- trunk/milena/mln/morpho/attribute/sharpness.hh (revision 3754) +++ trunk/milena/mln/morpho/attribute/sharpness.hh (revision 3755) @@ -177,8 +177,12 @@ double sharpness<I>::to_result() const { - double d = (double) volume_.to_result() / - (double)(volume_.area() * (height_.to_result() + 1)); + double d = 0; + if (height_.to_result() != 0) + { + d = (double) volume_.to_result() / + (double)((volume_.area() - 1) * (height_.to_result() + 1) + 1); + } mln_postcondition(d >= 0 && d <= 1); return d; }
participants (1)
-
Edwin Carlinet