------------------------------------------------------------------------------ Take the passed line segment and intersect it with the OBB cells. This method assumes that the data set is a vtkPolyData that describes a closed surface, and the intersection points that are returned in 'points' alternate between entrance points and exit points. The return value of the function is 0 if no intersection w
| 674 | // 1 if point 'p1' lies inside the polydata surface, or -1 if point 'p1' |
| 675 | // lies outside the polydata surface. |
| 676 | int vtkOBBTree::IntersectWithLine( |
| 677 | const double p1[3], const double p2[3], vtkPoints* points, vtkIdList* cellIds) |
| 678 | { |
| 679 | if (this->DataSet == nullptr) |
| 680 | { |
| 681 | if (points) |
| 682 | { |
| 683 | points->SetNumberOfPoints(0); |
| 684 | } |
| 685 | if (cellIds) |
| 686 | { |
| 687 | cellIds->SetNumberOfIds(0); |
| 688 | } |
| 689 | return 0; |
| 690 | } |
| 691 | if (!this->DataSet->IsA("vtkPolyData")) |
| 692 | { |
| 693 | vtkErrorMacro("IntersectWithLine: this method requires a vtkPolyData"); |
| 694 | return 0; |
| 695 | } |
| 696 | |
| 697 | int rval = 0; // return value for function |
| 698 | vtkIdList* cells; |
| 699 | |
| 700 | // temporary list used to sort intersections |
| 701 | int listSize = 0; |
| 702 | int listMaxSize = 10; |
| 703 | double* distanceList = new double[listMaxSize]; |
| 704 | vtkIdType* cellList = new vtkIdType[listMaxSize]; |
| 705 | char* senseList = new char[listMaxSize]; |
| 706 | |
| 707 | double point[3]; |
| 708 | double distance = 0; |
| 709 | int sense = 0; |
| 710 | vtkIdType cellId; |
| 711 | |
| 712 | // compute line vector from p1 to p2 |
| 713 | double v12[3]; |
| 714 | v12[0] = p2[0] - p1[0]; |
| 715 | v12[1] = p2[1] - p1[1]; |
| 716 | v12[2] = p2[2] - p1[2]; |
| 717 | |
| 718 | vtkOBBNode** OBBstack = new vtkOBBNode*[this->GetLevel() + 1]; |
| 719 | OBBstack[0] = this->Tree; |
| 720 | |
| 721 | // depth counter for stack |
| 722 | int depth = 1; |
| 723 | while (depth > 0) |
| 724 | { // simulate recursion without the overhead or limitations |
| 725 | vtkOBBNode* node = OBBstack[--depth]; |
| 726 | |
| 727 | // check for intersection with node |
| 728 | if (this->LineIntersectsNode(node, p1, p2)) |
| 729 | { |
| 730 | if (node->Kids == nullptr) |
| 731 | { // then this is a leaf node...get Cells |
| 732 | cells = node->Cells; |
| 733 | vtkIdType numCells = cells->GetNumberOfIds(); |
no test coverage detected