| 173 | } |
| 174 | |
| 175 | void CovarianceFeaturesFilter::filter(PointView& view) |
| 176 | { |
| 177 | KD3Index& kdi = view.build3dIndex(); |
| 178 | |
| 179 | point_count_t npoints = view.size(); |
| 180 | point_count_t chunk_size = npoints / m_threads; |
| 181 | if (npoints % m_threads) chunk_size++; |
| 182 | std::vector<std::thread> threadList(m_threads); |
| 183 | |
| 184 | log()->get(LogLevel::Debug) << "Processing " << npoints << " points in " |
| 185 | << m_threads << " threads.\n"; |
| 186 | |
| 187 | for(int t = 0; t < m_threads; t++) |
| 188 | { |
| 189 | threadList[t] = std::thread( |
| 190 | [&](const PointId start, const PointId end) |
| 191 | { |
| 192 | for(PointId i = start; i < end; i++) |
| 193 | setDimensionality(view, i, kdi); |
| 194 | }, |
| 195 | t * chunk_size, |
| 196 | (t + 1) == m_threads ? npoints : (t + 1) * chunk_size |
| 197 | ); |
| 198 | } |
| 199 | |
| 200 | for (auto &t: threadList) |
| 201 | t.join(); |
| 202 | } |
| 203 | |
| 204 | void CovarianceFeaturesFilter::setDimensionality(PointView &view, const PointId &id, const KD3Index &kdi) |
| 205 | { |