Subversion Repositories gelsvn

Rev

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

Rev 440 Rev 595
Line 1... Line -...
1
/*
-
 
-
 
1
/* ----------------------------------------------------------------------- *
2
 *  load.cpp
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
3
 *  GEL
-
 
4
 *
-
 
5
 *  Created by J. Andreas Bærentzen on 08/03/09.
3
 * Copyright (C) the authors and DTU Informatics
6
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
4
 * For license and list of authors, see ../../doc/intro.pdf
7
 *
-
 
8
 */
-
 
-
 
5
 * ----------------------------------------------------------------------- */
9
 
6
 
10
#include "load.h"
7
#include "load.h"
11
#include "obj_load.h"
8
#include "obj_load.h"
12
#include "ply_load.h"
9
#include "ply_load.h"
13
#include "HMesh/x3d_load.h"
-
 
14
#include "HMesh/FaceCirculator.h"
-
 
15
#include "CGLA/Vec3i.h"
10
#include "CGLA/Vec3i.h"
16
 
11
 
17
using namespace std;
12
using namespace std;
18
using namespace CGLA;
13
using namespace CGLA;
19
using namespace HMesh;
14
//using namespace HMesh;
20
 
15
 
21
namespace Geometry
16
namespace Geometry
22
{
17
{
23
	
18
	
24
	void load(const string& fn, TriMesh &mesh)
19
	void load(const string& fn, TriMesh &mesh)
Line 29... Line 24...
29
		}
24
		}
30
		else if(fn.substr(fn.length()-4,fn.length())==".ply")
25
		else if(fn.substr(fn.length()-4,fn.length())==".ply")
31
		{
26
		{
32
			ply_load(fn, mesh);
27
			ply_load(fn, mesh);
33
		}	
28
		}	
34
		else if(fn.substr(fn.length()-4,fn.length())==".x3d")
-
 
35
		{
-
 
36
			Manifold m;
-
 
37
			x3d_load(fn, m);
-
 
38
			
-
 
39
			for(VertexIter v=m.vertices_begin(); v != m.vertices_end();++v)
-
 
40
				v->touched = mesh.geometry.add_vertex(v->pos);
-
 
41
			
-
 
42
			for(FaceIter f = m.faces_begin(); f!= m.faces_end(); ++f)
-
 
43
			{
-
 
44
				Vec3i face;
-
 
45
				int i=0;
-
 
46
				for(FaceCirculator fc(f); !fc.end(); ++fc,++i)
-
 
47
				{
-
 
48
					if(i<2)
-
 
49
						face[i] = fc.get_vertex()->touched;
-
 
50
					else
-
 
51
					{
-
 
52
						face[2] = fc.get_vertex()->touched;
-
 
53
						mesh.geometry.add_face(face);
-
 
54
						face[1] = face[2];
-
 
55
					}
-
 
56
				}	
-
 
57
			}
-
 
58
		}
-
 
59
		else
29
		else
60
		{
30
		{
61
			cout << "Either the format was unrecognized or the file did not have the appropriate extension" << endl;
31
			cout << "Either the format was unrecognized or the file did not have the appropriate extension" << endl;
62
			exit(0);
32
			exit(0);
63
		}
33
		}