VectorQueue neighbour2D(int** matrix,int ignValue, int radius, VectorQueue vctQ,int sizeX, int sizeY) { int xLimitSup,xLimitInf,yLimitSup,yLimitInf; VectorQueue tmpQ; tmpQ.push(vctQ.x.front(),vctQ.y.front(),0); while(!vctQ.isEmpty()) { xLimitSup=vctQ.x.front()+2*radius+1; xLimitInf= vctQ.x.front()-2*radius-1; if(xLimitInf<1)xLimitInf=1; if (xLimitSup>=sizeX-1) xLimitSup=sizeX-1; for(int i=xLimitInf;i<=xLimitSup;i++) { yLimitSup=vctQ.y.front()+2*radius+1; yLimitInf= vctQ.y.front()-2*radius-1; if(yLimitInf<1) yLimitInf=1; yLimitSup=vctQ.y.front()+2*radius; if (yLimitSup>=sizeY-1) yLimitSup=sizeY-1; for(int j=yLimitInf;j<=yLimitSup;j++) { if((matrix[i][j]!=ignValue)&&(matrix[i][j]>0)) { vctQ.push(i,j,0); tmpQ.push(i,j,0); matrix[i][j]-=2*matrix[i][j]; } } } vctQ.pop(); } return tmpQ; }
VectorQueue neighbour3D(int*** matrix,int ignValue, int radius, VectorQueue vctQ) { VectorQueue tmpQ; tmpQ.push(vctQ.x.front(),vctQ.y.front(),vctQ.z.front()); while(!vctQ.isEmpty()) { for(int k=vctQ.z.front()-radius;k<=vctQ.z.front()+radius;k++) { for(int i=vctQ.y.front()-radius;i<=vctQ.y.front()+radius;i++) { for(int j=vctQ.x.front()-radius;j<=vctQ.x.front()+radius;j++) if((matrix[j][i][k]!=ignValue)&&(matrix[j][i][k]>0)) { vctQ.push(j,i,k); tmpQ.push(j,i,k); matrix[j][i][k]-=2*matrix[j][i][k]; } } } vctQ.pop(); } return tmpQ; }