Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Drawing / February 2007

Tip: Looking for answers? Try searching our database.

how to split region data?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kristopher Wragg - 15 Feb 2007 12:49 GMT
Hi,

I'm currently working on an application for my dissertation for my
final year at University.

I'm having a little trouble with the System.Drawing.Region class.

The application is being designed to help create and study the use of
Euler/Venn diagrams, the user can draw various shapes which are stored
as GraphicsPaths.

They can also shade the intersections of these paths to signify that
the two (or more) objects have no relation.

To do this I am using region.Intersect and region.Xor to get the
data... this works fine but I need some help solving a problem.

See image: http://www.xafiers-home.com/euler/euler.jpg

Here the two objects overlap, when creating the region with an Xor it
produces shading either side of the vertical shape.

I want to be able to differentiate between these two shaded regions in
the region, but I can not find any functionality to get at the data
and find each group of data.

If anyone could help I'd apprechiate it.

Regards,
Kris Wragg
Bob Powell [MVP] - 15 Feb 2007 13:17 GMT
You can get to the scan line data in a region using the
Region.GetRegionScans method.

#1 sort the scans into X and Y order.

#2 Step through the scans and see if the current scan overlaps with the
 previous one. If yes, add it to the list that it overlaps with, if
not, start a new list.

#3 continue to do this for all scans

#4 check all scans in all regions for overlap with scans in other
regions, if any overlap, combine the two lists, do this until you cannot
reduce the number of lists.

the resulting lists represent separate and contiguous areas

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> Hi,
>
[quoted text clipped - 26 lines]
> Regards,
> Kris Wragg
Kristopher Wragg - 16 Feb 2007 11:12 GMT
Hi,

Thanks for your reply, I've had an attempt at trying to do what you
said but so far haven't got it working correctly.

It seems an awfully long winded and processor intensive operation to
do something that should be fairly simple.

What I tried was to first get all the RectangleF's from the
GetRegionScan, then sorted them in order of Y then X.

Then I looped through them seeing whether rect[i] intersects with
rect[i+1] when rect[i+1] had been moved by -1,-1 then inflated by 2,2.

This worked to an extent but wasn't a very good solution, is there a
more optimal way of doing this? or perhaps you have an example of it
being used in practise?

many thanks,
Kris Wragg
Bob Powell [MVP] - 16 Feb 2007 13:15 GMT
I used this algorithm to find out how many different glyphs were on a
page of text and colour them with a different colour.

I didn't mess about inflating the rectangles but just looked to see if
any rectangle in the current Y+1 had a left-right overlap with the
current rectangle. You just need to see if any left-right boundary falls
in the length of the other rectangle.

I seem to remember processing a page of text in about 15 seconds.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> Hi,
>
[quoted text clipped - 16 lines]
> many thanks,
> Kris Wragg

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.