154{
155
156
157 static int next_cluster_index = 0;
158
159 m_hits.push_back(new_hit);
161
162
163
164
165 std::set<int> clusters_neighbouring_hit;
166
167
169
170 for (auto neighbour : new_hit->neighbours) {
172 neighbour->neighbours.size() + 1 >=
m_minPts) {
173
174
175 clusters_neighbouring_hit.insert(neighbour->cluster);
176 }
177 }
178
179 if (clusters_neighbouring_hit.empty()) {
180
181
182
183 if (new_hit->neighbours.size() + 1 >=
m_minPts) {
184
187 m_clusters.end(), next_cluster_index, next_cluster_index);
188 Cluster& new_cluster = new_it->second;
190 new_cluster.add_hit(new_hit);
191 next_cluster_index++;
193 }
194 else{
195
196 }
197 } else {
198
199
200
201
202 auto index_it = clusters_neighbouring_hit.begin();
203
206 Cluster& cluster = it->second;
207
208 cluster.add_hit(new_hit);
209
210
211
212
213
214 for (auto q : new_hit->neighbours) {
216
217 cluster.add_hit(q);
218 }
219
220
221
222 if(q->neighbours.size() + 1 ==
m_minPts){
223 for (auto r : q->neighbours) {
224 cluster.add_hit(r);
225 }
226 }
227 }
228
229
230 ++index_it;
231
232 for (; index_it != clusters_neighbouring_hit.end(); ++index_it) {
233
236 Cluster& other_cluster = other_it->second;
237 cluster.steal_hits(other_cluster);
238 }
239 }
240
241
242
243
244 for (auto& neighbour : new_hit->neighbours) {
245 if(neighbour->neighbours.size() + 1 >=
m_minPts){
246
250 m_clusters.end(), next_cluster_index, next_cluster_index);
251 Cluster& new_cluster = new_it->second;
253 new_cluster.add_hit(neighbour);
254 next_cluster_index++;
256 }
257 }
258 }
259 else {
260
261 }
262 }
263
264
265
266
269 Cluster& cluster = clust_it->second;
270
273 }
274
276 if(completed_clusters){
277
278
279
280
281
282 if(cluster.hits.size()!=0){
283 completed_clusters->push_back(cluster);
284 }
285 }
287 continue;
288 } else {
289 ++clust_it;
290 }
291 }
292}
std::vector< Hit * > m_hits
void cluster_reachable(Hit *seed_hit, Cluster &cluster)
std::map< int, Cluster > m_clusters
int neighbours_sorted(const std::vector< Hit * > &hits, Hit &q, float eps, int minPts)