I think this is going in a better direction than my suggestion.
Regarding ordering:
- If you find edges that appear in only one triangle (a boundary edge), then any contour line that intersects that edge will "start" or "end" there.
- You can then traverse it to the other edge/vertex of that first triangle; that other edge will be shared with a new triangle, and so forth, for a continuous line in the proper order.
- It will get a bit more complicated when you hit a vertex instead of an edge for that contour, because then you have to try a couple of adjacent triangles to see which direction the contour flows... but in general, it's pretty straightforward
- Keep track of all the triangles you've processed for a given contour height as you're going
- Keep going until you reach another edge (or until you find a second intersection with a triangle you've already hit (for example, if the contour line were shaped like a number 9)
- If you don't have any "start" edges for a given contour height, you can just start at any edge/vertex that crosses the height under question, and start another contour loop/line from there.
- For a given contour height, you may have more than one starting point (like my two-island example), or if you've got a Y-shaped contour going off to the edges. So after you've ended one loop or line, check to see if there are any other edges/vertexes that you haven't processed yet that cross through your given height, and start again.
- Once you've used all the edges/vertexes that go thru a given height, move on to the next height.
Those triangles ended up being a lot more help than I originally thought they would (++graff).
Very interesting discussion, and I'll have to store away some of these concepts if I ever need the details of the contours, rather than just being able to visually see them.