How does that work ? Do you have more than one vertex defined per xy position ?
I wasn't trying to be rude when I mentioned the need for more research - I was trying to gently point out the value of a quick google

. You should very easily find lots of references to multi-valued heightmaps there.
IIRC there are 2 main techniques. One is to have multiple heightmaps layered on each other, each one being "solid" or "space" and then you simply make the area between the top of a solid and the top of a space == space, and the top of a space to the top of a solid == solid. The other is to parametrically define the HM, which is a lot better in some ways (makes it easy to encode entire map in a single number), and then you very very simply just use a multivalued function

.
But...google it; it's been a very long time since I was doing HM's manually.