Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
433 jab 1
/*
2
 *  off_load.cpp
3
 *  GEL
4
 *
5
 *  Created by J. Andreas Bærentzen on 16/02/09.
6
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
7
 *
8
 */
9
#include <fstream>
10
#include "off_load.h"
11
#include "HMesh/Manifold.h"
12
#include "build_manifold.h"
13
 
14
 
15
using namespace std;
16
using namespace CGLA;
17
using namespace HMesh;
18
using namespace Geometry;
19
 
20
namespace HMesh
21
{
22
	bool off_load(const std::string& filename, HMesh::Manifold& m)
23
	{
24
		ifstream ifs(filename.c_str());
25
		string str;
26
		if(ifs.good())
27
			ifs >> str;
28
		if(str != "OFF") 
29
			return false;
30
 
31
		int NF, NV, NE;
32
 
33
		ifs >> NV >> NF >> NE;
34
 
35
		vector<Vec3f> vertices(NV);
36
		for(int i=0;i<NV;++i)
37
			ifs >> vertices[i];
38
 
39
		vector<int> faces(NF);
40
		vector<int> indices;
41
		for(int i=0;i<NF;++i)
42
		{
43
			int	verts_in_face;
44
			ifs >> verts_in_face;
45
			faces[i]=verts_in_face;
46
			for(int j=0;j<verts_in_face;++j)
47
			{
48
				int idx;
49
				ifs >> idx;
50
				indices.push_back(idx);
51
			}
52
		}
53
		build_manifold(m, NV, &vertices[0], NF, &faces[0], &indices[0]);
54
		return true;
55
	}
56
}
57