Tuesday, November 29, 2016

On the Road to Splines

A rounded non-uniform spline can offer a pleasant-looking route for a river, road, or railroad.  A fence or utility line may be represented by a polyline.  I need someplace to try all of that out, before I look to incorporate it into anything useful.  Hence my Drawing Example application, which does only a little bit now.  It lets me draw lines, polygons, and polylines.  I can select the shapes I've drawn, move them, and delete them.  In the screenshot, there are also toolbar items for polylines with curved corners (via circular arc fillet), arcs, and rounded splines - but I still have to add the code for them.

A few shapes drawn using the program: polygon, line, polyline

Things are just getting started, really.  The points (vertices, corners) of the multi-segment shapes should be adjustable after a shape is drawn.  Those other shapes I mentioned also need to be supported.  And right now, all it does is draw line segments.  I need to experiment with having it generate road, river, railroad, etc.  Persistence (saving/loading) would also be useful.

There's also an unresolved design issue, something that I'm having trouble resolving in my mind conceptually.  The shapes drawn represent things that can form networks: a river network, a road network, etc.  Such networks have their own topology, which is often described in terms of graphs, with nodes and links (or vertices and edges).  Short version: nodes are intersections, and links are the segments connecting them.  But how well does that relate to the shapes themselves?  And how about the points of a spline?  If you run one road into another, how does the intersection get formed - does a new vertex get added?  How is this all tracked?  Are shapes of each "substance" (road, water, etc.) handled separately?  What about when shapes made of such substances interact, such as when a road crosses a river, or a railroad crosses (or even runs down) a street?

Current architecture is trending toward MVC (model-view-controller) though it didn't start that way. But the shapes and "substances" seem like good candidates for model (along with topology when I have that figured out), and the rendering mechanisms are a good fit for view, so add in a little bit of controller and MVC makes a reasonable paradigm here.

There will probably be follow-up posts on this topic in the future.  And at some point this functionality will likely migrate into the 3D engine.

No comments:

Post a Comment