Subversion Repositories gelsvn

Rev

Rev 667 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 667 Rev 677
Line 42... Line 42...
42
	Q.Resize(mani.no_vertices(), mani.no_vertices());
42
	Q.Resize(mani.no_vertices(), mani.no_vertices());
43
	
43
	
44
	for(VertexIDIterator v = mani.vertices_begin(); v != mani.vertices_end(); ++v)
44
	for(VertexIDIterator v = mani.vertices_begin(); v != mani.vertices_end(); ++v)
45
		if(!boundary(mani, *v)){
45
		if(!boundary(mani, *v)){
46
			int i = vtouched[*v];
46
			int i = vtouched[*v];
47
			double area_i = voronoi_area(mani, *v);
47
			double area_i = mixed_area(mani, *v);
48
			Vec3d vertex(mani.pos(*v));
48
			Vec3d vertex(mani.pos(*v));
49
			Vec3d curv_normal(0);
49
			Vec3d curv_normal(0);
50
			double a_sum = 0;
50
			double a_sum = 0;
51
            for(Walker wv = mani.walker(*v); !wv.full_circle(); wv = wv.circulate_vertex_cw())
51
            for(Walker wv = mani.walker(*v); !wv.full_circle(); wv = wv.circulate_vertex_cw())
52
			{
52
			{
53
				int j = vtouched[wv.vertex()];
53
				int j = vtouched[wv.vertex()];
54
				double area_j = voronoi_area(mani, wv.vertex());
54
				double area_j = mixed_area(mani, wv.vertex());
55
				
55
				
56
				Vec3d nbr(mani.pos(wv.vertex()));
56
				Vec3d nbr(mani.pos(wv.vertex()));
57
				Vec3d left(mani.pos(wv.next().vertex()));
57
				Vec3d left(mani.pos(wv.next().vertex()));
58
				Vec3d right(mani.pos(wv.opp().prev().opp().vertex()));
58
				Vec3d right(mani.pos(wv.opp().prev().opp().vertex()));
59
				
59
				
Line 73... Line 73...
73
			Q[i][i] = -a_sum;
73
			Q[i][i] = -a_sum;
74
		}
74
		}
75
	EigenSolutionsSym(Q,V);
75
	EigenSolutionsSym(Q,V);
76
}
76
}
77
 
77
 
-
 
78
vector<Vec3d> Harmonics::analyze_signal(const VertexAttributeVector<Vec3d>& sig) {
-
 
79
    vector<Vec3d> sig_proj(maximum_eigenvalue, Vec3d(0));
-
 
80
    
-
 
81
    for(int es=0; es<maximum_eigenvalue; ++es)
-
 
82
		for(VertexID v: mani.vertices())
-
 
83
			sig_proj[es] +=  sig[v] * Q[es][vtouched[v]];
-
 
84
    
-
 
85
    return sig_proj;
-
 
86
}
-
 
87
 
-
 
88
VertexAttributeVector<Vec3d> Harmonics::reconstruct_signal(const vector<Vec3d>& sig_proj, int max_es) {
-
 
89
    VertexAttributeVector<Vec3d> sig(mani.allocated_vertices(), Vec3d(0));
-
 
90
    for(int es=0; es<max_es; ++es)
-
 
91
        for(VertexID v: mani.vertices())
-
 
92
            sig[v] += sig_proj[es] * Q[es][vtouched[v]];
-
 
93
    return sig;
-
 
94
}
-
 
95
 
-
 
96
 
-
 
97
 
78
Harmonics::Harmonics(HMesh::Manifold& _mani):mani(_mani), vtouched(_mani.allocated_vertices(), 0)
98
Harmonics::Harmonics(HMesh::Manifold& _mani):mani(_mani), vtouched(_mani.allocated_vertices(), 0)
79
{
99
{
80
  
100
  
81
    int i = 0;
101
    int i = 0;
82
    for(VertexIDIterator v = mani.vertices_begin(); v != mani.vertices_end(); ++v, ++i)
102
    for(VertexIDIterator v = mani.vertices_begin(); v != mani.vertices_end(); ++v, ++i)
Line 120... Line 140...
120
	for(int es=E0;es<=E1;++es)
140
	for(int es=E0;es<=E1;++es)
121
		add_frequency(es, scale);
141
		add_frequency(es, scale);
122
}
142
}
123
 
143
 
124
 
144
 
125
double Harmonics::compute_adf(HMesh::VertexAttributeVector<double>& F, double t)
145
double Harmonics::compute_adf(HMesh::VertexAttributeVector<double>& F, double t, double fiedler_boost)
126
{
146
{
127
	double F_max = 0;
147
	double F_max = 0;
-
 
148
    for(VertexID vid : mani.vertices())
-
 
149
        F[vid]=0;
-
 
150
    
128
	for(VertexID vid : mani.vertices()){
151
	for(VertexID vid : mani.vertices()){
129
		for(int e = 1; e < V.Length(); ++e)
152
		for(int e = 1; e < V.Length(); ++e)
130
			F[vid] += sqr(Q[e][vtouched[vid]]) * exp(-t*V[e]/V[1]);
153
			F[vid] += sqr(Q[e][vtouched[vid]]) * exp(-t*V[e]/V[1]);
-
 
154
            if(fiedler_boost>0)
-
 
155
                for(int e = 1; e < V.Length(); ++e)
-
 
156
                    F[vid] += sqr(Q[e][vtouched[vid]]) * exp(-t) * fiedler_boost;
-
 
157
        
-
 
158
		F_max = max(F[vid], F_max);
-
 
159
	}
-
 
160
    return F_max;
-
 
161
}
-
 
162
 
-
 
163
double Harmonics::compute_esum(HMesh::VertexAttributeVector<double>& F, int e0, int e1)
-
 
164
{
-
 
165
	double F_max = 0;
-
 
166
    for(VertexID vid : mani.vertices())
-
 
167
        F[vid]=0;
-
 
168
    
-
 
169
	for(VertexID vid : mani.vertices()){
-
 
170
		for(int e = e0; e < e1; ++e)
-
 
171
			F[vid] += sqr(Q[e][vtouched[vid]]);
-
 
172
        
131
		F_max = max(F[vid], F_max);
173
		F_max = max(F[vid], F_max);
132
	}
174
	}
133
    return F_max;
175
    return F_max;
134
}
176
}