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

Method ReadPieceData

IO/XML/vtkXMLStatisticalModelReader.cxx:164–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164int vtkXMLStatisticalModelReader::ReadPieceData(int vtkNotUsed(piece))
165{
166 // Split the progress range based on the approximate fraction of
167 // data that will be read by each step in this method.
168 float progressRange[2] = { 0, 0 };
169 this->GetProgressRange(progressRange);
170
171 // Set the range of progress.
172 this->SetProgressRange(progressRange, 0, 2);
173
174 // Let the superclass read its data.
175 vtkStatisticalModel* output = vtkStatisticalModel::SafeDownCast(this->GetCurrentOutput());
176
177 auto* pdata = this->ParamElement->GetCharacterData();
178 output->SetAlgorithmParameters(strlen(pdata) > 0 ? pdata : nullptr);
179 vtkNew<vtkXMLTableReader> tableReader;
180 tableReader->ReadFromInputStringOn();
181 for (const auto& tableGroupElement : this->TableGroupElements)
182 {
183 int nn = tableGroupElement->GetNumberOfNestedElements();
184 const char* tableTypeChar = tableGroupElement->GetAttribute("Type");
185 if (!tableTypeChar)
186 {
187 vtkErrorMacro("No table type for \"ModelTables\" element. Skipping.");
188 continue;
189 }
190 int tableType = vtkStatisticalModel::GetTableTypeValue(tableTypeChar);
191 if (tableType < 0)
192 {
193 vtkErrorMacro(
194 "Invalid table type \"" << tableTypeChar << "\" for \"ModelTables\" element. Skipping.");
195 continue;
196 }
197 const char* numModelTablesStr = tableGroupElement->GetAttribute("NumberOfTables");
198 if (!numModelTablesStr)
199 {
200 vtkErrorMacro("The \"NumberOfTables\" attribute of the \"ModelTables\" element is missing.");
201 return 0;
202 }
203 int numModelTables = vtk::scan_int<int>(numModelTablesStr)->value();
204 output->SetNumberOfTables(tableType, numModelTables);
205 int modelTableIdx = 0;
206 for (int tt = 0; tt < nn; ++tt)
207 {
208 if (tableGroupElement->GetNestedElement(tt)->GetName() != std::string("ModelTable"))
209 {
210 // Skip non-ModelTable entries (such as comments).
211 continue;
212 }
213 std::string tableName;
214 const char* tableNameChar = tableGroupElement->GetNestedElement(tt)->GetAttribute("Name");
215 if (!tableNameChar || !tableNameChar[0])
216 {
217 vtkErrorMacro("Missing \"Name\" attribute for \"Table\" element.");
218 }
219 else
220 {
221 tableName = tableNameChar;

Callers 1

ReadXMLDataMethod · 0.95

Calls 15

GetCurrentOutputMethod · 0.80
SetNumberOfTablesMethod · 0.80
GetNestedElementMethod · 0.80
stringClass · 0.50
GetProgressRangeMethod · 0.45
SetProgressRangeMethod · 0.45
GetAttributeMethod · 0.45
valueMethod · 0.45
GetNameMethod · 0.45
dataMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected