------------------------------------------------------------------------------
| 209 | |
| 210 | //------------------------------------------------------------------------------ |
| 211 | vtkImageData* vtkVolume16Reader::GetImage(int ImageNumber) |
| 212 | { |
| 213 | vtkUnsignedShortArray* newScalars; |
| 214 | int* dim; |
| 215 | int dimensions[3]; |
| 216 | vtkImageData* result; |
| 217 | |
| 218 | // Validate instance variables |
| 219 | if (this->FilePrefix == nullptr) |
| 220 | { |
| 221 | vtkErrorMacro(<< "FilePrefix is nullptr"); |
| 222 | return nullptr; |
| 223 | } |
| 224 | |
| 225 | if (this->HeaderSize < 0) |
| 226 | { |
| 227 | vtkErrorMacro(<< "HeaderSize " << this->HeaderSize << " must be >= 0"); |
| 228 | return nullptr; |
| 229 | } |
| 230 | |
| 231 | dim = this->DataDimensions; |
| 232 | |
| 233 | if (dim[0] <= 0 || dim[1] <= 0) |
| 234 | { |
| 235 | vtkErrorMacro(<< "x, y dimensions " << dim[0] << ", " << dim[1] << "must be greater than 0."); |
| 236 | return nullptr; |
| 237 | } |
| 238 | |
| 239 | result = vtkImageData::New(); |
| 240 | newScalars = vtkUnsignedShortArray::New(); |
| 241 | this->ReadImage(ImageNumber, newScalars); |
| 242 | dimensions[0] = dim[0]; |
| 243 | dimensions[1] = dim[1]; |
| 244 | dimensions[2] = 1; |
| 245 | result->SetDimensions(dimensions); |
| 246 | result->SetSpacing(this->DataSpacing); |
| 247 | result->SetOrigin(this->DataOrigin); |
| 248 | if (newScalars) |
| 249 | { |
| 250 | result->GetPointData()->SetScalars(newScalars); |
| 251 | newScalars->Delete(); |
| 252 | } |
| 253 | return result; |
| 254 | } |
| 255 | |
| 256 | //------------------------------------------------------------------------------ |
| 257 | // Read a slice of volume data. |
no test coverage detected