I would like to find out if a GoLabeledLink crosses any other object. I tried GoLabeledLink.Bounds.InstersectsWith(otherObject.Bounds) but it returns true as soon as the other object get in the total bounds of the line (not neccessarily touching or crossing the line).
I know about the AvoidsNodes-property but we cannot use it for certain reasons.
Regards / Mattias
GoDiagram doesn’t have support for general object intersection, just for special cases.
Did you want to include the GoLabeledLink’s labels in the intersection, or just the stroke (RealLink) part? Did you want to consider the width of the pen? Are your strokes Bezier style?
You’ll need to iterate over all of the document objects and, depending on the object, treat it as a rectangle, as a stroke, or as something else, and try intersecting with each segment of your link stroke. Alas we do have some methods that would be useful, along with some useful optimizations to avoid iterating over all the objects, but these are all inaccessible to you. We have considered exposing some of this functionality, but that won’t happen in this upcoming release.
I did just what you described (iterate over each point of the link as well as all the objects in the document) and was initially happy with the result. However, when experimenting with large documents (i.e. many objects) I noticed a huge performance loss. I guess the optimated methods for this would be useful here :-)
Actually, there is one method that you could use to speed it up: use PickObjectsInRectangle of GoDocument or GoLayer to limit the search for each link to those document or layer objects whose Bounds intersect the link’s Bounds. That will produce a presumably very much shorter list of objects to iterate over for each segment of your link.
I will try that one. Thanks.