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

Method RequestData

IO/Image/vtkImageWriter.cxx:87–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85//------------------------------------------------------------------------------
86
87int vtkImageWriter::RequestData(vtkInformation* vtkNotUsed(request),
88 vtkInformationVector** inputVector, vtkInformationVector* vtkNotUsed(outputVector))
89{
90 this->SetErrorCode(vtkErrorCode::NoError);
91
92 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
93 vtkImageData* input = vtkImageData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
94
95 // Error checking
96 if (input == nullptr)
97 {
98 vtkErrorMacro(<< "Write:Please specify an input!");
99 return 0;
100 }
101 if (!this->WriteToMemory && !this->FileName && !this->FilePattern)
102 {
103 vtkErrorMacro(<< "Write:Please specify either a FileName or a file prefix and pattern");
104 this->SetErrorCode(vtkErrorCode::NoFileNameError);
105 return 0;
106 }
107
108 // Make sure the file name is allocated
109 this->InternalFileNameSize = (this->FileName ? strlen(this->FileName) : 1) +
110 (this->FilePrefix ? strlen(this->FilePrefix) : 1) +
111 (this->FilePattern ? strlen(this->FilePattern) : 1) + 10;
112 this->InternalFileName = new char[this->InternalFileNameSize];
113
114 // Fill in image information.
115 int* wExt = inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
116 this->FileNumber = wExt[4];
117 this->MinimumFileNumber = this->MaximumFileNumber = this->FileNumber;
118 this->FilesDeleted = 0;
119
120 // Write
121 this->InvokeEvent(vtkCommand::StartEvent);
122 this->UpdateProgress(0.0);
123 if (this->WriteToMemory)
124 {
125 this->MemoryWrite(2, input, wExt, inInfo);
126 }
127 else
128 {
129 this->RecursiveWrite(2, input, inInfo, nullptr);
130 }
131
132 if (this->ErrorCode == vtkErrorCode::OutOfDiskSpaceError)
133 {
134 this->DeleteFiles();
135 }
136
137 this->UpdateProgress(1.0);
138 this->InvokeEvent(vtkCommand::EndEvent);
139
140 delete[] this->InternalFileName;
141 this->InternalFileName = nullptr;
142 this->InternalFileNameSize = 0;
143
144 return 1;

Callers

nothing calls this directly

Calls 6

GetInformationObjectMethod · 0.80
InvokeEventMethod · 0.80
MemoryWriteMethod · 0.80
GetMethod · 0.45
UpdateProgressMethod · 0.45
DeleteFilesMethod · 0.45

Tested by

no test coverage detected