| 302 | } |
| 303 | |
| 304 | void vtkXMLStatisticalModelWriter::WriteModelDataInline(vtkStatisticalModel* ds, vtkIndent indent) |
| 305 | { |
| 306 | ostream& os = *(this->Stream); |
| 307 | vtkIndent i2 = indent.GetNextIndent(); |
| 308 | vtkIndent i3 = i2.GetNextIndent(); |
| 309 | os << indent << "<StatisticalModelData>\n"; |
| 310 | const char* params = ds->GetAlgorithmParameters(); |
| 311 | if (!params) |
| 312 | { |
| 313 | params = ""; |
| 314 | } |
| 315 | os << i2 << "<AlgorithmParameters>" << params << "</AlgorithmParameters>\n"; |
| 316 | vtkNew<vtkXMLTableWriter> tableSerializer; |
| 317 | tableSerializer->SetDataModeToAscii(); |
| 318 | tableSerializer->SetPrecision(17); |
| 319 | tableSerializer->WriteToOutputStringOn(); |
| 320 | for (int ttype = vtkStatisticalModel::Learned; ttype <= vtkStatisticalModel::Derived; ++ttype) |
| 321 | { |
| 322 | int numTab = ds->GetNumberOfTables(ttype); |
| 323 | if (numTab <= 0) |
| 324 | { |
| 325 | continue; |
| 326 | } |
| 327 | os << i2 << "<ModelTables Type=\"" << vtkStatisticalModel::GetTableTypeName(ttype) |
| 328 | << "\" NumberOfTables=\"" << numTab << "\">\n"; |
| 329 | for (int ii = 0; ii < numTab; ++ii) |
| 330 | { |
| 331 | auto tab = ds->GetTable(ttype, ii); |
| 332 | auto tabName = ds->GetTableName(ttype, ii); |
| 333 | if (!tab) |
| 334 | { |
| 335 | continue; |
| 336 | } |
| 337 | tableSerializer->SetInputDataObject(tab); |
| 338 | tableSerializer->Write(); |
| 339 | std::string tableData = tableSerializer->GetOutputString(); |
| 340 | std::string b64(tableData.size() + tableData.size() / 2, '\0'); |
| 341 | unsigned long encLen = |
| 342 | vtkBase64Utilities::Encode(reinterpret_cast<const unsigned char*>(tableData.c_str()), |
| 343 | static_cast<unsigned long>(tableData.size()), |
| 344 | reinterpret_cast<unsigned char*>(b64.data()), 1); |
| 345 | b64.resize(encLen); |
| 346 | |
| 347 | os << i3 << "<ModelTable Name=\"" << tabName << "\" Length=\"" << encLen << "\">" |
| 348 | << b64.c_str() << "</ModelTable>\n"; |
| 349 | } |
| 350 | os << i2 << "</ModelTables>\n"; |
| 351 | } |
| 352 | os << indent << "</StatisticalModelData>\n"; |
| 353 | } |
| 354 | |
| 355 | void vtkXMLStatisticalModelWriter::AllocatePositionArrays() |
| 356 | { |
no test coverage detected