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

Method RequestData

IO/Image/vtkNIFTIImageReader.cxx:1029–1355  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1027
1028//------------------------------------------------------------------------------
1029int vtkNIFTIImageReader::RequestData(vtkInformation* request,
1030 vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
1031{
1032 // check whether the reader is in an error state
1033 if (this->GetErrorCode() != vtkErrorCode::NoError)
1034 {
1035 return 0;
1036 }
1037
1038 // which output port did the request come from
1039 int outputPort = request->Get(vtkDemandDrivenPipeline::FROM_OUTPUT_PORT());
1040
1041 // for now, this reader has only one output
1042 if (outputPort > 0)
1043 {
1044 return 1;
1045 }
1046
1047 vtkInformation* outInfo = outputVector->GetInformationObject(0);
1048
1049 int extent[6];
1050 outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), extent);
1051
1052 // get the data object, allocate memory
1053 vtkImageData* data = static_cast<vtkImageData*>(outInfo->Get(vtkDataObject::DATA_OBJECT()));
1054#if VTK_MAJOR_VERSION >= 6
1055 this->AllocateOutputData(data, outInfo, extent);
1056#else
1057 this->AllocateOutputData(data, extent);
1058#endif
1059
1060 data->GetPointData()->GetScalars()->SetName("NIFTI");
1061
1062 const char* filename = nullptr;
1063 char* imgname = nullptr;
1064
1065 if (this->FileNames)
1066 {
1067 vtkIdType n = this->FileNames->GetNumberOfValues();
1068 int headers = 0;
1069 for (vtkIdType i = 0; i < n; i++)
1070 {
1071 filename = this->FileNames->GetValue(i).c_str();
1072 // this checks for .hdr and .hdr.gz, case insensitive
1073 if (vtkNIFTIImageReader::CheckExtension(filename, ".hdr"))
1074 {
1075 headers++;
1076 }
1077 else
1078 {
1079 imgname = new char[strlen(filename) + 1];
1080 strcpy(imgname, filename);
1081 }
1082 }
1083 if (n != 2 || headers != 1)
1084 {
1085 vtkErrorMacro("There must be two files and one must be a .hdr file.");
1086 delete[] imgname;

Callers

nothing calls this directly

Calls 15

gzseekFunction · 0.85
gzeofFunction · 0.85
gzreadFunction · 0.85
gzcloseFunction · 0.85
GetInformationObjectMethod · 0.80
GetScalarPointerMethod · 0.80
GetScalarSizeMethod · 0.80
InvokeEventMethod · 0.80
GZFopenFunction · 0.70
GetMethod · 0.45
AllocateOutputDataMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected