Subversion Repositories gelsvn

Rev

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

Rev 595 Rev 601
1
/* ----------------------------------------------------------------------- *
1
/* ----------------------------------------------------------------------- *
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
3
 * Copyright (C) the authors and DTU Informatics
3
 * Copyright (C) the authors and DTU Informatics
4
 * For license and list of authors, see ../../doc/intro.pdf
4
 * For license and list of authors, see ../../doc/intro.pdf
5
 * ----------------------------------------------------------------------- */
5
 * ----------------------------------------------------------------------- */
6
 
6
 
7
#include <fstream>
7
#include <fstream>
8
#include "Geometry/load_raw.h"
8
#include "../Geometry/load_raw.h"
9
 
9
 
10
using namespace CGLA;
10
using namespace CGLA;
11
using namespace std;
11
using namespace std;
12
 
12
 
13
namespace Geometry
13
namespace Geometry
14
{
14
{
15
 
15
 
16
	template<class T>
16
	template<class T>
17
	bool load_raw(const string& file, RGrid<T>& grid)
17
	bool load_raw(const string& file, RGrid<T>& grid)
18
	{
18
	{
19
			int sz = grid.get_size();
19
			int sz = grid.get_size();
20
			ifstream f(file.c_str(),ios::binary);
20
			ifstream f(file.c_str(),ios::binary);
21
			if(f)
21
			if(f)
22
			{
22
			{
23
					f.read(reinterpret_cast<char*>(grid.get()),sz*sizeof(T));
23
					f.read(reinterpret_cast<char*>(grid.get()),sz*sizeof(T));
24
					return true;
24
					return true;
25
			}
25
			}
26
			cerr << "Could not open volume :" << file << endl;
26
			cerr << "Could not open volume :" << file << endl;
27
			return false;
27
			return false;
28
	}
28
	}
29
		
29
		
30
		template bool load_raw(const string&, RGrid<unsigned char>& grid);
30
		template bool load_raw(const string&, RGrid<unsigned char>& grid);
31
		template bool load_raw(const string&, RGrid<unsigned short>& grid);
31
		template bool load_raw(const string&, RGrid<unsigned short>& grid);
32
		template bool load_raw(const string&, RGrid<short>& grid);
32
		template bool load_raw(const string&, RGrid<short>& grid);
33
		template bool load_raw(const string&, RGrid<float>& grid);
33
		template bool load_raw(const string&, RGrid<float>& grid);
34
 
34
 
35
}
35
}
36
 
36