Exemplo n.º 1
0
        public PageComponent()
        {
            Components         = new List <PageComponent>(0);
            RecognitionResults = new List <RecognitionResult>(0);
            m_Stride           = 0;
            m_Area             = new Rectangle();
            Type                        = ePageComponentType.eUnknownRect;
            CompareMatrix               = new Byte[32, 32];
            StrokeMatrix                = new Byte[32, 32];
            PixelTypeMatrix             = new ePixelType[32, 32];
            PixelTypeProjectionEndpoint = new int[3, 3];
            PixelTypeProjectionJunction = new int[3, 3];
            Position                    = new ShapePosition();

            ID = newID;
            newID++;
        }
Exemplo n.º 2
0
 public ShapeListEntry()
 {
     Shape        = "";
     SampleFolder = "";
     Position     = new ShapePosition();
 }
Exemplo n.º 3
0
        /// <summary>
        /// This function calculates the distance between the bounding boxes of two components
        /// </summary>
        /// <param name="ChildFrom"></param>
        /// <param name="ChildTo"></param>
        /// <returns></returns>
        public static int DistanceBetweenComponents(PageComponent From, PageComponent To)
        {
            int lRetValue;

            int    xDelta, yDelta;
            int    xMoved, yMoved;
            double Direction;
            Point  PointFrom, PointTo, Position, Origin;

            lRetValue = 0;
            Direction = 0;

            PointFrom = From.CenterPoint;
            PointTo   = To.CenterPoint;
            Origin    = PointFrom;

            lRetValue = (int)Distance(From, To) + 1;

            if (System.Math.Abs(PointTo.X - PointFrom.X) > System.Math.Abs(PointTo.Y - PointFrom.Y))
            {
                if (PointTo.X != PointFrom.X)
                { //just to be sure we don't get a division by zero
                    Direction = (double)(PointTo.Y - PointFrom.Y) / (double)(PointTo.X - PointFrom.X);
                }

                Position = PointFrom;

                if (PointFrom.X > PointTo.X)
                {
                    xDelta = -1;
                }
                else
                {
                    xDelta = 1;
                }
                xMoved = 0;

                while (From.CoordinateInMe(Position))
                {
                    lRetValue--;

                    xMoved     += xDelta;
                    Position.X += xDelta;
                    Position.Y  = (Origin.Y + (int)(xMoved * Direction));
                }

                Position = PointTo;
                xMoved   = 0;
                xDelta   = xDelta * -1; //we walk to the different side

                while (To.CoordinateInMe(Position))
                {
                    lRetValue--;

                    xMoved     += xDelta;
                    Position.X += xDelta;
                    Position.Y  = (Origin.Y + (int)(xMoved * Direction));
                }
            }
            else
            {
                if (PointTo.Y != PointFrom.Y)   //just to be sure we don't get a division by zero
                {
                    Direction = (double)(PointTo.X - PointFrom.X) / (double)(PointTo.Y - PointFrom.Y);
                }

                Position = PointFrom;
                yDelta   = (PointFrom.Y > PointTo.Y) ? -1 : 1;
                yMoved   = 0;

                while (From.CoordinateInMe(Position))
                {
                    lRetValue--;

                    yMoved     += yDelta;
                    Position.Y += yDelta;
                    Position.X  = Origin.X + (int)(yMoved * Direction);
                }

                Position = PointTo;
                yMoved   = 0;
                yDelta   = yDelta * -1; //we walk to the different side

                while (To.CoordinateInMe(Position))
                {
                    lRetValue--;

                    yMoved     += yDelta;
                    Position.Y += yDelta;
                    Position.X  = Origin.X + (int)(yMoved * Direction);
                }
            }

            return(lRetValue);
        }