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 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 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); }