Insert a polygon into the hash. Input: an array of vertex ids the start index of the polygon in the array the end index of the polygon in the array the cellId of the polygon ------------------------------------------------------------------------------
| 2463 | // the cellId of the polygon |
| 2464 | //------------------------------------------------------------------------------ |
| 2465 | void vtkDataSetSurfaceFilter::InsertPolygonInHash( |
| 2466 | const vtkIdType* ids, int numPts, vtkIdType sourceId) |
| 2467 | { |
| 2468 | // sanity check |
| 2469 | if (numPts == 0) |
| 2470 | { |
| 2471 | return; |
| 2472 | } |
| 2473 | vtkFastGeomQuad *quad, **end; |
| 2474 | |
| 2475 | // find the index to the smallest id |
| 2476 | vtkIdType offset = 0; |
| 2477 | for (int i = 0; i < numPts; i++) |
| 2478 | { |
| 2479 | if (ids[i] < ids[offset]) |
| 2480 | { |
| 2481 | offset = i; |
| 2482 | } |
| 2483 | } |
| 2484 | |
| 2485 | // copy ids into ordered array with smallest id first |
| 2486 | vtkIdType* tab = new vtkIdType[numPts]; |
| 2487 | for (int i = 0; i < numPts; i++) |
| 2488 | { |
| 2489 | tab[i] = ids[(offset + i) % numPts]; |
| 2490 | } |
| 2491 | |
| 2492 | // Look for existing hex in the hash; |
| 2493 | end = this->QuadHash + tab[0]; |
| 2494 | quad = *end; |
| 2495 | while (quad) |
| 2496 | { |
| 2497 | end = &(quad->Next); |
| 2498 | // a has to match in this bin. |
| 2499 | // first just check the polygon size. |
| 2500 | bool match = true; |
| 2501 | if (numPts == quad->numPts) |
| 2502 | { |
| 2503 | if (tab[0] == quad->ptArray[0]) |
| 2504 | { |
| 2505 | // if the first two points match loop through forwards |
| 2506 | // checking all points |
| 2507 | if (numPts > 1 && tab[1] == quad->ptArray[1]) |
| 2508 | { |
| 2509 | for (int i = 2; i < numPts; ++i) |
| 2510 | { |
| 2511 | if (tab[i] != quad->ptArray[i]) |
| 2512 | { |
| 2513 | match = false; |
| 2514 | break; |
| 2515 | } |
| 2516 | } |
| 2517 | } |
| 2518 | else |
| 2519 | { |
| 2520 | // check if the points go in the opposite direction |
| 2521 | for (int i = 1; i < numPts; ++i) |
| 2522 | { |
no test coverage detected