Sign in to follow this  

Detecting closed spaces between lines

Recommended Posts

paulm19    122
I am trying to figure out the best way of detecting enclosed spaces between lines, then computing the area of the encolosed space. I am using C# and I have a collection of lines that the user can draw onto the screen. I then need to detect any enclosed areas (think photoshop fill tool). Once I detect the enclosed areas I need to compute the area. I have a function that can compute the area of a polygon by passin in all it's points. Does anyone have any thoughts or suggestions on where to start?

Share this post

Link to post
Share on other sites
dalep    331
Start with Google or Wikipedia ;)

Point in Polygon:

That won't reliably detect the condition of a closed polygon. That's something you'd maintain during line-input from the user. So they use a menu command to start drawing a polygon and they click, click, click and you add those points to a buffer and when they are done you make the last point in the buffer the same as the first.

Detecting conditions like twistings (i.e. figure 8) are a separate issue. As are overlaps and cutouts, islands, etc, etc, etc.

The flood fill type operations, which work on polygons that aren't formalized (that is to say are just pixels on the screen) are done along scanlines and are intrinsically raster-based.

There is a HUGE amount of literature on these subjects out there on the web. You just need to learn a little of the jargon so you know what to search on and that Wikipedia article is as good a place as any to start.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this