1 |
mmeineke |
1052 |
#define _FILE_OFFSET_BITS 64 |
2 |
|
|
|
3 |
|
|
#include <stdio.h> |
4 |
|
|
#include <stdlib.h> |
5 |
|
|
#include <sys/types.h> |
6 |
|
|
#include <sys/stat.h> |
7 |
|
|
#include <string.h> |
8 |
|
|
|
9 |
|
|
#include "params.h" |
10 |
|
|
#include "tcProps.h" |
11 |
|
|
#include "readWrite.h" |
12 |
|
|
|
13 |
|
|
|
14 |
mmeineke |
1053 |
#define BUFFER_SIZE 2000 |
15 |
mmeineke |
1052 |
int isScanned; |
16 |
|
|
FILE* inFile; |
17 |
|
|
|
18 |
|
|
|
19 |
|
|
struct linkedPos{ |
20 |
|
|
|
21 |
|
|
fpos_t *myPos; |
22 |
|
|
double timeStamp; |
23 |
|
|
double Hmat[3][3]; |
24 |
|
|
struct linkedPos* next; |
25 |
|
|
}; |
26 |
|
|
|
27 |
|
|
struct staticPos{ |
28 |
|
|
|
29 |
|
|
fpos_t *myPos; |
30 |
|
|
double timeStamp; |
31 |
|
|
double Hmat[3][3]; |
32 |
|
|
}; |
33 |
|
|
struct staticPos* posArray; |
34 |
|
|
|
35 |
|
|
|
36 |
|
|
void closeFile( void ){ |
37 |
|
|
|
38 |
|
|
fclose( inFile ); |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
int setFrames( char* inFile ){ |
42 |
|
|
|
43 |
|
|
int nFrames = 0; |
44 |
|
|
int i,j,k; |
45 |
|
|
struct linkedPos* headPos; |
46 |
|
|
struct linkedPos* currPos; |
47 |
|
|
fpos_t *currPT; |
48 |
mmeineke |
1053 |
char readBuffer[BUFFER_SIZE]; |
49 |
|
|
char* foo; |
50 |
|
|
int lineNum = 0; |
51 |
|
|
|
52 |
|
|
|
53 |
mmeineke |
1052 |
|
54 |
|
|
inFile = fopen(inName); |
55 |
|
|
if(inFile ==NULL){ |
56 |
|
|
fprintf(stderr, |
57 |
|
|
"Error opening file \"%s\"\n", |
58 |
|
|
inName); |
59 |
|
|
exit(0); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
|
63 |
mmeineke |
1053 |
headPos = (struct linkedPos*)malloc(sizeof(struct linkedPos)); |
64 |
mmeineke |
1052 |
while( !feof( inFile ) ){ |
65 |
|
|
|
66 |
mmeineke |
1053 |
currPT = (fpos_t *)malloc(sizeof(fpos_t)); |
67 |
|
|
fgetpos(inFile, currPT); |
68 |
|
|
|
69 |
|
|
fgets( readBuffer, sizeof( readBuffer ), inFile ); |
70 |
|
|
lineNum++; |
71 |
|
|
if( feof( inFile ) ){ |
72 |
|
|
fprintf( stderr, |
73 |
|
|
"File \"%s\" ended unexpectedly at line %d\n", |
74 |
|
|
inName, |
75 |
|
|
lineNum ); |
76 |
|
|
exit(0); |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
i = atoi(readBuffer); |
80 |
|
|
|
81 |
|
|
|
82 |
|
|
} |
83 |
mmeineke |
1052 |
|
84 |
|
|
isScanned = 1; |
85 |
|
|
return nFrames; |
86 |
|
|
} |