add MeshReconstruction dep and some test meshes
This commit is contained in:
58
src/hole_filling.cpp
Normal file
58
src/hole_filling.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include "hole_filling.h"
|
||||
#include "util.h"
|
||||
#include <MeshReconstruction.h>
|
||||
|
||||
|
||||
static std::vector<std::vector<HalfedgeHandle>> findHoles(MyMesh &mesh) {
|
||||
std::vector<std::vector<HalfedgeHandle>> holes;
|
||||
std::set<HalfedgeHandle> ignore;
|
||||
for (HalfedgeHandle it : mesh.halfedges()) {
|
||||
if (mesh.is_boundary(it)
|
||||
&& ignore.find(it) == ignore.end()) {
|
||||
holes.emplace_back();
|
||||
holes.back().push_back(it);
|
||||
ignore.insert(it);
|
||||
for (HalfedgeHandle it2 : HalfedgeLoopRange<MyMesh>(mesh, it)) {
|
||||
holes.back().push_back(it2);
|
||||
ignore.insert(it2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return holes;
|
||||
}
|
||||
|
||||
|
||||
void fillHoleDumb(MyMesh &mesh, std::vector<HalfedgeHandle> &hole) {
|
||||
mesh.request_vertex_status();
|
||||
mesh.request_edge_status();
|
||||
mesh.request_face_status();
|
||||
|
||||
Point center(0, 0, 0);
|
||||
size_t length = 0;
|
||||
for (HalfedgeHandle it : hole) {
|
||||
VertexHandle vert = mesh.to_vertex_handle(it);
|
||||
center += mesh.point(vert);
|
||||
length++;
|
||||
}
|
||||
center /= length;
|
||||
VertexHandle center_handle = mesh.new_vertex_dirty(center);
|
||||
mesh.set_color(center_handle, mesh.default_color);
|
||||
|
||||
for (HalfedgeHandle it : hole) {
|
||||
mesh.add_face(mesh.from_vertex_handle(it),
|
||||
mesh.to_vertex_handle(it),
|
||||
center_handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fillHolesDumb(MyMesh &mesh) {
|
||||
mesh.holes = findHoles(mesh);
|
||||
for (auto hole : mesh.holes) {
|
||||
fillHoleDumb(mesh, hole);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fillHolesImplicit(MyMesh &mesh) {
|
||||
}
|
13
src/hole_filling.h
Normal file
13
src/hole_filling.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef HOLE_FILLING_H
|
||||
#define HOLE_FILLING_H
|
||||
|
||||
#include "my_mesh.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
void fillHoleDumb(MyMesh &mesh, std::vector<HalfedgeHandle> &hole);
|
||||
void fillHolesDumb(MyMesh &mesh);
|
||||
void fillHolesImplicit(MyMesh &mesh);
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user