----------------------------------------------------------------------------
| 42 | |
| 43 | //---------------------------------------------------------------------------- |
| 44 | int vtkXMLPartitionedDataSetWriter::RequestData( |
| 45 | vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector*) |
| 46 | { |
| 47 | vtkLogScopeF(TRACE, "RequestData ('%s')", this->FileName); |
| 48 | this->SetErrorCode(vtkErrorCode::UnknownError); |
| 49 | |
| 50 | if (this->WriteToOutputString) |
| 51 | { |
| 52 | vtkErrorMacro("This writer does not support writing to string yet."); |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | if (!this->FileName || this->FileName[0] == '\0') |
| 57 | { |
| 58 | this->SetErrorCode(vtkErrorCode::NoFileNameError); |
| 59 | vtkErrorMacro("Filename cannot be empty!"); |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | auto controller = this->GetController(); |
| 64 | |
| 65 | auto inputPDS = vtkPartitionedDataSet::GetData(inputVector[0], 0); |
| 66 | assert(inputPDS != nullptr); |
| 67 | |
| 68 | this->UpdateProgress(0.0); |
| 69 | |
| 70 | std::string path, filename, artifactsDir; |
| 71 | std::tie(path, filename, artifactsDir) = vtkXMLWriter2::SplitFileName(this->FileName); |
| 72 | vtkLogF(TRACE, "Filename components(path='%s', filename='%s', artifactsDir='%s')", path.c_str(), |
| 73 | filename.c_str(), artifactsDir.c_str()); |
| 74 | if (!this->MakeDirectory(path)) |
| 75 | { |
| 76 | this->SetErrorCode(vtkErrorCode::OutOfDiskSpaceError); |
| 77 | vtkErrorMacro("Failed to create directory '" << path << "'."); |
| 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | // we intentionally don't add path as an artifact to cleanup if write fails. |
| 82 | // this->AddArtifact(path, true); |
| 83 | |
| 84 | const auto absoluteArtifactsDir = path + "/" + artifactsDir; |
| 85 | if (!this->MakeDirectory(absoluteArtifactsDir)) |
| 86 | { |
| 87 | this->SetErrorCode(vtkErrorCode::OutOfDiskSpaceError); |
| 88 | vtkErrorMacro("Failed to create directory '" << absoluteArtifactsDir << "'."); |
| 89 | return 0; |
| 90 | } |
| 91 | this->AddRootArtifact(absoluteArtifactsDir, /*isDir*/ true); |
| 92 | |
| 93 | // note: localDataSets may have nullptrs. |
| 94 | auto localDataSets = |
| 95 | vtkCompositeDataSet::GetDataSets<vtkDataObject>(inputPDS, /*preserveNull=*/true); |
| 96 | const int localOffset = |
| 97 | vtkXMLWriter2::ExclusiveScanSum(controller, static_cast<int>(localDataSets.size())); |
| 98 | |
| 99 | // note: localFilenames may have empty strings. |
| 100 | std::vector<std::string> localFilenames; |
| 101 |
no test coverage detected