Subversion Repositories gelsvn

Rev

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

Rev 205 Rev 216
Line 13... Line 13...
13
using namespace Util;
13
using namespace Util;
14
using namespace HMesh;
14
using namespace HMesh;
15
using namespace std;
15
using namespace std;
16
using namespace Geometry;
16
using namespace Geometry;
17
 
17
 
-
 
18
bool cuberille;
-
 
19
float iso = 40; 
-
 
20
string file;
-
 
21
string ofile;
-
 
22
 
-
 
23
template<class T>
18
typedef RGrid<unsigned char> RGridb;
24
void do_everything(RGrid<T> grid)
-
 
25
{
-
 
26
 		cout << "loading <" << file << ">" << endl;
-
 
27
 		load_raw(file,grid);
-
 
28
		
-
 
29
		cout << "Polygonizing, iso = " << iso << endl;
-
 
30
		Manifold mani;
-
 
31
 
-
 
32
		if(cuberille)
-
 
33
				cuberille_polygonize(grid, mani, iso, true);
-
 
34
		else
-
 
35
				mc_polygonize(grid, mani, iso);
-
 
36
 
-
 
37
		cout << "Triangulating" << endl;
-
 
38
		shortest_edge_triangulate(mani);
-
 
39
 
-
 
40
		cout << "Saving" << endl;
-
 
41
		obj_save(ofile, mani);
-
 
42
}
19
 
43
 
20
int main(int argc, char**argv)
44
int main(int argc, char**argv)
21
{
45
{
22
	
-
 
23
		ArgExtracter ae(argc, argv);
46
		ArgExtracter ae(argc, argv);
-
 
47
 
-
 
48
		if(ae.no_remaining_args() == 1 || ae.extract("-h"))
-
 
49
		{
-
 
50
				cout << "Usage: volpoly [-C] [-i <iso>] [-x <X>] [-y <Y>] [-z <Z>] " 
-
 
51
						 << "[-S|-f|-U|-b] raw-volume-file" << endl;
-
 
52
				cout << "where -C implies that the cuberille method rather than\n"
-
 
53
						 << "marching cubes should be used. -S -f -U -b indicate that\n"
-
 
54
						 << "the volume is in short, float, unsigned short or unsigned\n"
-
 
55
						 << "byte format" << endl;
24
		float iso = 40;
56
				exit(0);
-
 
57
		}
-
 
58
 
-
 
59
		cuberille = ae.extract("-c");
25
		ae.extract("-i", iso);
60
		ae.extract("-i", iso);
26
		int X  = 128;
61
		int X  = 128;
27
		ae.extract("-x", X);
62
		ae.extract("-x", X);
28
		int Y  = 128;
63
		int Y  = 128;
29
		ae.extract("-y", Y);
64
		ae.extract("-y", Y);
30
		int Z  = 62;
65
		int Z  = 62;
31
		ae.extract("-z", Z);
66
		ae.extract("-z", Z);
32
		
67
		
33
		string ofile = "../../data/isosurf.x3d";
68
		ofile = "isosurf.x3d";
34
		ae.extract("-o", ofile);
69
		ae.extract("-o", ofile);
-
 
70
		file = ae.get_last_arg();
35
 
71
 
36
		string file;
-
 
37
		if(ae.no_remaining_args()<2) 
72
		if(ae.extract("-S"))
38
				file ="../../data/teddybear.raw";
-
 
39
		else
73
		{
40
				file = ae.get_last_arg();
74
				cout << "Data type = short" << endl;
41
 
-
 
42
		//RGrid<unsigned short> grid(Vec3i(X,Y,Z));
75
				RGrid<short> grid(Vec3i(X,Y,Z));
43
		RGridb grid(Vec3i(X,Y,Z));
76
				do_everything(grid);
44
 
77
		}
45
//		RGridb grid(Vec3i(32));
78
		else if(ae.extract("-f"))
46
// 		srand(0);
79
		{
47
// 		for(int i=0;i<32;++i)
80
				cout << "Data type = float" << endl;
48
// 			for(int j=0;j<32;++j)
81
				RGrid<float> grid(Vec3i(X,Y,Z));
49
// 				for(int k=0;k<32;++k)		
82
				do_everything(grid);
50
// 					grid[Vec3i(i,j,k)] = 80.0 * rand()/double(RAND_MAX);
-
 
51
 
83
		}
52
 		cout << "loading " << file << endl;
-
 
53
 		load_raw(file,grid);
84
		else if(ae.extract("-U"))
54
		
85
		{
55
		cout << "Polygonizing, iso = " << iso << endl;
86
				cout << "Data type = unsigned short" << endl;
56
		Manifold mani;
-
 
57
		//cuberille_polygonize(grid, mani, iso, false);
87
				RGrid<unsigned short> grid(Vec3i(X,Y,Z));
58
		mc_polygonize(grid, mani, iso);
88
				do_everything(grid);
59
		
89
		}
60
				//shortest_edge_triangulate(mani);
90
		else 
61
 
91
		{
62
		cout << "Saving" << endl;
92
				cout << "Data type = unsigned char" << endl;
-
 
93
				RGrid<unsigned char> grid(Vec3i(X,Y,Z));
63
		x3d_save(ofile, mani);
94
				do_everything(grid);
-
 
95
		}
64
}
96
}