Subversion Repositories gelsvn

Rev

Rev 630 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 630 Rev 643
Line 17... Line 17...
17
    using namespace std;
17
    using namespace std;
18
    using namespace CGLA;
18
    using namespace CGLA;
19
    
19
    
20
    void dual(Manifold& m)
20
    void dual(Manifold& m)
21
    {
21
    {
-
 
22
        // Create new vertices. Each face becomes a vertex whose position
22
        // make sure every face knows its number
23
        // is the centre of the face
23
        int i = 0;
24
        int i = 0;
24
        
-
 
25
        FaceAttributeVector<int> ftouched;
25
        FaceAttributeVector<int> ftouched;
26
        for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f, ++i)
-
 
27
            ftouched[*f] = i;
-
 
28
        
-
 
29
        vector<Vec3d> vertices;
26
        vector<Vec3d> vertices;
30
        vertices.resize(m.no_faces());
27
        vertices.resize(m.no_faces());
31
        vector<int> faces;
28
        for(auto f : m.faces())
32
        vector<int> indices;
-
 
33
        
-
 
34
        // Create new vertices. Each face becomes a vertex whose position
-
 
35
        // is the centre of the face
-
 
36
        i = 0;
-
 
37
        for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f, ++i)
-
 
38
            vertices[i] = centre(m, *f);
29
            vertices[ftouched[f] = i++] = centre(m, f);
39
            
30
        
40
            // Create new faces. Each vertex is a new face with N=valency of vertex
31
        // Create new faces. Each vertex is a new face with N=valency of vertex
41
            // edges.
32
        // edges.
42
            for(VertexIDIterator v = m.vertices_begin(); v!= m.vertices_end(); ++v){
-
 
43
                if(boundary(m, *v))
33
        vector<int> faces;
44
                    continue;
34
        vector<int> indices;
45
                
35
        for(auto v : m.vertices())
46
                Walker w = m.walker(*v);
36
            if(valency(m, v) > 2 && !(boundary(m, v)))
47
                vector<int> index_tmp;
37
            {
48
                for(; !w.full_circle(); w = w.circulate_vertex_ccw())
38
                int N =circulate_vertex_ccw(m, v, [&](FaceID fid) {
49
                    indices.push_back(ftouched[w.face()]);
39
                    indices.push_back(ftouched[fid]);
50
                
40
                });
51
                // Insert face valency in the face vector.
41
                // Insert face valency in the face vector.
52
                faces.push_back(w.no_steps());
42
                faces.push_back(N);
53
                
-
 
54
            }
43
            }
55
            
44
        
56
            // Clear the manifold before new geometry is inserted.
45
        // Clear the manifold before new geometry is inserted.
57
            m.clear();
46
        m.clear();
58
            
47