Ejemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * {@inheritDoc}
         */
        public bool Intersects(int x, int y, int w, int h)
        {
            if (NumOfPoints <= 0 || !GetBoundingBox().Intersects(x, y, w, h))
            {
                return(false);
            }

            Crossings cross = GetCrossings(x, y, x + w, y + h);

            return(cross == null || !cross.IsEmpty());
        }
Ejemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * {@inheritDoc}
         */
        public bool Contains(int x, int y, int w, int h)
        {
            if (NumOfNpoints <= 0 || !GetBoundingBox().Intersects(x, y, w, h))
            {
                return(false);
            }

            Crossings cross = GetCrossings(x, y, x + w, y + h);

            return(cross != null && cross.Covers(y, y + h));
        }
Ejemplo n.º 3
0
        public override bool AccumulateCrossings(Crossings c)
        {
            double xlo = c.GetXLo();
            double ylo = c.GetYLo();
            double xhi = c.GetXHi();
            double yhi = c.GetYHi();

            if (_xmin >= xhi)
            {
                return(false);
            }
            double xstart, ystart, xend, yend;

            if (_y0 < ylo)
            {
                if (_y1 <= ylo)
                {
                    return(false);
                }
                ystart = ylo;
                xstart = XforY(ylo);
            }
            else
            {
                if (_y0 >= yhi)
                {
                    return(false);
                }
                ystart = _y0;
                xstart = _x0;
            }
            if (_y1 > yhi)
            {
                yend = yhi;
                xend = XforY(yhi);
            }
            else
            {
                yend = _y1;
                xend = _x1;
            }
            if (xstart >= xhi && xend >= xhi)
            {
                return(false);
            }
            if (xstart > xlo || xend > xlo)
            {
                return(true);
            }
            c.Record((int)(ystart + .5), (int)(yend + 0.5), _direction);
            return(false);
        }
Ejemplo n.º 4
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * {@inheritDoc}
         */
        public bool Intersects(int x, int y, int w, int h)
        {
            if (w < 0 || h < 0)
            {
                return(false);
            }
            if (!GetCachedBounds().Intersects(x, y, w, h))
            {
                return(false);
            }
            Crossings c = Crossings.FindCrossings(_curves, x, y, x + w, y + h);

            return(c == null || !c.IsEmpty());
        }
Ejemplo n.º 5
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * {@inheritDoc}
         */
        public bool Contains(int x, int y, int w, int h)
        {
            if (w < 0 || h < 0)
            {
                return(false);
            }
            if (!GetCachedBounds().Contains(x, y, w, h))
            {
                return(false);
            }
            Crossings c = Crossings.FindCrossings(_curves, x, y, x + w, y + h);

            return(c.Covers(y, y + h));
        }
Ejemplo n.º 6
0
 public override bool AccumulateCrossings(Crossings c)
 {
     double xlo = c.GetXLo();
     double ylo = c.GetYLo();
     double xhi = c.GetXHi();
     double yhi = c.GetYHi();
     if (_xmin >= xhi)
     {
         return false;
     }
     double xstart, ystart, xend, yend;
     if (_y0 < ylo)
     {
         if (_y1 <= ylo)
         {
             return false;
         }
         ystart = ylo;
         xstart = XforY(ylo);
     }
     else
     {
         if (_y0 >= yhi)
         {
             return false;
         }
         ystart = _y0;
         xstart = _x0;
     }
     if (_y1 > yhi)
     {
         yend = yhi;
         xend = XforY(yhi);
     }
     else
     {
         yend = _y1;
         xend = _x1;
     }
     if (xstart >= xhi && xend >= xhi)
     {
         return false;
     }
     if (xstart > xlo || xend > xlo)
     {
         return true;
     }
     c.Record((int)(ystart + .5), (int)(yend + 0.5), _direction);
     return false;
 }
Ejemplo n.º 7
0
 public virtual bool AccumulateCrossings(Crossings c)
 {
     double xhi = c.GetXHi();
     if (GetXMin() >= xhi)
     {
         return false;
     }
     double xlo = c.GetXLo();
     double ylo = c.GetYLo();
     double yhi = c.GetYHi();
     double y0 = GetYTop();
     double y1 = GetYBot();
     double tstart, ystart, tend, yend;
     if (y0 < ylo)
     {
         if (y1 <= ylo)
         {
             return false;
         }
         ystart = ylo;
         tstart = TforY(ylo);
     }
     else
     {
         if (y0 >= yhi)
         {
             return false;
         }
         ystart = y0;
         tstart = 0;
     }
     if (y1 > yhi)
     {
         yend = yhi;
         tend = TforY(yhi);
     }
     else
     {
         yend = y1;
         tend = 1;
     }
     bool hitLo = false;
     bool hitHi = false;
     while (true)
     {
         double x = XforT(tstart);
         if (x < xhi)
         {
             if (hitHi || x > xlo)
             {
                 return true;
             }
             hitLo = true;
         }
         else
         {
             if (hitLo)
             {
                 return true;
             }
             hitHi = true;
         }
         if (tstart >= tend)
         {
             break;
         }
         tstart = NextVertical(tstart, tend);
     }
     if (hitLo)
     {
         c.Record((int)(ystart + .5), (int)(yend + .5), _direction);
     }
     return false;
 }