------------------------------------------------------------------------------ Fast implementation of GetCellBounds(). Bounds are calculated without constructing a cell.
| 249 | // Fast implementation of GetCellBounds(). Bounds are calculated without |
| 250 | // constructing a cell. |
| 251 | void vtkImageData::GetCellBounds(vtkIdType cellId, double bounds[6]) |
| 252 | { |
| 253 | if (this->GetCells()->GetCellSize(cellId) == 0) |
| 254 | { |
| 255 | bounds[0] = bounds[1] = bounds[2] = bounds[3] = bounds[4] = bounds[5] = 0.0; |
| 256 | return; |
| 257 | } |
| 258 | int ijkMin[3], ijkMax[3]; |
| 259 | vtkStructuredData::ComputeCellStructuredMinMaxCoords( |
| 260 | cellId, this->GetDimensions(), ijkMin, ijkMax, this->GetDataDescription()); |
| 261 | |
| 262 | vtkPoints* points = this->GetPoints(); |
| 263 | const auto pointsBackend = |
| 264 | static_cast<vtkStructuredPointArray<double>*>(points->GetData())->GetBackend(); |
| 265 | int loc[3]; |
| 266 | double point[3]; |
| 267 | bounds[0] = bounds[2] = bounds[4] = VTK_DOUBLE_MAX; |
| 268 | bounds[1] = bounds[3] = bounds[5] = VTK_DOUBLE_MIN; |
| 269 | if (this->DirectionMatrixIsIdentity) |
| 270 | { |
| 271 | for (loc[2] = ijkMin[2]; loc[2] <= ijkMax[2]; loc[2]++) |
| 272 | { |
| 273 | point[2] = pointsBackend->mapStructuredZComponent(loc[2]); |
| 274 | bounds[4] = std::min(bounds[4], point[2]); |
| 275 | bounds[5] = std::max(bounds[5], point[2]); |
| 276 | } |
| 277 | for (loc[1] = ijkMin[1]; loc[1] <= ijkMax[1]; loc[1]++) |
| 278 | { |
| 279 | point[1] = pointsBackend->mapStructuredYComponent(loc[1]); |
| 280 | bounds[2] = std::min(bounds[2], point[1]); |
| 281 | bounds[3] = std::max(bounds[3], point[1]); |
| 282 | } |
| 283 | for (loc[0] = ijkMin[0]; loc[0] <= ijkMax[0]; loc[0]++) |
| 284 | { |
| 285 | point[0] = pointsBackend->mapStructuredXComponent(loc[0]); |
| 286 | bounds[0] = std::min(bounds[0], point[0]); |
| 287 | bounds[1] = std::max(bounds[1], point[0]); |
| 288 | } |
| 289 | } |
| 290 | else |
| 291 | { |
| 292 | for (loc[2] = ijkMin[2]; loc[2] <= ijkMax[2]; loc[2]++) |
| 293 | { |
| 294 | for (loc[1] = ijkMin[1]; loc[1] <= ijkMax[1]; loc[1]++) |
| 295 | { |
| 296 | for (loc[0] = ijkMin[0]; loc[0] <= ijkMax[0]; loc[0]++) |
| 297 | { |
| 298 | pointsBackend->mapStructuredTuple(loc, point); |
| 299 | bounds[0] = std::min(bounds[0], point[0]); |
| 300 | bounds[1] = std::max(bounds[1], point[0]); |
| 301 | bounds[2] = std::min(bounds[2], point[1]); |
| 302 | bounds[3] = std::max(bounds[3], point[1]); |
| 303 | bounds[4] = std::min(bounds[4], point[2]); |
| 304 | bounds[5] = std::max(bounds[5], point[2]); |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | } |
nothing calls this directly
no test coverage detected