1
// ---------------------------------------------------------
6
// Search for mesh edges which are near to each other, zipper their neighbouring triangles together.
8
// ---------------------------------------------------------
10
#ifndef EL_TOPO_MESHMERGER_H
11
#define EL_TOPO_MESHMERGER_H
13
// ---------------------------------------------------------
15
// ---------------------------------------------------------
20
// ---------------------------------------------------------
21
// Forwards and typedefs
22
// ---------------------------------------------------------
25
template<unsigned int N, class T> struct Vec;
26
typedef Vec<3,size_t> Vec3st;
28
// ---------------------------------------------------------
30
// ---------------------------------------------------------
32
// ---------------------------------------------------------
34
/// Pair of proximal edges, sortable by distance. Used to build a list of edge pairs in ascending order of proximity, so we can
35
/// handle them from nearest to farthest.
37
// ---------------------------------------------------------
39
struct SortableEdgeEdgeProximity
43
SortableEdgeEdgeProximity( size_t a, size_t b, double d ) :
51
size_t edge_a, edge_b;
53
/// Distance between the two edges
57
/// Comparison operator for this class, compares edge-edge distance for each pair
59
bool operator<( const SortableEdgeEdgeProximity& other ) const
61
return distance < other.distance;
66
// ---------------------------------------------------------
68
/// Mesh merger object. Sweeps over all pairs of edges, attempting to merge the surface when nearby edges are found.
70
// ---------------------------------------------------------
79
MeshMerger( SurfTrack& surf ) :
83
/// Look for pairs of edges close to each other, attempting to merge when close edges are found.
90
/// The mesh this object operates on
94
/// Move vertices around so v[0] and v[4] are closest together
96
void twist_vertices( size_t *zipper_vertices );
98
/// Create a set of triangles to add to perform the zippering operation
100
bool get_zipper_triangles( size_t edge_index_0, size_t edge_index_1, std::vector<Vec3st>& output_triangles );
102
/// Check whether the introduction of the new zippering triangles causes a collision
104
bool zippering_introduces_collision( const std::vector<Vec3st>& new_triangles, const std::vector<size_t>& deleted_triangles );
106
/// Attempt to merge between two edges
108
bool zipper_edges( size_t edge_index_a, size_t edge_index_b );