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

Method SelectAssessFunctor

Filters/Statistics/vtkDescriptiveStatistics.cxx:731–807  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

729
730//------------------------------------------------------------------------------
731void vtkDescriptiveStatistics::SelectAssessFunctor(
732 vtkTable* outData, vtkDataObject* inMetaDO, vtkStringArray* rowNames, AssessFunctor*& dfunc)
733{
734 dfunc = nullptr;
735 vtkStatisticalModel* inMeta = vtkStatisticalModel::SafeDownCast(inMetaDO);
736 vtkTable* primaryTab = inMeta ? inMeta->GetTable(vtkStatisticalModel::Learned, 0) : nullptr;
737 vtkTable* derivedTab = inMeta ? inMeta->GetTable(vtkStatisticalModel::Derived, 0) : nullptr;
738 if (!primaryTab || !derivedTab)
739 {
740 return;
741 }
742
743 vtkIdType nRowPrim = primaryTab->GetNumberOfRows();
744 if (nRowPrim != derivedTab->GetNumberOfRows())
745 {
746 return;
747 }
748
749 const auto& varName = rowNames->GetValue(0);
750
751 // Downcast meta columns to string arrays for efficient data access
752 vtkStringArray* vars = vtkArrayDownCast<vtkStringArray>(primaryTab->GetColumnByName("Variable"));
753 if (!vars)
754 {
755 return;
756 }
757
758 // Loop over primary statistics table until the requested variable is found
759 for (int r = 0; r < nRowPrim; ++r)
760 {
761 if (vars->GetValue(r) == varName)
762 {
763 // Grab the data for the requested variable
764 vtkAbstractArray* arr = outData->GetColumnByName(varName.c_str());
765 if (!arr)
766 {
767 return;
768 }
769
770 // For descriptive statistics, type must be convertible to DataArray
771 // E.g., StringArrays do not fit here
772 vtkDataArray* vals = vtkArrayDownCast<vtkDataArray>(arr);
773 if (!vals)
774 {
775 return;
776 }
777
778 // Fetch necessary value from primary model
779 double mean = primaryTab->GetValueByName(r, "Mean").ToDouble();
780
781 // Fetch necessary value from derived model
782 double stdv = derivedTab->GetValueByName(r, "Standard Deviation").ToDouble();
783 // NB: If derived values were specified (and not calculated by Derive)
784 // and are inconsistent, then incorrect assessments will be produced
785
786 if (stdv < VTK_DBL_MIN)
787 {
788 dfunc = new ZedDeviationDeviantFunctor(vals, mean);

Callers

nothing calls this directly

Calls 7

GetColumnByNameMethod · 0.80
GetValueByNameMethod · 0.80
GetTableMethod · 0.45
GetNumberOfRowsMethod · 0.45
GetValueMethod · 0.45
c_strMethod · 0.45
ToDoubleMethod · 0.45

Tested by

no test coverage detected