MCPcopy Create free account
hub / github.com/Kitware/VTK / ExecuteDataWithInformation

Method ExecuteDataWithInformation

IO/Image/vtkMRCReader.cxx:342–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342void vtkMRCReader::ExecuteDataWithInformation(
343 vtkDataObject* vtkNotUsed(output), vtkInformation* outInfo)
344{
345 vtkIdType outInc[3];
346 vtkIdType inOffsets[3];
347 int* outExt;
348 int modifiedOutExt[6];
349 int* execExt = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT());
350 vtkImageData* data = vtkImageData::GetData(outInfo);
351 this->AllocateOutputData(data, outInfo, execExt);
352
353 if (data->GetNumberOfPoints() <= 0)
354 {
355 return;
356 }
357 outExt = data->GetExtent();
358 // this should result in the bottom corner of the image having extent
359 // 0,0,0 which makes the 'where in the file is this extent' math easier
360 modifiedOutExt[0] = outExt[0] - this->Internals->header.nxstart;
361 modifiedOutExt[1] = outExt[1] - this->Internals->header.nxstart;
362 modifiedOutExt[2] = outExt[2] - this->Internals->header.nystart;
363 modifiedOutExt[3] = outExt[3] - this->Internals->header.nystart;
364 modifiedOutExt[4] = outExt[4] - this->Internals->header.nzstart;
365 modifiedOutExt[5] = outExt[5] - this->Internals->header.nzstart;
366 data->GetContinuousIncrements(outExt, outInc[0], outInc[1], outInc[2]);
367 void* outPtr = data->GetScalarPointer(outExt[0], outExt[2], outExt[4]);
368
369 if (!this->Internals->stream)
370 {
371 return;
372 }
373 // data start position is 1024 (the header size) plus the extended header size
374 vtkIdType dataStartPos = 1024 + this->Internals->header.next;
375 this->Internals->stream->seekg(dataStartPos, vtksys::ifstream::beg);
376
377 int vtkType = getFileDataType(this->Internals->header.mode);
378 int numComponents = getFileDataNumComponents(this->Internals->header.mode);
379 inOffsets[0] = numComponents;
380 inOffsets[1] = this->Internals->header.nx * numComponents;
381 inOffsets[2] = this->Internals->header.ny * this->Internals->header.nx * numComponents;
382
383 // This is what the big-endian MRC files are supposed to look like. I don't have one to
384 // test with though. However, if it does not look like that, assume it is little endian.
385 // There are some non-conformant programs that don't correctly fill in this field, and
386 // assuming little endian is safer.
387 bool fileIsLittleEndian = (this->Internals->header.stamp[0] != ((char)17));
388
389 ByteSwapFunction byteSwapFunction = getByteSwapFunction(vtkType, fileIsLittleEndian);
390 switch (vtkType)
391 {
392 vtkTemplateMacro(readData<VTK_TT>(numComponents, modifiedOutExt, outInc, inOffsets,
393 static_cast<VTK_TT*>(outPtr), *this->Internals->stream, dataStartPos, byteSwapFunction));
394 default:
395 vtkErrorMacro("Unknown data type");
396 }
397}
398VTK_ABI_NAMESPACE_END

Callers

nothing calls this directly

Calls 10

getFileDataTypeFunction · 0.85
getFileDataNumComponentsFunction · 0.85
getByteSwapFunctionFunction · 0.85
GetScalarPointerMethod · 0.80
GetDataFunction · 0.50
GetMethod · 0.45
AllocateOutputDataMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetExtentMethod · 0.45

Tested by

no test coverage detected