示例#1
0
        // Token: 0x06002E12 RID: 11794 RVA: 0x000D0138 File Offset: 0x000CE338
        protected FixedSOMSemanticBox.SpatialComparison _CompareVertical(FixedSOMSemanticBox otherBox)
        {
            Rect boundingRect  = this.BoundingRect;
            Rect boundingRect2 = otherBox.BoundingRect;

            FixedSOMSemanticBox.SpatialComparison result;
            if (boundingRect.Top == boundingRect2.Top)
            {
                result = FixedSOMSemanticBox.SpatialComparison.Equal;
            }
            else if (boundingRect.Bottom <= boundingRect2.Top)
            {
                result = FixedSOMSemanticBox.SpatialComparison.Before;
            }
            else if (boundingRect2.Bottom <= boundingRect.Top)
            {
                result = FixedSOMSemanticBox.SpatialComparison.After;
            }
            else if (boundingRect.Top < boundingRect2.Top)
            {
                result = FixedSOMSemanticBox.SpatialComparison.OverlapBefore;
            }
            else
            {
                result = FixedSOMSemanticBox.SpatialComparison.OverlapAfter;
            }
            return(result);
        }
示例#2
0
        //Method that compares horizontally according to specific reading order
        //In the future we should take into account the document language and plug it into this algorithm
        protected SpatialComparison _CompareVertical(FixedSOMSemanticBox otherBox)
        {
            SpatialComparison result = SpatialComparison.None;

            Rect thisRect  = this.BoundingRect;
            Rect otherRect = otherBox.BoundingRect;

            if (thisRect.Top == otherRect.Top)
            {
                result = SpatialComparison.Equal;
            }
            else if (thisRect.Bottom <= otherRect.Top)
            {
                //Clearly before the other object
                result = SpatialComparison.Before;
            }
            else if (otherRect.Bottom <= thisRect.Top)
            {
                //Clearly after the other object
                result = SpatialComparison.After;
            }
            else
            {
                //Objects overlap
                if (thisRect.Top < otherRect.Top)
                {
                    result = SpatialComparison.OverlapBefore;
                }
                else
                {
                    result = SpatialComparison.OverlapAfter;
                }
            }
            return(result);
        }
示例#3
0
        // Token: 0x06002E17 RID: 11799 RVA: 0x000D0404 File Offset: 0x000CE604
        protected void AddSorted(FixedSOMSemanticBox box)
        {
            int num = this._semanticBoxes.Count - 1;

            while (num >= 0 && box.CompareTo(this._semanticBoxes[num]) != 1)
            {
                num--;
            }
            this._semanticBoxes.Insert(num + 1, box);
            this._UpdateBoundingRect(box.BoundingRect);
        }
示例#4
0
        //--------------------------------------------------------------------
        //
        // Protected Methods
        //
        //---------------------------------------------------------------------
        #region Private Methods

        //Method that compares horizontally according to specific reading order
        protected SpatialComparison _CompareHorizontal(FixedSOMSemanticBox otherBox, bool RTL)
        {
            SpatialComparison result = SpatialComparison.None;

            Rect thisRect  = this.BoundingRect;
            Rect otherRect = otherBox.BoundingRect;

            double thisRectRefX  = RTL ? thisRect.Right : thisRect.Left;
            double otherRectRefX = RTL ? otherRect.Right : otherRect.Left;

            if (thisRectRefX == otherRectRefX)
            {
                result = SpatialComparison.Equal;
            }
            //Easiest way: calculate as if it's LTR and invert the result if RTL
            else if (thisRect.Right < otherRect.Left)
            {
                //Clearly before the other object
                result = SpatialComparison.Before;
            }
            else if (otherRect.Right < thisRect.Left)
            {
                //Clearly after the other object
                result = SpatialComparison.After;
            }
            else
            {
                double overlap     = Math.Abs(thisRectRefX - otherRectRefX);
                double longerWidth = thisRect.Width > otherRect.Width ? thisRect.Width : otherRect.Width;

                if (overlap / longerWidth < 0.1)
                {
                    //If less than 10% overlap then assume these are equal in horizontal comparison
                    result = SpatialComparison.Equal;
                }

                //Objects overlap
                else if (thisRect.Left < otherRect.Left)
                {
                    result = SpatialComparison.OverlapBefore;
                }
                else
                {
                    result = SpatialComparison.OverlapAfter;
                }
            }
            if (RTL && result != SpatialComparison.Equal)
            {
                result = _InvertSpatialComparison(result);
            }
            return(result);
        }
示例#5
0
        protected void AddSorted(FixedSOMSemanticBox box)
        {
            int i = _semanticBoxes.Count - 1;

            for (; i >= 0; i--)
            {
                if (box.CompareTo(_semanticBoxes[i]) == 1)
                {
                    break;
                }
            }
            _semanticBoxes.Insert(i + 1, box);

            _UpdateBoundingRect(box.BoundingRect);
        }
示例#6
0
        // Token: 0x06002E11 RID: 11793 RVA: 0x000D0058 File Offset: 0x000CE258
        protected FixedSOMSemanticBox.SpatialComparison _CompareHorizontal(FixedSOMSemanticBox otherBox, bool RTL)
        {
            Rect   boundingRect  = this.BoundingRect;
            Rect   boundingRect2 = otherBox.BoundingRect;
            double num           = RTL ? boundingRect.Right : boundingRect.Left;
            double num2          = RTL ? boundingRect2.Right : boundingRect2.Left;

            FixedSOMSemanticBox.SpatialComparison spatialComparison;
            if (num == num2)
            {
                spatialComparison = FixedSOMSemanticBox.SpatialComparison.Equal;
            }
            else if (boundingRect.Right < boundingRect2.Left)
            {
                spatialComparison = FixedSOMSemanticBox.SpatialComparison.Before;
            }
            else if (boundingRect2.Right < boundingRect.Left)
            {
                spatialComparison = FixedSOMSemanticBox.SpatialComparison.After;
            }
            else
            {
                double num3 = Math.Abs(num - num2);
                double num4 = (boundingRect.Width > boundingRect2.Width) ? boundingRect.Width : boundingRect2.Width;
                if (num3 / num4 < 0.1)
                {
                    spatialComparison = FixedSOMSemanticBox.SpatialComparison.Equal;
                }
                else if (boundingRect.Left < boundingRect2.Left)
                {
                    spatialComparison = FixedSOMSemanticBox.SpatialComparison.OverlapBefore;
                }
                else
                {
                    spatialComparison = FixedSOMSemanticBox.SpatialComparison.OverlapAfter;
                }
            }
            if (RTL && spatialComparison != FixedSOMSemanticBox.SpatialComparison.Equal)
            {
                spatialComparison = this._InvertSpatialComparison(spatialComparison);
            }
            return(spatialComparison);
        }
示例#7
0
 private bool _IsSpatiallyCombinable(FixedSOMSemanticBox box1, FixedSOMSemanticBox box2, double inflateH, double inflateV)
 {
     return(_IsSpatiallyCombinable(box1.BoundingRect, box2.BoundingRect, inflateH, inflateV));
 }
 private bool _IsSpatiallyCombinable(FixedSOMSemanticBox box1, FixedSOMSemanticBox box2, double inflateH, double inflateV) 
 {
     return _IsSpatiallyCombinable(box1.BoundingRect, box2.BoundingRect, inflateH, inflateV); 
 }
示例#9
0
 protected void Add(FixedSOMSemanticBox box)
 {
     _semanticBoxes.Add(box);
     _UpdateBoundingRect(box.BoundingRect);
 }
示例#10
0
        //Method that compares horizontally according to specific reading order
        //In the future we should take into account the document language and plug it into this algorithm
        protected SpatialComparison _CompareVertical(FixedSOMSemanticBox otherBox)
        { 
            SpatialComparison result = SpatialComparison.None;
 
            Rect thisRect = this.BoundingRect; 
            Rect otherRect = otherBox.BoundingRect;
 
            if (thisRect.Top == otherRect.Top)
            {
                result =  SpatialComparison.Equal;
            } 
            else if (thisRect.Bottom <= otherRect.Top)
            { 
                //Clearly before the other object 
                result = SpatialComparison.Before;
            } 
            else if (otherRect.Bottom <= thisRect.Top)
            {
                //Clearly after the other object
                result = SpatialComparison.After; 
            }
            else 
            { 
                //Objects overlap
                if (thisRect.Top < otherRect.Top) 
                {
                    result = SpatialComparison.OverlapBefore;
                }
                else 
                {
                    result =  SpatialComparison.OverlapAfter; 
                } 
            }
            return result; 
        }
示例#11
0
        //-------------------------------------------------------------------
        // 
        // Protected Methods
        // 
        //---------------------------------------------------------------------- 
        #region Private Methods
 
        //Method that compares horizontally according to specific reading order
        protected SpatialComparison _CompareHorizontal(FixedSOMSemanticBox otherBox, bool RTL)
        {
            SpatialComparison result = SpatialComparison.None; 

            Rect thisRect = this.BoundingRect; 
            Rect otherRect = otherBox.BoundingRect; 

            double thisRectRefX = RTL ? thisRect.Right : thisRect.Left; 
            double otherRectRefX = RTL ? otherRect.Right : otherRect.Left;

            if (thisRectRefX == otherRectRefX)
            { 
                result = SpatialComparison.Equal;
            } 
            //Easiest way: calculate as if it's LTR and invert the result if RTL 
            else if (thisRect.Right < otherRect.Left)
            { 
                //Clearly before the other object
                result = SpatialComparison.Before;
            }
            else if (otherRect.Right < thisRect.Left) 
            {
                //Clearly after the other object 
                result = SpatialComparison.After; 
            }
            else 
            {
                double overlap = Math.Abs(thisRectRefX - otherRectRefX);
                double longerWidth = thisRect.Width > otherRect.Width ? thisRect.Width : otherRect.Width;
 
                if (overlap/longerWidth < 0.1)
                { 
                    //If less than 10% overlap then assume these are equal in horizontal comparison 
                    result = SpatialComparison.Equal;
                } 

                //Objects overlap
                else if (thisRect.Left < otherRect.Left)
                { 
                    result = SpatialComparison.OverlapBefore;
                } 
                else 
                {
                    result =  SpatialComparison.OverlapAfter; 
                }
            }
            if (RTL && result != SpatialComparison.Equal)
            { 
                result = _InvertSpatialComparison(result);
            } 
            return result; 
        }
 protected void Add(FixedSOMSemanticBox box)
 {
     _semanticBoxes.Add(box);
     _UpdateBoundingRect(box.BoundingRect);
     
 }
        protected void AddSorted(FixedSOMSemanticBox box)
        {
            int i=_semanticBoxes.Count-1;
            for (; i>=0; i--)
            {
                if (box.CompareTo(_semanticBoxes[i]) == 1)
                {
                    break;
                }
            }
            _semanticBoxes.Insert(i+1, box);

            _UpdateBoundingRect(box.BoundingRect);
            
        }