HSpanColumn FindTouchColumn(HSpan newspan, ref int colIndex) { for (int i = colIndex; i < _hSpanColumns.Length; ++i) { HSpanColumn col = _hSpanColumns[i]; if (col.BottomSideTouchWith(newspan.y, newspan.startX, newspan.endX)) { //found colIndex = i; return(col); } } //---- if (colIndex > 0) { //we didn't start from the first for (int i = 0; i < colIndex; ++i) { HSpanColumn col = _hSpanColumns[i]; if (col.BottomSideTouchWith(newspan.y, newspan.startX, newspan.endX)) { //found colIndex = i; return(col); } } } //not found return(null); }
public ColumnWalkerCcw(VerticalGroupList verticalGroupList) { _pathWriter = null; _latestReadOnRightSide = false; _vertGroupList = verticalGroupList; _vertGroupCount = verticalGroupList.Count; _currentCol = null; }
public HSpanColumn BottomSideFindFirstTouchColumnFromRight(int lowerGroupTop, int lowerGroupTopLeft, int lowerGroupTopRight) { //[ THIS group ] //--------------------- //[ other (lower)group] // //find the first column that its bottom side touch with //another lower group for (int i = _hSpanColumns.Length - 1; i >= 0; --i) { HSpanColumn col = _hSpanColumns[i]; if (col.BottomSideTouchWith(lowerGroupTop, lowerGroupTopLeft, lowerGroupTopRight)) { return(col); } } return(null); }
public HSpanColumn TopSideFindFirstTouchColumnFromLeft(int upperBottom, int upperBottomLeft, int upperBottomRight) { //[ other (lower)group] //--------------------- //[ THIS group ] //find the first column that its top side touch with //another uppper group for (int i = 0; i < _hSpanColumns.Length; ++i) { HSpanColumn col = _hSpanColumns[i]; if (col.TopSideTouchWith(upperBottom, upperBottomLeft, upperBottomRight)) { return(col); } } return(null); }
public VerticalGroup(VerticalGroupList ownerVertGroupList, int groupNo, HSpan[] hspans, int startIndex, int colCount) { _ownerVertGroupList = ownerVertGroupList; _hSpanColumns = new HSpanColumn[colCount]; GroupNo = groupNo; int index = startIndex; for (int i = 0; i < colCount; ++i) { var col = new HSpanColumn(this, i); col.AddHSpan(hspans[index]); _hSpanColumns[i] = col; index++; } StartY = hspans[startIndex].y; }
public void CollectIncompleteRead(List <Remaining> incompleteColumns) { if (_completeAll) { return; } // bool hasSomeIncompleteColumn = false; for (int i = 0; i < _hSpanColumns.Length; ++i) { HSpanColumn hspanCol = _hSpanColumns[i]; ReadSide incompleteSide = hspanCol.FindUnreadSide(); if (incompleteSide != ReadSide.None) { hasSomeIncompleteColumn = true; incompleteColumns.Add(new Remaining(hspanCol, incompleteSide)); } } _completeAll = !hasSomeIncompleteColumn; }
public bool AddHSpans(HSpan[] hspans, int startIndex, int count) { int index = startIndex; //we must ... //1. touch one by one //and 2. no overlaped column for (int i = 0; i < _hSpanColumns.Length; ++i) { HSpanColumn col = _hSpanColumns[i]; HSpan hspan = hspans[index]; if (!col.BottomSideTouchWith(hspan.y, hspan.startX, hspan.endX)) { //found some 'untouch column' //break all //need another vertical group return(false); } else if (i > 0 && _hSpanColumns[i - 1].BottomSideTouchWith(hspan.y, hspan.startX, hspan.endX)) { //see Test/Data/lion_1_v3_2.png for example //check if current hspan dose not touch with prev column //in this case => start a new column return(false); } index++; } //--- //pass all index = startIndex; //reset for (int i = 0; i < _hSpanColumns.Length; ++i) { HSpanColumn col = _hSpanColumns[i]; col.AddHSpan(hspans[index]); index++; } return(true); }
public Remaining FindReadNextColumn() { if (!_latestReadOnRightSide) { //latest state is on LEFT side of the column HSpanColumn leftLowerCol = _currentCol.FindLeftLowerColumn(); HSpanColumn leftCol = _currentCol.FindLeftColumn(); if (leftLowerCol != null) { if (leftCol != null) { HSpanColumn rightLowerCol = leftCol.FindRightLowerColumn(); if (leftLowerCol == rightLowerCol) { //if they share the same return(leftCol.RightSideIsRead ? new Remaining() : //complete new Remaining(leftCol, ReadSide.Right)); } else { if (leftLowerCol.LeftSideIsRead && !leftCol.RightSideIsRead) { return(new Remaining(leftCol, ReadSide.Right)); } } } return(leftLowerCol.LeftSideIsRead ? new Remaining() : //complete new Remaining(leftLowerCol, ReadSide.Left)); } else { //no lower column => this is Bottom-End if (!_currentCol.RightSideIsRead) { return(new Remaining(_currentCol, ReadSide.Right)); } else { } return(new Remaining()); //complete } } else { //latest state is on RIGHT side of the column HSpanColumn rightUpperCol = _currentCol.FindRightUpperColumn(); HSpanColumn rightCol = _currentCol.FindRightColumn(); if (rightUpperCol != null) { if (rightCol != null) { HSpanColumn leftUpperCol = rightCol.FindLeftUpperColumn(); if (rightUpperCol == leftUpperCol) { return(rightCol.LeftSideIsRead ? new Remaining() : //complete new Remaining(rightCol, ReadSide.Left)); } else { if (rightUpperCol.RightSideIsRead && !rightCol.LeftSideIsRead) { //??? return(new Remaining(rightCol, ReadSide.Left)); } } } return(rightUpperCol.RightSideIsRead ? new Remaining() : new Remaining(rightUpperCol, ReadSide.Right)); } else { if (rightCol != null && !rightCol.LeftSideIsRead) { } //no upper column => this is Top-End return(_currentCol.LeftSideIsRead ? new Remaining() : new Remaining(_currentCol, ReadSide.Left)); } } }
public void Bind(HSpanColumn hspanCol) { _currentCol = hspanCol; }
public Remaining(HSpanColumn column, ReadSide unreadSide) { this.column = column; this.unreadSide = unreadSide; }