------------------------------------------------------------------------------ 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 is 25% slower!!!!
| 129 | // WARNING!!!!! Be very careful altering this routine. Simple changes to this |
| 130 | // routine can make is 25% slower!!!! |
| 131 | double vtkBucketList::Distance2ToBounds(const double x[3], const double bounds[6]) |
| 132 | { |
| 133 | double distance; |
| 134 | double deltas[3]; |
| 135 | |
| 136 | // Are we within the bounds? |
| 137 | if (x[0] >= bounds[0] && x[0] <= bounds[1] && x[1] >= bounds[2] && x[1] <= bounds[3] && |
| 138 | x[2] >= bounds[4] && x[2] <= bounds[5]) |
| 139 | { |
| 140 | return 0.0; |
| 141 | } |
| 142 | |
| 143 | deltas[0] = deltas[1] = deltas[2] = 0.0; |
| 144 | |
| 145 | // dx |
| 146 | // |
| 147 | if (x[0] < bounds[0]) |
| 148 | { |
| 149 | deltas[0] = bounds[0] - x[0]; |
| 150 | } |
| 151 | else if (x[0] > bounds[1]) |
| 152 | { |
| 153 | deltas[0] = x[0] - bounds[1]; |
| 154 | } |
| 155 | |
| 156 | // dy |
| 157 | // |
| 158 | if (x[1] < bounds[2]) |
| 159 | { |
| 160 | deltas[1] = bounds[2] - x[1]; |
| 161 | } |
| 162 | else if (x[1] > bounds[3]) |
| 163 | { |
| 164 | deltas[1] = x[1] - bounds[3]; |
| 165 | } |
| 166 | |
| 167 | // dz |
| 168 | // |
| 169 | if (x[2] < bounds[4]) |
| 170 | { |
| 171 | deltas[2] = bounds[4] - x[2]; |
| 172 | } |
| 173 | else if (x[2] > bounds[5]) |
| 174 | { |
| 175 | deltas[2] = x[2] - bounds[5]; |
| 176 | } |
| 177 | |
| 178 | distance = vtkMath::Dot(deltas, deltas); |
| 179 | return distance; |
| 180 | } |
| 181 | |
| 182 | //------------------------------------------------------------------------------ |
| 183 | // Utility class to store an array of ijk values |
no test coverage detected