Example #1
0
        public override void IntersectWith(GShape gShape)
        {
            if (gShape is GCircle)
            {
                var res = Intersection.CircleLine((GCircle)gShape, this);

                if (res.IntersectionPoints.Count > 0)
                {
                    IntersectionResults.Add(res);
                }
            }
            else if (gShape is GLine)
            {
                var res = Intersection.LineLine((GLine)gShape, this);

                if (res.IntersectionPoints.Count > 0)
                {
                    IntersectionResults.Add(res);
                }
            }

            else if (gShape is GRectangle)
            {
                foreach (var line in ((GRectangle)gShape).Lines)
                {
                    var res = Intersection.LineLine(line, this);

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

                    if (res.IntersectionPoints.Count > 0)
                    {
                        IntersectionResults.Add(res);
                    }
                }
            }
            else if (gShape is GCurve)
            {
                var res = Intersection.CurveLine((GCurve)gShape, this);
                if (res.IntersectionPoints.Count == 0)
                {
                    return;
                }
                IntersectionResults.Add(res);
            }
        }
Example #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);
            }
        }