Changeset 319 for cpp/frams/canvas
- Timestamp:
- 02/01/15 01:08:50 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/canvas/nn_smart_layout.cpp
r286 r319 13 13 #endif 14 14 15 #define DB(x) 15 //#define DB(x) x 16 #define DB(x) 16 17 17 18 #if DB(1)+0 … … 105 106 h = maxy - miny + 1; 106 107 map = (char*)calloc(1, w*h); 107 int i, e; 108 DB(printf("mapa bloku #%ld\n", id)); 109 for (i = 0; i < elementy.size(); i++) 110 { 111 e = elementy[i]; 108 DB(printf("mapa bloku #%d\n", id)); 109 for (size_t i = 0; i < elementy.size(); i++) 110 { 111 int e = elementy[i]; 112 112 map[w*(einfo[e].y - miny) + (einfo[e].x - minx)] = 1; 113 113 } 114 DB(for (i = 0; i < h; i++){ for (e = 0; e < w; e++)printf("%c", map[w*i + e] ? '*' : '.'); printf("\n"); })114 DB(for (int i = 0; i < h; i++){ for (int e = 0; e < w; e++)printf("%c", map[w*i + e] ? '*' : '.'); printf("\n"); }) 115 115 } 116 116 … … 154 154 { // return 1 if successful 155 155 if (!moznadolaczyc(b, b2, dx, dy)) return 0; // merging causes no collision 156 DB(printf("#% ld(%ld,%ld,%ld,%ld) + #%ld(%ld,%ld,%ld,%ld)<%ld,%ld>", b->id, b->minx, b->miny, b->maxx, b->maxy, b2->id, b2->minx, b2->miny, b2->maxx, b2->maxy, dx, dy));156 DB(printf("#%d(%d,%d,%d,%d) + #%d(%d,%d,%d,%d)<%d,%d>", b->id, b->minx, b->miny, b->maxx, b->maxy, b2->id, b2->minx, b2->miny, b2->maxx, b2->maxy, dx, dy)); 157 157 158 158 b->zwolnijmape(); 159 int i, e; 160 for (i = 0; i < b2->elementy.size(); i++) 161 { 162 e = b2->elementy[i]; 159 for (size_t i = 0; i < b2->elementy.size(); i++) 160 { 161 int e = b2->elementy[i]; 163 162 b->dodajelement(e, einfo[e].x + dx, einfo[e].y + dy); 164 163 } … … 168 167 b->maxy = max(b->maxy, dy + b2->maxy); 169 168 170 DB(printf(" -> (%ld,%ld,%ld,%ld)\n", b->minx, b->miny, b->maxx, b->maxy)); 171 172 DB(printf(" ...#%ld...(%ld)...", b->id, b->elementy.size())); 173 for (i = 0; i < b->elementy.size(); i++) 174 { 175 e = b->elementy[i]; 176 DB(assert(einfo[e].x >= b->minx);) 177 DB(assert(einfo[e].x <= b->maxx);) 178 DB(assert(einfo[e].y >= b->miny);) 179 DB(assert(einfo[e].y <= b->maxy);) 180 DB(printf("(%ld)%ld,%ld ", e, einfo[e].x, einfo[e].y)); 181 } 182 183 DB(printf("\n")); 169 DB( 170 printf(" -> (%d,%d,%d,%d)\n", b->minx, b->miny, b->maxx, b->maxy); 171 172 printf(" ...#%d...(%d)...", b->id, b->elementy.size()); 173 for (size_t i = 0; i < b->elementy.size(); i++) 174 { 175 int e = b->elementy[i]; 176 assert(einfo[e].x >= b->minx); 177 assert(einfo[e].x <= b->maxx); 178 assert(einfo[e].y >= b->miny); 179 assert(einfo[e].y <= b->maxy); 180 printf("(%d)%d,%d ", e, einfo[e].x, einfo[e].y); 181 } 182 183 printf("\n") 184 ); 184 185 185 186 delete b2; … … 205 206 dx = einfo[e].x - einfo[e2].x; 206 207 dy = einfo[e].y - einfo[e2].y; 207 DB(printf(" elem.% ld (%ld,%ld@%ld) + elem.%ld (%ld,%ld@%ld)...\n", e, einfo[e].x, einfo[e].y, b->id, e2, einfo[e2].x, einfo[e2].y, b2->id));208 DB(printf(" elem.%d (%d,%d@%d) + elem.%d (%d,%d@%d)...\n", e, einfo[e].x, einfo[e].y, b->id, e2, einfo[e2].x, einfo[e2].y, b2->id)); 208 209 if (dolaczblock(b, b2, dx - 1, dy)) return; 209 210 int proba; // retry - increasing the y offset (keeps x offset at -1) … … 222 223 if (einfo[e].block) 223 224 { 224 DB(printf("block#% ld exists\n", e));225 DB(printf("block#%d exists\n", e)); 225 226 return; 226 227 } … … 312 313 { 313 314 DB(printf(" - - setting coordinates - -\n")); 314 int i;315 315 DB(first->odtworzmape()); 316 for ( i = 0; i < first->elementy.size(); i++)316 for (size_t i = 0; i < first->elementy.size(); i++) 317 317 { 318 318 el = first->elementy[i];
Note: See TracChangeset
for help on using the changeset viewer.