Subversion Repositories gelsvn

Rev

Rev 519 | Rev 572 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 519 Rev 536
Line 30... Line 30...
30
    FaceAttributeVector<int> ftouched(m.total_faces());
30
    FaceAttributeVector<int> ftouched(m.total_faces());
31
    for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f, ++i)
31
    for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f, ++i)
32
        ftouched[*f] = i;
32
        ftouched[*f] = i;
33
 
33
 
34
    vector<Vec3f> vertices;
34
    vector<Vec3f> vertices;
35
    vertices.reserve(m.active_faces());
35
    vertices.resize(m.active_faces());
36
    vector<int> faces;
36
    vector<int> faces;
37
    vector<int> indices;
37
    vector<int> indices;
38
 
38
 
39
    // Create new vertices. Each face becomes a vertex whose position
39
    // Create new vertices. Each face becomes a vertex whose position
40
    // is the centre of the face
40
    // is the centre of the face
-
 
41
    i = 0;
41
    for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f)
42
    for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f, ++i)
42
        vertices.push_back(centre(m, *f));
43
        vertices[i] = centre(m, *f);
43
 
44
 
44
    // Create new faces. Each vertex is a new face with N=valency of vertex
45
    // Create new faces. Each vertex is a new face with N=valency of vertex
45
    // edges.
46
    // edges.
46
    for(VertexIDIterator v = m.vertices_begin(); v!= m.vertices_end(); ++v){
47
    for(VertexIDIterator v = m.vertices_begin(); v!= m.vertices_end(); ++v){
47
        if(!boundary(m, *v)){
48
        if(boundary(m, *v))
-
 
49
            continue;
-
 
50
        
48
            HalfEdgeWalker w = m.halfedgewalker(*v);
51
        HalfEdgeWalker w = m.halfedgewalker(*v);
49
            vector<int> index_tmp;
52
        vector<int> index_tmp;
50
            for(; !w.full_circle(); w = w.circulate_vertex_cw())
53
        for(; !w.full_circle(); w = w.circulate_vertex_cw())
51
                index_tmp.push_back(ftouched[w.face()]);
54
            index_tmp.push_back(ftouched[w.face()]);
52
 
55
 
53
            // Push vertex indices for this face onto indices vector.
56
        // Push vertex indices for this face onto indices vector.
54
            // The circulator moves around the face in a clockwise fashion
57
        // The circulator moves around the face in a clockwise fashion
55
            // so we just reverse the ordering.
58
        // so we just reverse the ordering.
56
            indices.insert(indices.end(), index_tmp.rbegin(), index_tmp.rend());
59
        indices.insert(indices.end(), index_tmp.rbegin(), index_tmp.rend());
57
 
60
 
58
            // Insert face valency in the face vector.
61
        // Insert face valency in the face vector.
59
            faces.push_back(w.no_steps());
62
        faces.push_back(w.no_steps());
60
        }
63
        
61
    }
64
    }
62
 
65
 
63
    // Clear the manifold before new geometry is inserted.
66
    // Clear the manifold before new geometry is inserted.
64
    m.clear();
67
    m.clear();
65
 
68