80 rc_ptr<DataSourceInfo> dsi,
89 std::cout <<
"WARNING: reopening freesurfer curv file at beginning\n";
93 throw file_not_found_error( ds->url() );
99 hdr->getProperty(
"ascii", asciii );
100 bool ascii = bool( asciii );
101 hdr->getProperty(
"byte_swapping", bswapi );
102 bool bswap = bool( bswapi );
103 int nv = 0, np = 0, ps;
104 hdr->getProperty(
"vertex_number", nv );
111 rc_ptr<DataSource> mds( 0 );
114 mds = dsi->list().dataSource(
"minf" );
123 if( dsi->header().get() )
147 std::unique_ptr<ItemReader<uint32_t> > itemr;
148 itemr.reset( dir.
reader( !ascii, bswap ) );
150 std::vector<T> & tex = obj[0].data();
153 std::vector<uint32_t> data( nv * 2 );
154 long n = itemr->read( *ds, &data[0], nv * 2 );
157 std::cout <<
"not read the right size: " << n <<
" instead of expected " << nv * 2 << std::endl;
161 if( !ds->isOpen() || ds->eof() )
164 std::vector<uint32_t> v( 4, 0 );
165 n = itemr->read( *ds, &v[0], 4 );
168 std::cout <<
"EOF\n";
171 if( v[0] != 1 || v[1] != 0xfffffffe )
173 std::cout <<
"unexpected values after data table: " << v[0] <<
", " << v[1] <<
", " << v[2] <<
", " << v[3] << std::endl;
176 if( !ds->isOpen() || ds->eof() )
183 std::cout <<
"EOF\n";
187 if( line.length() + 1 != v[3] )
188 std::cout <<
"colortable filename string length mismatch\n";
189 n = itemr->read( *ds, &v[0], 1 );
192 std::cout <<
"EOF\n";
196 unsigned ncmap = v[0];
198 carto::Object cmap = Object::value( std::map<int, carto::Object>() );
200 std::map<uint32_t, T> rev_cols;
204 while( ds->isOpen() && !ds->eof() )
206 n = itemr->read( *ds, &v[0], 2 );
209 std::cout <<
"EOF in cmap reading\n";
215 std::cout <<
"EOF in cmap label reading\n";
218 if( line.length() + 1 != v[1] )
219 std::cout <<
"string length mismatch in cmap label: " << line
222 cmitem->setProperty(
"Label", line );
224 cmap->setArrayItem( v[0], cmitem );
225 n = itemr->read( *ds, &v[0], 4 );
228 std::cout <<
"EOF in cmap colors reading\n";
231 std::vector<float> col( 4, 1. );
232 col[0] = float( v[0] ) / 255.;
233 col[1] = float( v[1] ) / 255.;
234 col[2] = float( v[2] ) / 255.;
235 col[3] = float( 255 - v[3] ) / 255.;
236 cmitem->setProperty(
"RGB", col );
238 uint32_t rgb = v[2] * 0x10000 + v[1] * 0x100 + v[0];
239 rev_cols[rgb] = lindex;
243 std::cout <<
"wrong cmap entries found: " << i <<
" items, expected: "
244 << ncmap << std::endl;
246 uint32_t index, value;
247 typename std::map<uint32_t, T>::const_iterator ic, ec = rev_cols.end();
248 for( i=0; i<nv; ++i )
250 index = data[i * 2 ];
253 std::cout <<
"wrong index at: " << i <<
": " << index << std::endl;
256 value = data[ i * 2 + 1 ];
258 ic = rev_cols.find( value );
const aims::PythonHeader & header() const
Get the header.