Subversion Repositories gelsvn

Rev

Rev 105 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 105 Rev 119
1
#include "CGLA/Mat4x4f.h"
1
#include "CGLA/Mat4x4f.h"
2
#include "Util/ArgExtracter.h"
2
#include "Util/ArgExtracter.h"
3
#include "Geometry/RGrid.h"
3
#include "Geometry/RGrid.h"
4
#include "Geometry/load_raw.h"
4
#include "Geometry/load_raw.h"
5
#include "Geometry/save_raw.h"
5
#include "Geometry/save_raw.h"
6
#include "HMeshUtil/obj_save.h"
6
#include "HMeshUtil/obj_save.h"
7
#include "HMeshUtil/x3d_save.h"
7
#include "HMeshUtil/x3d_save.h"
8
#include "HMeshUtil/caps_and_needles.h"
8
#include "HMeshUtil/caps_and_needles.h"
9
#include "HMeshUtil/fair_polygonize.h"
9
#include "HMeshUtil/fair_polygonize.h"
10
 
10
 
11
using namespace CGLA;
11
using namespace CGLA;
12
using namespace HMeshUtil;
12
using namespace HMeshUtil;
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
typedef RGrid<unsigned char> RGridb;
18
typedef RGrid<unsigned char> RGridb;
19
 
19
 
20
int main(int argc, char**argv)
20
int main(int argc, char**argv)
21
{
21
{
22
		ArgExtracter ae(argc, argv);
22
		ArgExtracter ae(argc, argv);
23
		float iso = 40;
23
		float iso = 40;
24
		ae.extract("-i", iso);
24
		ae.extract("-i", iso);
25
		int X  = 128;
25
		int X  = 128;
26
		ae.extract("-x", X);
26
		ae.extract("-x", X);
27
		int Y  = 128;
27
		int Y  = 128;
28
		ae.extract("-y", Y);
28
		ae.extract("-y", Y);
29
		int Z  = 62;
29
		int Z  = 62;
30
		ae.extract("-z", Z);
30
		ae.extract("-z", Z);
31
		string file;
31
		string file;
32
		if(ae.no_remaining_args()<2) 
32
		if(ae.no_remaining_args()<2) 
33
				file ="../../data/teddybear.raw";
33
				file ="../../data/teddybear.raw";
34
		else
34
		else
35
				file = ae.get_last_arg();
35
				file = ae.get_last_arg();
36
		
36
		
37
		RGridb grid(Vec3i(X,Y,Z));
37
		RGridb grid(Vec3i(X,Y,Z));
38
		cout << "loading " << file << endl;
38
		cout << "loading " << file << endl;
39
		load_raw(file,grid);
39
		load_raw(file,grid);
40
		
40
		
41
		
41
		
42
		cout << "Polygonizing, iso = " << iso << endl;
42
		cout << "Polygonizing, iso = " << iso << endl;
43
		Manifold mani;
43
		Manifold mani;
44
		fair_polygonize(grid, mani, iso);
44
		fair_polygonize(grid, mani, iso);
45
 
45
 
46
		cout << "Removing caps and needles ... " << endl;
46
		cout << "Removing caps and needles ... " << endl;
47
		remove_caps_from_trimesh(mani, M_PI * 0.85);
47
		remove_caps_from_trimesh(mani, M_PI * 0.85);
48
		remove_needles_from_trimesh(mani, 1e-2);
48
		remove_needles_from_trimesh(mani, 1e-2);
49
		
49
		
50
		cout << "Saving" << endl;
50
		cout << "Saving" << endl;
51
		obj_save("../../data/isosurf.obj", mani);
51
		obj_save("../../data/isosurf.obj", mani);
52
}
52
}
53
 
53