------------------------------------------------------------------------------ Line-line intersection. Intersection has to occur within [0,1] parametric coordinates and with specified tolerance.
| 601 | // Line-line intersection. Intersection has to occur within [0,1] parametric |
| 602 | // coordinates and with specified tolerance. |
| 603 | int vtkLine::IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, |
| 604 | double x[3], double pcoords[3], int& subId) |
| 605 | { |
| 606 | double a1[3], a2[3]; |
| 607 | int i; |
| 608 | |
| 609 | subId = 0; |
| 610 | pcoords[1] = pcoords[2] = 0.0; |
| 611 | |
| 612 | this->Points->GetPoint(0, a1); |
| 613 | this->Points->GetPoint(1, a2); |
| 614 | |
| 615 | // check line-line intersection; use inf tolerance which will force |
| 616 | // vtkLine::Intersection() to only check parametric intersection |
| 617 | // we then perform the tolerance check here using the absolute tolerance tol |
| 618 | if (this->Intersection(p1, p2, a1, a2, t, pcoords[0], vtkMath::Inf()) == Intersect) |
| 619 | { |
| 620 | double projXYZ[3]; |
| 621 | // make sure we are within tolerance |
| 622 | for (i = 0; i < 3; i++) |
| 623 | { |
| 624 | x[i] = a1[i] + pcoords[0] * (a2[i] - a1[i]); |
| 625 | projXYZ[i] = p1[i] + t * (p2[i] - p1[i]); |
| 626 | } |
| 627 | return (vtkMath::Distance2BetweenPoints(x, projXYZ) <= tol * tol); |
| 628 | } |
| 629 | |
| 630 | else // check to see if it lies within tolerance |
| 631 | { |
| 632 | // one of the parametric coords must be outside 0-1 |
| 633 | if (t < 0.0) |
| 634 | { |
| 635 | t = 0.0; |
| 636 | return (vtkLine::DistanceToLine(p1, a1, a2, pcoords[0], x) <= tol * tol); |
| 637 | } |
| 638 | if (t > 1.0) |
| 639 | { |
| 640 | t = 1.0; |
| 641 | return (vtkLine::DistanceToLine(p2, a1, a2, pcoords[0], x) <= tol * tol); |
| 642 | } |
| 643 | if (pcoords[0] < 0.0) |
| 644 | { |
| 645 | pcoords[0] = 0.0; |
| 646 | return (vtkLine::DistanceToLine(a1, p1, p2, t, x) <= tol * tol); |
| 647 | } |
| 648 | if (pcoords[0] > 1.0) |
| 649 | { |
| 650 | pcoords[0] = 1.0; |
| 651 | return (vtkLine::DistanceToLine(a2, p1, p2, t, x) <= tol * tol); |
| 652 | } |
| 653 | } |
| 654 | return 0; |
| 655 | } |
| 656 | |
| 657 | //------------------------------------------------------------------------------ |
| 658 | int vtkLine::TriangulateLocalIds(int vtkNotUsed(index), vtkIdList* ptIds) |
nothing calls this directly
no test coverage detected