-
Notifications
You must be signed in to change notification settings - Fork 13
/
meshfix.h
66 lines (59 loc) · 1.48 KB
/
meshfix.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef MESHFIX_H
#define MESHFIX_H
#include <exttrimesh.h>
// Run the meshfix program to clean a given mesh
//
// Inputs:
// epsilon_angle used to change default of JMesh::acos_tolerance (0.0 -->
// use default value)
// keep_all_components whether to keep all components of input
// tin input messy mesh (changed in place)
// Outputs:
// tin see output
// Returns true on success
bool meshfix(
const double epsilon_angle,
const bool keep_all_components,
ExtTriMesh & tin);
#ifdef MESHFIX_WITH_EIGEN
#include <Eigen/Core>
// Run meshfix on (V,F) producing (W,G)
//
// Inputs:
// V #V by 3 vertex positions
// F #F by 3 face indices into V
// Outputs:
// W #W by 3 vertex positions
// G #G by 3 face indices into W
// Returns true on success
inline bool meshfix(
const Eigen::MatrixXd & V,
const Eigen::MatrixXi & F,
Eigen::MatrixXd & W,
Eigen::MatrixXi & G);
// Implementation
#include "mesh_to_ext_tri_mesh.h"
#include "ext_tri_mesh_to_mesh.h"
inline bool meshfix(
const Eigen::MatrixXd & V,
const Eigen::MatrixXi & F,
Eigen::MatrixXd & W,
Eigen::MatrixXi & G)
{
ExtTriMesh tin;
mesh_to_ext_tri_mesh(V,F,tin);
// These **must** be called after loading, before calling `meshfix`
tin.removeVertices();
tin.cutAndStitch();
tin.forceNormalConsistence();
tin.duplicateNonManifoldVertices();
tin.removeDuplicatedTriangles();
if(!meshfix(0,false,tin))
{
return false;
}
ext_tri_mesh_to_mesh(tin,W,G);
return true;
}
#endif
#endif