663 for (
int i = 0 ; i < 6 ; i ++ ) {
1017 for (
int i = 0 ; i < 2 ; i ++ )
1018 for (
int j = 0 ; j < 2 ; j ++ )
1019 for (
int k = 0 ; k < 2 ; k ++ ) {
1020 if (
getDataAt( ox + i, oy + j, oz + k ) < 0 ) {
1033 for ( i = 0 ; i <
getSizeX() ; i ++ )
1034 for ( j = 0 ; j <
getSizeY() ; j ++ )
1035 for ( k = 0 ; k <
getSizeZ() ; k ++ )
1041 for (
int m = 0 ; m < 6 ; m ++ )
1178 int edge[6] = { 0,0,0,0,0,0 } ;
1179 int faceflag[ 12 ] ;
1184 for ( i = -1 ; i < 1 ; i ++ )
1185 for ( j = -1 ; j < 1 ; j ++ )
1186 for ( k = -1 ; k < 1 ; k ++ )
1188 if (
hasCell( ox + i, oy + j, oz + k ) )
1190 cellflag[ ct ] = 1 ;
1194 cellflag[ ct ] = 0 ;
1199 for ( i = 0 ; i < 12 ; i ++ )
1202 for ( j = 0 ; j < 4 ; j ++ )
1215 if ( faceflag[ i ] )
1220 ox - 1 + ((
faceCells[i][0] >> 2 ) & 1 ),
1221 oy - 1 + ((
faceCells[i][0] >> 1 ) & 1 ),
1224 ox - 1 + ((
faceCells[i][1] >> 2 ) & 1 ),
1225 oy - 1 + ((
faceCells[i][1] >> 1 ) & 1 ),
1227 if ( ((v1 >> (2 * (2 - i/4))) & 1) ||
1228 ((v2 >> (2 * (2 - i/4) + 1 )) & 1) )
1235 if ( faceflag[ i ] )
1246 for ( i = 0 ; i < 6 ; i ++ )
1248 if ( edge[ i ] == 1 )
1253 while( numones > 0 )
1256 for ( i = 0 ; i < 6 ; i ++ )
1258 if ( edge[ i ] == 1 )
1272 for ( j = 0 ; j < 4 ; j ++ )
1275 if ( faceflag[ f ] )
1304 if ( edge[ e2 ] == 1 )
1308 else if ( edge[ e2 ] == 0 )
1464 for ( i = 0 ; i < 6 ; i ++ )
1520 for ( i = 0 ; i < 6 ; i ++ )
1534 int val = (int)fvol->
getDataAt( nx, ny, nz) ;
1535 if ( (( val >> ( 2 * ( i / 2 ) ) ) & 1) == 0 )
1582 int c1 = 0 , c2 = 0 ;
1585 for ( i = 0 ; i < 6 ; i ++ )
1596 if ( val > 0 && val < MAX_ERODE && nvol->
getDataAt( nx, ny, nz ) == 0 )
1604 if ( c1 == 1 && c2 == 1 )
1792 int c1 = 0 , c2 = 0 ;
1795 for ( i = 0 ; i < 6 ; i ++ )
1814 if ( c1 == 1 && c2 == 1 )
1827 int edge[6] = { 0,0,0,0,0,0 } ;
1828 int faceflag[ 12 ] ;
1829 int hasFeatureFace = 0 ;
1832 for ( i = 0 ; i < 12 ; i ++ )
1835 int hasFeature = 1 ;
1837 for ( j = 0 ; j < 4 ; j ++ )
1853 if ( faceflag[ i ] == 1 && hasFeature )
1859 if ( faceflag[ i ] )
1868 if ( tot == 0 || hasFeatureFace == 0 )
1875 for ( i = 0 ; i < 6 ; i ++ )
1877 if ( edge[ i ] == 1 )
1882 while( numones > 0 )
1885 for ( i = 0 ; i < 6 ; i ++ )
1887 if ( edge[ i ] == 1 )
1901 for ( j = 0 ; j < 4 ; j ++ )
1904 if ( faceflag[ f ] )
1933 if ( edge[ e2 ] == 1 )
1937 else if ( edge[ e2 ] == 0 )
2143 for ( i = 0 ; i < 12 ; i ++ )
2146 for ( j = 0 ; j < 4 ; j ++ )
2169 if ( ct == -1 || ct >= 1 )
2320 double vox[3][3][3] ;
2323 for ( i = -1 ; i < 2 ; i ++ )
2324 for ( j = -1 ; j < 2 ; j ++ )
2325 for ( k = -1 ; k < 2 ; k ++ )
2327 double tval =
getDataAt( ox + i, oy + j, oz + k ) ;
2344 vox[ i + 1 ][ j + 1 ][ k + 1 ] = tval ;
2385 double vox[3][3][3] ;
2388 for ( i = -1 ; i < 2 ; i ++ )
2389 for ( j = -1 ; j < 2 ; j ++ )
2390 for ( k = -1 ; k < 2 ; k ++ )
2392 double tval =
getDataAt( ox + i, oy + j, oz + k ) ;
2409 vox[ i + 1 ][ j + 1 ][ k + 1 ] = tval ;
2564 int rvalue = 0, nx, ny, nz ;
2585 for ( i = 0 ; i < 6 ; i ++ )
2704 int head = 0, tail = 1 ;
2706 for ( i = 0 ; i < 3 ; i ++ )
2707 for ( j = 0 ; j < 3 ; j ++ )
2708 for ( k = 0 ; k < 3 ; k ++ )
2730 while ( head != tail )
2732 int x = queue[head][0] ;
2733 int y = queue[head][1] ;
2734 int z = queue[head][2] ;
2737 for ( i = 0 ; i < 6 ; i ++ )
2742 if ( nx >=0 && nx < 3 && ny >=0 && ny < 3 && nz >=0 && nz < 3 )
2744 if ( vox[nx][ny][nz] && ! vis[nx][ny][nz] )
2746 queue[tail][0] = nx ;
2747 queue[tail][1] = ny ;
2748 queue[tail][2] = nz ;
2750 vis[nx][ny][nz] = 1 ;
2773 int head = 0, tail = 1 ;
2775 for ( i = 0 ; i < 3 ; i ++ )
2776 for ( j = 0 ; j < 3 ; j ++ )
2777 for ( k = 0 ; k < 3 ; k ++ )
2798 while ( head != tail )
2800 int x = queue[head][0] ;
2801 int y = queue[head][1] ;
2802 int z = queue[head][2] ;
2805 for ( i = -1 ; i < 2 ; i ++ )
2806 for ( j = -1 ; j < 2 ; j ++ )
2807 for ( k = -1 ; k < 2 ; k ++ )
2812 if ( nx >=0 && nx < 3 && ny >=0 && ny < 3 && nz >=0 && nz < 3 )
2814 if ( vox[nx][ny][nz] && ! vis[nx][ny][nz] )
2816 queue[tail][0] = nx ;
2817 queue[tail][1] = ny ;
2818 queue[tail][2] = nz ;
2820 vis[nx][ny][nz] = 1 ;
2842 for (
int i = 0 ; i < 3 ; i ++ )
2843 for (
int j = 0 ; j < 3 ; j ++ )
2844 for (
int k = 0 ; k < 3 ; k ++ )
2846 if ( vox[i][j][k] < 0 )
2864 for ( i = 0 ; i < 3 ; i ++ )
2865 for ( j = 0 ; j < 3 ; j ++ )
2866 for ( k = 0 ; k < 3 ; k ++ )
2871 for ( i = 0 ; i < 6 ; i ++ )
2876 if ( vox[ nx ][ ny ][ nz ] >= 0 )
2878 tvox[ nx ][ ny ][ nz ] = 1 ;
2879 for ( j = 0 ; j < 4 ; j ++ )
2884 if ( vox[ nnx ][ nny ][ nnz ] >= 0 )
2886 tvox[ nnx ][ nny ][ nnz ] = 1 ;
2897 int nv = 0 , ne = 0, nc = 0 ;
2901 double vox[3][3][3] ;
2903 for ( i = 0 ; i < 3 ; i ++ )
2904 for ( j = 0 ; j < 3 ; j ++ )
2905 for ( k = 0 ; k < 3 ; k ++ )
2907 vox[i][j][k] =
getDataAt( ox - 1 + i, oy - 1 + j, oz - 1 + k ) ;
2911 for ( i = 0 ; i < 6 ; i ++ )
2916 if ( vox[nx][ny][nz] >= 0 )
2918 tvox[ nx ][ ny ][ nz ] = 1 ;
2922 for ( j = 0 ; j < 4 ; j ++ )
2927 if ( vox[nnx][nny][nnz] >= 0 )
2929 if ( tvox[nnx][nny][nnz] == 0 )
2931 tvox[nnx][nny][nnz] = 1 ;
2943 return ( nc - ( nv - ne ) ) ;
3817 printf(
"Thresholding the volume to -1/0...\n") ;
3826 printf(
"Initializing queue...\n") ;
3833 for ( i = 0 ; i <
getSizeX() ; i ++ )
3834 for ( j = 0 ; j <
getSizeY() ; j ++ )
3835 for ( k = 0 ; k <
getSizeZ() ; k ++ )
3839 float v = (float)grayvol->
getDataAt(i,j,k) ;
3840 if ( v <= lowthr || v > highthr || svol->
getDataAt(i,j,k) > 0 )
3846 for (
int m = 0 ; m < 6 ; m ++ )
3861 printf(
"Start erosion to %d...\n", wid) ;
3876 #ifdef NOISE_DIS_HELIX
3880 for (
int curwid = 1 ; curwid <= wid ; curwid ++ )
3886 int numComplex = 0, numSimple = 0 ;
3888 printf(
"Processing %d nodes in layer %d\n", queue2->
getNumElements(), curwid) ;
3896 while ( ele != NULL )
3914 while ( ele != NULL )
3926 #ifdef NOISE_DIS_HELIX
3932 while ( ( ele = queue2->
getNext() ) != NULL )
3937 if ( NOISE_DIS_HELIX <= 1 )
3944 for (
int m = 0 ; m < 6 ; m ++ )
3964 for ( cur = 1 ; cur < NOISE_DIS_HELIX ; cur ++ )
3970 while ( ( ele = queue2->
getNext() ) != NULL )
3976 if ( noisevol->
getDataAt( ox, oy, oz ) == 1 )
3983 for (
int m = 0 ; m < 6 ; m ++ )
4003 printf(
"Maximum feature distance: %d Un-touched: %d\n", cur, queue2->
getNumElements() - visited ) ;
4046 while ( ele != NULL )
4054 scrvol->
setDataAt( ox, oy, oz, score ) ;
4062 queue->
add( gp, score ) ;
4078 queue->
remove( gp, score ) ;
4088 if (
getDataAt( ox, oy, oz ) != curwid || (
int) scrvol->
getDataAt( ox, oy, oz ) != score )
4103 #ifndef NOISE_DIS_HELIX
4112 queue4->
prepend( ox, oy, oz ) ;
4123 for (
int m = 0 ; m < 6 ; m ++ )
4131 queue2->
prepend( nx, ny, nz ) ;
4171 for ( i = -2 ; i < 3 ;i ++ )
4172 for ( j = -2 ; j < 3 ; j ++ )
4173 for ( k = -2 ; k < 3 ; k ++ )
4179 if (
getDataAt( nx, ny, nz ) == curwid )
4184 if ( score != (
int) scrvol->
getDataAt( nx, ny, nz ) )
4187 scrvol->
setDataAt( nx, ny, nz, score ) ;
4194 queue->
add( gp, score ) ;
4203 printf(
"%d complex, %d simple\n", numComplex, numSimple) ;
4206 if ( numSimple == 0 )
4210 printf(
"*************************wierd here*************************\n");
4220 while ( ele != NULL )
4234 for ( i = 0 ; i <
getSizeX() ; i ++ )
4235 for ( j = 0 ; j <
getSizeY() ; j ++ )
4236 for ( k = 0 ; k <
getSizeZ() ; k ++ )
4245 while ( ele != NULL )
4262 printf(
"Thresholding the volume to 0/1...\n") ;
4273 printf(
"Thresholding the volume to -1/0...\n") ;
4282 printf(
"Initializing queue...\n") ;
4289 for ( i = 0 ; i <
getSizeX() ; i ++ )
4290 for ( j = 0 ; j <
getSizeY() ; j ++ )
4291 for ( k = 0 ; k <
getSizeZ() ; k ++ )
4301 for (
int m = 0 ; m < 6 ; m ++ )
4317 printf(
"Start erosion to %d...\n", wid) ;
4332 #ifdef NOISE_DIS_HELIX
4336 for (
int curwid = 1 ; curwid <= wid ; curwid ++ )
4342 int numComplex = 0, numSimple = 0 ;
4344 printf(
"Processing %d nodes in layer %d\n", queue2->
getNumElements(), curwid) ;
4352 while ( ele != NULL )
4370 while ( ele != NULL )
4382 #ifdef NOISE_DIS_HELIX
4388 while ( ( ele = queue2->
getNext() ) != NULL )
4393 if ( NOISE_DIS_HELIX <= 1 )
4400 for (
int m = 0 ; m < 6 ; m ++ )
4420 for ( cur = 1 ; cur < NOISE_DIS_HELIX ; cur ++ )
4426 while ( ( ele = queue2->
getNext() ) != NULL )
4432 if ( noisevol->
getDataAt( ox, oy, oz ) == 1 )
4439 for (
int m = 0 ; m < 6 ; m ++ )
4459 printf(
"Maximum feature distance: %d Un-touched: %d\n", cur, queue2->
getNumElements() - visited ) ;
4502 while ( ele != NULL )
4510 scrvol->
setDataAt( ox, oy, oz, score ) ;
4518 queue->
add( gp, score ) ;
4534 queue->
remove( gp, score ) ;
4544 if (
getDataAt( ox, oy, oz ) != curwid || (
int) scrvol->
getDataAt( ox, oy, oz ) != score )
4559 #ifndef NOISE_DIS_HELIX
4568 queue4->
prepend( ox, oy, oz ) ;
4579 for (
int m = 0 ; m < 6 ; m ++ )
4587 queue2->
prepend( nx, ny, nz ) ;
4624 for ( i = -2 ; i < 3 ;i ++ )
4625 for ( j = -2 ; j < 3 ; j ++ )
4626 for ( k = -2 ; k < 3 ; k ++ )
4632 if (
getDataAt( nx, ny, nz ) == curwid )
4637 if ( score != (
int) scrvol->
getDataAt( nx, ny, nz ) )
4640 scrvol->
setDataAt( nx, ny, nz, score ) ;
4647 queue->
add( gp, score ) ;
4656 printf(
"%d complex, %d simple\n", numComplex, numSimple) ;
4659 if ( numSimple == 0 )
4672 printf(
"Thresholding the volume to 0/1...\n") ;
4683 printf(
"Thresholding the volume to -1/0...\n") ;
4692 printf(
"Initializing queue...\n") ;
4699 for ( i = 0 ; i <
getSizeX() ; i ++ )
4700 for ( j = 0 ; j <
getSizeY() ; j ++ )
4701 for ( k = 0 ; k <
getSizeZ() ; k ++ )
4711 for (
int m = 0 ; m < 4 ; m ++ )
4726 printf(
"Start erosion to %d...\n", wid) ;
4741 #ifdef NOISE_DIS_HELIX
4745 for (
int curwid = 1 ; curwid <= wid ; curwid ++ )
4751 int numComplex = 0, numSimple = 0 ;
4753 printf(
"Processing %d nodes in layer %d\n", queue2->
getNumElements(), curwid) ;
4761 while ( ele != NULL )
4779 while ( ele != NULL )
4791 #ifdef NOISE_DIS_HELIX
4797 while ( ( ele = queue2->
getNext() ) != NULL )
4802 if ( NOISE_DIS_HELIX <= 1 )
4809 for (
int m = 0 ; m < 6 ; m ++ )
4829 for ( cur = 1 ; cur < NOISE_DIS_HELIX ; cur ++ )
4835 while ( ( ele = queue2->
getNext() ) != NULL )
4841 if ( noisevol->
getDataAt( ox, oy, oz ) == 1 )
4848 for (
int m = 0 ; m < 6 ; m ++ )
4868 printf(
"Maximum feature distance: %d Un-touched: %d\n", cur, queue2->
getNumElements() - visited ) ;
4911 while ( ele != NULL )
4920 scrvol->
setDataAt( ox, oy, oz, score ) ;
4928 queue->
add( gp, score ) ;
4944 queue->
remove( gp, score ) ;
4954 if (
getDataAt( ox, oy, oz ) != curwid || (
int) scrvol->
getDataAt( ox, oy, oz ) != score )
4969 #ifndef NOISE_DIS_HELIX
4978 queue4->
prepend( ox, oy, oz ) ;
4989 for (
int m = 0 ; m < 4 ; m ++ )
4997 queue2->
prepend( nx, ny, nz ) ;
5034 for ( i = -2 ; i < 3 ;i ++ )
5035 for ( j = -2 ; j < 3 ; j ++ )
5036 for ( k = -2 ; k < 3 ; k ++ )
5042 if (
getDataAt( nx, ny, nz ) == curwid )
5048 if ( score != (
int) scrvol->
getDataAt( nx, ny, nz ) )
5051 scrvol->
setDataAt( nx, ny, nz, score ) ;
5058 queue->
add( gp, score ) ;
5067 printf(
"%d complex, %d simple\n", numComplex, numSimple) ;
5070 if ( numSimple == 0 )
5078 printf(
"Thresholding the volume to 0/1...\n") ;
5094 printf(
"Thresholding the volume to -1/0...\n") ;
5103 printf(
"Initializing queue...\n") ;
5108 for ( i = 0 ; i <
getSizeX() ; i ++ )
5109 for ( j = 0 ; j <
getSizeY() ; j ++ )
5110 for ( k = 0 ; k <
getSizeZ() ; k ++ )
5115 for (
int m = 0 ; m < 6 ; m ++ )
5130 printf(
"Start erosion to %d...\n", wid) ;
5145 int numComplex = 0, numSimple = 0 ;
5147 printf(
"Processing %d nodes in layer %d\n", queue2->
getNumElements(), wid) ;
5160 while ( ele != NULL )
5171 queue2->
prepend( ox, oy, oz ) ;
5188 for (
int m = 0 ; m < 6 ; m ++ )
5196 queue2->
prepend( nx, ny, nz ) ;
5205 printf(
"Level %d: %d complex, %d simple\n", wid, numComplex, numSimple) ;
5208 if ( numSimple == 0 )
5218 printf(
"Thresholding the volume to 0/1...\n") ;
5697 printf(
"Thresholding the volume to -1/0...\n") ;
5706 printf(
"Initializing queue...\n") ;
5712 for ( i = 0 ; i <
getSizeX() ; i ++ )
5713 for ( j = 0 ; j <
getSizeY() ; j ++ )
5714 for ( k = 0 ; k <
getSizeZ() ; k ++ )
5724 for (
int m = 0 ; m < 6 ; m ++ )
5742 printf(
"Start erosion to %d...\n", wid) ;
5755 for (
int curwid = 1 ; curwid <= wid ; curwid ++ )
5761 int numComplex = 0, numSimple = 0 ;
5763 printf(
"Processing %d nodes in layer %d\n", queue2->
getNumElements(), curwid) ;
5772 while ( ele != NULL )
5780 scrvol->
setDataAt( ox, oy, oz, score ) ;
5788 queue->
add( gp, score ) ;
5804 queue->
remove( gp, score ) ;
5814 if (
getDataAt( ox, oy, oz ) != curwid || (
int) scrvol->
getDataAt( ox, oy, oz ) != score )
5825 queue2->
prepend( ox, oy, oz ) ;
5836 for (
int m = 0 ; m < 6 ; m ++ )
5844 queue2->
prepend( nx, ny, nz ) ;
5851 for ( i = -2 ; i < 3 ;i ++ )
5852 for ( j = -2 ; j < 3 ; j ++ )
5853 for ( k = -2 ; k < 3 ; k ++ )
5859 if (
getDataAt( nx, ny, nz ) == curwid )
5864 if ( score != (
int) scrvol->
getDataAt( nx, ny, nz ) )
5867 scrvol->
setDataAt( nx, ny, nz, score ) ;
5874 queue->
add( gp, score ) ;
5883 printf(
"%d complex, %d simple\n", numComplex, numSimple) ;
5886 if ( numSimple == 0 )
5895 printf(
"Thresholding the volume to 0/1...\n") ;
5929 for ( i = 0 ; i <
getSizeX() ; i ++ )
5930 for ( j = 0 ; j <
getSizeY() ; j ++ )
5931 for ( k = 0 ; k <
getSizeZ() ; k ++ )
5955 while( ( ele = queue2->
getNext() ) != NULL )
5958 queues[ -dis ]->
prepend( ele->
x, ele->
y, ele->
z ) ;
5965 while ( ele != NULL )
5967 for (
int m = 0 ; m < 6 ; m ++ )
5980 queue3->
prepend( nx, ny, nz ) ;
5998 printf(
"Detecting closed rings %d...", dis) ;
6001 for ( i = 0 ; i <
getSizeX() ; i ++ )
6002 for ( j = 0 ; j <
getSizeY() ; j ++ )
6003 for ( k = 0 ; k <
getSizeZ() ; k ++ )
6008 queues[ -dis ]->
prepend( i, j, k ) ;