340 |
341 |
341 SpikeHeap::iterator pit = spikeheap.end(); |
342 SpikeHeap::iterator pit = spikeheap.end(); |
342 if (prev != -1 && |
343 if (prev != -1 && |
343 circle_form(points[prev], points[curr], points[site])) { |
344 circle_form(points[prev], points[curr], points[site])) { |
344 double x = circle_point(points[prev], points[curr], points[site]); |
345 double x = circle_point(points[prev], points[curr], points[site]); |
345 pit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end()))); |
346 pit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end()))); |
346 pit->second.it = |
347 pit->second->it = |
347 beach.insert(std::make_pair(Part(prev, curr, site), pit)); |
348 beach.insert(std::make_pair(Part(prev, curr, site), pit)); |
348 } else { |
349 } else { |
349 beach.insert(std::make_pair(Part(prev, curr, site), pit)); |
350 beach.insert(std::make_pair(Part(prev, curr, site), pit)); |
350 } |
351 } |
351 |
352 |
353 |
354 |
354 SpikeHeap::iterator nit = spikeheap.end(); |
355 SpikeHeap::iterator nit = spikeheap.end(); |
355 if (next != -1 && |
356 if (next != -1 && |
356 circle_form(points[site], points[curr],points[next])) { |
357 circle_form(points[site], points[curr],points[next])) { |
357 double x = circle_point(points[site], points[curr], points[next]); |
358 double x = circle_point(points[site], points[curr], points[next]); |
358 nit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end()))); |
359 nit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end()))); |
359 nit->second.it = |
360 nit->second->it = |
360 beach.insert(std::make_pair(Part(site, curr, next), nit)); |
361 beach.insert(std::make_pair(Part(site, curr, next), nit)); |
361 } else { |
362 } else { |
362 beach.insert(std::make_pair(Part(site, curr, next), nit)); |
363 beach.insert(std::make_pair(Part(site, curr, next), nit)); |
363 } |
364 } |
364 |
365 |
365 ++siteindex; |
366 ++siteindex; |
366 } else { |
367 } else { |
367 sweep = spit->first; |
368 sweep = spit->first; |
368 |
369 |
369 Beach::iterator bit = spit->second.it; |
370 Beach::iterator bit = spit->second->it; |
370 |
371 |
371 int prev = bit->first.prev; |
372 int prev = bit->first.prev; |
372 int curr = bit->first.curr; |
373 int curr = bit->first.curr; |
373 int next = bit->first.next; |
374 int next = bit->first.next; |
374 |
375 |
397 Beach::iterator pbit = bit; --pbit; |
398 Beach::iterator pbit = bit; --pbit; |
398 int ppv = pbit->first.prev; |
399 int ppv = pbit->first.prev; |
399 Beach::iterator nbit = bit; ++nbit; |
400 Beach::iterator nbit = bit; ++nbit; |
400 int nnt = nbit->first.next; |
401 int nnt = nbit->first.next; |
401 |
402 |
402 if (bit->second != spikeheap.end()) spikeheap.erase(bit->second); |
403 if (bit->second != spikeheap.end()) |
403 if (pbit->second != spikeheap.end()) spikeheap.erase(pbit->second); |
404 { |
404 if (nbit->second != spikeheap.end()) spikeheap.erase(nbit->second); |
405 delete bit->second->second; |
405 |
406 spikeheap.erase(bit->second); |
|
407 } |
|
408 if (pbit->second != spikeheap.end()) |
|
409 { |
|
410 delete pbit->second->second; |
|
411 spikeheap.erase(pbit->second); |
|
412 } |
|
413 if (nbit->second != spikeheap.end()) |
|
414 { |
|
415 delete nbit->second->second; |
|
416 spikeheap.erase(nbit->second); |
|
417 } |
|
418 |
406 beach.erase(nbit); |
419 beach.erase(nbit); |
407 beach.erase(bit); |
420 beach.erase(bit); |
408 beach.erase(pbit); |
421 beach.erase(pbit); |
409 |
422 |
410 SpikeHeap::iterator pit = spikeheap.end(); |
423 SpikeHeap::iterator pit = spikeheap.end(); |
411 if (ppv != -1 && ppv != next && |
424 if (ppv != -1 && ppv != next && |
412 circle_form(points[ppv], points[prev], points[next])) { |
425 circle_form(points[ppv], points[prev], points[next])) { |
413 double x = circle_point(points[ppv], points[prev], points[next]); |
426 double x = circle_point(points[ppv], points[prev], points[next]); |
414 if (x < sweep) x = sweep; |
427 if (x < sweep) x = sweep; |
415 pit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end()))); |
428 pit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end()))); |
416 pit->second.it = |
429 pit->second->it = |
417 beach.insert(std::make_pair(Part(ppv, prev, next), pit)); |
430 beach.insert(std::make_pair(Part(ppv, prev, next), pit)); |
418 } else { |
431 } else { |
419 beach.insert(std::make_pair(Part(ppv, prev, next), pit)); |
432 beach.insert(std::make_pair(Part(ppv, prev, next), pit)); |
420 } |
433 } |
421 |
434 |
422 SpikeHeap::iterator nit = spikeheap.end(); |
435 SpikeHeap::iterator nit = spikeheap.end(); |
423 if (nnt != -1 && prev != nnt && |
436 if (nnt != -1 && prev != nnt && |
424 circle_form(points[prev], points[next], points[nnt])) { |
437 circle_form(points[prev], points[next], points[nnt])) { |
425 double x = circle_point(points[prev], points[next], points[nnt]); |
438 double x = circle_point(points[prev], points[next], points[nnt]); |
426 if (x < sweep) x = sweep; |
439 if (x < sweep) x = sweep; |
427 nit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end()))); |
440 nit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end()))); |
428 nit->second.it = |
441 nit->second->it = |
429 beach.insert(std::make_pair(Part(prev, next, nnt), nit)); |
442 beach.insert(std::make_pair(Part(prev, next, nnt), nit)); |
430 } else { |
443 } else { |
431 beach.insert(std::make_pair(Part(prev, next, nnt), nit)); |
444 beach.insert(std::make_pair(Part(prev, next, nnt), nit)); |
432 } |
445 } |
433 |
446 |