Subversion Repositories gelsvn

Rev

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

Rev 630 Rev 631
Line 119... Line 119...
119
 
119
 
120
int main(int argc, char** argv)
120
int main(int argc, char** argv)
121
{	
121
{	
122
	// LOAD OBJ
122
	// LOAD OBJ
123
    Manifold m;
123
    Manifold m;
-
 
124
    string fn;
124
    if(argc>1)
125
    if(argc>1)
125
	{
126
	{
126
		ArgExtracter ae(argc, argv);
127
		ArgExtracter ae(argc, argv);
127
		
128
		
128
		do_aabb = ae.extract("-A");
129
		do_aabb = ae.extract("-A");
Line 130... Line 131...
130
		ae.extract("-x", vol_dim[0]);
131
		ae.extract("-x", vol_dim[0]);
131
		ae.extract("-y", vol_dim[1]);
132
		ae.extract("-y", vol_dim[1]);
132
		ae.extract("-z", vol_dim[2]);
133
		ae.extract("-z", vol_dim[2]);
133
		do_ray_tests = ae.extract("-R");
134
		do_ray_tests = ae.extract("-R");
134
		flip_normals = ae.extract("-f");
135
		flip_normals = ae.extract("-f");
135
		string file = ae.get_last_arg();
136
		fn = ae.get_last_arg();
136
        
137
    }
137
        cout << "loading " << file << "... " << flush; 
-
 
138
		load(file, m);
138
    load(fn, m);
139
        cout << " done" << endl;
-
 
140
	}
-
 
141
    else
139
    
142
	{
-
 
143
		string fn("../../data/bunny-little.x3d");
140
    string file_prefix = fn.substr(0, fn.length()-4) + "-";
144
		x3d_load(fn, m);
-
 
145
	}
-
 
146
	cout << "Volume dimensions " << vol_dim << endl;
141
	cout << "Volume dimensions " << vol_dim << endl;
147
	if(!valid(m))
142
	if(!valid(m))
148
	{
143
	{
149
		cout << "Not a valid manifold" << endl;
144
		cout << "Not a valid manifold" << endl;
150
		exit(0);
145
		exit(0);
Line 182... Line 177...
182
		DistCompCache<OBBTree> dist(&obb_tree);
177
		DistCompCache<OBBTree> dist(&obb_tree);
183
		for_each_voxel(grid, dist);
178
		for_each_voxel(grid, dist);
184
		T_dist_obb = tim.get_secs();
179
		T_dist_obb = tim.get_secs();
185
		
180
		
186
		cout << "Saving distance field" << endl;
181
		cout << "Saving distance field" << endl;
187
		save_raw_float("obb_dist.raw", grid);
182
		save_raw_float(file_prefix+"obb_dist.raw", grid);
188
		
183
		
189
		if(do_ray_tests)
184
		if(do_ray_tests)
190
		{
185
		{
191
			cout << "Ray tests on OBB Tree" << endl;
186
			cout << "Ray tests on OBB Tree" << endl;
192
			tim.start();
187
			tim.start();
193
			RayCast<OBBTree> ray(&obb_tree);
188
			RayCast<OBBTree> ray(&obb_tree);
194
			for_each_voxel(grid, ray);
189
			for_each_voxel(grid, ray);
195
			T_ray_obb = tim.get_secs();
190
			T_ray_obb = tim.get_secs();
196
			
191
			
197
			cout << "Saving ray volume" << endl;
192
			cout << "Saving ray volume" << endl;
198
			save_raw_float("obb_ray.raw", grid);
193
			save_raw_float(file_prefix+"obb_ray.raw", grid);
199
		}
194
		}
200
	}
195
	}
201
	
196
	
202
	if(do_aabb)
197
	if(do_aabb)
203
	{
198
	{
Line 212... Line 207...
212
		DistCompCache<AABBTree> dist(&aabb_tree);
207
		DistCompCache<AABBTree> dist(&aabb_tree);
213
		for_each_voxel(grid, dist);
208
		for_each_voxel(grid, dist);
214
		T_dist_aabb = tim.get_secs();
209
		T_dist_aabb = tim.get_secs();
215
		
210
		
216
		cout << "Saving distance field" << endl;
211
		cout << "Saving distance field" << endl;
217
		save_raw_float("aabb_dist.raw", grid);
212
		save_raw_float(file_prefix+"aabb_dist.raw", grid);
218
		
213
		
219
		if(do_ray_tests)
214
		if(do_ray_tests)
220
		{
215
		{
221
			cout << "Ray tests on AABB tree" << endl;
216
			cout << "Ray tests on AABB tree" << endl;
222
			tim.start();
217
			tim.start();
223
			RayCast<AABBTree> ray(&aabb_tree);
218
			RayCast<AABBTree> ray(&aabb_tree);
224
			for_each_voxel(grid, ray);
219
			for_each_voxel(grid, ray);
225
			T_ray_aabb = tim.get_secs();
220
			T_ray_aabb = tim.get_secs();
226
			
221
			
227
			cout << "Saving ray volume" << endl;
222
			cout << "Saving ray volume" << endl;
228
			save_raw_float("aabb_ray.raw", grid);
223
			save_raw_float(file_prefix+"aabb_ray.raw", grid);
229
		}
224
		}
230
	}
225
	}
231
	cout.width(10);
226
	cout.width(10);
232
	cout << "Poly";
227
	cout << "Poly";
233
	cout.width(11);
228
	cout.width(11);