Subversion Repositories gelsvn

Rev

Rev 382 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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