optimize 2-ring traversal
This commit is contained in:
parent
1d1f2c22f7
commit
1d88c993b9
@ -1,5 +1,6 @@
|
||||
#include "curvature.h"
|
||||
#include "util.h"
|
||||
#include <OpenMesh/Core/Utils/PropertyManager.hh>
|
||||
|
||||
|
||||
void Courbures::normales_locales() {
|
||||
@ -21,43 +22,36 @@ void Courbures::normales_locales() {
|
||||
}
|
||||
|
||||
|
||||
std::vector<MyMesh::VertexHandle> Courbures::get_two_neighborhood(const MyMesh::VertexHandle vh) {
|
||||
OpenMesh::VPropHandleT<bool> vprop_flag;
|
||||
_mesh.add_property(vprop_flag, "vprop_flag");
|
||||
void Courbures::get_two_neighborhood(std::vector<MyMesh::VertexHandle> &out,
|
||||
const MyMesh::VertexHandle vh) {
|
||||
auto flag_prop =
|
||||
OpenMesh::getOrMakeProperty<VertexHandle, bool>(_mesh, "vprop_flag");
|
||||
flag_prop.set_range(_mesh.vertices_begin(), _mesh.vertices_end(), false);
|
||||
|
||||
// Initialisation
|
||||
for (VertexHandle vh : _mesh.vertices()) {
|
||||
_mesh.property(vprop_flag, vh) = false;
|
||||
}
|
||||
// Circulateur sur le premier cercle
|
||||
std::vector<MyMesh::VertexHandle> neigh, neigh2;
|
||||
|
||||
_mesh.property(vprop_flag, vh) = true;
|
||||
// Parcours du 1-anneau
|
||||
flag_prop[vh] = true;
|
||||
for(VertexHandle vv : _mesh.vv_range(vh)) {
|
||||
neigh.push_back(vv); // ajout du point à la liste
|
||||
_mesh.property(vprop_flag, vv) = true;
|
||||
out.push_back(vv); // ajout du point à la liste
|
||||
flag_prop[vv] = true;
|
||||
}
|
||||
|
||||
// Parcours du premier cercle et ajout du second cercle par circulateurs
|
||||
for (size_t i = 0; i < neigh.size(); i++) {
|
||||
MyMesh::VertexHandle vh = neigh.at(i) ;
|
||||
for (VertexHandle vv : _mesh.vv_range(vh)) {
|
||||
if (!_mesh.property(vprop_flag, vv)) {
|
||||
neigh2.push_back(vv);
|
||||
}
|
||||
_mesh.property(vprop_flag, vv) = true;
|
||||
// Parcours du 1-anneau de chaque sommet du 1-anneau
|
||||
size_t old_size = out.size();
|
||||
for (size_t i = 0; i < old_size; i++) {
|
||||
for (VertexHandle vv : _mesh.vv_range(out[i])) {
|
||||
if (!flag_prop[vv]) {
|
||||
out.push_back(vv);
|
||||
flag_prop[vv] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Concaténation des deux cercles
|
||||
neigh.insert(neigh.end(), neigh2.begin(), neigh2.end());
|
||||
_mesh.remove_property(vprop_flag);
|
||||
return neigh;
|
||||
}
|
||||
|
||||
|
||||
QuadPatch Courbures::fit_quad(MyMesh::VertexHandle vh) {
|
||||
std::vector<MyMesh::VertexHandle> neigh = get_two_neighborhood(vh);
|
||||
static std::vector<MyMesh::VertexHandle> neigh;
|
||||
neigh.clear();
|
||||
get_two_neighborhood(neigh, vh);
|
||||
if (neigh.size() < 5) throw "Quad fitting: not enough neighbors";
|
||||
|
||||
// Calcul de la matrice de changement de base
|
||||
|
@ -18,7 +18,8 @@ public:
|
||||
|
||||
void set_fixed_colors();
|
||||
void normales_locales();
|
||||
std::vector<MyMesh::VertexHandle> get_two_neighborhood(MyMesh::VertexHandle vh);
|
||||
void get_two_neighborhood(std::vector<MyMesh::VertexHandle> &out,
|
||||
MyMesh::VertexHandle vh);
|
||||
QuadPatch fit_quad(MyMesh::VertexHandle vh);
|
||||
void compute_KH();
|
||||
void set_K_colors();
|
||||
|
Loading…
Reference in New Issue
Block a user