小编ste*_*tef的帖子

洪水填充三维多边形

这是给你的问题;)

我有一个填充1和0的三维数组.1代表3维复杂多边形(不是简单的多边形).只有多边形的边界值为1,内部填充0.现在问题是:

我需要一个快速算法来填充这些多边形1s.阵列的尺寸通常约为.512x512x100.

提前致谢!

这是2d中的一个例子:

0000111110000
0000100010000
0000100010000
0000111110000

应该导致

0000111110000
0000111110000
0000111110000
0000111110000


这是@Mikolas算法的正确三维解决方案吗?

    void scan_polygon(int frames, int rows, int cols, char data[][][], char result[][][]){
for(int f=0; f < frames; ++f)
for(int r=0; r<rows; ++r)
for(int s = 0, c=0; c<cols-1; ++c)
{
    s ^= s ? ( data[f][r][c] && !data[f][r][c+1]) :
             (!data[f][r][c] &&  data[f][r][c-1]);

    result[f][r][c] = s;
}

for(int f=0; f < frames; ++f)
for(int c=0; c<cols; ++c)
for(int s = 0, r=0; r<rows-1; ++r)
{
    s ^= …
Run Code Online (Sandbox Code Playgroud)

c++ math polygon flood-fill computational-geometry

5
推荐指数
1
解决办法
1309
查看次数

标签 统计

c++ ×1

computational-geometry ×1

flood-fill ×1

math ×1

polygon ×1