Changeset 27342
- Timestamp:
- Mar 18, 2010, 3:57:43 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/magic/remove/src/diffedpixels.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/magic/remove/src/diffedpixels.c
r27223 r27342 240 240 ocur at pt0.y and pt2.y 241 241 242 Example 1242 Type 1 243 243 244 244 3 … … 250 250 1 line 2_3 y >= pt.y 251 251 ************************** 252 Example 2 252 253 253 3 254 254 C … … 260 260 261 261 ************************** 262 Example 3 262 If The left side corners have the same x we also have a Type 1 263 263 264 264 3 2 … … 282 282 nameCorners(psPlane pt[4]) 283 283 { 284 psPlane pt0, pt1, pt2, pt3;285 286 284 // sort points top to bottom 287 285 int i; … … 297 295 } 298 296 } 297 psPlane bl, br; 299 298 // sort bottom two points in x 300 299 if (pt[3].x < pt[2].x) { 301 psPlane tmpPt = pt[3]; 302 pt[3] = pt[2]; 303 pt[2] = tmpPt; 304 } 305 // now we know that p[3] point is pt1 - the lower right corner 306 pt1 = pt[3]; 307 308 // And pt[2] is left most of the bottom 2 (either pt0 or pt2) 309 310 // find which of the top two is to the left 300 bl = pt[3]; 301 br = pt[2]; 302 } else { 303 bl = pt[2]; 304 br = pt[3]; 305 } 306 // sort the top two points in x 307 psPlane tl, tr; 311 308 if (pt[0].x < pt[1].x) { 312 pt3 = pt[0]; 313 // now decide which of pt[1] and pt[2] is pt0 - on the left) 314 if (pt[1].x < pt[2].x) { 315 pt0 = pt[1]; 316 pt2 = pt[2]; 317 } else { 318 pt0 = pt[2]; 319 pt2 = pt[1]; 320 } 321 } else { 322 pt3 = pt[1]; 323 // now decide which of pt[0] and pt[2] is pt0 - on the left) 324 if (pt[0].x < pt[2].x) { 325 pt0 = pt[0]; 326 pt2 = pt[2]; 327 } else { 328 pt0 = pt[2]; 329 pt2 = pt[0]; 330 } 331 } 332 333 /* now write the outputs back to the input array*/ 334 pt[0] = pt0; 335 pt[1] = pt1; 336 pt[2] = pt2; 337 pt[3] = pt3; 338 339 // And Check the results 340 // y3 > y0 341 // y2 > y0 342 // y3 > y1 343 // x1 > x0 344 // x2 > x0 345 // x2 > x3 309 tl = pt[0]; 310 tr = pt[1]; 311 } else { 312 tl = pt[1]; 313 tr = pt[0]; 314 } 315 if (tl.y >= tr.y) { 316 // Type 1 (or 3 which is equivalent) 317 pt[0] = bl; 318 pt[1] = br; 319 pt[2] = tr; 320 pt[3] = tl; 321 } else { 322 pt[0] = tl; 323 pt[1] = bl; 324 pt[2] = br; 325 pt[3] = tr; 326 } 327 328 // Now check the results match our requirements 329 // pt3 is above pt0 346 330 if (pt[3].y <= pt[0].y) { 347 331 fprintf(stderr, "ERROR calculating diff overlap\n"); … … 349 333 streaksExit("", PS_EXIT_PROG_ERROR); 350 334 } 351 if (pt[2].y <= pt[0].y) { 352 fprintf(stderr, "ERROR calculating diff overlap\n"); 353 fprintf(stderr, "pt[2].y (%f) <= pt[0].y (%f)\n", pt[2].y, pt[0].y); 354 streaksExit("", PS_EXIT_PROG_ERROR); 355 } 335 // pt3 is above pt1 356 336 if (pt[3].y <= pt[1].y) { 357 337 fprintf(stderr, "ERROR calculating diff overlap\n"); … … 359 339 streaksExit("", PS_EXIT_PROG_ERROR); 360 340 } 341 // pt2 is above pt1 342 if (pt[2].y <= pt[1].y) { 343 fprintf(stderr, "ERROR calculating diff overlap\n"); 344 fprintf(stderr, "pt[2].y (%f) <= pt[1].y (%f)\n", pt[2].x, pt[1].x); 345 streaksExit("", PS_EXIT_PROG_ERROR); 346 } 347 // pt1 is to the right of pt0 361 348 if (pt[1].x <= pt[0].x) { 362 349 fprintf(stderr, "ERROR calculating diff overlap\n"); … … 364 351 streaksExit("", PS_EXIT_PROG_ERROR); 365 352 } 353 // pt2 is to the right of pt0 366 354 if (pt[2].x <= pt[0].x) { 367 355 fprintf(stderr, "ERROR calculating diff overlap\n"); … … 369 357 streaksExit("", PS_EXIT_PROG_ERROR); 370 358 } 359 // pt2 is to the right of pt3 371 360 if (pt[2].x <= pt[3].x) { 372 361 fprintf(stderr, "ERROR calculating diff overlap\n"); … … 374 363 streaksExit("", PS_EXIT_PROG_ERROR); 375 364 } 376 } 365 // pt2 is below or at the same y as pt3 366 if (pt[2].y > pt[3].y) { 367 fprintf(stderr, "ERROR calculating diff overlap\n"); 368 fprintf(stderr, "pt[2].y (%f) > pt[3].y (%f)\n", pt[2].y, pt[3].y); 369 streaksExit("", PS_EXIT_PROG_ERROR); 370 } 371 }
Note:
See TracChangeset
for help on using the changeset viewer.
