------------------------------------------------------------------------------
| 411 | |
| 412 | //------------------------------------------------------------------------------ |
| 413 | vtkSmartPointer<vtkStatisticsAlgorithm> vtkStatisticsAlgorithm::NewFromAlgorithmParameters( |
| 414 | const std::string& algorithmParameters) |
| 415 | { |
| 416 | static bool once = false; |
| 417 | if (!once) |
| 418 | { |
| 419 | once = true; |
| 420 | vtkStatisticsAlgorithm::RegisterAlgorithm<vtkAutoCorrelativeStatistics>(); |
| 421 | vtkStatisticsAlgorithm::RegisterAlgorithm<vtkContingencyStatistics>(); |
| 422 | vtkStatisticsAlgorithm::RegisterAlgorithm<vtkCorrelativeStatistics>(); |
| 423 | vtkStatisticsAlgorithm::RegisterAlgorithm<vtkDescriptiveStatistics>(); |
| 424 | vtkStatisticsAlgorithm::RegisterAlgorithm<vtkHighestDensityRegionsStatistics>(); |
| 425 | vtkStatisticsAlgorithm::RegisterAlgorithm<vtkKMeansStatistics>(); |
| 426 | vtkStatisticsAlgorithm::RegisterAlgorithm<vtkMultiCorrelativeStatistics>(); |
| 427 | vtkStatisticsAlgorithm::RegisterAlgorithm<vtkOrderStatistics>(); |
| 428 | vtkStatisticsAlgorithm::RegisterAlgorithm<vtkVisualStatistics>(); |
| 429 | } |
| 430 | vtkSmartPointer<vtkStatisticsAlgorithm> result; |
| 431 | std::size_t parameterStart = algorithmParameters.find('('); |
| 432 | std::string className; |
| 433 | std::string parameterList; |
| 434 | if (parameterStart == std::string::npos) |
| 435 | { |
| 436 | className = algorithmParameters; |
| 437 | } |
| 438 | else |
| 439 | { |
| 440 | className = algorithmParameters.substr(0, parameterStart); |
| 441 | if (algorithmParameters.back() != ')') |
| 442 | { |
| 443 | vtkGenericWarningMacro("Missing closing parenthesis for algorithm parameters."); |
| 444 | return result; |
| 445 | } |
| 446 | parameterList = algorithmParameters.substr(parameterStart + 1, algorithmParameters.size() - 1); |
| 447 | } |
| 448 | auto& cmap = vtkStatisticsAlgorithm::GetConstructorMap(); |
| 449 | auto it = cmap.find(vtkStringToken(className)); |
| 450 | result = (it != cmap.end() ? it->second() : nullptr); |
| 451 | if (result) |
| 452 | { |
| 453 | if (!result->ConfigureFromAlgorithmParameters(parameterList)) |
| 454 | { |
| 455 | vtkGenericWarningMacro("Cannot parse parameters."); |
| 456 | result = nullptr; // Destroy the algorithm. |
| 457 | } |
| 458 | } |
| 459 | else |
| 460 | { |
| 461 | vtkGenericWarningMacro("Can not create algorithm of type \"" << className << "\"."); |
| 462 | } |
| 463 | return result; |
| 464 | } |
| 465 | |
| 466 | //------------------------------------------------------------------------------ |
| 467 | int vtkStatisticsAlgorithm::RequestData( |