Use fread() to read facet number

This commit is contained in:
Alessandro Ranellucci 2013-11-12 15:27:42 +01:00
parent d0d842e24a
commit 3464e646f7
2 changed files with 1 additions and 13 deletions

View File

@ -180,5 +180,4 @@ extern void stl_allocate(stl_file *stl);
static void stl_read(stl_file *stl, int first_facet, int first); static void stl_read(stl_file *stl, int first_facet, int first);
static void stl_facet_stats(stl_file *stl, stl_facet facet, int first); static void stl_facet_stats(stl_file *stl, stl_facet facet, int first);
extern void stl_reallocate(stl_file *stl); extern void stl_reallocate(stl_file *stl);
static int stl_get_little_int(FILE *fp);
extern void stl_get_size(stl_file *stl); extern void stl_get_size(stl_file *stl);

View File

@ -41,17 +41,6 @@ stl_open(stl_file *stl, char *file)
fclose(stl->fp); fclose(stl->fp);
} }
static int
stl_get_little_int(FILE *fp)
{
int value;
value = fgetc(fp) & 0xFF;
value |= (fgetc(fp) & 0xFF) << 0x08;
value |= (fgetc(fp) & 0xFF) << 0x10;
value |= (fgetc(fp) & 0xFF) << 0x18;
return(value);
}
void void
stl_initialize(stl_file *stl) stl_initialize(stl_file *stl)
@ -132,7 +121,7 @@ stl_count_facets(stl_file *stl, char *file)
stl->stats.header[80] = '\0'; stl->stats.header[80] = '\0';
/* Read the int following the header. This should contain # of facets */ /* Read the int following the header. This should contain # of facets */
header_num_facets = stl_get_little_int(stl->fp); fread(&header_num_facets, sizeof(int), 1, stl->fp);
if(num_facets != header_num_facets) if(num_facets != header_num_facets)
{ {
fprintf(stderr, fprintf(stderr,