M
Mark P
I recently wrote a medium sized package to do some tasks in
computational geometry. I define basic items like Points, Edges, and
Polygons, and then more advanced operations that work with these items,
for example, computing intersection points or performing geometric
Boolean operations (unions, intersections, etc.).
Now I want to provide additional optional features, for example, maybe
Points will be able to contain a short list of extra data that can be
propagated through the algorithms and in some way appear in the output.
The problem I have is that all of my data structures seem intricately
dependent upon one another. I could derive from Point to make DataPoint
(a point + data), but then I'll need a DataEdge with 2 endpoint
DataPoints (since my Edges "own" their endpoints), I'll need a
DataPolygon which works with DataPoints, etc. I also make liberal use
of STL container classes (for example, a Polygon derives from
std::list<Point>) which seem inhospitable to inheritance unless I want
to contain only pointers (which I do for large items, but find tedious
for smaller items that aren't copied ever).
I'm sure this issue is a common one, and I'm equally sure there must be
a long std::list<Better Ideas> that would ease my pain. I'd be grateful
for any suggestions on this.
Thanks,
Mark
computational geometry. I define basic items like Points, Edges, and
Polygons, and then more advanced operations that work with these items,
for example, computing intersection points or performing geometric
Boolean operations (unions, intersections, etc.).
Now I want to provide additional optional features, for example, maybe
Points will be able to contain a short list of extra data that can be
propagated through the algorithms and in some way appear in the output.
The problem I have is that all of my data structures seem intricately
dependent upon one another. I could derive from Point to make DataPoint
(a point + data), but then I'll need a DataEdge with 2 endpoint
DataPoints (since my Edges "own" their endpoints), I'll need a
DataPolygon which works with DataPoints, etc. I also make liberal use
of STL container classes (for example, a Polygon derives from
std::list<Point>) which seem inhospitable to inheritance unless I want
to contain only pointers (which I do for large items, but find tedious
for smaller items that aren't copied ever).
I'm sure this issue is a common one, and I'm equally sure there must be
a long std::list<Better Ideas> that would ease my pain. I'd be grateful
for any suggestions on this.
Thanks,
Mark