Subversion Repositories gelsvn

Rev

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

Rev 341 Rev 382
Line 12... Line 12...
12
#include "Geometry/build_bbtree.h"
12
#include "Geometry/build_bbtree.h"
13
#include "Geometry/AABox.h"
13
#include "Geometry/AABox.h"
14
 
14
 
15
#include "HMesh/triangulate.h"
15
#include "HMesh/triangulate.h"
16
 
16
 
17
#include "HMesh/obj_load.h"
17
#include "HMesh/load.h"
18
#include "HMesh/x3d_load.h"
18
#include "HMesh/x3d_load.h"
19
#include "HMesh/x3d_save.h"
19
#include "HMesh/x3d_save.h"
20
 
20
 
21
using namespace std;
21
using namespace std;
22
using namespace HMesh;
22
using namespace HMesh;
Line 125... Line 125...
125
    if(argc>1)
125
    if(argc>1)
126
	{
126
	{
127
		ArgExtracter ae(argc, argv);
127
		ArgExtracter ae(argc, argv);
128
		
128
		
129
		do_aabb = ae.extract("-A");
129
		do_aabb = ae.extract("-A");
-
 
130
		do_obb = ae.extract("-O");
-
 
131
		ae.extract("-X", vol_dim[0]);
-
 
132
		ae.extract("-Y", vol_dim[1]);
-
 
133
		ae.extract("-Z", vol_dim[2]);
130
		do_ray_tests = ae.extract("-R");
134
		do_ray_tests = ae.extract("-R");
131
		flip_normals = ae.extract("-f");
135
		flip_normals = ae.extract("-f");
132
		string file = ae.get_last_arg();
136
		string file = ae.get_last_arg();
133
		if(file.substr(file.length()-4,file.length())==".obj")
-
 
134
		{
-
 
135
			obj_load(file, m);
137
		load(file, m);
136
		}
-
 
137
		else
-
 
138
			x3d_load(file, m);
-
 
139
	}
138
	}
140
    else
139
    else
141
	{
140
	{
142
		string fn("../../data/bunny-little.x3d");
141
		string fn("../../data/bunny-little.x3d");
143
		x3d_load(fn, m);
142
		x3d_load(fn, m);
Line 166... Line 165...
166
	float T_build_obb=0, T_build_aabb=0, T_dist_obb=0, 
165
	float T_build_obb=0, T_build_aabb=0, T_dist_obb=0, 
167
		T_dist_aabb=0, T_ray_obb=0, T_ray_aabb=0;
166
		T_dist_aabb=0, T_ray_obb=0, T_ray_aabb=0;
168
	
167
	
169
	if(do_obb)
168
	if(do_obb)
170
	{
169
	{
-
 
170
		cout << "Building OBB Tree" << endl;
171
		tim.start();
171
		tim.start();
172
		OBBTree obb_tree;
172
		OBBTree obb_tree;
173
		build_OBBTree(m, obb_tree);
173
		build_OBBTree(m, obb_tree);
174
		T_build_obb = tim.get_secs();
174
		T_build_obb = tim.get_secs();
175
		
175
		
-
 
176
		cout << "Computing distances from OBB Tree" << endl;
176
		tim.start();
177
		tim.start();
177
		DistCompCache<OBBTree> dist(&obb_tree);
178
		DistCompCache<OBBTree> dist(&obb_tree);
178
		for_each_voxel(grid, dist);
179
		for_each_voxel(grid, dist);
179
		T_dist_obb = tim.get_secs();
180
		T_dist_obb = tim.get_secs();
180
		
181
		
-
 
182
		cout << "Saving distance field" << endl;
181
		save_raw_float("obb_dist.raw", grid);
183
		save_raw_float("obb_dist.raw", grid);
182
		
184
		
183
		if(do_ray_tests)
185
		if(do_ray_tests)
184
		{
186
		{
-
 
187
			cout << "Ray tests on OBB Tree" << endl;
185
			tim.start();
188
			tim.start();
186
			RayCast<OBBTree> ray(&obb_tree);
189
			RayCast<OBBTree> ray(&obb_tree);
187
			for_each_voxel(grid, ray);
190
			for_each_voxel(grid, ray);
188
			T_ray_obb = tim.get_secs();
191
			T_ray_obb = tim.get_secs();
189
			
192
			
-
 
193
			cout << "Saving ray volume" << endl;
190
			save_raw_float("obb_ray.raw", grid);
194
			save_raw_float("obb_ray.raw", grid);
191
		}
195
		}
192
	}
196
	}
193
	
197
	
194
	if(do_aabb)
198
	if(do_aabb)
195
	{
199
	{
-
 
200
		cout << "Building AABB Tree" << endl;
196
		tim.start();
201
		tim.start();
197
		AABBTree aabb_tree;
202
		AABBTree aabb_tree;
198
		build_AABBTree(m, aabb_tree);
203
		build_AABBTree(m, aabb_tree);
199
		T_build_aabb = tim.get_secs();
204
		T_build_aabb = tim.get_secs();
200
		
205
		
-
 
206
		cout << "Computing distances from AABB Tree" << endl;
201
		tim.start();
207
		tim.start();
202
		DistCompCache<AABBTree> dist(&aabb_tree);
208
		DistCompCache<AABBTree> dist(&aabb_tree);
203
		for_each_voxel(grid, dist);
209
		for_each_voxel(grid, dist);
204
		T_dist_aabb = tim.get_secs();
210
		T_dist_aabb = tim.get_secs();
205
		
211
		
-
 
212
		cout << "Saving distance field" << endl;
206
		save_raw_float("aabb_dist.raw", grid);
213
		save_raw_float("aabb_dist.raw", grid);
207
		
214
		
208
		if(do_ray_tests)
215
		if(do_ray_tests)
209
		{
216
		{
-
 
217
			cout << "Ray tests on AABB tree" << endl;
210
			tim.start();
218
			tim.start();
211
			RayCast<AABBTree> ray(&aabb_tree);
219
			RayCast<AABBTree> ray(&aabb_tree);
212
			for_each_voxel(grid, ray);
220
			for_each_voxel(grid, ray);
213
			T_ray_aabb = tim.get_secs();
221
			T_ray_aabb = tim.get_secs();
214
			
222
			
-
 
223
			cout << "Saving ray volume" << endl;
215
			save_raw_float("aabb_ray.raw", grid);
224
			save_raw_float("aabb_ray.raw", grid);
216
		}
225
		}
217
	}
226
	}
218
	cout.width(10);
227
	cout.width(10);
219
	cout << "Poly";
228
	cout << "Poly";