vigra icon indicating copy to clipboard operation
vigra copied to clipboard

Refactor and merge Hans' and Ulli's polygon support

Open ukoethe opened this issue 13 years ago • 1 comments

ukoethe avatar Jul 10 '11 22:07 ukoethe

Concerning my polygon class, I wonder if a cleaner approach could be a combination of

  • a data container class based on NumpyArray[View](thus offering full numpy compatibility and potential) instead of std::vector as it is now, and
  • free functions containing the different algorithms.

The implementation I have is based on a PointArray class (originally intended to represent a set, not necessarily even a sequence of points), which wraps a std::vector, and a derived Polygon class which has additional conceptual properties (e.g. arc length, which is not defined on a point array), data members caching various interesting values, and some member functions.

This has the following problems:

  • The PointArray base class restricts the use of the algorithms to other point array representations, i.e. we cannot work with views of e.g. data from numpy arrays.
  • The "is-a" relationship between the two classes is broken, due to the caching data members. I.e. if I use PointArray's modifying methods, the meta information managed by the derived Polygon class becomes invalid.

I think the design needs to be revamped, while the algorithms should be quite easy to reuse, and the existing functionality gives a good impression of what's commonly needed.

hmeine avatar Jul 25 '11 13:07 hmeine