ça marche/compile pas parce que j'ai pas trouvé comment passer d'un halfedge au sommet de départ/arrivée et du halfedge au edge associé
This commit is contained in:
parent
06adb5e51e
commit
5e4252da7e
@ -1,6 +1,9 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
using namespace std;
|
||||
/* **** début de la partie à compléter **** */
|
||||
|
||||
void MainWindow::showSelections(MyMesh* _mesh)
|
||||
@ -112,6 +115,52 @@ void MainWindow::showPath(MyMesh* _mesh, int v1, int v2)
|
||||
displayMesh(_mesh);
|
||||
}
|
||||
|
||||
int minimal_new(vector<ulong> dist, set<int> visited) {
|
||||
long mini = LONG_MAX;
|
||||
int mini_id = -1;
|
||||
for (int i = 0; i < dist.size(); i++) {
|
||||
if (visited.count(i) == 0 && dist[i] < mini) {
|
||||
mini = dist[i];
|
||||
mini_id = i;
|
||||
}
|
||||
}
|
||||
return mini_id;
|
||||
}
|
||||
|
||||
vector<EdgeHandle> meinDijkstra(MyMesh *_mesh, int v1, int v2) {
|
||||
set<int> visited_nodes_id = {};
|
||||
const int nb = _mesh->n_faces();
|
||||
vector<ulong> dist_min (nb, ULONG_MAX);
|
||||
vector<int> prec_hv_id (nb, -1);
|
||||
dist_min[v1] = 0;
|
||||
int current;
|
||||
VertexHandle current_node;
|
||||
uint distance;
|
||||
while (visited_nodes_id.size() != nb) {
|
||||
current = minimal_new(dist_min, visited_nodes_id);
|
||||
visited_nodes_id.insert(current);
|
||||
if (current == v2) break;
|
||||
current_node = _mesh->vertex_handle(current);
|
||||
for (auto voh_it = _mesh->voh_iter(current_node); voh_it.is_valid(); ++voh_it) {
|
||||
distance = dist_min[current] + _mesh->valence(*voh_it);
|
||||
//following = *voh_it->outgoingvertex;
|
||||
if (distance < dist_min[following]) {
|
||||
dist_min[successeur] = distance;
|
||||
prec_hv_id[successeur] = *voh_it->idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
vector<EdgeHandle> path;
|
||||
if (prec_hv_id[v2] != -1) {
|
||||
current = v2;
|
||||
while (predecesseur[current] != -1) {
|
||||
path.push_back(predecesseur[current].edge);
|
||||
current = path.end()->incoming_node;
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/* **** fin de la partie à compléter **** */
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user