Esempio n. 1
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);
            }
        }