2010/1/10 Alex Leone <acleone@...400...>:
I'm willing to refactor to remove OptRect. Any objections?
OptRect exists for a reason. For example it is the prefect result type for getting a bounding box of a possibly empty set of points. Compare this:
Geom::OptRect bounds; for (int i = 0; i < n; ++i) { bounds.unionWith(Geom::OptRect(points[i], points[i]); }
to this:
Geom::Rect bounds; bool has_bounds = false; for (int i = 0; i < n; ++i) { if (!has_bounds) { has_bounds = true; bounds = Geom::Rect(points[i], points[i]); } else { bounds.expandTo(points[i]); } }
The methods might have slighty different names, but you get the idea. It's immensely useful to have two types of rectangle: one that can be empty (OptRect) and one that can't. This way you can avoid a lot of redundant error checking in functions that expect a non-empty rectangle.
I think the aliasing warnings can be fixed by tweaking the definition of OptRect a bit, because they did not appear before.
Regards, Krzysztof