------------------------------------------------------------------------------
| 2356 | |
| 2357 | //------------------------------------------------------------------------------ |
| 2358 | double vtkPolygon::DistanceToPolygon( |
| 2359 | double x[3], int numPts, double* pts, double bounds[6], double closest[3]) |
| 2360 | { |
| 2361 | // First check to see if the point is inside the polygon |
| 2362 | // do a quick bounds check |
| 2363 | if (x[0] >= bounds[0] && x[0] <= bounds[1] && x[1] >= bounds[2] && x[1] <= bounds[3] && |
| 2364 | x[2] >= bounds[4] && x[2] <= bounds[5]) |
| 2365 | { |
| 2366 | double n[3]; |
| 2367 | vtkPolygon::ComputeNormal(numPts, pts, n); |
| 2368 | if (vtkPolygon::PointInPolygon(x, numPts, pts, bounds, n)) |
| 2369 | { |
| 2370 | closest[0] = x[0]; |
| 2371 | closest[1] = x[1]; |
| 2372 | closest[2] = x[2]; |
| 2373 | return 0.0; |
| 2374 | } |
| 2375 | } |
| 2376 | |
| 2377 | // Not inside, compute the distance of the point to the edges. |
| 2378 | double minDist2 = VTK_FLOAT_MAX; |
| 2379 | double *p0, *p1, dist2, t, c[3]; |
| 2380 | for (int i = 0; i < numPts; i++) |
| 2381 | { |
| 2382 | p0 = pts + 3 * i; |
| 2383 | p1 = pts + 3 * ((i + 1) % numPts); |
| 2384 | dist2 = vtkLine::DistanceToLine(x, p0, p1, t, c); |
| 2385 | if (dist2 < minDist2) |
| 2386 | { |
| 2387 | minDist2 = dist2; |
| 2388 | closest[0] = c[0]; |
| 2389 | closest[1] = c[1]; |
| 2390 | closest[2] = c[2]; |
| 2391 | } |
| 2392 | } |
| 2393 | |
| 2394 | return sqrt(minDist2); |
| 2395 | } |
| 2396 | |
| 2397 | //------------------------------------------------------------------------------ |
| 2398 | int vtkPolygon::IntersectConvex2DCells( |
nothing calls this directly
no test coverage detected