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

Method RequestData

IO/ParallelXML/vtkXMLPartitionedDataSetCollectionWriter.cxx:50–153  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

48
49//----------------------------------------------------------------------------
50int vtkXMLPartitionedDataSetCollectionWriter::RequestData(
51 vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector*)
52{
53 vtkLogScopeF(TRACE, "RequestData ('%s')", this->FileName);
54 this->SetErrorCode(vtkErrorCode::UnknownError);
55
56 if (this->WriteToOutputString)
57 {
58 vtkErrorMacro("This writer does not support writing to string yet.");
59 return 0;
60 }
61
62 if (!this->FileName || this->FileName[0] == '\0')
63 {
64 this->SetErrorCode(vtkErrorCode::NoFileNameError);
65 vtkErrorMacro("Filename cannot be empty!");
66 return 0;
67 }
68
69 auto inputPDC = vtkPartitionedDataSetCollection::GetData(inputVector[0], 0);
70 assert(inputPDC != nullptr);
71
72 this->UpdateProgress(0.0);
73
74 std::string path, filename, artifactsDir;
75 std::tie(path, filename, artifactsDir) = vtkXMLWriter2::SplitFileName(this->FileName);
76 vtkLogF(TRACE, "Filename components(path='%s', filename='%s', artifactsDir='%s')", path.c_str(),
77 filename.c_str(), artifactsDir.c_str());
78 if (!this->MakeDirectory(path))
79 {
80 this->SetErrorCode(vtkErrorCode::OutOfDiskSpaceError);
81 vtkErrorMacro("Failed to create directory '" << path << "'.");
82 return 0;
83 }
84
85 // we intentionally don't add path as an artifact to cleanup if write fails.
86 // this->AddArtifact(path, true);
87 const auto absoluteArtifactsDir = path + "/" + artifactsDir;
88 if (!this->MakeDirectory(absoluteArtifactsDir))
89 {
90 this->SetErrorCode(vtkErrorCode::OutOfDiskSpaceError);
91 vtkErrorMacro("Failed to create directory '" << absoluteArtifactsDir << "'.");
92 return 0;
93 }
94 this->AddRootArtifact(absoluteArtifactsDir, /*isDir*/ true);
95
96 auto controller = this->GetController();
97
98 vtkNew<vtkXMLCompositeDataSetWriterHelper> helper;
99 helper->SetWriter(this);
100
101 const auto filenameNoExt = vtksys::SystemTools::GetFilenameWithoutLastExtension(filename);
102 std::vector<std::vector<std::string>> allFilenames(inputPDC->GetNumberOfPartitionedDataSets());
103
104 // Write individual files for each dataset in every partitioned-dataset
105 // and build the list of filenames to write the summary file.
106 for (unsigned int pidx = 0, max = inputPDC->GetNumberOfPartitionedDataSets(); pidx < max; ++pidx)
107 {

Callers

nothing calls this directly

Calls 15

WriteSummaryXMLMethod · 0.95
AddRootArtifactMethod · 0.80
GetPartitionedDataSetMethod · 0.80
AddArtifactMethod · 0.80
GetNumberOfProcessesMethod · 0.80
GetDataFunction · 0.50
assertFunction · 0.50
to_stringFunction · 0.50
GatherFunction · 0.50
UpdateProgressMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected