| 1029 | // marks whether the bin has been visited previously and skip it if we have. |
| 1030 | template <typename TIds> |
| 1031 | int BucketList2D<TIds>::IntersectWithLine(double a0[3], double a1[3], double tol, double& t, |
| 1032 | double lineX[3], double ptX[3], vtkIdType& ptId) |
| 1033 | { |
| 1034 | double* bounds = this->Bounds; |
| 1035 | int* ndivs = this->Divisions; |
| 1036 | double* h = this->H; |
| 1037 | double n[3] = { 0, 0, 1 }; |
| 1038 | |
| 1039 | // First check if this line is in a 2D plane or not. If not, intersect the |
| 1040 | // locator plane with the line and return closest point. |
| 1041 | if (a0[2] != a1[2]) // not in locator plane |
| 1042 | { |
| 1043 | double minPnt[3]; |
| 1044 | vtkBoundingBox bbox(bounds); |
| 1045 | bbox.Inflate(tol, tol, 0.0); |
| 1046 | bbox.GetMinPoint(minPnt); |
| 1047 | if (vtkPlane::IntersectWithLine(a0, a1, n, minPnt, t, lineX) && bbox.ContainsPoint(lineX)) |
| 1048 | { |
| 1049 | ptId = this->FindClosestPoint(lineX); |
| 1050 | if (ptId < 0) |
| 1051 | { |
| 1052 | return 0; |
| 1053 | } |
| 1054 | this->DataSet->GetPoint(ptId, ptX); |
| 1055 | return 1; |
| 1056 | } |
| 1057 | else |
| 1058 | { |
| 1059 | ptId = (-1); |
| 1060 | return 0; |
| 1061 | } |
| 1062 | } // line not in z-plane |
| 1063 | |
| 1064 | // If here then the ray is parallel to the z-plane. In this case, traversing the |
| 1065 | // pixels (i.e., buckets) in the locator is required. |
| 1066 | TIds ii, numPtsInBin; |
| 1067 | double x[3], xl[3], rayDir[3], xmin[3], xmax[3]; |
| 1068 | int ij[2], ijMin[2], ijMax[2]; |
| 1069 | int i, j, enterExitCount; |
| 1070 | vtkIdType idx, pId, bestPtId = (-1); |
| 1071 | double step[2], next[2], tMax[2], tDelta[2]; |
| 1072 | double curPos[3], curT, tHit, tMin = VTK_FLOAT_MAX; |
| 1073 | double tol2 = tol * tol; |
| 1074 | unsigned char* bucketHasBeenVisited = nullptr; |
| 1075 | vtkMath::Subtract(a1, a0, rayDir); |
| 1076 | |
| 1077 | // Need to pad out bbox |
| 1078 | vtkBoundingBox bbox(bounds); |
| 1079 | bbox.Inflate(0.0, 0.0, tol); |
| 1080 | bbox.GetBounds(bounds); |
| 1081 | |
| 1082 | if (vtkBox::IntersectBox(bounds, a0, rayDir, curPos, curT)) |
| 1083 | { |
| 1084 | // Initialize intersection query array if necessary. This is done |
| 1085 | // locally to ensure thread safety. |
| 1086 | bucketHasBeenVisited = new unsigned char[this->NumBuckets]; |
| 1087 | memset(bucketHasBeenVisited, 0, this->NumBuckets); |
| 1088 |
nothing calls this directly
no test coverage detected