Subversion Repositories gelsvn

Rev

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

Rev 386 Rev 387
Line 34... Line 34...
34
#include <HMesh/FaceCirculator.h>
34
#include <HMesh/FaceCirculator.h>
35
#include <HMesh/build_manifold.h>
35
#include <HMesh/build_manifold.h>
36
#include <HMesh/mesh_optimization.h>
36
#include <HMesh/mesh_optimization.h>
37
#include <HMesh/triangulate.h>
37
#include <HMesh/triangulate.h>
38
#include <HMesh/load.h>
38
#include <HMesh/load.h>
-
 
39
#include <HMesh/quadric_simplify.h>
-
 
40
#include <HMesh/smooth.h>
39
#include <HMesh/x3d_save.h>
41
#include <HMesh/x3d_save.h>
-
 
42
#include <HMesh/mesh_optimization.h>
40
 
43
 
41
#include <GLConsole/GLConsole.h>
44
#include <GLConsole/GLConsole.h>
42
 
45
 
43
#include "harmonics.h"
46
#include "harmonics.h"
44
#include "wireframe.h"
47
#include "wireframe.h"
Line 84... Line 87...
84
	Manifold mani;	
87
	Manifold mani;	
85
	bool create_display_list = true;
88
	bool create_display_list = true;
86
}
89
}
87
 
90
 
88
 
91
 
-
 
92
char* console_minimize_curvature(std::vector<std::string> &args)
-
 
93
{
-
 
94
	bool anneal=false;
-
 
95
	if(args.size()>0)
-
 
96
	{
-
 
97
		istringstream a0(args[0]);
-
 
98
		a0 >> anneal;
-
 
99
	}
-
 
100
 
-
 
101
	minimize_curvature(mani, anneal);
-
 
102
	return "";
-
 
103
}
-
 
104
 
-
 
105
char* console_minimize_dihedral(std::vector<std::string> &args)
-
 
106
{
-
 
107
	int iter = 1000;
-
 
108
	if(args.size()>0)
-
 
109
	{
-
 
110
		istringstream a0(args[0]);
-
 
111
		a0 >> iter;
-
 
112
	}
-
 
113
 
-
 
114
	bool anneal = false;
-
 
115
	if(args.size()>1)
-
 
116
	{
-
 
117
		istringstream a0(args[0]);
-
 
118
		a0 >> anneal;
-
 
119
	}
-
 
120
 
-
 
121
	bool use_alpha = true;
-
 
122
	if(args.size()>22)
-
 
123
	{
-
 
124
		istringstream a0(args[0]);
-
 
125
		a0 >> use_alpha;
-
 
126
	}
-
 
127
 
-
 
128
	float gamma = 4.0;
-
 
129
	if(args.size()>3)
-
 
130
	{
-
 
131
		istringstream a0(args[0]);
-
 
132
		a0 >> gamma;
-
 
133
	}
-
 
134
	
-
 
135
	
-
 
136
	minimize_dihedral_angle(mani, iter, anneal, use_alpha, gamma);
-
 
137
	return "";
-
 
138
}
-
 
139
 
-
 
140
char* console_optimize_valency(std::vector<std::string> &args)
-
 
141
{
-
 
142
	bool anneal=false;
-
 
143
	if(args.size()>0)
-
 
144
	{
-
 
145
		istringstream a0(args[0]);
-
 
146
		a0 >> anneal;
-
 
147
	}
-
 
148
	optimize_valency(mani, anneal);
-
 
149
	return "";
-
 
150
}
89
 
151
 
90
char* console_partial_reconstruct(std::vector<std::string> &args)
152
char* console_partial_reconstruct(std::vector<std::string> &args)
91
{
153
{
92
	int E0,E1;
154
	int E0,E1;
93
	float scale;
155
	float scale;
Line 111... Line 173...
111
{
173
{
112
	view_ctrl->reshape(W,H);
174
	view_ctrl->reshape(W,H);
113
}
175
}
114
 
176
 
115
 
177
 
-
 
178
char* console_simplify(std::vector<std::string> &args)
-
 
179
{
-
 
180
	float keep_fraction;
-
 
181
	if(args.size()==0) return "you must specify fraction of vertices to keep";
-
 
182
	istringstream a0(args[0]);
-
 
183
	a0 >> keep_fraction;
-
 
184
 
-
 
185
	Vec3f p0, p7;
-
 
186
	mani.get_bbox(p0, p7);
-
 
187
	Vec3f d = p7-p0;
-
 
188
	float s = 1.0/d.max_coord();
-
 
189
	Vec3f pcentre = (p7+p0)/2.0;
-
 
190
	for(VertexIter vi = mani.vertices_begin(); vi != mani.vertices_end(); ++vi)
-
 
191
		vi->pos = (vi->pos - pcentre) * s;
-
 
192
	quadric_simplify(mani,keep_fraction,0.0001f,true);
-
 
193
	for(VertexIter vi = mani.vertices_begin(); vi != mani.vertices_end(); ++vi)
-
 
194
		vi->pos = vi->pos*d.max_coord() + pcentre;
-
 
195
	return "";
-
 
196
}
-
 
197
 
-
 
198
char* console_laplacian_smooth(std::vector<std::string> &args)
-
 
199
{
-
 
200
	float t=1.0;
-
 
201
	if(args.size()>0)
-
 
202
	{
-
 
203
		istringstream a0(args[0]);
-
 
204
		a0 >> t;
-
 
205
	}
-
 
206
	/// Simple laplacian smoothing with an optional weight.
-
 
207
	laplacian_smooth(mani, t);
-
 
208
	return "";
-
 
209
}
-
 
210
 
-
 
211
char* console_taubin_smooth(std::vector<std::string> &args)
-
 
212
{
-
 
213
	int iter=1;
-
 
214
	if(args.size()>0)
-
 
215
	{
-
 
216
		istringstream a0(args[0]);
-
 
217
		a0 >> iter;
-
 
218
	}
-
 
219
	
-
 
220
	/// Taubin smoothing is similar to laplacian smoothing but reduces shrinkage
-
 
221
	taubin_smooth(mani,  iter);
-
 
222
	return "";
-
 
223
}
-
 
224
 
-
 
225
char* console_fvm_smooth(std::vector<std::string> &args)
-
 
226
{	
-
 
227
	int iter=1;
-
 
228
	if(args.size()>0)
-
 
229
	{
-
 
230
		istringstream a0(args[0]);
-
 
231
		a0 >> iter;
-
 
232
	}
-
 
233
	/** Fuzzy vector median smoothing is effective when it comes to
-
 
234
	 preserving sharp edges. */
-
 
235
	fvm_smooth(mani,  iter);
-
 
236
	return "";
-
 
237
 
-
 
238
}
116
 
239
 
117
void display() 
240
void display() 
118
{
241
{
119
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
242
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
120
	
243
	
Line 292... Line 415...
292
	glEnable(GL_DEPTH_TEST);
415
	glEnable(GL_DEPTH_TEST);
293
	
416
	
294
	static CVar<ConsoleFunc> help( "help", ConsoleHelp );
417
	static CVar<ConsoleFunc> help( "help", ConsoleHelp );
295
	static CVar<ConsoleFunc> rs("reset_shape", console_reset_shape);
418
	static CVar<ConsoleFunc> rs("reset_shape", console_reset_shape);
296
	static CVar<ConsoleFunc> pr("partial_reconstruct", console_partial_reconstruct);
419
	static CVar<ConsoleFunc> pr("partial_reconstruct", console_partial_reconstruct);
-
 
420
	static CVar<ConsoleFunc> simpl("simplify", console_simplify);
-
 
421
	static CVar<ConsoleFunc> lsmooth("laplacian_smooth", console_laplacian_smooth);
-
 
422
	static CVar<ConsoleFunc> tsmooth("taubin_smooth", console_taubin_smooth);
-
 
423
	static CVar<ConsoleFunc> fsmooth("fvm_smooth", console_fvm_smooth);
297
 
424
 
-
 
425
	static CVar<ConsoleFunc> opt_val("optimize_valency", console_optimize_valency);
-
 
426
	static CVar<ConsoleFunc> min_dih("minimize_dihedral", console_minimize_dihedral);
-
 
427
	static CVar<ConsoleFunc> min_curv("minimize_curvature", console_minimize_curvature);
-
 
428
	
-
 
429
	
298
}
430
}
299
 
431
 
300
 
-
 
301
int main(int argc, char** argv)
432
int main(int argc, char** argv)
302
{
433
{
303
	ArgExtracter ae(argc, argv);
434
	ArgExtracter ae(argc, argv);
304
	ae.extract("-E", E);
435
	ae.extract("-E", E);
305
    if(argc>1)
436
    if(argc>1)