------------------------------------------------------------------------------
| 113 | |
| 114 | //------------------------------------------------------------------------------ |
| 115 | void vtkPOrderStatistics::Learn( |
| 116 | vtkTable* inData, vtkTable* inParameters, vtkStatisticalModel* outMeta) |
| 117 | { |
| 118 | if (!outMeta) |
| 119 | { |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | // First calculate order statistics on local data set |
| 124 | this->Superclass::Learn(inData, inParameters, outMeta); |
| 125 | |
| 126 | if (!outMeta || outMeta->GetNumberOfTables(vtkStatisticalModel::Learned) < 1) |
| 127 | { |
| 128 | // No statistics were calculated. |
| 129 | return; |
| 130 | } |
| 131 | |
| 132 | // Make sure that parallel updates are needed, otherwise leave it at that. |
| 133 | int np = this->Controller->GetNumberOfProcesses(); |
| 134 | if (np < 2) |
| 135 | { |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | // Get ready for parallel calculations |
| 140 | vtkCommunicator* com = this->Controller->GetCommunicator(); |
| 141 | if (!com) |
| 142 | { |
| 143 | vtkErrorMacro("No parallel communicator."); |
| 144 | } |
| 145 | |
| 146 | // Figure local process id |
| 147 | vtkIdType myRank = com->GetLocalProcessId(); |
| 148 | |
| 149 | // NB: Use process 0 as sole reducer for now |
| 150 | vtkIdType rProc = 0; |
| 151 | |
| 152 | // Iterate over primary tables |
| 153 | int nParts = outMeta->GetNumberOfTables(vtkStatisticalModel::Learned); |
| 154 | for (int b = 0; b < nParts; ++b) |
| 155 | { |
| 156 | // Fetch histogram table |
| 157 | vtkTable* histoTab = outMeta->GetTable(vtkStatisticalModel::Learned, b); |
| 158 | if (!histoTab) |
| 159 | { |
| 160 | continue; |
| 161 | } |
| 162 | std::string histoTabName = outMeta->GetTableName(vtkStatisticalModel::Learned, b); |
| 163 | |
| 164 | // Downcast columns to typed arrays for efficient data access |
| 165 | vtkAbstractArray* vals = histoTab->GetColumnByName("Value"); |
| 166 | vtkIdTypeArray* card = |
| 167 | vtkArrayDownCast<vtkIdTypeArray>(histoTab->GetColumnByName("Cardinality")); |
| 168 | if (!vals || !card) |
| 169 | { |
| 170 | vtkErrorMacro("Column fetching error on process " << myRank << "."); |
| 171 | |
| 172 | return; |
nothing calls this directly
no test coverage detected