34#ifndef AIMS_IO_SOMA_FSSURFFORMATREADER_D_H
35#define AIMS_IO_SOMA_FSSURFFORMATREADER_D_H
41#include <soma-io/datasourceinfo/datasourceinfoloader.h>
43#include <cartobase/stream/stringutil.h>
47#include <cartobase/config/verbose.h>
48#define localMsg( message ) cartoCondMsg( 4, message, "FSSURFFORMATREADER" )
65 localMsg(
"createAndRead " + ds->url() );
69 read( *mesh, dsi, context, options );
83 rc_ptr<DataSourceInfo> dsi,
92 std::cout <<
"WARNING: reopening freesurfer surf file at beginning\n";
96 throw file_not_found_error( ds->url() );
102 hdr->getProperty(
"ascii", asciii );
103 bool ascii = bool( asciii );
104 hdr->getProperty(
"byte_swapping", bswapi );
105 bool bswap = bool( bswapi );
106 int nv = 0, np = 0, ps;
107 hdr->getProperty(
"vertex_number", nv );
108 hdr->getProperty(
"polygon_number", np );
118 rc_ptr<DataSource> mds( 0 );
121 mds = dsi->list().dataSource(
"minf" );
130 if( dsi->header().get() )
154 std::unique_ptr<ItemReader<float> > itemr;
155 itemr.reset( dir.
reader( !ascii, bswap ) );
157 std::vector<Point3df> & vert = obj.
vertex();
160 long n = itemr->read( *ds, (
float *) &vert[0], nv * 3 );
177 std::unique_ptr<ItemReader<uint32_t> > itemr;
178 itemr.reset( dir.
reader( !ascii, bswap ) );
180 std::vector<AimsVector<uint32_t, D> > & poly = obj.
polygon();
183 long n = itemr->read( *ds, (uint32_t *) &poly[0], np * D );
194 bool ascii,
bool bswap )
const
199 std::unique_ptr<ItemReader<uint32_t> > itemr;
200 itemr.reset( dir.
reader( !ascii, bswap ) );
202 std::vector<uint32_t> dat( 3 );
204 long n = itemr->read( *ds, &dat[0], 3 );
206 if( n != 3 || dat[0] != 2 || dat[2] != 0x14 )
208 bool using_old_real_ras = bool( dat[1] );
210 int( using_old_real_ras ) );
214 std::vector<std::string> lines( 8 );
216 bool has_trans =
false;
223 lines[i] = StringUtil::strip( lines[i] );
224 std::vector<std::string> val = StringUtil::split( lines[i],
"=", 1 );
225 if( val.size() == 2 )
227 val[0] = StringUtil::strip( val[0] );
228 val[1] = StringUtil::strip( val[1] );
229 if( val[0] ==
"valid" )
231 if( val[0] ==
"volume" )
233 std::vector<std::string> sdims = StringUtil::split( val[1],
" " );
234 std::vector<int> dims( sdims.size() );
235 for(
int j=0; j<sdims.size(); ++j )
237 std::stringstream s( sdims[j] );
242 else if( val[0] ==
"filename" )
244 else if( val[0] ==
"voxelsize" )
246 std::vector<std::string> svs = StringUtil::split( val[1],
" " );
247 std::vector<float> vs( svs.size() );
248 for(
int j=0; j<svs.size(); ++j )
250 std::stringstream s( svs[j] );
255 else if( val[0] ==
"xras" || val[0] ==
"yras" || val[0] ==
"zras"
256 || val[0] ==
"cras" )
259 if( val[0][0] ==
'x' )
261 else if( val[0][0] ==
'y' )
263 else if( val[0][0] ==
'z' )
267 std::vector<std::string> sv = StringUtil::split( val[1],
" " );
268 for(
int j=0; j<sv.size(); ++j )
270 std::stringstream s( sv[j] );
279 std::vector<std::vector<float> > trvec(2);
286 std::vector<std::string> sref(2);
293 n = itemr->read( *ds, &dat[0], 3 );
295 if( n != 3 || dat[0] != 3 )
297 unsigned len = dat[2];
The template class to manage a mesh with time if needed.
const aims::PythonHeader & header() const
Get the header.
const std::vector< AimsVector< uint, D > > & polygon() const
Get a const reference to the vector of polygons of the 0 surface.
const std::vector< Point3df > & vertex() const
Get a const reference to the vector of verteces of the surface of index 0.
static std::string commonScannerBasedReferential()
virtual void copyProperties(Object source)
virtual void setProperty(const std::string &, Object)
static carto::Object readMinf(DataSource &ds, carto::Object base=carto::none(), carto::Object options=carto::none())
virtual ItemReader< T > * reader(bool binary=true, bool bswap=false) const
static bool getline(DataSource &ds, std::string &)
#define localMsg(message)