예제 #1
0
        static int GetSquareForDatum(ARParam arParams, double[,] model, clsPoint pt)
        {
            var cpt = ModelToImageSpace(arParams, model, pt);
            var pt1 = ModelToImageSpace(arParams, model, new clsPoint(pt.x - 8, pt.y - 8));
            var pt2 = ModelToImageSpace(arParams, model, new clsPoint(pt.x + 8, pt.y - 8));
            var pt3 = ModelToImageSpace(arParams, model, new clsPoint(pt.x + 8, pt.y + 8));
            var pt4 = ModelToImageSpace(arParams, model, new clsPoint(pt.x - 8, pt.y + 8));
            var l1  = new clsLine(pt1, pt2);
            var l2  = new clsLine(pt2, pt3);
            var l3  = new clsLine(pt3, pt4);
            var l4  = new clsLine(pt4, pt1);

            double d  = 100;
            var    l  = new clsLine(cpt, new clsPoint(cpt.x - 1, cpt.y - 1));
            var    p1 = l.Intersect(l1);

            if (p1 != null && p1.Dist(cpt) < d)
            {
                d = p1.Dist(cpt);
            }
            p1 = l.Intersect(l2);
            if (p1 != null && p1.Dist(cpt) < d)
            {
                d = p1.Dist(cpt);
            }
            p1 = l.Intersect(l3);
            if (p1 != null && p1.Dist(cpt) < d)
            {
                d = p1.Dist(cpt);
            }
            p1 = l.Intersect(l4);
            if (p1 != null && p1.Dist(cpt) < d)
            {
                d = p1.Dist(cpt);
            }

            l  = new clsLine(cpt, new clsPoint(cpt.x + 1, cpt.y - 1));
            p1 = l.Intersect(l1);
            if (p1 != null && p1.Dist(cpt) < d)
            {
                d = p1.Dist(cpt);
            }
            p1 = l.Intersect(l2);
            if (p1 != null && p1.Dist(cpt) < d)
            {
                d = p1.Dist(cpt);
            }
            p1 = l.Intersect(l3);
            if (p1 != null && p1.Dist(cpt) < d)
            {
                d = p1.Dist(cpt);
            }
            p1 = l.Intersect(l4);
            if (p1 != null && p1.Dist(cpt) < d)
            {
                d = p1.Dist(cpt);
            }

            return((int)(d / Sqrt(2.0) + 0.5));
        }
예제 #2
0
        public clsPoint FilletPoint()
        {
            clsLine  l1;
            clsLine  l2;
            clsPoint p1;
            clsPoint p2;

            p1 = StartPoint();
            p2 = Tangent(Angle1);
            l1 = new clsLine(p1.X, p1.Y, p1.X + p2.X, p1.Y + p2.Y);
            p1 = EndPoint();
            p2 = Tangent(Angle2);
            l2 = new clsLine(p1.X, p1.Y, p1.X + p2.X, p1.Y + p2.Y);
            return(l1.Intersect(l2));
        }
예제 #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);
        }