146void DnnPlane::RemoveAndAddPoints(
147 const vector<int> & indices_to_remove,
148 const vector<EtaPhi> & points_to_add,
149 vector<int> & indices_added,
150 vector<int> & indices_of_updated_neighbours) {
152 if (_verbose) cout <<
"Starting DnnPlane::RemoveAndAddPoints" << endl;
156 set<int> NeighbourUnion;
159 set<int> indices_removed;
164 for (
size_t ir = 0; ir < indices_to_remove.size(); ir++) {
165 int index = indices_to_remove[ir];
166 indices_removed.insert(index);
167 if (_verbose) cout <<
" scheduling point " << index <<
" for removal" << endl;
169 if (_supervertex[index].coincidence != index){
175 int new_index = _supervertex[index].coincidence;
176 while (_supervertex[new_index].coincidence != index)
177 new_index = _supervertex[new_index].coincidence;
178 if (_verbose) cout <<
" inserted coinciding " << new_index <<
" to neighbours union" << endl;
179 NeighbourUnion.insert(new_index);
184 if (index != _supervertex[index].vertex->info().val())
continue;
197 if (_verbose) cout <<
"examining " << vc->info().val() << endl;
198 if (vc->info().val() != INFINITE_VERTEX) {
202 NeighbourUnion.insert(vc->info().val());
203 if (_verbose) cout <<
" inserted " << vc->info().val() <<
" to neighbours union" << endl;
205 }
while (++vc != done);
210 set<int>::iterator it = NeighbourUnion.begin();
211 cout <<
"Union of neighbours of combined points" << endl;
212 for ( ; it != NeighbourUnion.end(); ++it ) {
218 for (
size_t ir = 0; ir < indices_to_remove.size(); ir++) {
219 int index = indices_to_remove[ir];
220 if (_verbose) cout <<
" removing " << index << endl;
224 NeighbourUnion.erase(indices_to_remove[ir]);
227 if (_supervertex[index].coincidence != index){
228 int new_index = _supervertex[index].coincidence;
240 if (index == _supervertex[index].vertex->info().val())
241 _supervertex[new_index].vertex->info() = new_index;
246 while (_supervertex[new_index].coincidence != index)
247 new_index = _supervertex[new_index].coincidence;
248 _supervertex[new_index].coincidence = _supervertex[index].coincidence;
252 _supervertex[index].coincidence = index;
253 _supervertex[index].vertex = NULL;
261 _TR.remove(_supervertex[index].vertex);
262 if (_verbose) cout <<
"DnnPlane about to set _supervertex["<< index<<
"].vertex to NULL" << endl;
263 _supervertex[index].vertex = NULL;
264 if (_verbose) cout <<
" value is " << (_is_not_null(_supervertex[index].vertex)) << endl;
289 if (NeighbourUnion.size() > 0) {
291 face = _TR.incident_faces(
292 _supervertex[*NeighbourUnion.begin()].vertex);}
294 indices_added.clear();
295 indices_of_updated_neighbours.clear();
296 for (
size_t ia = 0; ia < points_to_add.size(); ia++) {
298 _supervertex.push_back(sv);
299 int index = _supervertex.size()-1;
300 indices_added.push_back(index);
301 if (_verbose) cout <<
" adding " << index <<
" at "
302 << points_to_add[ia].first<<
" " << points_to_add[ia].second << endl;
305 if (NeighbourUnion.size() > 0) {
307 _supervertex[index].vertex = _TR.insert(Point(points_to_add[ia].first,
308 points_to_add[ia].second),face);}
310 _supervertex[index].vertex = _TR.insert(Point(points_to_add[ia].first,
311 points_to_add[ia].second));
315 int coinciding_index = _CheckIfVertexPresent(_supervertex[index].vertex, index);
316 if (coinciding_index == index){
320 _supervertex[index].vertex->info() = _supervertex[index].coincidence = index;
322 if (_verbose) cout <<
" coinciding with vertex " << coinciding_index << endl;
331 _supervertex[coinciding_index].NNindex = index;
332 _supervertex[coinciding_index].NNdistance = 0.0;
333 indices_of_updated_neighbours.push_back(coinciding_index);
339 _supervertex[index].coincidence = _supervertex[coinciding_index].coincidence;
340 _supervertex[coinciding_index].coincidence = index;
351 indices_of_updated_neighbours.push_back(index);
352 _SetAndUpdateNearest(index, indices_of_updated_neighbours);
363 set<int>::iterator it2 = NeighbourUnion.begin();
364 for ( ; it2 != NeighbourUnion.end(); ++it2 ) {
367 if( j != INFINITE_VERTEX ) {
370 if (indices_removed.count(_supervertex[j].NNindex)) {
371 if (_verbose) cout <<
"j " << j << endl;
373 indices_of_updated_neighbours.push_back(j);
374 if (_verbose) cout <<
"NN of " << j <<
" : "
375 << _supervertex[j].NNindex
376 <<
", dist = " << _supervertex[j].NNdistance <<endl;
381 if (_verbose) cout <<
"Leaving DnnPlane::RemoveAndAddPoints" << endl;