Повышение полигона: доступ к исходным точкам диаграммы Вороного

С Увеличить полигон Я строю диаграмму Вороного следующим образом

 voronoi_diagram<double> vd;
construct_voronoi(discrete_positions.begin(), discrete_positions.end(), &vd);

Исходные точки (здесь называемые discrete_positions) являются

1:  pos = 5350.000000, 10089.000000
2:  pos = 5958.000000, 10254.000000
3:  pos = 5967.000000, 10573.000000
4:  pos = 5032.000000, 10573.000000
5:  pos = 5032.000000, 9826.000000
6:  pos = 5967.000000, 9826.000000
7:  pos = 5958.000000, 10145.000000

Чтобы получить исходные точки, я пройдусь по диаграмме двумя различными способами:

Метод первый: обход клеткамудр:

for (voronoi_diagram<double>::const_cell_iterator it = vd.cells().begin();
it != vd.cells().end(); ++it) {
std::size_t index = it->source_index();
Point p = discrete_positions[index];
printf("Cell_index # %d, contains a point: (%f, %f).\n", index, p._x, p._y);
}

Выход:

Cell_index # 4, contains a point: (5032.000000, 9826.000000).
Cell_index # 3, contains a point: (5032.000000, 10573.000000).
Cell_index # 0, contains a point: (5350.000000, 10089.000000).
Cell_index # 6, contains a point: (5958.000000, 10145.000000).
Cell_index # 1, contains a point: (5958.000000, 10254.000000).
Cell_index # 5, contains a point: (5967.000000, 9826.000000).
Cell_index # 2, contains a point: (5967.000000, 10573.000000).

Способ второй: обход темямудр:

for (auto it = vd.vertices().begin(); it != vd.vertices().end(); ++it){
const voronoi_diagram<double>::vertex_type &vertex = *it;
const voronoi_diagram<double>::edge_type *edge = vertex.incident_edge();
std::size_t index = ( edge->cell() )->source_index();
Point p = discrete_positions[index];
printf("Cell_index # %d, contains a point: (%f, %f).\n", index, p._x, p._y);
}

Выход:

Cell_index # 3, contains a point: (5032.000000, 10573.000000).
Cell_index # 1, contains a point: (5958.000000, 10254.000000).
Cell_index # 2, contains a point: (5967.000000, 10573.000000).
Cell_index # 2, contains a point: (5967.000000, 10573.000000).
Cell_index # 6, contains a point: (5958.000000, 10145.000000).
Cell_index # 5, contains a point: (5967.000000, 9826.000000).
Cell_index # 2, contains a point: (5967.000000, 10573.000000).

Как я и ожидал с первый метод Я могу получить доступ ко всем исходным точкам index, Однако с второй способ это не вариант.

  • Зачем?
  • Почему некоторые показатели, например, 2 не уникальный?

Предпосылки моего вопроса: я хочу рассчитать для каждой вершины $ v_i $ расстояние $ d_i $ до ее исходной точки $ p_i $. Поэтому меня больше интересует зацикливание вершин (метод 2).

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector