------------------------------------------------------------------------------
| 2396 | |
| 2397 | //------------------------------------------------------------------------------ |
| 2398 | int vtkPolygon::IntersectConvex2DCells( |
| 2399 | vtkCell* cell1, vtkCell* cell2, double tol, double p0[3], double p1[3]) |
| 2400 | { |
| 2401 | // Intersect the six total edges of the two triangles against each other. Two points are |
| 2402 | // all that are required. |
| 2403 | double *x[2], pcoords[3], t, x0[3], x1[3]; |
| 2404 | x[0] = p0; |
| 2405 | x[1] = p1; |
| 2406 | int subId, idx = 0; |
| 2407 | double t2 = tol * tol; |
| 2408 | |
| 2409 | // Loop over edges of second polygon and intersect against first polygon |
| 2410 | vtkIdType i, numPts = cell2->Points->GetNumberOfPoints(); |
| 2411 | for (i = 0; i < numPts; i++) |
| 2412 | { |
| 2413 | cell2->Points->GetPoint(i, x0); |
| 2414 | cell2->Points->GetPoint((i + 1) % numPts, x1); |
| 2415 | |
| 2416 | if (cell1->IntersectWithLine(x0, x1, tol, t, x[idx], pcoords, subId)) |
| 2417 | { |
| 2418 | if (idx == 0) |
| 2419 | { |
| 2420 | idx++; |
| 2421 | } |
| 2422 | else if (((x[1][0] - x[0][0]) * (x[1][0] - x[0][0]) + |
| 2423 | (x[1][1] - x[0][1]) * (x[1][1] - x[0][1]) + |
| 2424 | (x[1][2] - x[0][2]) * (x[1][2] - x[0][2])) > t2) |
| 2425 | { |
| 2426 | return 2; |
| 2427 | } |
| 2428 | } // if edge intersection |
| 2429 | } // over all edges |
| 2430 | |
| 2431 | // Loop over edges of first polygon and intersect against second polygon |
| 2432 | numPts = cell1->Points->GetNumberOfPoints(); |
| 2433 | for (i = 0; i < numPts; i++) |
| 2434 | { |
| 2435 | cell1->Points->GetPoint(i, x0); |
| 2436 | cell1->Points->GetPoint((i + 1) % numPts, x1); |
| 2437 | |
| 2438 | if (cell2->IntersectWithLine(x0, x1, tol, t, x[idx], pcoords, subId)) |
| 2439 | { |
| 2440 | if (idx == 0) |
| 2441 | { |
| 2442 | idx++; |
| 2443 | } |
| 2444 | else if (((x[1][0] - x[0][0]) * (x[1][0] - x[0][0]) + |
| 2445 | (x[1][1] - x[0][1]) * (x[1][1] - x[0][1]) + |
| 2446 | (x[1][2] - x[0][2]) * (x[1][2] - x[0][2])) > t2) |
| 2447 | { |
| 2448 | return 2; |
| 2449 | } |
| 2450 | } // if edge intersection |
| 2451 | } // over all edges |
| 2452 | |
| 2453 | // Evaluate what we got |
| 2454 | if (idx == 1) |
| 2455 | { |
nothing calls this directly
no test coverage detected