------------------------------------------------------------------------------
| 712 | |
| 713 | //------------------------------------------------------------------------------ |
| 714 | int vtkKdNode::IntersectsCell(vtkCell* cell, int useDataBounds, int cellRegion, double* bounds) |
| 715 | { |
| 716 | vtkIdType i; |
| 717 | |
| 718 | if ((useDataBounds == 0) && (cellRegion >= 0)) |
| 719 | { |
| 720 | if ((cellRegion >= this->MinID) && (cellRegion <= this->MaxID)) |
| 721 | { |
| 722 | return 1; // the cell centroid is contained in this spatial region |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | double* cellBounds = nullptr; |
| 727 | int deleteCellBounds = (bounds == nullptr); |
| 728 | |
| 729 | if (deleteCellBounds) |
| 730 | { |
| 731 | cellBounds = new double[6]; |
| 732 | |
| 733 | vtkPoints* pts = cell->GetPoints(); |
| 734 | pts->Modified(); // VTK bug - so bounds will be re-calculated |
| 735 | pts->GetBounds(cellBounds); |
| 736 | } |
| 737 | else |
| 738 | { |
| 739 | cellBounds = bounds; |
| 740 | } |
| 741 | |
| 742 | int intersects = -1; |
| 743 | int dim = cell->GetCellDimension(); |
| 744 | |
| 745 | if (!this->IntersectsBox(cellBounds[0], cellBounds[1], cellBounds[2], cellBounds[3], |
| 746 | cellBounds[4], cellBounds[5], useDataBounds)) |
| 747 | { |
| 748 | intersects = 0; // cell bounding box is outside region |
| 749 | } |
| 750 | else if (this->ContainsBox(cellBounds[0], cellBounds[1], cellBounds[2], cellBounds[3], |
| 751 | cellBounds[4], cellBounds[5], useDataBounds)) |
| 752 | { |
| 753 | intersects = 1; // cell bounding box is completely inside region |
| 754 | } |
| 755 | else |
| 756 | { |
| 757 | // quick test - if any of the points are in this region, |
| 758 | // then it intersects |
| 759 | |
| 760 | vtkPoints* pts = cell->GetPoints(); |
| 761 | vtkIdType npts = pts->GetNumberOfPoints(); |
| 762 | |
| 763 | for (i = 0; i < npts; i++) |
| 764 | { |
| 765 | double* pt = pts->GetPoint(i); |
| 766 | if (this->ContainsPoint(pt[0], pt[1], pt[2], useDataBounds)) |
| 767 | { |
| 768 | intersects = 1; |
| 769 | break; |
| 770 | } |
| 771 | } |
no test coverage detected