0
나는이 포럼을 광범위하게 검색 했으므로이 내용을 다루지는 않았습니다. 나는 기본적으로 열거 형의 배열에 3D Flood Fill 알고리즘이라고 부르는 것을하려고합니다. 배열 요소의 "색"을 변경하는 대신 열거 형을 변경하고 싶습니다. 이것은 내가 지금까지 가지고있는 것입니다. 만약 당신이 이것이 효과가 있다고 생각하거나 어떤 제안이 있다면 당신이 저에게 알려주시겠습니까?3D 배열 (3D 배열)에 3D 홍수 채우기 알고리즘
/*
* CellType is my enum type. BOUNDRY_BOX enum type is type that I line the whole 3D array with. So the
* whole inside surface of the 3D box is filled with CellType.BOUNDRY_BOX.
**/
public void fillAllVoidCells(CellType[][][] grid, CellType targetType, CellType replacementType, int x, int y, int z)
{
if ((grid[x][y][z] != targetType) && grid[x][y][z] != CellType.BOUNDRY_BOX)
{
break;
}
else
{
grid[x][y][z] = replacementType;
fillAllVoidCells(grid, targetType, replacementType, x + 1, y, z); // right
fillAllVoidCells(grid, targetType, replacementType, x - 1, y, z); // left
fillAllVoidCells(grid, targetType, replacementType, x, y + 1, z); // in front
fillAllVoidCells(grid, targetType, replacementType, x, y - 1, z); // behind
fillAllVoidCells(grid, targetType, replacementType, x, y, z + 1); // above
fillAllVoidCells(grid, targetType, replacementType, x, y, z - 1); // below
}
}
도움 주셔서 감사합니다. 매우 유용했습니다. 나는 많은 진전을 이루었습니다. 여기에서 후속 질문을 참조 할 수 있습니까? http://stackoverflow.com/questions/16294856/using-recursion-for-3d-array-manipulation-causing-stackoverflow-not-infinite –