| 79 |
|
} |
| 80 |
|
|
| 81 |
|
/* |
| 82 |
< |
The next three functions deal with creating and initializing of the |
| 83 |
< |
members statements used by the bonds, bends, and torsions. |
| 82 |
> |
The next function deals with creating and initializing of the |
| 83 |
> |
members statements used by the bonds, bends, torsions, and rigid bodies. |
| 84 |
|
*/ |
| 85 |
|
|
| 86 |
< |
struct node_tag* members_2( int a, int b ){ |
| 86 |
> |
struct node_tag* members( char* list_str ){ |
| 87 |
|
|
| 88 |
|
struct node_tag* the_node; |
| 89 |
|
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 90 |
|
|
| 91 |
< |
the_node->type = MEMBER_STMT; |
| 91 |
> |
the_node->type = MEMBERS_STMT; |
| 92 |
|
the_node->index = 0; |
| 93 |
|
the_node->next_stmt = NULL; |
| 94 |
|
the_node->prev_stmt = NULL; |
| 95 |
|
the_node->stmt_list = NULL; |
| 96 |
|
|
| 97 |
< |
the_node->the_data.mbr.a = a; |
| 98 |
< |
the_node->the_data.mbr.b = b; |
| 99 |
< |
the_node->the_data.mbr.c = 0; |
| 100 |
< |
the_node->the_data.mbr.d = 0; |
| 97 |
> |
int nTokens, i; |
| 98 |
> |
char *foo; |
| 99 |
|
|
| 100 |
< |
return the_node; |
| 103 |
< |
} |
| 100 |
> |
nTokens = count_tokens(list_str, " ,;\t"); |
| 101 |
|
|
| 102 |
< |
struct node_tag* members_3( int a, int b, int c ){ |
| 102 |
> |
if (nTokens < 1) { |
| 103 |
> |
yyerror("can't find any members in this members statement"); |
| 104 |
> |
} |
| 105 |
|
|
| 106 |
< |
struct node_tag* the_node; |
| 108 |
< |
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 109 |
< |
|
| 110 |
< |
the_node->type = MEMBER_STMT; |
| 111 |
< |
the_node->index = 0; |
| 112 |
< |
the_node->next_stmt = NULL; |
| 113 |
< |
the_node->prev_stmt = NULL; |
| 114 |
< |
the_node->stmt_list = NULL; |
| 115 |
< |
|
| 116 |
< |
the_node->the_data.mbr.a = a; |
| 117 |
< |
the_node->the_data.mbr.b = b; |
| 118 |
< |
the_node->the_data.mbr.c = c; |
| 119 |
< |
the_node->the_data.mbr.d = 0; |
| 106 |
> |
the_node->the_data.mbrs.nMembers = nTokens; |
| 107 |
|
|
| 108 |
< |
return the_node; |
| 122 |
< |
} |
| 108 |
> |
the_node->the_data.mbrs.memberList = (int *) calloc(nTokens, sizeof(int)); |
| 109 |
|
|
| 110 |
< |
struct node_tag* members_4( int a, int b, int c, int d ){ |
| 110 |
> |
foo = strtok(list_str, " ,;\t"); |
| 111 |
> |
the_node->the_data.mbrs.memberList[0] = atoi( foo ); |
| 112 |
|
|
| 113 |
< |
struct node_tag* the_node; |
| 114 |
< |
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 115 |
< |
|
| 116 |
< |
the_node->type = MEMBER_STMT; |
| 130 |
< |
the_node->index = 0; |
| 131 |
< |
the_node->next_stmt = NULL; |
| 132 |
< |
the_node->prev_stmt = NULL; |
| 133 |
< |
the_node->stmt_list = NULL; |
| 134 |
< |
|
| 135 |
< |
the_node->the_data.mbr.a = a; |
| 136 |
< |
the_node->the_data.mbr.b = b; |
| 137 |
< |
the_node->the_data.mbr.c = c; |
| 138 |
< |
the_node->the_data.mbr.d = d; |
| 113 |
> |
for (i = 1; i < nTokens; i++) { |
| 114 |
> |
foo = strtok(NULL, " ,;\t"); |
| 115 |
> |
the_node->the_data.mbrs.memberList[i] = atoi( foo ); |
| 116 |
> |
} |
| 117 |
|
|
| 118 |
|
return the_node; |
| 119 |
|
} |
| 122 |
|
This function does the C & I of the constraint statements |
| 123 |
|
*/ |
| 124 |
|
|
| 125 |
< |
struct node_tag* constraint( double constraint_val ){ |
| 125 |
> |
struct node_tag* constraint( char* list_str ){ |
| 126 |
|
|
| 127 |
|
struct node_tag* the_node; |
| 128 |
|
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 133 |
|
the_node->prev_stmt = NULL; |
| 134 |
|
the_node->stmt_list = NULL; |
| 135 |
|
|
| 136 |
< |
the_node->the_data.cnstr.constraint_val = constraint_val; |
| 136 |
> |
int nTokens; |
| 137 |
> |
char *foo; |
| 138 |
|
|
| 139 |
+ |
nTokens = count_tokens(list_str, " ,;\t"); |
| 140 |
+ |
if (nTokens != 1) { |
| 141 |
+ |
yyerror("wrong number of arguments given in constraint statement"); |
| 142 |
+ |
} |
| 143 |
+ |
|
| 144 |
+ |
foo = strtok(list_str, " ,;\t"); |
| 145 |
+ |
the_node->the_data.cnstr.constraint_val = atof( foo ); |
| 146 |
+ |
|
| 147 |
|
return the_node; |
| 148 |
|
} |
| 149 |
|
|
| 151 |
|
This function does the C & I for the orientation statements |
| 152 |
|
*/ |
| 153 |
|
|
| 154 |
< |
struct node_tag* orientation( double x, double y, double z ){ |
| 154 |
> |
struct node_tag* orientation( char* list_str ){ |
| 155 |
|
|
| 156 |
|
struct node_tag* the_node; |
| 157 |
|
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 161 |
|
the_node->next_stmt = NULL; |
| 162 |
|
the_node->prev_stmt = NULL; |
| 163 |
|
the_node->stmt_list = NULL; |
| 164 |
< |
|
| 165 |
< |
the_node->the_data.pos.x = x; |
| 166 |
< |
the_node->the_data.pos.y = y; |
| 167 |
< |
the_node->the_data.pos.z = z; |
| 168 |
< |
|
| 164 |
> |
|
| 165 |
> |
int nTokens; |
| 166 |
> |
char *foo; |
| 167 |
> |
|
| 168 |
> |
nTokens = count_tokens(list_str, " ,;\t"); |
| 169 |
> |
if (nTokens != 3) { |
| 170 |
> |
yyerror("wrong number of arguments given in orientation"); |
| 171 |
> |
} |
| 172 |
> |
|
| 173 |
> |
foo = strtok(list_str, " ,;\t"); |
| 174 |
> |
the_node->the_data.ort.phi = atof( foo ); |
| 175 |
> |
|
| 176 |
> |
foo = strtok(NULL, " ,;\t"); |
| 177 |
> |
the_node->the_data.ort.theta = atof( foo ); |
| 178 |
> |
|
| 179 |
> |
foo = strtok(NULL, " ,;\t"); |
| 180 |
> |
the_node->the_data.ort.psi = atof( foo ); |
| 181 |
> |
|
| 182 |
|
return the_node; |
| 183 |
|
} |
| 184 |
|
|
| 186 |
|
This function does the C & I for the position statements |
| 187 |
|
*/ |
| 188 |
|
|
| 189 |
< |
struct node_tag* position( double x, double y, double z ){ |
| 189 |
> |
struct node_tag* position( char* list_str ){ |
| 190 |
|
|
| 191 |
|
struct node_tag* the_node; |
| 192 |
|
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 196 |
|
the_node->next_stmt = NULL; |
| 197 |
|
the_node->prev_stmt = NULL; |
| 198 |
|
the_node->stmt_list = NULL; |
| 199 |
+ |
|
| 200 |
+ |
int nTokens; |
| 201 |
+ |
char *foo; |
| 202 |
+ |
|
| 203 |
+ |
nTokens = count_tokens(list_str, " ,;\t"); |
| 204 |
+ |
if (nTokens != 3) { |
| 205 |
+ |
yyerror("wrong number of arguments given in position"); |
| 206 |
+ |
} |
| 207 |
+ |
|
| 208 |
+ |
foo = strtok(list_str, " ,;\t"); |
| 209 |
+ |
the_node->the_data.pos.x = atof( foo ); |
| 210 |
+ |
|
| 211 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 212 |
+ |
the_node->the_data.pos.y = atof( foo ); |
| 213 |
+ |
|
| 214 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 215 |
+ |
the_node->the_data.pos.z = atof( foo ); |
| 216 |
+ |
|
| 217 |
|
|
| 200 |
– |
the_node->the_data.pos.x = x; |
| 201 |
– |
the_node->the_data.pos.y = y; |
| 202 |
– |
the_node->the_data.pos.z = z; |
| 203 |
– |
|
| 218 |
|
return the_node; |
| 219 |
|
} |
| 220 |
|
|
| 334 |
|
|
| 335 |
|
return the_node; |
| 336 |
|
} |
| 337 |
+ |
|
| 338 |
+ |
|
| 339 |
+ |
int count_tokens(char *line, char *delimiters) { |
| 340 |
+ |
/* PURPOSE: RETURN A COUNT OF THE NUMBER OF TOKENS ON THE LINE. */ |
| 341 |
+ |
|
| 342 |
+ |
char *working_line; /* WORKING COPY OF LINE. */ |
| 343 |
+ |
int ntokens; /* NUMBER OF TOKENS FOUND IN LINE. */ |
| 344 |
+ |
char *strtok_ptr; /* POINTER FOR STRTOK. */ |
| 345 |
+ |
|
| 346 |
+ |
strtok_ptr= working_line= strdup(line); |
| 347 |
+ |
|
| 348 |
+ |
ntokens=0; |
| 349 |
+ |
while (strtok(strtok_ptr,delimiters)!=NULL) |
| 350 |
+ |
{ |
| 351 |
+ |
ntokens++; |
| 352 |
+ |
strtok_ptr=NULL; |
| 353 |
+ |
} |
| 354 |
+ |
|
| 355 |
+ |
free(working_line); |
| 356 |
+ |
return(ntokens); |
| 357 |
+ |
} |