In my game the player can dynamically modify terrain. The map is stored within a 2D array of prefabricated 3D objects. This is working well for now. The player modifies terrain by selecting what sort of tile they'd like to create (like cliff going up or down), and then clicking individual tiles, or "painting" over multiple by holding down mouse button and scrolling.
I don't want the player to have to manually click every tile they want to rise or fall in elevation. The most elegant solution I can conceive, is for the player to "paint" a loop of cliff tiles, which is then filled in automatically when the loop closes. Imagine, perhaps, someone drawing a line using MS Paint or Photoshop, until that line closes into a shape which then autofills.
Let's say the player wants a plateau, and so they select cliff going up, and then click and drag the desired shape. Upon closing the loop, when the last cliff tile is created beside the first cliff tile, witchcraft is invoked which fills the inside.
I have no idea how this can be done, never mind elegantly or optimally. There are obvious possible solutions (find the average vector of all tiles in the loop, and then dijkstra algorithm from the average until the space is filled with the correct elevation), but these assume the shape generated is blobby or boxy. An irregular shape where the mid point falls outside of the shape is possible and would probably ruin that solution!
How can I fill the inside of a closed loop? I'd like a theoretical solution I can go away and implement in C#. At this point it seems like there is probably conceptual overlap between raster graphics and procedural maps!