34 #define MOT_CLEF_INV 2
35 #define GRANDEUR_INV 4
228 #define N_MAX_ITEMS 30
229 #define L_MAX_ITEM 49
245 "",
"byte",
"char",
"short",
"long",
"float",
"double",
"complex",
246 "double_complex",
"rgba",
"structure",
"pointer",
"list",
"int",
"uint",
248 "vec3f",
"vec3d",
"vec4f",
"vec4d",
"hfloat",
"vec9f",
"vec9d"
254 "fac_x",
"fac_y",
"fac_z",
"fac_t"
260 0,
sizeof(
Byte),
sizeof(
char),
sizeof(short),
sizeof(
long),
sizeof(float),
261 sizeof(
double), 0, 0, 0, 0,
sizeof(
void *), 0,
sizeof(
int),
sizeof(
UInt),
262 sizeof(
unsigned short),
263 3*
sizeof(float), 3*
sizeof(
double), 4*
sizeof(float), 4*
sizeof(
double),
264 sizeof(
short_float), 9*
sizeof(
float), 9*
sizeof(double)
271 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 3, 3, 4, 4, 1, 9, 9
291 is_deprecated(
char *s ) {
298 #define MAKE_CONSISTENT( D ) \
299 if( bool_dim_##D && bool_inc_##D && bool_##D ) \
300 if( !almost_equal(v_dim_##D, v_inc_##D * (v_##D-1) ) ) { \
301 fprintf( stderr, "Adjusting dim_%s to make dimensions consistent\n", #D ); \
302 v_dim_##D = v_inc_##D * (v_##D-1);\
351 cerr<<
"\nERREUR: descripteur de fichier nul\n";
358 cerr <<
"\nCompressed IGB output is not supported\n";
360 "\nCompressed IGB output is not supported\n");
366 cerr<<
"\nHeader_Write: type inconnu: "<< v_type;
375 cerr <<
"\nHeader_Write: taille invalide:" << v_taille << endl;
381 if (v_trame<MIN_TRAME || v_trame>
MAX_TRAME) {
383 fprintf(stderr,
"\nHeader_Write: trame inconnue: %d\n", v_trame);
397 snprintf(ligne,
sizeof ligne,
"x:%zu y:%zu z:%zu t:%zu type:%s systeme:%s ",
398 v_x, v_y, v_z, v_t, type, systemestr());
400 snprintf(ligne,
sizeof ligne,
"x:%zu y:%zu t:%zu type:%s systeme:%s ",
401 v_x, v_y, v_t, type, systemestr());
405 snprintf(ligne,
sizeof ligne,
"x:%zu y:%zu z:%zu type:%s systeme:%s ",
406 v_x, v_y, v_z, type, systemestr());
408 snprintf(ligne,
sizeof ligne,
"x:%zu y:%zu type:%s systeme:%s ",
409 v_x, v_y, type, systemestr());
412 int n_car = strlen(ligne);
423 snprintf(&items[n_items][0],
L_MAX_ITEM,
"taille:%d ", v_taille);
424 l_item[n_items] = strlen(&items[n_items][0]);
428 snprintf(&items[n_items][0],
L_MAX_ITEM,
"org_x:%g ", v_org_x);
429 l_item[n_items] = strlen(&items[n_items][0]);
433 snprintf(&items[n_items][0],
L_MAX_ITEM,
"org_y:%g ", v_org_y);
434 l_item[n_items] = strlen(&items[n_items][0]);
438 snprintf(&items[n_items][0],
L_MAX_ITEM,
"org_z:%g ", v_org_z);
439 l_item[n_items] = strlen(&items[n_items][0]);
443 snprintf(&items[n_items][0],
L_MAX_ITEM,
"org_t:%g ", v_org_t);
444 l_item[n_items] = strlen(&items[n_items][0]);
448 snprintf(&items[n_items][0],
L_MAX_ITEM,
"dim_x:%g ", v_dim_x);
449 l_item[n_items] = strlen(&items[n_items][0]);
453 snprintf(&items[n_items][0],
L_MAX_ITEM,
"dim_x:%g ", v_inc_x);
454 l_item[n_items] = strlen(&items[n_items][0]);
458 snprintf(&items[n_items][0],
L_MAX_ITEM,
"dim_y:%g ", v_dim_y);
459 l_item[n_items] = strlen(&items[n_items][0]);
463 snprintf(&items[n_items][0],
L_MAX_ITEM,
"dim_y:%g ", v_inc_y);
464 l_item[n_items] = strlen(&items[n_items][0]);
468 snprintf(&items[n_items][0],
L_MAX_ITEM,
"dim_z:%g ", v_dim_z);
469 l_item[n_items] = strlen(&items[n_items][0]);
473 snprintf(&items[n_items][0],
L_MAX_ITEM,
"dim_z:%g ", v_inc_z);
474 l_item[n_items] = strlen(&items[n_items][0]);
478 snprintf(&items[n_items][0],
L_MAX_ITEM,
"dim_t:%g ", v_dim_t);
479 l_item[n_items] = strlen(&items[n_items][0]);
483 snprintf(&items[n_items][0],
L_MAX_ITEM,
"inc_t:%g ", v_inc_t);
484 l_item[n_items] = strlen(&items[n_items][0]);
488 snprintf(&items[n_items][0],
L_MAX_ITEM,
"vect_z:1 ");
489 l_item[n_items] = strlen(&items[n_items][0]);
493 snprintf(&items[n_items][0],
L_MAX_ITEM,
"unites_x:%.40s ", v_unites_x);
494 l_item[n_items] = strlen(&items[n_items][0]);
498 snprintf(&items[n_items][0],
L_MAX_ITEM,
"unites_y:%.40s ", v_unites_y);
499 l_item[n_items] = strlen(&items[n_items][0]);
503 snprintf(&items[n_items][0],
L_MAX_ITEM,
"unites_z:%.40s ", v_unites_z);
504 l_item[n_items] = strlen(&items[n_items][0]);
508 snprintf(&items[n_items][0],
L_MAX_ITEM,
"unites_t:%.40s ", v_unites_t);
509 l_item[n_items] = strlen(&items[n_items][0]);
513 snprintf(&items[n_items][0],
L_MAX_ITEM,
"num:%d ", v_num);
514 l_item[n_items] = strlen(&items[n_items][0]);
518 snprintf(&items[n_items][0],
L_MAX_ITEM,
"bin:%d ", v_bin);
519 l_item[n_items] = strlen(&items[n_items][0]);
525 snprintf(&items[n_items][0],
L_MAX_ITEM,
"trame:c8 ");
528 snprintf(&items[n_items][0],
L_MAX_ITEM,
"trame:c4 ");
531 snprintf(&items[n_items][0],
L_MAX_ITEM,
"trame:hex ");
534 snprintf(&items[n_items][0],
L_MAX_ITEM,
"trame:hexedges ");
537 snprintf(&items[n_items][0],
L_MAX_ITEM,
"trame:hexbridges ");
540 snprintf(&items[n_items][0],
L_MAX_ITEM,
"trame:hexlines ");
543 snprintf(&items[n_items][0],
L_MAX_ITEM,
"trame:hex2 ");
546 l_item[n_items] = strlen(&items[n_items][0]);
550 snprintf(&items[n_items][0],
L_MAX_ITEM,
"lut:%d ", v_lut);
551 l_item[n_items] = strlen(&items[n_items][0]);
555 snprintf(&items[n_items][0],
L_MAX_ITEM,
"comp:%d ", v_comp);
556 l_item[n_items] = strlen(&items[n_items][0]);
560 snprintf(&items[n_items][0],
L_MAX_ITEM,
"epais:%g ", v_epais);
561 l_item[n_items] = strlen(&items[n_items][0]);
565 snprintf(&items[n_items][0],
L_MAX_ITEM,
"unites:%.40s ", v_unites);
566 l_item[n_items] = strlen(&items[n_items][0]);
570 snprintf(&items[n_items][0],
L_MAX_ITEM,
"facteur:%g ", v_facteur);
571 l_item[n_items] = strlen(&items[n_items][0]);
575 snprintf(&items[n_items][0],
L_MAX_ITEM,
"zero:%g ", v_zero);
576 l_item[n_items] = strlen(&items[n_items][0]);
579 if ( v_transparent != NULL ) {
580 char *p=(
char *)v_transparent, value[
MAXL];
583 snprintf( value+a*2,
MAXL,
"%0.2x", *(p++) );
585 snprintf(&items[n_items][0],
L_MAX_ITEM,
"transparent:%s ", value );
586 l_item[n_items] = strlen(&items[n_items][0]);
589 if (bool_struct_desc) {
590 snprintf(&items[n_items][0],
L_MAX_ITEM,
"struct:%.40s ", v_struct_desc);
591 l_item[n_items] = strlen(&items[n_items][0]);
595 snprintf(&items[n_items][0],
L_MAX_ITEM,
"aut:%.40s ", v_aut_name);
596 l_item[n_items] = strlen(&items[n_items][0]);
604 while (*comment != NULL) {
606 n_car_total += strlen(*comment++) + 3;
613 for (
int i=0;i<n_items;i++) {
614 if (n_car+l_item[i]<71) {
615 strcat(ligne, &items[i][0]);
618 ligne[n_car++] =
'\r';
619 ligne[n_car++] =
'\n';
620 ligne[n_car] =
'\000';
621 n_car_total += n_car;
622 if (puts_fcn( ligne)==-1) {
624 fprintf(stderr,
"\nHeader_Write: Erreur a l'ecriture \n");
626 fprintf(stderr,
"\n");
631 strcpy(ligne, &items[i][0]);
640 ligne[n_car++] =
'\r';
641 ligne[n_car++] =
'\n';
642 ligne[n_car] =
'\000';
643 n_car_total += n_car;
644 if (puts_fcn( ligne )==-1) {
646 fprintf(stderr,
"\nHeader_Write: Erreur a l'ecriture \n");
648 fprintf(stderr,
"\n");
659 int n_blocs = 1 + (n_car_total-1)/1024;
660 int n_car_sup = n_blocs*1024 - n_car_total;
663 n_lig_sup = 1 + (n_car_sup-1)/72;
667 int n_car_dl = 1 + (n_car_sup-1)%72;
674 while (*comment != NULL) {
675 n_car = fprintf((FILE*)file,
"#%.80s\r\n", *comment++);
678 fprintf(stderr,
"\nHeader_Write: Erreur a l'ecriture \n");
680 fprintf(stderr,
"\n");
691 for (
int i=0;i<70;i++) ligne[i] =
' ';
695 for (
int i=0;i<n_lig_sup-1;i++) {
696 if (puts_fcn( ligne)==-1) {
698 fprintf(stderr,
"\nHeader_Write: Erreur a l'ecriture \n");
700 fprintf(stderr,
"\n");
710 for (
int i=0;i<n_car_dl-2;i++) ligne[i] =
' ';
711 if (n_car_dl>2) ligne[n_car_dl-3] =
'\r';
712 if (n_car_dl>1) ligne[n_car_dl-2] =
'\n';
713 ligne[n_car_dl-1] =
FF;
714 ligne[n_car_dl] =
'\000';
715 if (puts_fcn( ligne )==-1) {
717 fprintf(stderr,
"\nHeader_Write: Erreur a l'ecriture \n");
719 fprintf(stderr,
"\n");
725 if (n_car_total>1024) {
728 "\nHeader_Write ATTENTION: etiquette de grandeur non-standard \n");
730 "\nHeader_Write ATTENTION: etiquette de grandeur non-standard \n");
734 "\nHeader_Write: Entete transcrite sans problemes\n");
757 bool bool_fac_t =
false;
762 for (
int s=8; (s>0 || nosup) && go; s-- ) {
766 if( tell()<0 )
return 2;
774 "\nERREUR ligne trop longue (>80) dans l'entete !\n" ) ;
776 "\nERREUR ligne trop longue (>80) dans l'entete !\n" ) ;
781 in = get_character() ;
787 "\nERREUR Fin de fichier dans l'entete !\n" ) ;
789 "\nERREUR Fin de fichier dans l'entete !\n" ) ;
794 else if ( in ==
FF ) {
801 else if ( in ==
CR ) {
803 }
else if ( in ==
LF ) {
809 else if ( in && ! isprint(in) ) {
812 "\nERREUR caract. non imprim. 0x%.2X dans "
813 "l'entete at byte number %ld\n", in, tell() );
815 "\nERREUR caract. non imprim. 0x%.2X dans l'entete !\n", in );
818 str[i++] = (char) in ;
824 for (
char* pt_1=str; *pt_1; pt_1++ ) {
827 if ( *pt_1 ==
'*' || *pt_1 ==
'#') {
829 v_comment[com] = (
char *)malloc( strlen(pt_1+1) + 1 ) ;
830 strcpy( v_comment[com++], pt_1+1 ) ;
832 v_comment = (
char **)
833 realloc(v_comment, (com+
NALLOC)*
sizeof(
char *));
834 v_comment[com] = NULL ;
842 if (isupper(*pt_1)) *pt_1 = tolower( *pt_1 ) ;
848 for (
char *pt_1=strtok(str,
" ,;\t"); pt_1; pt_1=strtok(NULL,
" ,;\t") ) {
854 for ( pt_2 = pt_1; *pt_2 !=
':'; pt_2 ++ )
858 "\nERREUR de syntaxe dans l'entete (%s)\n", pt_1);
860 "\nERREUR de syntaxe dans l'entete (%s)\n", pt_1);
867 if ( ! strcmp( pt_1,
"x" ) ) {
868 v_x = strtoul(pt_2, NULL, 10);
871 }
else if ( ! strcmp( pt_1,
"y" ) ) {
872 v_y = strtoul(pt_2, NULL, 10) ;
875 }
else if ( ! strcmp( pt_1,
"z" ) ) {
876 v_z = strtoul(pt_2, NULL, 10) ;
879 }
else if ( ! strcmp( pt_1,
"t" ) ) {
880 v_t = strtoul(pt_2, NULL, 10) ;
884 }
else if ( ! strcmp( pt_1,
"sup" ) ) {
888 }
else if ( ! strcmp( pt_1,
"type" ) ) {
896 }
else if ( ! strcmp( pt_1,
"taille" ) ) {
897 v_taille = atoi( pt_2 ) ;
900 }
else if ( ! strcmp( pt_1,
"systeme" ) ) {
909 }
else if ( ! strcmp( pt_1,
"bin" ) ) {
910 v_bin = atoi( pt_2 ) ;
913 }
else if ( ! strcmp( pt_1,
"trame" ) ) {
915 if ( ! strcmp( pt_2,
"c8" ) ) {
917 }
else if ( ! strcmp( pt_2,
"c4" ) ) {
919 }
else if ( ! strcmp( pt_2,
"hex" ) ) {
921 }
else if ( ! strcmp( pt_2,
"hexedges" ) ) {
923 }
else if ( ! strcmp( pt_2,
"hexbridges" ) ) {
925 }
else if ( ! strcmp( pt_2,
"hexlines" ) ) {
927 }
else if ( ! strcmp( pt_2,
"hex2" ) ) {
932 }
else if ( ! strcmp( pt_1,
"num" ) ) {
933 v_num = atoi( pt_2 ) ;
936 }
else if ( ! strcmp( pt_1,
"comp" ) ) {
937 v_comp = atoi( pt_2 ) ;
940 }
else if ( ! strcmp( pt_1,
"lut" ) ) {
941 v_lut = atoi( pt_2 ) ;
944 }
else if ( ! strcmp( pt_1,
"dim_x" ) ) {
945 v_dim_x = atof( pt_2 ) ;
948 }
else if ( ! strcmp( pt_1,
"dim_y" ) ) {
949 v_dim_y = atof( pt_2 ) ;
952 }
else if ( ! strcmp( pt_1,
"dim_z" ) ) {
953 v_dim_z = atof( pt_2 ) ;
956 }
else if ( ! strcmp( pt_1,
"dim_t" ) ) {
957 v_dim_t = atof( pt_2 ) ;
960 }
else if ( ! strcmp( pt_1,
"inc_x" ) ) {
961 v_inc_x = atof( pt_2 ) ;
964 }
else if ( ! strcmp( pt_1,
"inc_y" ) ) {
965 v_inc_y = atof( pt_2 ) ;
968 }
else if ( ! strcmp( pt_1,
"inc_z" ) ) {
969 v_inc_z = atof( pt_2 ) ;
972 }
else if ( ! strcmp( pt_1,
"inc_t" ) ) {
973 v_inc_t = atof( pt_2 ) ;
976 }
else if ( ! strcmp( pt_1,
"org_x" ) ) {
977 v_org_x = atof( pt_2 ) ;
980 }
else if ( ! strcmp( pt_1,
"org_y" ) ) {
981 v_org_y = atof( pt_2 ) ;
984 }
else if ( ! strcmp( pt_1,
"org_z" ) ) {
985 v_org_z = atof( pt_2 ) ;
988 }
else if ( ! strcmp( pt_1,
"org_t" ) ) {
989 v_org_t = atof( pt_2 ) ;
992 }
else if ( ! strcmp( pt_1,
"vect_z" ) ) {
995 }
else if ( ! strcmp( pt_1,
"unites_x" ) ) {
996 strncpy( v_unites_x, pt_2, 40 ) ;
997 bool_unites_x =
VRAI;
999 }
else if ( ! strcmp( pt_1,
"unites_y" ) ) {
1000 strncpy( v_unites_y, pt_2, 40 ) ;
1001 bool_unites_y =
VRAI;
1003 }
else if ( ! strcmp( pt_1,
"unites_z" ) ) {
1004 strncpy( v_unites_z, pt_2, 40 ) ;
1005 bool_unites_z =
VRAI;
1007 }
else if ( ! strcmp( pt_1,
"unites_t" ) ) {
1008 strncpy( v_unites_t, pt_2, 40 ) ;
1009 bool_unites_t =
VRAI;
1011 }
else if ( ! strcmp( pt_1,
"epais" ) ) {
1012 v_epais = atof( pt_2 ) ;
1015 }
else if ( ! strcmp( pt_1,
"unites" ) ) {
1016 strncpy( v_unites, pt_2, 40 ) ;
1019 }
else if ( ! strcmp( pt_1,
"facteur" ) ) {
1020 v_facteur = atof( pt_2 ) ;
1021 bool_facteur =
VRAI;
1023 }
else if ( ! strcmp( pt_1,
"zero" ) ) {
1024 v_zero = atof( pt_2 ) ;
1027 }
else if ( ! strcmp( pt_1,
"struct" ) ) {
1028 strncpy( v_struct_desc, pt_2, 40 ) ;
1029 bool_struct_desc =
VRAI;
1031 }
else if ( ! strcmp( pt_1,
"aut" ) ) {
1032 strncpy( v_aut_name, pt_2, 40 ) ;
1033 bool_aut_name =
VRAI;
1035 }
else if ( !strcmp( pt_1,
"transparent" ) ) {
1036 strcpy( transstr, pt_2 );
1037 bool_transparent =
VRAI;
1040 if( is_deprecated( pt_1 ) ){
1042 fprintf(stderr,
"\nATTENTION: mot-clef %s obsolete !\n", pt_1 ) ;
1043 if( !strcmp( pt_1,
"fac_t" ) ){
1044 v_fac_t = atof( pt_2 );
1049 fprintf(stderr,
"\nATTENTION: mot-clef %s non reconnu !\n", pt_1 );
1051 "\nATTENTION: mot-clef %s non reconnu !\n", pt_1 ) ;
1058 if ( bool_transparent ) {
1059 if ( strlen(transstr) != 2*
Data_Size[v_type] ) {
1060 fprintf(stderr,
"ATTENTION: ignoring invalid transparent value !\n");
1064 v = (
char *)(v_transparent = calloc(
Data_Size[v_type], 1 ));
1065 for (
int i=0; i<
Data_Size[v_type]; i++ ) {
1066 s[0] = transstr[i*2];
1067 s[1] = transstr[i*2+1];
1068 v[i] = strtol( s, &p, 16 );
1074 if ( !bool_x || !bool_y || !bool_type ) {
1076 fprintf(stderr,
"\nERREUR x, y ou type non definis\n") ;
1084 float dim_x = v_inc_x * v_x ;
1087 fprintf(stderr,
"\nATTENTION:\n") ;
1089 "conflit entre x (%zu) * inc_x (%.12g) = %.12g et dim_x (%.12g)\n",
1090 v_x, v_inc_x, dim_x, v_dim_x) ;
1093 "conflit entre x (%zu) * inc_x (%.12g) = %.12g et dim_x (%.12g)\n",
1094 v_x, v_inc_x, dim_x, v_dim_x) ;
1098 v_inc_x = v_dim_x / v_x ;
1102 v_dim_x = v_x * v_inc_x ;
1103 if ( bool_inc_x ) bool_dim_x =
VRAI;
1108 float dim_y = v_inc_y * v_y ;
1111 fprintf(stderr,
"\nATTENTION:\n") ;
1113 "conflit entre y (%zu) * inc_y (%.12g) = %.12g et dim_y (%.12g)\n",
1114 v_y, v_inc_y, dim_y, v_dim_y) ;
1117 "conflit entre y (%zu) * inc_y (%.12g) = %.12g et dim_y (%.12g)\n",
1118 v_y, v_inc_y, dim_y, v_dim_y) ;
1122 v_inc_y = v_dim_y / v_y ;
1126 v_dim_y = v_y * v_inc_y ;
1127 if ( bool_inc_y ) bool_dim_y =
VRAI;
1132 float dim_z = v_inc_z * v_z ;
1135 fprintf(stderr,
"\nATTENTION:\n") ;
1137 "conflit entre z (%zu) * inc_z (%.12g) = %.12g et dim_z (%.12g)\n",
1138 v_z, v_inc_z, dim_z, v_dim_z) ;
1141 "conflit entre z (%zu) * inc_z (%.12g) = %.12g et dim_z (%.12g)\n",
1142 v_z, v_inc_z, dim_z, v_dim_z) ;
1146 v_inc_z = v_dim_z / v_z ;
1150 v_dim_z = v_z * v_inc_z ;
1151 if ( bool_inc_z ) bool_dim_z =
VRAI;
1154 if( !bool_inc_t && bool_fac_t ) {
1160 float dim_t = v_inc_t * (v_t-1) ;
1163 fprintf(stderr,
"\nATTENTION:\n") ;
1165 "conflit entre t (%zu) * inc_t (%.12g) = %.12g et dim_t (%.12g)\n",
1166 v_t, v_inc_t, dim_t, v_dim_t) ;
1169 "conflit entre t (%zu) * inc_t (%.12g) = %.12g et dim_t (%.12g)\n",
1170 v_t, v_inc_t, dim_t, v_dim_t) ;
1175 v_inc_t = v_dim_t / (v_t - 1) ;
1179 v_dim_t = (v_t-1) * v_inc_t ;
1184 if ( bool_taille ) {
1188 "\nERREUR taille redefinie pour type autre que structure\n") ;
1190 "\nERREUR taille redefinie pour type autre que structure\n") ;
1197 "\nERREUR taille non definie pour type structure\n") ;
1199 "\nERREUR taille non definie pour type structure\n") ;
1207 seek( 1024, SEEK_SET );
1210 "\nATTENTION: etiquette de grandeur non-standard: %ld \n", tell());
1213 "\nATTENTION: etiquette de grandeur non-standard \n");
1217 "\nHeader_Read: Etiquette lue sans problemes\n");
1221 v_vect_z = (
float *)malloc(v_z*
sizeof(
float));
1222 read_vz(v_vect_z,
sizeof(
float)*v_z);
1234 const int maxln = 78;
1235 int i = 0, n_lignes = 0;
1237 if ( ligne == NULL ) {
1238 while ( v_comment[n_lignes] != NULL )
1239 free( v_comment[n_lignes++] );
1243 int newlines = (strlen(ligne)+maxln-1)/maxln;
1244 while (v_comment[i++]!=NULL) n_lignes++;
1245 v_comment = (
char **)realloc(v_comment, (n_lignes+newlines+1)*
sizeof(
char *));
1247 for(
int j=0; j<newlines; j++ ){
1248 v_comment[n_lignes] = (
char *)malloc(maxln+2) ;
1249 v_comment[n_lignes][maxln] =
'\0';
1250 strncpy(v_comment[n_lignes++], ligne+j*maxln, maxln);
1252 v_comment[n_lignes] = NULL;
1253 bool_comment =
true;
1291 cerr <<
"illegal data type specified for IGB header" << endl;
1302 return gztell( (gzFile)file );
1307 return ftell( (FILE*)file );
1312 int IGBheader::puts_fcn(
char* s )
1314 return fputs(s, (FILE*)file);
1325 if ( data_size()==1 || v_type==
IGB_RGBA )
1328 unsigned char *bp = (
unsigned char *)data;
1329 int ds = data_size()/num_components();
1331 if ( nd<0 ) nd = v_x*v_y*v_z*v_t;
1333 nd *= num_components();
1337 for (
int i=0; i<nd; i++ ) {
1338 unsigned char tmpb = bp[0];
1345 for (
int i=0; i<nd; i++ ) {
1346 unsigned char tmpb = bp[0];
1356 for (
int i=0; i<nd; i++ ) {
1357 unsigned char tmpb = bp[0];
1381 *pval = (
unsigned char *)(&val);
1383 assert(
sizeof(
float) == 4 );
1385 if ( *pval == le_val[0] )
1391 int IGBheader::get_character()
1394 return gzgetc( (gzFile)file );
1396 if( file==stdin ) bytes_read++;
1397 return fgetc( (FILE*)file );
1402 int IGBheader::seek(
size_t offset,
int whence)
1405 return gzseek( (gzFile)file, offset, whence );
1407 if( file == stdin ) {
1409 if(whence==SEEK_SET) {
1410 if( offset < bytes_read )
1412 pos = offset - bytes_read;
1413 }
else if(whence==SEEK_CUR)
1417 for(
int i=0; i<pos; i++ ) getchar();
1421 return fseek( (FILE*)file, offset, whence );
1425 int IGBheader::read_vz(
float *vz,
int sz )
1428 return gzread( (gzFile)file, vz, sz );
1431 return fread( vz, sz, 1, (FILE*)file );
1447 s *= slice_sz() * data_size();
1449 return seek( s, SEEK_SET );
1459 gzseek( (gzFile)file, 1024L+frame*slice_sz()*data_size(), SEEK_SET );
1461 fseek( (FILE*)file, 1024L+frame*slice_sz()*data_size(), SEEK_SET );