------------------------------------------------------------------------------ Calculate the distance between the point x and the specified bounds WARNING!!!!! Be very careful altering this routine. Simple changes to this routine can make it 25% slower!!!! Return closest point (if any) AND the cell on which this closest point lies
| 984 | // routine can make it 25% slower!!!! |
| 985 | // Return closest point (if any) AND the cell on which this closest point lies |
| 986 | double Distance2ToBounds(const double x[3], const double bounds[6]) |
| 987 | { |
| 988 | // Are we within the bounds? |
| 989 | if (x[0] >= bounds[0] && x[0] <= bounds[1] && x[1] >= bounds[2] && x[1] <= bounds[3] && |
| 990 | x[2] >= bounds[4] && x[2] <= bounds[5]) |
| 991 | { |
| 992 | return 0.0; |
| 993 | } |
| 994 | double deltas[3]; |
| 995 | // NOLINTNEXTLINE(readability-avoid-nested-conditional-operator) |
| 996 | deltas[0] = x[0] < bounds[0] ? bounds[0] - x[0] : (x[0] > bounds[1] ? x[0] - bounds[1] : 0.0); |
| 997 | // NOLINTNEXTLINE(readability-avoid-nested-conditional-operator) |
| 998 | deltas[1] = x[1] < bounds[2] ? bounds[2] - x[1] : (x[1] > bounds[3] ? x[1] - bounds[3] : 0.0); |
| 999 | // NOLINTNEXTLINE(readability-avoid-nested-conditional-operator) |
| 1000 | deltas[2] = x[2] < bounds[4] ? bounds[4] - x[2] : (x[2] > bounds[5] ? x[2] - bounds[5] : 0.0); |
| 1001 | return vtkMath::SquaredNorm(deltas); |
| 1002 | } |
| 1003 | |
| 1004 | //------------------------------------------------------------------------------ |
| 1005 | // Return closest point (if any) AND the cell on which this closest point lies |
no test coverage detected