예제 #1
0
        public bool Overlaps(clsLine aLine, double aTol = 0)
        {
            clsLine  l1 = default(clsLine);
            clsPoint p3 = default(clsPoint);
            clsPoint p4 = default(clsPoint);

            if (aTol == 0)
            {
                aTol = mdlGeometry.myTol;
            }
            l1 = aLine.Copy();
            if ((!IsOnLine(l1.P1, aTol)) | (!IsOnLine(l1.P2, aTol)))
            {
                return(false);
            }
            if (Dot(l1) < 0)
            {
                l1.Reverse();
            }
            p3 = l1.P1;
            p4 = l1.P2;
            if (P1 == p3)
            {
                return(true);
            }
            if (P1 == p4 | P2 == p3)
            {
                return(false);
            }
            if (IsOnShortLine(p4, aTol))
            {
                return(true);
            }
            if (l1.IsOnShortLine(P1, aTol) | l1.IsOnShortLine(P2, aTol))
            {
                return(true);
            }
            return(false);
        }
예제 #2
0
        public bool IsPointTouching(clsPoint p1)
        {
            //Avoids the case when the point is exactly on one of the lines
            int     i;
            int     j;
            clsLine l1;
            bool    bRet;

            bRet = false;
            for (i = 0; i <= myPoints.Count - 1; i++)
            {
                j = i + 1;
                if (j > myPoints.Count - 1)
                {
                    j = 0;
                }
                l1 = new clsLine(Point(i), Point(j));
                if (l1.IsOnShortLine(p1))
                {
                    bRet = true;
                }
            }
            return(bRet);
        }
예제 #3
0
        public bool Overlaps(clsSketch aSketch, double aTol)
        {
            int      i;
            int      j;
            int      k;
            clsLine  l1;
            clsLine  l2;
            clsPoint p1;
            bool     isInside;

            //Disregard the case of when one sketch is contained in the other.
            isInside = true;
            for (i = 0; i <= NumPoints; i++)
            {
                if (aSketch.IsPointInside2(Point(i)) == false)
                {
                    isInside = false;
                }
            }
            if (isInside)
            {
                return(false);
            }
            isInside = true;
            for (i = 0; i <= aSketch.NumPoints; i++)
            {
                if (IsPointInside2(aSketch.Point(i)) == false)
                {
                    isInside = false;
                }
            }
            if (isInside)
            {
                return(false);
            }

            //Firstly see if a point of one sketch lies inside the other
            for (i = 0; i <= NumPoints; i++)
            {
                if (aSketch.IsPointInside2(Point(i)))
                {
                    return(true);
                }
            }
            for (i = 0; i <= aSketch.NumPoints; i++)
            {
                if (IsPointInside2(aSketch.Point(i)))
                {
                    return(true);
                }
            }

            //Next, do more than 3 points coincide?
            if (NumCommonPoints(aSketch, aTol) > 1)
            {
                return(true);
            }

            //Is there a non-trivial intersection?
            for (i = 0; i <= NumPoints; i++)
            {
                if (i < NumPoints)
                {
                    k = i + 1;
                }
                else
                {
                    k = 0;
                }
                l1 = new clsLine(Point(i), Point(k));

                //Is there a non-trivial intersection?
                for (j = 0; j <= aSketch.NumPoints; j++)
                {
                    if (j < aSketch.NumPoints)
                    {
                        k = j + 1;
                    }
                    else
                    {
                        k = 0;
                    }
                    l2 = new clsLine(aSketch.Point(j), aSketch.Point(k));
                    p1 = l1.Intersect(l2);
                    if (p1 != null)
                    {
                        if (l1.IsOnShortLine(p1, 0, true) & l2.IsOnShortLine(p1, 0, true))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }