views:

113

answers:

3

Hello, I have map (openstreetmap project) with many buildings. Each building is a polygon. How can I make saddle roof parts polygons for every building outline?

Algorithm should transform one polygon in 2D to set of polygons in 2D (or 3D).

Reason for this transformation is visualization - better rendering isometric view.

For example (shading isn't important):

alt text

Thanks

+1  A: 

Isn't this just what you get with a 4-neighbor watershed algorithm, plus marking all edges that are local extrema along the line perpendicular to the direction of fastest ascent? (The shading would need to be added somehow, of course, but wouldn't this give you the position of the roof peaks and angles?)

Rex Kerr
Watershed algorithm is pixel oriented. I have input data in vector form (list of vertex coordinates) and result should be vector form too.
Ah. Well, you can still use the same idea: parameterize your polygon so you can shrink it, then shrink until vertices combine. (This isn't a multiplicative shift, but a shift of the vertex along the "equal distance from each edge" line, just like with watershed.) Then throw away lines (i.e. regions with no thickness) and repeat. The lines you draw are the original polygon, the paths taken by the vertices, and the shrunken zero-area regions. This will produce all the figures you've shown. I don't know whether you can make simplifying assumptions about adjacent vertices combining.
Rex Kerr
+2  A: 

Main part (like 90%) of what you are looking for is called "skeleton". Take a look here, at the figure called "Other examples". This page is from a manual of a computer graphics library, so you'll find there a general description, and links to the (free) code.

AVB
The other 10%: each region in the skeleton contains exactly one segment on the boundary of the original polygon, whose (oriented) slope you can use to compute the shading.
This looks useful too: http://en.wikipedia.org/wiki/Straight_skeleton#External_links. And +1 @ the algorithmist.
Cam
+1  A: 

Your examples seem to assume that all roof slopes are the same. The additional lines (when seen directly from above) are then the lines of equal distance from the edges. These can be constructed by taking the angle bisector between two edges.

The algorithm would look like this:

  • Start with any two neighbouring edges.
  • Add a line along their angle bisector.
  • Take the next neighbouring edge.
  • Add a line along this angle bisector.
  • Where two new lines meet, mark a new vertex, and clip the lines.
  • From this vertex, add a line along the angle bisector of the two outer edges where the two lines originated.
  • Take the next edge, etc..
  • Take care to correctly clip the new lines and manage the new vertices.
Svante