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
AMercer - 17 Feb 2006 16:30 GMT
> 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
[quoted text clipped - 3 lines]
> 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.