------------------------------------------------------------------------------ Compute interpolation weights using 1/r**2 normalized sum or mean value coordinate.
| 480 | // Compute interpolation weights using 1/r**2 normalized sum or mean value |
| 481 | // coordinate. |
| 482 | void vtkPolygon::InterpolateFunctions(const double x[3], double* weights) |
| 483 | { |
| 484 | // Compute interpolation weights using mean value coordinate. |
| 485 | if (this->UseMVCInterpolation) |
| 486 | { |
| 487 | this->InterpolateFunctionsUsingMVC(x, weights); |
| 488 | return; |
| 489 | } |
| 490 | |
| 491 | // Compute interpolation weights using 1/r**2 normalized sum. |
| 492 | int i; |
| 493 | int numPts = this->Points->GetNumberOfPoints(); |
| 494 | double sum, pt[3]; |
| 495 | |
| 496 | for (sum = 0.0, i = 0; i < numPts; i++) |
| 497 | { |
| 498 | this->Points->GetPoint(i, pt); |
| 499 | weights[i] = vtkMath::Distance2BetweenPoints(x, pt); |
| 500 | if (weights[i] == 0.0) // exact hit |
| 501 | { |
| 502 | for (int j = 0; j < numPts; j++) |
| 503 | { |
| 504 | weights[j] = 0.0; |
| 505 | } |
| 506 | weights[i] = 1.0; |
| 507 | return; |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | weights[i] = 1.0 / weights[i]; |
| 512 | sum += weights[i]; |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | for (i = 0; i < numPts; i++) |
| 517 | { |
| 518 | weights[i] /= sum; |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | //------------------------------------------------------------------------------ |
| 523 | // Compute interpolation weights using mean value coordinate. |