http://qs321.pair.com?node_id=1161734


in reply to Re^2: Contour mapping?
in thread Contour mapping?

Wow.

I'd say don't worry about ordering (until later). Take one triangle at a time, and look at its three edges in whatever sequence is given.

For 2.4 million vertices (how many triangles?), it's a lot to keep track of, but it seems like just a matter of looping over triangles, and for each of those, looping over edges, keeping track of the edges you've done, and keeping a properly indexed list of iso-contour line segments as they come up, so that you know when you encounter each interior edge the second time, and can traverse the connections of linked contour lines.

Regarding that first point above, the logical possibilities are:

  1. None of the three edges contain a whole-number Z value
  2. One or more of the vertices is itself a whole-number Z value
  3. An edge contains just one whole-number Z value, so that value appears on one other edge (or may be the at the opposite vertex)
  4. An edge contains two or more whole-number Z values; either all those values will also appear on one other edge, or else they'll be divvied up among the other two edges (or one of them may be at the opposite vertex)
I hope you have a generous schedule (and are getting paid enough) for doing this. Sounds like a lot of work.

(updated wording in a couple bullet points)

Replies are listed 'Best First'.
Re^4: Contour mapping?
by pryrt (Abbot) on Apr 28, 2016 at 13:24 UTC

    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.