示例#1
0
        public override void IntersectWith(GShape gShape)
        {
            IntersectionResult res;

            if (gShape is GCircle)
            {
                res = Intersection.CircleCircle(this, (GCircle)gShape);

                if (res.IntersectionPoints.Count == 0)
                {
                    return;
                }

                IntersectionResults.Add(res);
            }
            else if (gShape is GLine)
            {
                res = Intersection.CircleLine(this, (GLine)gShape);

                if (res.IntersectionPoints.Count == 0)
                {
                    return;
                }

                IntersectionResults.Add(res);
            }
            else if (gShape is GRectangle)
            {
                res = Intersection.CircleRectangle(this, (GRectangle)gShape);

                if (res.IntersectionPoints.Count == 0)
                {
                    return;
                }

                IntersectionResults.Add(res);
            }
            else if (gShape is GPolyLine)
            {
                foreach (var line in ((GPolyLine)gShape).Lines)
                {
                    res = Intersection.CircleLine(this, line);

                    if (res.IntersectionPoints.Count > 0)
                    {
                        IntersectionResults.Add(res);
                    }
                }
            }
        }
示例#2
0
        public override void IntersectWith(GShape gShape)
        {
            IntersectionResult result;

            if (gShape is GLine)
            {
                foreach (var line in Lines)
                {
                    result = Intersection.LineLine((GLine)gShape, line);

                    if (result.IntersectionPoints.Count > 0)
                    {
                        IntersectionResults.Add(result);
                    }
                }
            }
            else if (gShape is GCircle)
            {
                foreach (var line in Lines)
                {
                    result = Intersection.CircleRectangle((GCircle)gShape, this);

                    if (result.IntersectionPoints.Count == 0)
                    {
                        return;
                    }

                    IntersectionResults.Add(result);
                }
            }
            else if (gShape is GRectangle)
            {
                foreach (var line in Lines)
                {
                    foreach (var recLine in ((GRectangle)gShape).Lines)
                    {
                        result = Intersection.LineLine(line, recLine);

                        if (result.IntersectionPoints.Count == 0)
                        {
                            continue;
                        }

                        IntersectionResults.Add(result);
                    }
                }
            }

            else if (gShape is GPolyLine)
            {
                foreach (var line in Lines)
                {
                    foreach (var pLine in ((GPolyLine)gShape).Lines)
                    {
                        result = Intersection.LineLine(line, pLine);

                        if (result.IntersectionPoints.Count == 0)
                        {
                            continue;
                        }

                        IntersectionResults.Add(result);
                    }
                }
            }

            else if (gShape is GCurve)
            {
                result = Intersection.CurveRectangle((GCurve)gShape, this);

                if (result.IntersectionPoints.Count == 0)
                {
                    return;
                }

                IntersectionResults.Add(result);
            }
        }