667 |
khor |
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 |
|
|
|
7 |
#include <fstream>
|
|
|
8 |
#include "../Geometry/load_raw.h"
|
|
|
9 |
|
|
|
10 |
using namespace CGLA;
|
|
|
11 |
using namespace std;
|
|
|
12 |
|
|
|
13 |
namespace Geometry
|
|
|
14 |
{
|
|
|
15 |
|
|
|
16 |
template<class T>
|
|
|
17 |
bool load_raw(const string& file, RGrid<T>& grid)
|
|
|
18 |
{
|
|
|
19 |
int sz = grid.get_size();
|
|
|
20 |
ifstream f(file.c_str(),ios::binary);
|
|
|
21 |
if(f)
|
|
|
22 |
{
|
|
|
23 |
f.read(reinterpret_cast<char*>(grid.get()),sz*sizeof(T));
|
|
|
24 |
return true;
|
|
|
25 |
}
|
|
|
26 |
cerr << "Could not open volume :" << file << endl;
|
|
|
27 |
return false;
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
template bool load_raw(const string&, RGrid<unsigned char>& grid);
|
|
|
31 |
template bool load_raw(const string&, RGrid<unsigned short>& grid);
|
|
|
32 |
template bool load_raw(const string&, RGrid<short>& grid);
|
|
|
33 |
template bool load_raw(const string&, RGrid<float>& grid);
|
|
|
34 |
|
|
|
35 |
}
|