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

Method RequestData

IO/ParallelXML/vtkXMLPartitionedDataSetWriter.cxx:44–139  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

42
43//----------------------------------------------------------------------------
44int 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

Callers 1

ProcessRequestMethod · 0.45

Calls 15

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

Tested by

no test coverage detected