**find longest horizontal lines: hmax_1 = 0; hmax_2 = 1; i = 0; SHAVEVEC_ITERATE(lines, LineData, ln) if (LineData::isHorizontal()(ln)) { if (LineData::LengthGreaterThan()(ln, lines[max_1])) { hmax_2 = hmax_1; hmax_1 = i; } else if (LineData::LengthGreaterThan()(ln, lines[max_2])) { hmax_2 = i; } i++; } } ** find longest non-horizontal lines vmax_1 = 0; vmax_2 = 1; i = 0; SHAVEVEC_ITERATE(lines, LineData, ln) if (!LineData::ParallelTest()(lines[hmax_1], ln)) { if (LineData::LengthGreaterThan()(ln, lines[vmax_1])) { vmax_2 = vmax_1; vmax_1 = i; } else if (LineData::LengthGreaterThan()(ln, lines[vmax_2])) { vmax_2 = i; } i++; } } ** construct boundary lines *** left: find leftmost endpt of two horiontal lines find leftmost ln of two vertical lines contruct infty line thru endpt at orientation of ln *** right: find righttmost endpt of two horiontal lines find righttmost ln of two vertical lines contruct infty line thru endpt at orientation of ln *** top: find topmost endpt of two vertical lines find topmost ln of two horizontal lines contruct infty line thru endpt at orientation of ln *** bottom: find bottommost endpt of two vertical lines find bottommost ln of two horizontal lines contruct infty line thru endpt at orientation of ln ** construct sketches for each grid square *** example: middle leftHalfPlane(vert2) && rightHalfPlane(vert1) && bottomHalfPlane(horiz1) && topHalfPlane(horiz2) ** find bottom blue and pink pixels: sk & !sk[*camSkS.idxS] ** calculate contents of each board pos: for each grid square sketch if !NEW_SKETCH(sq & bluebottoms)->isEmpty() mark sq blue else if !NEW_SKETCH(sq & pinkbottoms)->isEmpty() mark sq pink else mark sq empty