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

Method Write

IO/Parallel/vtkPDataSetWriter.cxx:72–282  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

70
71//------------------------------------------------------------------------------
72int vtkPDataSetWriter::Write()
73{
74 int i;
75 int length;
76
77 ostream* fptr;
78 vtkDataSet* input = this->GetInput();
79 int inputAlgPort;
80 vtkAlgorithm* inputAlg = this->GetInputAlgorithm(0, 0, inputAlgPort);
81
82 if (this->FileName == nullptr)
83 {
84 vtkErrorMacro("No file name.");
85 return 0;
86 }
87
88 this->StartPiece = std::max(this->StartPiece, 0);
89 if (this->NumberOfPieces < 0 || this->EndPiece < this->StartPiece)
90 {
91 vtkWarningMacro("No pieces to write.");
92 return 1;
93 }
94
95 // Only one piece? The just write one vtk file.
96 if (this->StartPiece == 0 && this->NumberOfPieces == 1)
97 {
98 return this->vtkDataSetWriter::Write();
99 }
100
101 // Lets compute the file root from the file name supplied by the user.
102 length = static_cast<int>(strlen(this->FileName));
103 std::vector<char> fileRoot(length + 1);
104 size_t fileNameSize = length + this->FilePatternStdFormat.size() + 20;
105 std::vector<char> fileName(fileNameSize);
106 strncpy(fileRoot.data(), this->FileName, length);
107 fileRoot[length] = '\0';
108 // Trim off the pvtk extension.
109 if (strncmp(fileRoot.data() + length - 5, ".pvtk", 5) == 0)
110 {
111 fileRoot[length - 5] = '\0';
112 }
113 if (strncmp(fileRoot.data() + length - 4, ".vtk", 4) == 0)
114 {
115 fileRoot[length - 4] = '\0';
116 }
117 // If we are using relative file names, trim off the directory path.
118 if (this->UseRelativeFileNames)
119 {
120 char *tmp, *slash;
121 // Find the last / or \ in the file name.
122 slash = nullptr;
123 tmp = fileRoot.data();
124 while (*tmp != '\0')
125 {
126 if (*tmp == '/' || *tmp == '\\')
127 {
128 slash = tmp;
129 }

Calls 15

DeleteFilesMethod · 0.95
OpenFileMethod · 0.95
WriteImageMetaDataMethod · 0.95
UpdatePieceMethod · 0.80
GetDataObjectTypeMethod · 0.80
DeleteMethod · 0.65
maxFunction · 0.50
NewFunction · 0.50
format_to_nFunction · 0.50

Tested by 8

TestPLYWriterAlphaFunction · 0.36
TestPLYWriterNormalsFunction · 0.36
TestPLYWriterFunction · 0.36
TestPLYWriterStringFunction · 0.36
ExecuteMethod · 0.36
testMethod · 0.36
testMethod · 0.36
TestDataTypeFunction · 0.36