Exemplo n.º 1
0
        //when we check for inclusion we expand the box by slack
        internal Geometry Hit(P2 p, double slack, EntityFilterDelegate filter)
        {
            if (filter != null && this.geometry != null)
            {
                if (filter(geometry.dObject) == false)
                {
                    return(null);
                }
            }
            if (left == null)
            {
                if (Box.Contains(p, slack))
                {
                    Line line = geometry as Line;

                    if (line != null)
                    {
                        if (Tessellator.DistToSegm(p, line.start, line.end) < slack + line.LineWidth / 2)
                        {
                            return(line);
                        }
                        return(null);
                    }
                    else if (Box.Contains(p))
                    {
                        return(geometry);
                    }

                    return(null);
                }
                else
                {
                    return(null);
                }
            }

            if (left.Box.Contains(p, slack))
            {
                Geometry g = left.Hit(p, slack, filter);
                if (g != null)
                {
                    return(g);
                }
            }

            if (right.Box.Contains(p, slack))
            {
                Geometry g = right.Hit(p, slack, filter);
                if (g != null)
                {
                    return(g);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        //when we check for inclusion we expand the box by slack
        internal Geometry Hit(P2 p, double slack)
        {
            if (l == null)
            {
                if (Box.Contains(p, slack))
                {
                    Line line = geometry as Line;

                    if (line != null)
                    {
                        if (Tessellator.DistToSegm(p, line.start, line.end) < slack + line.LineWidth / 2)
                        {
                            return(line);
                        }
                        return(null);
                    }
                    else if (Box.Contains(p))
                    {
                        return(geometry);
                    }

                    return(null);
                }
                else
                {
                    return(null);
                }
            }

            if (l.Box.Contains(p, slack))
            {
                Geometry g = l.Hit(p, slack);
                if (g != null)
                {
                    return(g);
                }
            }

            if (r.Box.Contains(p, slack))
            {
                Geometry g = r.Hit(p, slack);
                if (g != null)
                {
                    return(g);
                }
            }

            return(null);
        }
        //when we check for inclusion we expand the box by slack
        internal Geometry Hit(P2 p, double slack, EntityFilterDelegate filter, List <Geometry> subgraphCandidates)
        {
            if (filter != null && geometry != null)
            {
                if (filter(geometry.dObject) == false)
                {
                    return(null);
                }
            }
            if (left == null)
            {
                if (Box.Contains(p, slack))
                {
                    Line line = geometry as Line;

                    if (line != null)
                    {
                        if (Tessellator.DistToSegm(p, line.start, line.end) < slack + line.LineWidth / 2)
                        {
                            return(line);
                        }
                        return(null);
                    }
                    if (Box.Contains(p))
                    {
                        var subg = geometry.dObject.DrawingObject as Subgraph;
                        if (subg != null)
                        {
                            subgraphCandidates.Add(geometry);
                        }
                        else
                        {
                            return(geometry);
                        }
                    }

                    return(null);
                }
                else
                {
                    return(null);
                }
            }

            if (left.Box.Contains(p, slack))
            {
                Geometry g = left.Hit(p, slack, filter, subgraphCandidates);
                if (g != null)
                {
                    return(g);
                }
            }

            if (right.Box.Contains(p, slack))
            {
                Geometry g = right.Hit(p, slack, filter, subgraphCandidates);
                if (g != null)
                {
                    return(g);
                }
            }

            return(null);
        }