473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to split region data?

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

Feb 15 '07 #1
3 5599
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

--
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.

Kristopher Wragg wrote:
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
Feb 15 '07 #2
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

Feb 16 '07 #3
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.

--
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.

Kristopher Wragg wrote:
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
Feb 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Steve Jorgensen | last post by:
Hi all, I'm working on the schema for a database that must represent data about stock & bond funds over time. My connundrum is that, for any of several dimension fields, including the fund name...
11
by: Altramagnus | last post by:
I have a complicated Region object, which I need to draw the outline, but not fill How can I convert the Region object to GraphicsPath object? or How can I draw the outline of the Region object?
9
by: Java and Swing | last post by:
Say I have a string which contains numbers separated by a comma... such as "0,1,2,3,4,5"...I want to split the string at the commas and return an array containing, 0,1...5. Suggestions? I've...
5
by: Mike | last post by:
I'm new to the C# world and learning as I go. I have a question, I'm getting data back from my database such as name/region. How can I split this and only return the region?
7
by: byoxemeek | last post by:
I have an array created from an undelimited text file I receive with a format like: 60190012003010203040506070809101112 60190012004010203040506070809101112 6019001200501020304...
0
by: Piccinini Andrea | last post by:
Hi, I'have a class that contains a Region and I need to serialize it. I'm istalled ISerializable interface and I try to serialize Region as following; Serialize: ...
37
by: Ajai Jose | last post by:
Hi , I work on an ARM processor based embedded system. Code is mainly in C language. The project has a huge source base. We are supposed to optimise it. Most datastructures are declared as static...
6
by: patrick.waldo | last post by:
Hi all, I'm analyzing some data that has a lot of country data. What I need to do is sort through this data and output it into an excel doc with summary information. The countries, though,...
1
by: adamjblakey | last post by:
Hi, At the moment i have a country and region ajax list so depending on which country you select the region field will auto fill. Now this is the code that makes this work: JS var...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.