------------------------------------------------------------------------------
| 259 | |
| 260 | //------------------------------------------------------------------------------ |
| 261 | void vtkAbstractImageInterpolator::Initialize(vtkDataObject* o) |
| 262 | { |
| 263 | // free any previous scalars |
| 264 | this->ReleaseData(); |
| 265 | |
| 266 | // check for valid data |
| 267 | vtkImageData* data = vtkImageData::SafeDownCast(o); |
| 268 | vtkDataArray* scalars = nullptr; |
| 269 | if (data) |
| 270 | { |
| 271 | scalars = data->GetPointData()->GetScalars(); |
| 272 | } |
| 273 | |
| 274 | if (data == nullptr || scalars == nullptr) |
| 275 | { |
| 276 | vtkErrorMacro("Initialize(): no image data to interpolate!"); |
| 277 | return; |
| 278 | } |
| 279 | |
| 280 | // claim the scalars |
| 281 | scalars->Register(this); |
| 282 | this->Scalars = scalars; |
| 283 | |
| 284 | // get the image information |
| 285 | data->GetSpacing(this->Spacing); |
| 286 | vtkMatrix3x3* matrix = data->GetDirectionMatrix(); |
| 287 | if (matrix->IsIdentity()) |
| 288 | { |
| 289 | this->UseDirection = false; |
| 290 | vtkMatrix3x3::Identity(this->Direction); |
| 291 | } |
| 292 | else |
| 293 | { |
| 294 | this->UseDirection = true; |
| 295 | vtkMatrix3x3::DeepCopy(this->Direction, data->GetDirectionMatrix()); |
| 296 | vtkMatrix3x3::Invert(this->Direction, this->InverseDirection); |
| 297 | } |
| 298 | data->GetOrigin(this->Origin); |
| 299 | data->GetExtent(this->Extent); |
| 300 | |
| 301 | // call update |
| 302 | this->Update(); |
| 303 | } |
| 304 | |
| 305 | //------------------------------------------------------------------------------ |
| 306 | void vtkAbstractImageInterpolator::ReleaseData() |
nothing calls this directly
no test coverage detected