~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to extern/eltopo/eltopo3d/meshmerger.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ---------------------------------------------------------
2
 
//
3
 
//  meshmerger.h
4
 
//  Tyson Brochu 2011
5
 
//  
6
 
//  Search for mesh edges which are near to each other, zipper their neighbouring triangles together.
7
 
//
8
 
// ---------------------------------------------------------
9
 
 
10
 
#ifndef EL_TOPO_MESHMERGER_H
11
 
#define EL_TOPO_MESHMERGER_H
12
 
 
13
 
// ---------------------------------------------------------
14
 
//  Nested includes
15
 
// ---------------------------------------------------------
16
 
 
17
 
#include <cstddef>
18
 
#include <vector>
19
 
 
20
 
// ---------------------------------------------------------
21
 
//  Forwards and typedefs
22
 
// ---------------------------------------------------------
23
 
 
24
 
class SurfTrack;
25
 
template<unsigned int N, class T> struct Vec;
26
 
typedef Vec<3,size_t> Vec3st;
27
 
 
28
 
// ---------------------------------------------------------
29
 
//  Class definitions
30
 
// ---------------------------------------------------------
31
 
 
32
 
// ---------------------------------------------------------
33
 
///
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.
36
 
///
37
 
// ---------------------------------------------------------
38
 
 
39
 
struct SortableEdgeEdgeProximity
40
 
{
41
 
    /// Constructor
42
 
    /// 
43
 
    SortableEdgeEdgeProximity( size_t a, size_t b, double d ) :
44
 
    edge_a( a ),
45
 
    edge_b( b ),
46
 
    distance( d )
47
 
    {}
48
 
    
49
 
    /// Edges indices
50
 
    ///
51
 
    size_t edge_a, edge_b;
52
 
    
53
 
    /// Distance between the two edges
54
 
    /// 
55
 
    double distance;
56
 
    
57
 
    /// Comparison operator for this class, compares edge-edge distance for each pair
58
 
    /// 
59
 
    bool operator<( const SortableEdgeEdgeProximity& other ) const
60
 
    {
61
 
        return distance < other.distance;
62
 
    }
63
 
    
64
 
};
65
 
 
66
 
// ---------------------------------------------------------
67
 
///
68
 
/// Mesh merger object.  Sweeps over all pairs of edges, attempting to merge the surface when nearby edges are found.
69
 
///
70
 
// ---------------------------------------------------------
71
 
 
72
 
class MeshMerger
73
 
{
74
 
    
75
 
public:
76
 
    
77
 
    /// Constructor
78
 
    /// 
79
 
    MeshMerger( SurfTrack& surf ) :
80
 
    m_surf( surf )
81
 
    {}
82
 
    
83
 
    /// Look for pairs of edges close to each other, attempting to merge when close edges are found.
84
 
    ///
85
 
    bool merge_pass();
86
 
    
87
 
    
88
 
private:
89
 
 
90
 
    /// The mesh this object operates on
91
 
    /// 
92
 
    SurfTrack& m_surf;
93
 
    
94
 
    /// Move vertices around so v[0] and v[4] are closest together
95
 
    ///
96
 
    void twist_vertices( size_t *zipper_vertices );
97
 
    
98
 
    /// Create a set of triangles to add to perform the zippering operation
99
 
    ///
100
 
    bool get_zipper_triangles( size_t edge_index_0, size_t edge_index_1, std::vector<Vec3st>& output_triangles );
101
 
    
102
 
    /// Check whether the introduction of the new zippering triangles causes a collision 
103
 
    ///
104
 
    bool zippering_introduces_collision( const std::vector<Vec3st>& new_triangles, const std::vector<size_t>& deleted_triangles );
105
 
    
106
 
    /// Attempt to merge between two edges
107
 
    ///    
108
 
    bool zipper_edges( size_t edge_index_a, size_t edge_index_b );
109
 
    
110
 
};
111
 
 
112
 
 
113
 
#endif