------------------------------------------------------------------------------
| 560 | |
| 561 | //------------------------------------------------------------------------------ |
| 562 | void vtkStatisticsAlgorithm::Assess( |
| 563 | vtkTable* inData, vtkStatisticalModel* inMeta, vtkTable* outData, int numVariables) |
| 564 | { |
| 565 | if (!inData) |
| 566 | { |
| 567 | return; |
| 568 | } |
| 569 | |
| 570 | if (!inMeta) |
| 571 | { |
| 572 | return; |
| 573 | } |
| 574 | |
| 575 | // Loop over requests |
| 576 | for (std::set<std::set<vtkStdString>>::const_iterator rit = this->Internals->Requests.begin(); |
| 577 | rit != this->Internals->Requests.end(); ++rit) |
| 578 | { |
| 579 | // Storage for variable names of the request (smart pointer because of several exit points) |
| 580 | vtkSmartPointer<vtkStringArray> varNames = vtkSmartPointer<vtkStringArray>::New(); |
| 581 | varNames->SetNumberOfValues(numVariables); |
| 582 | |
| 583 | // Each request must contain numVariables columns of interest (additional columns are ignored) |
| 584 | bool invalidRequest = false; |
| 585 | int v = 0; |
| 586 | for (std::set<vtkStdString>::const_iterator it = rit->begin(); |
| 587 | v < numVariables && it != rit->end(); ++v, ++it) |
| 588 | { |
| 589 | // Try to retrieve column with corresponding name in input data |
| 590 | std::string const& varName = *it; |
| 591 | |
| 592 | // If requested column does not exist in input, ignore request |
| 593 | if (!inData->GetColumnByName(varName.c_str())) |
| 594 | { |
| 595 | vtkWarningMacro( |
| 596 | "InData table does not have a column " << varName << ". Ignoring request containing it."); |
| 597 | |
| 598 | invalidRequest = true; |
| 599 | break; |
| 600 | } |
| 601 | |
| 602 | // If column with corresponding name was found, store name |
| 603 | varNames->SetValue(v, varName); |
| 604 | } |
| 605 | if (invalidRequest) |
| 606 | { |
| 607 | continue; |
| 608 | } |
| 609 | |
| 610 | // If request is too short, it must also be ignored |
| 611 | if (v < numVariables) |
| 612 | { |
| 613 | vtkWarningMacro("Only " << v << " variables in the request while " << numVariables |
| 614 | << "are needed. Ignoring request."); |
| 615 | |
| 616 | continue; |
| 617 | } |
| 618 | |
| 619 | // Store names to be able to use SetValueByName, and create the outData columns |
no test coverage detected