From: Krzysztof K. <twe...@gm...> - 2014-07-26 07:10:44
|
Hello There are several virtual methods in Curve which return Curve * (a raw pointer). They must return a pointer, because they are defined in the base class but return an object of a derived class. I propose replacing all these returns with std::auto_ptr<Curve>, and once we switch to C++11 - with std::unique_ptr<Curve>. This will allow us to write things such as curve->portion(0.1, 0.9)->boundsExact(), which are currently provided as redundant methods such as boundsLocal(). Similarly, the parametrized version of nearestTime() could be reimplemented as: Coord nearest_time_local(Curve const &c, Interval const &i, Point const &p) { return i.nearestTime(c.portion(i)->nearestTime(p)); } where Interval::nearestTime() is something I added just now, and defined as: Coord nearestTime(Coord t) const { if (t < min()) return 0; if (t > max()) return 1; return (t - min()) / extent(); } Any objections? Regards, Krzysztof |