------------------------------------------------------------------------------ Return the entry point and exit point of a given cell for the segment [p1,p2].
| 171 | //------------------------------------------------------------------------------ |
| 172 | // Return the entry point and exit point of a given cell for the segment [p1,p2]. |
| 173 | HitCellInfo GetInOutCell(const vtkVector3d& p1, const vtkVector3d& p2, vtkIdType cellId, |
| 174 | vtkDataSet* input, double tolerance) |
| 175 | { |
| 176 | HitCellInfo res; |
| 177 | res.CellId = cellId; |
| 178 | |
| 179 | vtkCell* cell = input->GetCell(cellId); |
| 180 | double t; |
| 181 | int subId; |
| 182 | if (cell->IntersectWithLine( |
| 183 | p1.GetData(), p2.GetData(), tolerance, t, res.InPos.data(), res.InPCoords.data(), subId)) |
| 184 | { |
| 185 | res.InT = t; |
| 186 | } |
| 187 | if (cell->IntersectWithLine( |
| 188 | p2.GetData(), p1.GetData(), tolerance, t, res.OutPos.data(), res.OutPCoords.data(), subId)) |
| 189 | { |
| 190 | res.OutT = 1.0 - t; |
| 191 | } |
| 192 | |
| 193 | if (vtkMathUtilities::FuzzyCompare(res.InT, res.OutT, tolerance)) |
| 194 | { |
| 195 | res.InT = res.OutT = -1.0; |
| 196 | } |
| 197 | |
| 198 | return res; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | VTK_ABI_NAMESPACE_BEGIN |
no test coverage detected