Warning: session_start(): open(/var/lib/php/sessions/sess_6sm3hdjjhohrf4m92ut3d3deb3, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// should return outer outline first and then outline of holes
// (without a separator)
scope regionBorder_innerPoints.
static Pt[] #directions = {
pt(1, 0), pt(0, 1), pt(-1, 0), pt(0, -1) // r, d, l, u
};
static L regionBorder_innerPoints(BWImage_FastRegions regions, int iRegion) {
new PtBuffer out;
int w = regions.w;
var it = regions.regionIterator(iRegion);
new BitSet seen;
while (it.next()) {
int x = it.x(), y = it.y();
// is it a border pixel?
if (regions.inRegion(iRegion, x, y-1)
&& regions.inRegion(iRegion, x-1, y)
&& regions.inRegion(iRegion, x+1, y)
&& regions.inRegion(iRegion, x, y+1))
continue;
//print("border pixel: " + x + "/" + y);
int dir = 3; // start with direction up (any direction should do)
loop: while (true) {
int pos = y*w+x;
if (seen.get(pos))
break;
seen.set(pos);
out.add(x, y);
for (int turn = 3; turn <= 6; turn++) { // try left, straight, right, back
int newDir = (dir+turn) & 3;
Pt d = directions[newDir];
int x2 = x+d.x, y2 = y+d.y;
if (regions.inRegion(iRegion, x2, y2)) {
x = x2; y = y2; dir = newDir;
continue loop;
}
}
// if we get here, the region is just 1 pixel (so we're done)
break;
}
}
ret out;
}