diff --git a/src/meshlabplugins/filter_texture/rect_packer.cpp b/src/meshlabplugins/filter_texture/rect_packer.cpp index 710f4a2dd..e667d3275 100644 --- a/src/meshlabplugins/filter_texture/rect_packer.cpp +++ b/src/meshlabplugins/filter_texture/rect_packer.cpp @@ -4,15 +4,7 @@ #include "rect_packer.h" -inline int min( const int a, const int b ) -{ - return ab ? a:b ; -} +using namespace std; class point2iConf { @@ -36,21 +28,20 @@ bool rect_packer::pack(const std::vector & sizes, const point2i & max_s assert(max_size[1]>0); - int gdim = max_size[0]*max_size[1]; // Size dell griglia - + int gdim = max_size[0]*max_size[1]; // grid size int i,j,x,y; posiz.resize(n); - for(i=0;i grid(gdim); // Creazione griglia + std::vector grid(gdim); // grid creation for(i=0;i perm(n); // Creazione permutazione + std::vector perm(n); // permutation creation for(i=0;i & sizes, const point2i & max_s sizes[perm[0]][1]>max_size[1] ) return false; - // Posiziono il primo + // Find the position of the first one j = perm[0]; global_size[0] = sizes[j][0]; global_size[1] = sizes[j][1]; @@ -75,7 +66,7 @@ bool rect_packer::pack(const std::vector & sizes, const point2i & max_s grid[x+y*max_size[0]] = j+1; } - // Posiziono tutti gli altri + // Lets position all the others for(i=1;i & sizes, const point2i & max_s besta = -1; - int sx = sizes[j][0]; // Pe comodita' mi copio la dimensione + int sx = sizes[j][0]; // it is easier to copy the sizes int sy = sizes[j][1]; assert(sx>0); assert(sy>0); - // Calcolo la posizione limite + // limit positions int lx = min(global_size[0],max_size[0]-sx); int ly = min(global_size[1],max_size[1]-sy); @@ -107,7 +98,7 @@ bool rect_packer::pack(const std::vector & sizes, const point2i & max_s { int px; int c; - // Controllo intersezione + // intersection check c = Grid(x,y+sy-1); if(!c) c = Grid(x+sx-1,y+sy-1); if(!c) @@ -119,7 +110,7 @@ bool rect_packer::pack(const std::vector & sizes, const point2i & max_s } } - if(c) // Salto il rettangolo + if(c) // do not consider this rectangle { --c; assert(c>=0); @@ -171,7 +162,7 @@ bool rect_packer::pack(const std::vector & sizes, const point2i & max_s } #if 0 - // Codice di debugging + // debugging code: it saves into a simple bitmap the computed packing. FILE * fp = fopen("debpack.ppm","wb"); fprintf(fp,"P6\n%d %d\n255\n",global_size[0],global_size[1]); for(j=0;j