------------------------------------------------------------------------------
| 158 | |
| 159 | //------------------------------------------------------------------------------ |
| 160 | int vtkXMLCompositeDataWriter::RequestData( |
| 161 | vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector*) |
| 162 | { |
| 163 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 164 | |
| 165 | this->InputInformation = inInfo; |
| 166 | |
| 167 | vtkCompositeDataSet* compositeData = |
| 168 | vtkCompositeDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 169 | if (!compositeData) |
| 170 | { |
| 171 | vtkErrorMacro("No hierarchical input has been provided. Cannot write"); |
| 172 | this->InputInformation = nullptr; |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | // Create writers for each input. |
| 177 | this->CreateWriters(compositeData); |
| 178 | |
| 179 | this->SetErrorCode(vtkErrorCode::NoError); |
| 180 | |
| 181 | // Make sure we have a file to write. |
| 182 | if (!this->Stream && !this->FileName) |
| 183 | { |
| 184 | vtkErrorMacro("Writer called with no FileName set."); |
| 185 | this->SetErrorCode(vtkErrorCode::NoFileNameError); |
| 186 | this->InputInformation = nullptr; |
| 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | // We are just starting to write. Do not call |
| 191 | // UpdateProgressDiscrete because we want a 0 progress callback the |
| 192 | // first time. |
| 193 | this->UpdateProgress(0); |
| 194 | |
| 195 | // Initialize progress range to entire 0..1 range. |
| 196 | float wholeProgressRange[2] = { 0.f, 1.f }; |
| 197 | this->SetProgressRange(wholeProgressRange, 0, 1); |
| 198 | |
| 199 | // Prepare file prefix for creation of internal file names. |
| 200 | this->SplitFileName(); |
| 201 | |
| 202 | float progressRange[2] = { 0.f, 0.f }; |
| 203 | this->GetProgressRange(progressRange); |
| 204 | |
| 205 | // Create the subdirectory for the internal files. |
| 206 | std::string subdir = this->Internal->FilePath; |
| 207 | subdir += this->Internal->FilePrefix; |
| 208 | this->MakeDirectory(subdir.c_str()); |
| 209 | |
| 210 | this->Internal->Root = vtkSmartPointer<vtkXMLDataElement>::New(); |
| 211 | this->Internal->Root->SetName(compositeData->GetClassName()); |
| 212 | |
| 213 | int writerIdx = 0; |
| 214 | if (!this->WriteComposite(compositeData, this->Internal->Root, writerIdx)) |
| 215 | { |
| 216 | this->RemoveWrittenFiles(subdir.c_str()); |
| 217 | return 0; |
no test coverage detected