Subversion Repositories gelsvn

Rev

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

Rev 572 Rev 586
Line 19... Line 19...
19
    using namespace std;
19
    using namespace std;
20
    using namespace CGLA;
20
    using namespace CGLA;
21
	
21
	
22
    void flatten(Manifold& m, WeightScheme ws)
22
    void flatten(Manifold& m, WeightScheme ws)
23
    {
23
    {
24
        HalfEdgeAttributeVector<double> edge_weights(m.total_halfedges(), 0);
24
        HalfEdgeAttributeVector<double> edge_weights(m.allocated_halfedges(), 0);
25
		for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f)
25
		for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f)
26
		{
26
		{
27
			for(HalfEdgeWalker wv = m.halfedgewalker(*f); !wv.full_circle(); wv = wv.circulate_face_ccw())
27
			for(HalfEdgeWalker wv = m.halfedgewalker(*f); !wv.full_circle(); wv = wv.circulate_face_ccw())
28
			{
28
			{
29
				HalfEdgeID h = wv.halfedge();
29
				HalfEdgeID h = wv.halfedge();
Line 59... Line 59...
59
		
59
		
60
        for(VertexIDIterator v = m.vertices_begin(); v != m.vertices_end(); ++v)
60
        for(VertexIDIterator v = m.vertices_begin(); v != m.vertices_end(); ++v)
61
            ofs << "v " << m.pos(*v)[0] << " " << m.pos(*v)[1] << " " << m.pos(*v)[2] << endl;
61
            ofs << "v " << m.pos(*v)[0] << " " << m.pos(*v)[1] << " " << m.pos(*v)[2] << endl;
62
        ofs << endl;
62
        ofs << endl;
63
		
63
		
64
		VertexAttributeVector<double> touched(m.total_vertices(), 0);
64
		VertexAttributeVector<double> touched(m.allocated_vertices(), 0);
65
        VertexIDIterator v = m.vertices_begin();
65
        VertexIDIterator v = m.vertices_begin();
66
        for(; v != m.vertices_end(); ++v){
66
        for(; v != m.vertices_end(); ++v){
67
            if(boundary(m, *v))
67
            if(boundary(m, *v))
68
                break;
68
                break;
69
        }
69
        }
Line 88... Line 88...
88
		
88
		
89
        for(v = m.vertices_begin(); v != m.vertices_end(); ++v)
89
        for(v = m.vertices_begin(); v != m.vertices_end(); ++v)
90
            if(!boundary(m, *v))
90
            if(!boundary(m, *v))
91
                m.pos(*v) = Vec3f(0.0);
91
                m.pos(*v) = Vec3f(0.0);
92
		
92
		
93
        VertexAttributeVector<Vec3f> new_pos(m.active_vertices());
93
        VertexAttributeVector<Vec3f> new_pos(m.no_vertices());
94
        for(int i = 0; i < 10000; ++i){
94
        for(int i = 0; i < 10000; ++i){
95
            for(v = m.vertices_begin(); v != m.vertices_end(); ++v){
95
            for(v = m.vertices_begin(); v != m.vertices_end(); ++v){
96
				if(boundary(m, *v))
96
				if(boundary(m, *v))
97
				{
97
				{
98
					if(ws == LSCM_W && touched[*v] != 1)
98
					if(ws == LSCM_W && touched[*v] != 1)
Line 135... Line 135...
135
            }
135
            }
136
            for(v = m.vertices_begin(); v != m.vertices_end(); ++v)
136
            for(v = m.vertices_begin(); v != m.vertices_end(); ++v)
137
                m.pos(*v) = new_pos[*v];
137
                m.pos(*v) = new_pos[*v];
138
        }
138
        }
139
		
139
		
140
        VertexAttributeVector<int> vtouched(m.total_vertices(), 0);
140
        VertexAttributeVector<int> vtouched(m.allocated_vertices(), 0);
141
        i = 0;
141
        i = 0;
142
        for(v = m.vertices_begin(); v != m.vertices_end(); ++v, ++i){
142
        for(v = m.vertices_begin(); v != m.vertices_end(); ++v, ++i){
143
            ofs << "vt " << (0.5*m.pos(*v)[0]+0.5) << " " << (0.5*m.pos(*v)[1]+0.5)  << endl;
143
            ofs << "vt " << (0.5*m.pos(*v)[0]+0.5) << " " << (0.5*m.pos(*v)[1]+0.5)  << endl;
144
            vtouched[*v] = i;
144
            vtouched[*v] = i;
145
        }
145
        }