Commit 3c6a0f61 authored by Edward Vigmond's avatar Edward Vigmond
Browse files

More bug fixes for display of vector IGB files

parent 4a9e1a8d
......@@ -1295,7 +1295,11 @@ int IGBheader::puts_fcn( void* f, char* s )
}
/** swap bytes */
/** swap bytes ]]
*
* \param data data buffer
* \param nd number of items in buffer
*/
void IGBheader :: swab( void *data, int nd )
{
unsigned char tmpb;
......
......@@ -346,16 +346,21 @@ int
read_IGB_data( T* dp, int numt, IGBheader* h, char *buf )
{
int slicesize = h->data_size()*h->x()*h->y()*h->z()*numt;
bool alloc_buf = false;
if ( buf==NULL ) {
buf = new char[slicesize];
alloc_buf = true;
}
int numread = gzread( h->fileptr(), buf, slicesize )/h->data_size();
if ( numread == Z_NULL ) return 0;
if ( h->systeme() != h->endian() ) h->swab(buf, numread);
for ( int a=0; a<numread; a++ )
int numprimitive = numread*h->data_size()/sizeof(T); // adjust vector types
for ( int a=0; a<numprimitive; a++ )
dp[a] = IGB_convert_buffer_datum<T>( h, buf, a );
if ( alloc_buf ) delete[] buf;
return numread;
}
......@@ -386,9 +391,13 @@ T IGB_convert_buffer_datum( IGBheader *h, void *buf, int a )
datum = ((long *)buf)[a];
break;
case IGB_FLOAT:
case IGB_VEC3_f:
case IGB_VEC4_f:
datum = ((float *)buf)[a];
break;
case IGB_DOUBLE:
case IGB_VEC3_d:
case IGB_VEC4_d:
datum = ((double *)buf)[a];
break;
case IGB_INT:
......@@ -397,9 +406,6 @@ T IGB_convert_buffer_datum( IGBheader *h, void *buf, int a )
case IGB_UINT:
datum = ((unsigned int *)buf)[a];
break;
case IGB_VEC3_f:
datum = ((float *)buf)[a];
break;
default:
memset(&datum,0,sizeof(datum));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment