Пример #1
0
		public void TestOverlap2()
		{
			RECT r0 = new RECT( 10,0,10,10);
			RECT r1 = new RECT( 0,0,10,10);
			Assertion.Assert( r1.overlaps(r0) );
			Assertion.Assert( !r1.overlaps_interior(r0) );
		}
Пример #2
0
        public static int decompose_overlapping(RECT A, RECT B, RECT [] ra)
        {
            int  overlaps = 0;
            RECT C;
            RECT i;

            if (A.overlaps_interior(B))
            {
                if (B.y0 < A.y0)
                {
                    //0
                    C = new RECT(B.x0, B.y0, B.w, A.y0 - B.y0);
                    i = C.intersection(B);
                    if (!is_sliver(i))
                    {
                        ra[overlaps] = i;
                        RECTTOOLS.CHECK_NO_INTERIOR_OVERLAP(C, A);
                        overlaps++;
                    }
                }
                if (B.x1 > A.x1)
                {
                    //1
                    C = RECT.FromPoints(A.x1, A.y0, B.x1, A.y1);
                    i = C.intersection(B);
                    if (!is_sliver(i))
                    {
                        RECTTOOLS.CHECK_NO_INTERIOR_OVERLAP(C, A);
                        ra[overlaps] = i;
                        overlaps++;
                    }
                }
                if (B.x0 < A.x0)
                {
                    //2
                    C = RECT.FromPoints(B.x0, A.y0, A.x0, A.y1);
                    i = C.intersection(B);
                    if (!is_sliver(i))
                    {
                        RECTTOOLS.CHECK_NO_INTERIOR_OVERLAP(C, A);
                        ra[overlaps] = i;
                        overlaps++;
                    }
                }
                if (B.y1 > A.y1)
                {
                    //3
                    C = new RECT(B.x0, A.y1, B.w, B.y1 - A.y1);
                    i = C.intersection(B);
                    if (!is_sliver(i))
                    {
                        ra[overlaps] = i;
                        overlaps++;
                    }
                }
            }

            return(overlaps);
        }
Пример #3
0
 public static void CHECK_NO_INTERIOR_OVERLAP(RECT A, RECT B)
 {
     if (A.overlaps_interior(B))
     {
         RECT i = A.intersection(B);
         if ((i.w >= 1.0) && (i.h >= 1.0))
         {
             throw new Exception("should not overlap");
         }
     }
 }
Пример #4
0
		public void TestOverlap1()
		{
			RECT r0 = new RECT( 0,0,10,10);
			RECT r1 = new RECT( 10,10,20,20);
			RECT r2 = new RECT( 11,11,20,20);
			RECT r3 = new RECT( 9.999,9.999,20,20);
			Assertion.Assert( r1.overlaps(r0) );
			Assertion.Assert( !r1.overlaps_interior(r0) );
			Assertion.Assert( !r2.overlaps(r0) );
			Assertion.Assert( r3.overlaps(r0) );
			Assertion.Assert( r3.overlaps_interior(r0) );
		}