Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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");
         }
     }
 }
Ejemplo n.º 3
0
		public void TestIntersection()
		{
			RECT rA = new RECT(10,10,10,10);
			RECT rB = new RECT(0,0,30,30);
			RECT rC = new RECT(15,15,20,20);
			RECT rD = new RECT(0,0,15,15);
			RECT rI;

			rI = rA.intersection( rB );
			Assertion.AssertEquals( rI, rA );

			rI = rA.intersection( rC );
			Assertion.AssertEquals( rI, new RECT( 15,15,5,5 ) );

			rI = rA.intersection( rD );
			Assertion.AssertEquals( rI, new RECT( 10,10,5,5 ) );


		}