HighTechTalks DotNet Forums  

Rectangle Intersect problem

Dotnet Framework (Performance) microsoft.public.dotnet.framework.performance


Discuss Rectangle Intersect problem in the Dotnet Framework (Performance) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Xafier
 
Posts: n/a

Default Rectangle Intersect problem - 02-16-2006 , 09:25 AM






Hi

I'm working on a custom control thats pretty graphics intensive, it can
at an extreme with current test data, have upto 60,000 lines (each with
upto around 4 or 5 points).

To improve speed I'm using a pretty slow checking procedure that tests
the start and end points and whether the line intersects the box I'm
giving it as my screen.

The problem is, is that its slow... and so far I'm unable to find a
built in procedure for this or any fast code anywhere to solve the
problem.

Surely the Rectangle.IntersectsWith() procedure uses line intersect
algorithm... but I can't figure how to get access to it... which I
probably can't...

so, any suggestions or advice?

GDI+ seems to be dirt slow at drawing thousands of lines, I'm trying to
optimize things as much as I can as when I originally wrote this I was
new to C#, but 6 months later I have made quite a few optimizations but
it's still terribly slow when I "zoom out" and need to render a lot
more lines with scaling.

Thanks


Reply With Quote
  #2  
Old   
AMercer
 
Posts: n/a

Default RE: Rectangle Intersect problem - 02-17-2006 , 11:30 AM






Quote:
To improve speed I'm using a pretty slow checking procedure that tests
the start and end points and whether the line intersects the box I'm
giving it as my screen.

The problem is, is that its slow... and so far I'm unable to find a
built in procedure for this or any fast code anywhere to solve the
problem.
Maybe you could speed things up as follows. You have a rectangle for the
screen box. For each line, make a new rectangle with the line on one or the
other diagonal. Now use Rectangle.IntersectsWith on these two rectangles.
If false, you do not have an intersection, and if true you might, so run your
slow routine. If both (1) IntersectsWith is fast and (2) you have enough
lines that return false, you should speed things up. I haven't tried it, no
guarantees, just a suggestion.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.