Subversion Repositories gelsvn

Rev

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

Rev 214 Rev 382
1
#include <fstream>
1
#include <fstream>
2
#include "Geometry/load_raw.h"
2
#include "Geometry/load_raw.h"
3
 
3
 
4
using namespace CGLA;
4
using namespace CGLA;
5
using namespace std;
5
using namespace std;
6
 
6
 
7
namespace Geometry
7
namespace Geometry
8
{
8
{
9
 
9
 
10
	template<class T>
10
	template<class T>
11
	bool load_raw(const string& file, RGrid<T>& grid)
11
	bool load_raw(const string& file, RGrid<T>& grid)
12
	{
12
	{
13
			int sz = grid.get_size();
13
			int sz = grid.get_size();
14
			ifstream f(file.c_str(),ios::binary);
14
			ifstream f(file.c_str(),ios::binary);
15
			if(f)
15
			if(f)
16
			{
16
			{
17
					f.read(reinterpret_cast<char*>(grid.get()),sz*sizeof(T));
17
					f.read(reinterpret_cast<char*>(grid.get()),sz*sizeof(T));
18
					return true;
18
					return true;
19
			}
19
			}
20
			cout << "Could not open volume" << endl;
20
			cerr << "Could not open volume :" << file << endl;
21
			return false;
21
			return false;
22
	}
22
	}
23
		
23
		
24
		template bool load_raw(const string&, RGrid<unsigned char>& grid);
24
		template bool load_raw(const string&, RGrid<unsigned char>& grid);
25
		template bool load_raw(const string&, RGrid<unsigned short>& grid);
25
		template bool load_raw(const string&, RGrid<unsigned short>& grid);
26
		template bool load_raw(const string&, RGrid<short>& grid);
26
		template bool load_raw(const string&, RGrid<short>& grid);
27
		template bool load_raw(const string&, RGrid<float>& grid);
27
		template bool load_raw(const string&, RGrid<float>& grid);
28
 
28
 
29
}
29
}
30
 
30