| 1 |
mmeineke |
1095 |
#define _FILE_OFFSET_BITS 64 |
| 2 |
|
|
|
| 3 |
mmeineke |
60 |
#include <stdio.h> |
| 4 |
|
|
#include <stdlib.h> |
| 5 |
|
|
#include <string.h> |
| 6 |
|
|
#include <math.h> |
| 7 |
|
|
#include <unistd.h> |
| 8 |
|
|
#include <sys/types.h> |
| 9 |
|
|
#include <sys/stat.h> |
| 10 |
|
|
|
| 11 |
|
|
#include "frameCount.h" |
| 12 |
|
|
#include "atom_parser.h" |
| 13 |
|
|
#include "pov_writer.h" |
| 14 |
|
|
|
| 15 |
|
|
|
| 16 |
|
|
#define POV_DIR "./pov" |
| 17 |
|
|
|
| 18 |
mmeineke |
508 |
|
| 19 |
mmeineke |
60 |
struct linked_xyz{ |
| 20 |
|
|
struct coords *r; |
| 21 |
gezelter |
625 |
double Hmat[3][3]; |
| 22 |
mmeineke |
60 |
struct linked_xyz *next; |
| 23 |
|
|
}; |
| 24 |
|
|
|
| 25 |
|
|
char *program_name; /*the name of the program */ |
| 26 |
|
|
int draw_bonds = 0; /* boolean to draw bonds or not */ |
| 27 |
|
|
int draw_hydrogens = 0; /*boolean to draw hydrogens */ |
| 28 |
|
|
int draw_atoms = 0; /*boolean to draw atoms */ |
| 29 |
gezelter |
864 |
int draw_vectors = 0; /*boolean to draw vectors */ |
| 30 |
mmeineke |
515 |
int draw_box = 0; // boolean to draw the periodic Box |
| 31 |
mmeineke |
508 |
int regenerateBonds = 0; // boolean to regenearate bonds each frame |
| 32 |
mmeineke |
60 |
|
| 33 |
|
|
void usage(void); |
| 34 |
gezelter |
864 |
int count_tokens(char *line, char *delimiters); |
| 35 |
mmeineke |
60 |
|
| 36 |
|
|
int main(argc, argv) |
| 37 |
|
|
int argc; |
| 38 |
|
|
char *argv[]; |
| 39 |
|
|
{ |
| 40 |
|
|
|
| 41 |
|
|
|
| 42 |
|
|
struct coords *out_coords; |
| 43 |
|
|
|
| 44 |
gezelter |
625 |
int i,j,k; /* loop counters */ |
| 45 |
mmeineke |
60 |
mode_t dir_mode = S_IRWXU; |
| 46 |
|
|
|
| 47 |
|
|
int generate_header = 0; /* boolean for generating the pov ray header */ |
| 48 |
|
|
double big_x = 0; |
| 49 |
|
|
double big_y = 0; /* lets me know the biggest x y and z */ |
| 50 |
|
|
double big_z = 0; |
| 51 |
|
|
double small_x = 0; |
| 52 |
|
|
double small_y = 0; /* lets me know the smallest x, y, z */ |
| 53 |
|
|
double small_z = 0; |
| 54 |
gezelter |
864 |
int extremaSet = 0; |
| 55 |
mmeineke |
60 |
double rsqr; /* the square of the diagonal */ |
| 56 |
|
|
double diagonal; /* the diagonal length of the sim box */ |
| 57 |
|
|
|
| 58 |
|
|
unsigned int n_atoms; /*the number of atoms in each time step */ |
| 59 |
mmeineke |
649 |
char read_buffer[2000]; /*the line buffer for reading */ |
| 60 |
mmeineke |
60 |
char *eof_test; /*ptr to see when we reach the end of the file */ |
| 61 |
|
|
char *foo; /*the pointer to the current string token */ |
| 62 |
|
|
FILE *in_file; /* the input file */ |
| 63 |
|
|
FILE *out_file; /*the output file */ |
| 64 |
|
|
char *out_prefix = NULL; /*the prefix of the output file */ |
| 65 |
|
|
int have_prefix = 0; |
| 66 |
|
|
char out_name[500]; /*the output name */ |
| 67 |
|
|
char out_format[1000]; |
| 68 |
|
|
char *in_name = NULL; /*the name of the input file */ |
| 69 |
|
|
unsigned int n_out = 0; /*keeps track of which output file is being written*/ |
| 70 |
|
|
int done; |
| 71 |
|
|
char current_flag; |
| 72 |
|
|
int nFrames; |
| 73 |
|
|
int nZeroes; |
| 74 |
gezelter |
864 |
int nTokens; |
| 75 |
mmeineke |
60 |
double count; |
| 76 |
|
|
|
| 77 |
mmeineke |
515 |
int startFrame = 1; |
| 78 |
|
|
int endFrame; |
| 79 |
|
|
int span = 0; |
| 80 |
|
|
int currentCount = 0; |
| 81 |
|
|
int haveEnd = 0; |
| 82 |
|
|
|
| 83 |
mmeineke |
60 |
struct linked_xyz *current_frame; |
| 84 |
|
|
struct linked_xyz *temp_frame; |
| 85 |
|
|
|
| 86 |
|
|
unsigned int n_interpolate = 0; /* number of frames to interpolate */ |
| 87 |
|
|
double dx, dy, dz; /* temp variables for interpolating distances */ |
| 88 |
gezelter |
625 |
double dm[3][3]; |
| 89 |
mmeineke |
515 |
|
| 90 |
mmeineke |
60 |
|
| 91 |
|
|
char pov_dir[500]; /* the pov_dir */ |
| 92 |
|
|
|
| 93 |
|
|
program_name = argv[0]; /*save the program name in case we need it*/ |
| 94 |
|
|
|
| 95 |
mmeineke |
508 |
|
| 96 |
mmeineke |
60 |
for( i = 1; i < argc; i++){ |
| 97 |
|
|
|
| 98 |
|
|
if(argv[i][0] =='-'){ |
| 99 |
|
|
|
| 100 |
|
|
// parse the option |
| 101 |
|
|
|
| 102 |
|
|
if(argv[i][1] == '-' ){ |
| 103 |
|
|
|
| 104 |
|
|
// parse long word options |
| 105 |
|
|
|
| 106 |
|
|
fprintf( stderr, |
| 107 |
|
|
"Invalid option \"%s\"\n", argv[i] ); |
| 108 |
|
|
usage(); |
| 109 |
|
|
|
| 110 |
|
|
} |
| 111 |
|
|
|
| 112 |
|
|
else{ |
| 113 |
|
|
|
| 114 |
|
|
// parse single character options |
| 115 |
|
|
|
| 116 |
|
|
done = 0; |
| 117 |
|
|
j = 1; |
| 118 |
|
|
current_flag = argv[i][j]; |
| 119 |
|
|
while( (current_flag != '\0') && (!done) ){ |
| 120 |
|
|
|
| 121 |
|
|
switch(current_flag){ |
| 122 |
|
|
|
| 123 |
|
|
case 'o': |
| 124 |
|
|
// -o <prefix> => the output prefix. |
| 125 |
|
|
|
| 126 |
|
|
i++; |
| 127 |
|
|
out_prefix = argv[i]; |
| 128 |
|
|
have_prefix = 1; |
| 129 |
|
|
done = 1; |
| 130 |
|
|
break; |
| 131 |
|
|
|
| 132 |
|
|
case 'i': |
| 133 |
|
|
// -i <#> => the number to interpolate |
| 134 |
|
|
|
| 135 |
|
|
i++; |
| 136 |
|
|
n_interpolate = atoi( argv[i] ); |
| 137 |
|
|
done = 1; |
| 138 |
|
|
break; |
| 139 |
|
|
|
| 140 |
mmeineke |
515 |
case 'f': |
| 141 |
|
|
// -f <#> => frame to render |
| 142 |
|
|
|
| 143 |
|
|
i++; |
| 144 |
|
|
startFrame = atoi( argv[i] ); |
| 145 |
|
|
endFrame = startFrame; |
| 146 |
|
|
haveEnd = 1; |
| 147 |
|
|
done = 1; |
| 148 |
|
|
break; |
| 149 |
|
|
|
| 150 |
|
|
case 's': |
| 151 |
|
|
// -s <#> => frame to start |
| 152 |
|
|
|
| 153 |
|
|
i++; |
| 154 |
|
|
startFrame = atoi( argv[i] ); |
| 155 |
|
|
done = 1; |
| 156 |
|
|
break; |
| 157 |
|
|
|
| 158 |
|
|
case 'e': |
| 159 |
|
|
// -e <#> => frame to end |
| 160 |
|
|
|
| 161 |
|
|
i++; |
| 162 |
|
|
endFrame = atoi( argv[i] ); |
| 163 |
|
|
haveEnd = 1; |
| 164 |
|
|
done = 1; |
| 165 |
|
|
break; |
| 166 |
|
|
|
| 167 |
mmeineke |
60 |
case 'H': |
| 168 |
|
|
// -h => generate a pov-ray Header |
| 169 |
|
|
|
| 170 |
|
|
generate_header = 1; |
| 171 |
|
|
break; |
| 172 |
|
|
|
| 173 |
|
|
case 'h': |
| 174 |
|
|
// -h => draw Hydrogens |
| 175 |
|
|
|
| 176 |
|
|
draw_hydrogens = 1; |
| 177 |
|
|
break; |
| 178 |
|
|
|
| 179 |
|
|
case 'b': |
| 180 |
|
|
// -b => draw bonds |
| 181 |
|
|
|
| 182 |
|
|
draw_bonds = 1; |
| 183 |
|
|
break; |
| 184 |
|
|
|
| 185 |
|
|
case 'a': |
| 186 |
|
|
// -a => draw the atoms |
| 187 |
|
|
|
| 188 |
|
|
draw_atoms = 1; |
| 189 |
|
|
break; |
| 190 |
|
|
|
| 191 |
gezelter |
864 |
case 'v': |
| 192 |
|
|
// -v => draw the vectors |
| 193 |
|
|
|
| 194 |
|
|
draw_vectors = 1; |
| 195 |
|
|
break; |
| 196 |
|
|
|
| 197 |
mmeineke |
508 |
case 'r': |
| 198 |
|
|
// -r => regenerate bonds |
| 199 |
|
|
|
| 200 |
|
|
regenerateBonds = 1; |
| 201 |
|
|
break; |
| 202 |
|
|
|
| 203 |
mmeineke |
515 |
case 'p': |
| 204 |
|
|
// -r => draw periodic box |
| 205 |
|
|
|
| 206 |
|
|
draw_box = 1; |
| 207 |
|
|
break; |
| 208 |
|
|
|
| 209 |
mmeineke |
60 |
default: |
| 210 |
|
|
|
| 211 |
|
|
(void)fprintf(stderr, "Bad option \"-%c\"\n", current_flag); |
| 212 |
|
|
usage(); |
| 213 |
|
|
} |
| 214 |
|
|
j++; |
| 215 |
|
|
current_flag = argv[i][j]; |
| 216 |
|
|
} |
| 217 |
|
|
} |
| 218 |
|
|
} |
| 219 |
|
|
|
| 220 |
|
|
else{ |
| 221 |
|
|
|
| 222 |
|
|
if( in_name != NULL ){ |
| 223 |
|
|
fprintf( stderr, |
| 224 |
|
|
"Error at \"%s\", program does not currently support\n" |
| 225 |
|
|
"more than one input file.\n" |
| 226 |
|
|
"\n", |
| 227 |
|
|
argv[i]); |
| 228 |
|
|
usage(); |
| 229 |
|
|
} |
| 230 |
|
|
|
| 231 |
|
|
in_name = argv[i]; |
| 232 |
|
|
} |
| 233 |
|
|
} |
| 234 |
|
|
|
| 235 |
|
|
if(in_name == NULL){ |
| 236 |
|
|
usage(); |
| 237 |
|
|
} |
| 238 |
|
|
|
| 239 |
|
|
|
| 240 |
|
|
|
| 241 |
|
|
in_file = fopen(in_name, "r"); |
| 242 |
|
|
if(in_file == NULL){ |
| 243 |
|
|
printf("Cannot open file: %s\n", in_name); |
| 244 |
|
|
exit(8); |
| 245 |
|
|
} |
| 246 |
|
|
|
| 247 |
|
|
|
| 248 |
|
|
|
| 249 |
|
|
if(access(POV_DIR, F_OK)){ |
| 250 |
|
|
/*create the pov directory*/ |
| 251 |
|
|
mkdir(POV_DIR, dir_mode); |
| 252 |
|
|
} |
| 253 |
|
|
strcpy(pov_dir, POV_DIR); strcat(pov_dir, "/"); |
| 254 |
|
|
|
| 255 |
|
|
|
| 256 |
|
|
// initialize atom type parser |
| 257 |
|
|
|
| 258 |
|
|
initializeParser(); |
| 259 |
mmeineke |
508 |
initBondList(); |
| 260 |
mmeineke |
60 |
|
| 261 |
|
|
// count the number of frames |
| 262 |
|
|
|
| 263 |
|
|
printf( "Counting the number of frames..." ); |
| 264 |
|
|
fflush(stdout); |
| 265 |
|
|
|
| 266 |
|
|
nFrames = frameCount( in_name ); |
| 267 |
|
|
|
| 268 |
|
|
printf( "done.\n" |
| 269 |
|
|
"%d frames found\n", |
| 270 |
|
|
nFrames); |
| 271 |
|
|
fflush(stdout); |
| 272 |
|
|
|
| 273 |
|
|
// create the output string |
| 274 |
|
|
|
| 275 |
|
|
nZeroes = 1; |
| 276 |
|
|
count = (double)( nFrames * (n_interpolate+1) ); |
| 277 |
|
|
while( count >= 10.0 ){ |
| 278 |
|
|
count /= 10.0; |
| 279 |
|
|
nZeroes++; |
| 280 |
|
|
} |
| 281 |
|
|
|
| 282 |
|
|
if(!have_prefix){ |
| 283 |
|
|
out_prefix = strtok(in_name, "."); |
| 284 |
|
|
} |
| 285 |
|
|
|
| 286 |
mmeineke |
649 |
sprintf( out_format, "%s%s-%%0%dd.pov", pov_dir, out_prefix, nZeroes ); |
| 287 |
mmeineke |
60 |
|
| 288 |
|
|
// start reading the first frame |
| 289 |
|
|
|
| 290 |
|
|
eof_test = fgets(read_buffer, sizeof(read_buffer), in_file); |
| 291 |
|
|
|
| 292 |
|
|
current_frame = (struct linked_xyz *)malloc(sizeof(struct linked_xyz)); |
| 293 |
|
|
current_frame->next = NULL; |
| 294 |
|
|
|
| 295 |
|
|
|
| 296 |
mmeineke |
515 |
if( haveEnd ) span = endFrame - startFrame; |
| 297 |
|
|
done = 0; |
| 298 |
|
|
if( span < 0 ) done = 1; |
| 299 |
|
|
while( (eof_test != NULL) && !done ){ |
| 300 |
mmeineke |
60 |
|
| 301 |
|
|
(void)sscanf(read_buffer, "%d", &n_atoms); |
| 302 |
|
|
current_frame->r = |
| 303 |
|
|
(struct coords *)calloc(n_atoms, sizeof(struct coords)); |
| 304 |
|
|
|
| 305 |
|
|
/*read and toss the comment line */ |
| 306 |
|
|
|
| 307 |
|
|
eof_test = fgets(read_buffer, sizeof(read_buffer), in_file); |
| 308 |
|
|
if(eof_test == NULL){ |
| 309 |
|
|
printf("error in reading file\n"); |
| 310 |
|
|
exit(8); |
| 311 |
|
|
} |
| 312 |
mmeineke |
515 |
|
| 313 |
|
|
// unless we need to get the box size |
| 314 |
|
|
|
| 315 |
|
|
if( draw_box ){ |
| 316 |
|
|
foo = strtok(read_buffer, " ,;\t"); |
| 317 |
|
|
if(foo == NULL){ |
| 318 |
mmeineke |
649 |
printf("error in reading file time\n"); |
| 319 |
mmeineke |
515 |
exit(8); |
| 320 |
|
|
} |
| 321 |
|
|
|
| 322 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 323 |
|
|
if(foo == NULL){ |
| 324 |
mmeineke |
649 |
printf("error in reading file h00\n"); |
| 325 |
mmeineke |
515 |
exit(8); |
| 326 |
|
|
} |
| 327 |
gezelter |
625 |
current_frame->Hmat[0][0] = atof( foo ); |
| 328 |
mmeineke |
60 |
|
| 329 |
mmeineke |
515 |
foo = strtok(NULL, " ,;\t"); |
| 330 |
|
|
if(foo == NULL){ |
| 331 |
mmeineke |
649 |
printf("error in reading file h10\n"); |
| 332 |
mmeineke |
515 |
exit(8); |
| 333 |
|
|
} |
| 334 |
gezelter |
625 |
current_frame->Hmat[1][0] = atof( foo ); |
| 335 |
mmeineke |
515 |
|
| 336 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 337 |
|
|
if(foo == NULL){ |
| 338 |
mmeineke |
649 |
printf("error in reading file h20\n"); |
| 339 |
mmeineke |
515 |
exit(8); |
| 340 |
|
|
} |
| 341 |
gezelter |
625 |
current_frame->Hmat[2][0] = atof( foo ); |
| 342 |
|
|
|
| 343 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 344 |
|
|
if(foo == NULL){ |
| 345 |
mmeineke |
649 |
printf("error in reading file h01\n"); |
| 346 |
gezelter |
625 |
exit(8); |
| 347 |
|
|
} |
| 348 |
|
|
current_frame->Hmat[0][1] = atof( foo ); |
| 349 |
|
|
|
| 350 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 351 |
|
|
if(foo == NULL){ |
| 352 |
mmeineke |
649 |
printf("error in reading file h11\n"); |
| 353 |
gezelter |
625 |
exit(8); |
| 354 |
|
|
} |
| 355 |
|
|
current_frame->Hmat[1][1] = atof( foo ); |
| 356 |
|
|
|
| 357 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 358 |
|
|
if(foo == NULL){ |
| 359 |
mmeineke |
649 |
printf("error in reading file h21\n"); |
| 360 |
gezelter |
625 |
exit(8); |
| 361 |
|
|
} |
| 362 |
|
|
current_frame->Hmat[2][1] = atof( foo ); |
| 363 |
|
|
|
| 364 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 365 |
|
|
if(foo == NULL){ |
| 366 |
mmeineke |
649 |
printf("error in reading file h02\n"); |
| 367 |
gezelter |
625 |
exit(8); |
| 368 |
|
|
} |
| 369 |
|
|
current_frame->Hmat[0][2] = atof( foo ); |
| 370 |
|
|
|
| 371 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 372 |
|
|
if(foo == NULL){ |
| 373 |
mmeineke |
649 |
printf("error in reading file h12\n"); |
| 374 |
gezelter |
625 |
exit(8); |
| 375 |
|
|
} |
| 376 |
|
|
current_frame->Hmat[1][2] = atof( foo ); |
| 377 |
|
|
|
| 378 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 379 |
|
|
if(foo == NULL){ |
| 380 |
mmeineke |
649 |
printf("error in reading file h22\n"); |
| 381 |
gezelter |
625 |
exit(8); |
| 382 |
|
|
} |
| 383 |
|
|
current_frame->Hmat[2][2] = atof( foo ); |
| 384 |
|
|
|
| 385 |
mmeineke |
515 |
} |
| 386 |
|
|
|
| 387 |
mmeineke |
60 |
for( i=0; i < n_atoms; i++){ |
| 388 |
|
|
|
| 389 |
|
|
eof_test = fgets(read_buffer, sizeof(read_buffer), in_file); |
| 390 |
|
|
if(eof_test == NULL){ |
| 391 |
mmeineke |
649 |
printf("error in reading file line at atom %d\n", i); |
| 392 |
mmeineke |
60 |
exit(8); |
| 393 |
|
|
} |
| 394 |
|
|
|
| 395 |
gezelter |
864 |
nTokens = count_tokens(read_buffer, " ,;\t"); |
| 396 |
|
|
|
| 397 |
|
|
if (nTokens < 4) { |
| 398 |
|
|
printf("Not enough tokens while parsing file at atom %d\n", i); |
| 399 |
|
|
exit(8); |
| 400 |
|
|
} |
| 401 |
|
|
|
| 402 |
mmeineke |
60 |
foo = strtok(read_buffer, " ,;\t"); |
| 403 |
|
|
(void)strcpy(current_frame->r[i].name, foo); /*copy the atom name */ |
| 404 |
|
|
|
| 405 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 406 |
|
|
(void)sscanf(foo, "%lf",¤t_frame->r[i].x); |
| 407 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 408 |
|
|
(void)sscanf(foo, "%lf", ¤t_frame->r[i].y); |
| 409 |
gezelter |
864 |
foo = strtok(NULL, " ,;\t"); |
| 410 |
|
|
(void)sscanf(foo, "%lf", ¤t_frame->r[i].z); |
| 411 |
mmeineke |
60 |
|
| 412 |
gezelter |
864 |
if (extremaSet) { |
| 413 |
|
|
if(current_frame->r[i].x > big_x) big_x = current_frame->r[i].x; |
| 414 |
|
|
if(current_frame->r[i].x < small_x) small_x = current_frame->r[i].x; |
| 415 |
|
|
|
| 416 |
|
|
if(current_frame->r[i].y > big_y) big_y = current_frame->r[i].y; |
| 417 |
|
|
if(current_frame->r[i].y < small_y) small_y = current_frame->r[i].y; |
| 418 |
|
|
|
| 419 |
|
|
if(current_frame->r[i].z > big_z) big_z = current_frame->r[i].z; |
| 420 |
|
|
if(current_frame->r[i].z < small_z) small_z = current_frame->r[i].z; |
| 421 |
|
|
} else { |
| 422 |
|
|
big_x = current_frame->r[i].x; |
| 423 |
|
|
small_x = current_frame->r[i].x; |
| 424 |
|
|
|
| 425 |
|
|
big_y = current_frame->r[i].y; |
| 426 |
|
|
small_y = current_frame->r[i].y; |
| 427 |
|
|
|
| 428 |
|
|
big_z = current_frame->r[i].z; |
| 429 |
|
|
small_z = current_frame->r[i].z; |
| 430 |
mmeineke |
60 |
|
| 431 |
gezelter |
864 |
extremaSet = 1; |
| 432 |
|
|
|
| 433 |
mmeineke |
60 |
} |
| 434 |
|
|
|
| 435 |
gezelter |
864 |
if (nTokens == 5 || nTokens > 7) { |
| 436 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 437 |
|
|
(void)sscanf(foo, "%lf", ¤t_frame->r[i].charge); |
| 438 |
|
|
current_frame->r[i].hasCharge = 1; |
| 439 |
|
|
} else { |
| 440 |
|
|
current_frame->r[i].hasCharge = 0; |
| 441 |
|
|
} |
| 442 |
|
|
|
| 443 |
|
|
|
| 444 |
|
|
if (nTokens >= 7) { |
| 445 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 446 |
|
|
(void)sscanf(foo, "%lf", ¤t_frame->r[i].ux); |
| 447 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 448 |
|
|
(void)sscanf(foo, "%lf", ¤t_frame->r[i].uy); |
| 449 |
|
|
foo = strtok(NULL, " ,;\t"); |
| 450 |
|
|
(void)sscanf(foo, "%lf", ¤t_frame->r[i].uz); |
| 451 |
|
|
current_frame->r[i].hasVector = 1; |
| 452 |
|
|
} else { |
| 453 |
|
|
current_frame->r[i].hasVector = 0; |
| 454 |
|
|
} |
| 455 |
mmeineke |
60 |
} |
| 456 |
mmeineke |
515 |
currentCount++; |
| 457 |
mmeineke |
60 |
|
| 458 |
mmeineke |
515 |
|
| 459 |
|
|
if( currentCount >= startFrame ){ |
| 460 |
|
|
if(n_interpolate && current_frame->next != NULL){ |
| 461 |
mmeineke |
60 |
|
| 462 |
mmeineke |
515 |
temp_frame = current_frame->next; |
| 463 |
mmeineke |
60 |
|
| 464 |
mmeineke |
515 |
for(i = 0; i < n_interpolate; i++){ |
| 465 |
|
|
|
| 466 |
|
|
/* open the new output file */ |
| 467 |
|
|
|
| 468 |
|
|
sprintf(out_name, out_format, currentCount ); |
| 469 |
|
|
out_file = fopen(out_name, "w"); |
| 470 |
|
|
currentCount++; |
| 471 |
|
|
if(out_file == NULL){ |
| 472 |
|
|
printf("error opening output file: %s\n", out_name); |
| 473 |
|
|
exit(8); |
| 474 |
|
|
} |
| 475 |
|
|
(void)fprintf(out_file, |
| 476 |
|
|
"// The following script was automatically generated by:\n" |
| 477 |
|
|
"// xyz2pov Copyright 2001 by MATTHEW A. MEINEKE\n" |
| 478 |
|
|
"\n" |
| 479 |
|
|
"#include \"pov_header.pov\"\n" |
| 480 |
|
|
"\n"); |
| 481 |
|
|
if( draw_box ){ |
| 482 |
gezelter |
625 |
|
| 483 |
|
|
for (j = 0; j < 3; j++) { |
| 484 |
|
|
for (k = 0; k < 3; k++) { |
| 485 |
|
|
dm[j][k] = current_frame->Hmat[j][k] - temp_frame->Hmat[j][k]; |
| 486 |
|
|
dm[j][k] /= (double)(n_interpolate + 1); |
| 487 |
|
|
} |
| 488 |
|
|
} |
| 489 |
|
|
|
| 490 |
mmeineke |
515 |
fprintf( out_file, |
| 491 |
gezelter |
625 |
"makePeriodicBox( %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf)\n" |
| 492 |
mmeineke |
515 |
"\n", |
| 493 |
gezelter |
625 |
temp_frame->Hmat[0][0] + dm[0][0] * (i+1), |
| 494 |
mmeineke |
629 |
temp_frame->Hmat[2][0] + dm[2][0] * (i+1), |
| 495 |
gezelter |
625 |
temp_frame->Hmat[1][0] + dm[1][0] * (i+1), |
| 496 |
|
|
temp_frame->Hmat[0][1] + dm[0][1] * (i+1), |
| 497 |
mmeineke |
629 |
temp_frame->Hmat[2][1] + dm[2][1] * (i+1), |
| 498 |
gezelter |
625 |
temp_frame->Hmat[1][1] + dm[1][1] * (i+1), |
| 499 |
|
|
temp_frame->Hmat[0][2] + dm[0][2] * (i+1), |
| 500 |
mmeineke |
629 |
temp_frame->Hmat[2][2] + dm[2][2] * (i+1), |
| 501 |
|
|
temp_frame->Hmat[1][2] + dm[1][2] * (i+1) ); |
| 502 |
mmeineke |
515 |
} |
| 503 |
|
|
|
| 504 |
|
|
|
| 505 |
|
|
out_coords = |
| 506 |
|
|
(struct coords *)calloc(n_atoms, sizeof(struct coords)); |
| 507 |
|
|
|
| 508 |
|
|
for(j=0; j < n_atoms; j++){ |
| 509 |
|
|
dx = current_frame->r[j].x - temp_frame->r[j].x; |
| 510 |
|
|
dy = current_frame->r[j].y - temp_frame->r[j].y; |
| 511 |
|
|
dz = current_frame->r[j].z - temp_frame->r[j].z; |
| 512 |
|
|
|
| 513 |
|
|
dx /= (double)(n_interpolate + 1); |
| 514 |
|
|
dy /= (double)(n_interpolate + 1); |
| 515 |
|
|
dz /= (double)(n_interpolate + 1); |
| 516 |
|
|
|
| 517 |
|
|
strcpy(out_coords[j].name, temp_frame->r[j].name); |
| 518 |
|
|
out_coords[j].x = temp_frame->r[j].x + dx * (i+1); |
| 519 |
|
|
out_coords[j].y = temp_frame->r[j].y + dy * (i+1); |
| 520 |
|
|
out_coords[j].z = temp_frame->r[j].z + dz * (i+1); |
| 521 |
gezelter |
864 |
|
| 522 |
|
|
if (current_frame->r[j].hasVector) { |
| 523 |
|
|
dx = current_frame->r[j].ux - temp_frame->r[j].ux; |
| 524 |
|
|
dy = current_frame->r[j].uy - temp_frame->r[j].uy; |
| 525 |
|
|
dz = current_frame->r[j].uz - temp_frame->r[j].uz; |
| 526 |
|
|
|
| 527 |
|
|
dx /= (double)(n_interpolate + 1); |
| 528 |
|
|
dy /= (double)(n_interpolate + 1); |
| 529 |
|
|
dz /= (double)(n_interpolate + 1); |
| 530 |
|
|
|
| 531 |
|
|
out_coords[j].hasVector = current_frame->r[j].hasVector; |
| 532 |
|
|
out_coords[j].ux = temp_frame->r[j].ux + dx * (i+1); |
| 533 |
|
|
out_coords[j].uy = temp_frame->r[j].uy + dy * (i+1); |
| 534 |
|
|
out_coords[j].uz = temp_frame->r[j].uz + dz * (i+1); |
| 535 |
|
|
} |
| 536 |
|
|
|
| 537 |
|
|
if (current_frame->r[j].hasCharge) { |
| 538 |
|
|
dx = current_frame->r[j].charge - temp_frame->r[j].charge; |
| 539 |
|
|
|
| 540 |
|
|
dx /= (double)(n_interpolate + 1); |
| 541 |
|
|
|
| 542 |
|
|
out_coords[j].hasCharge = current_frame->r[j].hasCharge; |
| 543 |
|
|
out_coords[j].charge = temp_frame->r[j].charge + dx * (i+1); |
| 544 |
|
|
} |
| 545 |
|
|
|
| 546 |
mmeineke |
515 |
} |
| 547 |
|
|
|
| 548 |
|
|
pov_write(out_file, out_coords, n_atoms, draw_hydrogens, draw_bonds, |
| 549 |
gezelter |
864 |
draw_atoms, draw_vectors); |
| 550 |
mmeineke |
515 |
free(out_coords); |
| 551 |
|
|
(void)fclose(out_file); |
| 552 |
mmeineke |
60 |
} |
| 553 |
mmeineke |
515 |
} |
| 554 |
|
|
|
| 555 |
|
|
/* open the new output file */ |
| 556 |
|
|
|
| 557 |
|
|
sprintf(out_name, out_format, currentCount ); |
| 558 |
|
|
out_file = fopen(out_name, "w"); |
| 559 |
|
|
if(out_file == NULL){ |
| 560 |
|
|
printf("error opening output file: %s\n", out_name); |
| 561 |
|
|
exit(8); |
| 562 |
|
|
} |
| 563 |
|
|
(void)fprintf(out_file, |
| 564 |
|
|
"// The following script was automatically generated by:\n" |
| 565 |
|
|
"// xyz2pov Copyright 2001 by MATTHEW A. MEINEKE\n" |
| 566 |
|
|
"\n" |
| 567 |
|
|
"#include \"pov_header.pov\"\n" |
| 568 |
|
|
"\n"); |
| 569 |
|
|
|
| 570 |
|
|
if( draw_box ){ |
| 571 |
mmeineke |
60 |
|
| 572 |
mmeineke |
515 |
fprintf( out_file, |
| 573 |
gezelter |
630 |
"makePeriodicBox( %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf )\n" |
| 574 |
mmeineke |
515 |
"\n", |
| 575 |
gezelter |
625 |
current_frame->Hmat[0][0], |
| 576 |
mmeineke |
629 |
current_frame->Hmat[2][0], |
| 577 |
gezelter |
625 |
current_frame->Hmat[1][0], |
| 578 |
|
|
current_frame->Hmat[0][1], |
| 579 |
mmeineke |
629 |
current_frame->Hmat[2][1], |
| 580 |
gezelter |
625 |
current_frame->Hmat[1][1], |
| 581 |
|
|
current_frame->Hmat[0][2], |
| 582 |
mmeineke |
629 |
current_frame->Hmat[2][2], |
| 583 |
|
|
current_frame->Hmat[1][2] ); |
| 584 |
mmeineke |
60 |
} |
| 585 |
mmeineke |
515 |
|
| 586 |
|
|
|
| 587 |
|
|
|
| 588 |
|
|
out_coords = |
| 589 |
|
|
(struct coords *)calloc(n_atoms, sizeof(struct coords)); |
| 590 |
|
|
|
| 591 |
|
|
for(i = 0; i < n_atoms; i++){ |
| 592 |
|
|
strcpy(out_coords[i].name, current_frame->r[i].name); |
| 593 |
|
|
out_coords[i].x = current_frame->r[i].x; |
| 594 |
|
|
out_coords[i].y = current_frame->r[i].y; |
| 595 |
|
|
out_coords[i].z = current_frame->r[i].z; |
| 596 |
gezelter |
864 |
|
| 597 |
|
|
if (current_frame->r[i].hasVector) { |
| 598 |
|
|
out_coords[i].hasVector = current_frame->r[i].hasVector; |
| 599 |
|
|
out_coords[i].ux = current_frame->r[i].ux; |
| 600 |
|
|
out_coords[i].uy = current_frame->r[i].uy; |
| 601 |
|
|
out_coords[i].uz = current_frame->r[i].uz; |
| 602 |
|
|
} |
| 603 |
|
|
|
| 604 |
|
|
if (current_frame->r[i].hasCharge) { |
| 605 |
|
|
out_coords[i].hasCharge = current_frame->r[i].hasCharge; |
| 606 |
|
|
out_coords[i].charge = current_frame->r[i].charge; |
| 607 |
|
|
} |
| 608 |
mmeineke |
515 |
} |
| 609 |
|
|
pov_write(out_file, out_coords, n_atoms, draw_hydrogens, draw_bonds, |
| 610 |
gezelter |
864 |
draw_atoms, draw_vectors); |
| 611 |
mmeineke |
515 |
free(out_coords); |
| 612 |
|
|
|
| 613 |
|
|
(void)fclose(out_file); |
| 614 |
mmeineke |
60 |
} |
| 615 |
|
|
|
| 616 |
|
|
/*free up memory */ |
| 617 |
|
|
|
| 618 |
|
|
temp_frame = current_frame->next; |
| 619 |
|
|
current_frame->next = NULL; |
| 620 |
|
|
|
| 621 |
|
|
if(temp_frame != NULL){ |
| 622 |
|
|
|
| 623 |
|
|
free(temp_frame->r); |
| 624 |
|
|
free(temp_frame); |
| 625 |
|
|
} |
| 626 |
|
|
|
| 627 |
|
|
/* make a new frame */ |
| 628 |
|
|
|
| 629 |
|
|
temp_frame = (struct linked_xyz *)malloc(sizeof(struct linked_xyz)); |
| 630 |
|
|
temp_frame->next = current_frame; |
| 631 |
|
|
current_frame = temp_frame; |
| 632 |
|
|
|
| 633 |
|
|
eof_test = fgets(read_buffer, sizeof(read_buffer), in_file); |
| 634 |
|
|
|
| 635 |
mmeineke |
515 |
if( haveEnd ){ |
| 636 |
|
|
if( currentCount >= (endFrame + n_interpolate * span) ) done = 1; |
| 637 |
|
|
} |
| 638 |
mmeineke |
60 |
} |
| 639 |
|
|
|
| 640 |
|
|
(void)fclose(in_file); |
| 641 |
|
|
|
| 642 |
|
|
|
| 643 |
|
|
if(generate_header){ |
| 644 |
|
|
|
| 645 |
|
|
dx = big_x - small_x; |
| 646 |
|
|
dy = big_y - small_y; |
| 647 |
|
|
dz = big_z - small_z; |
| 648 |
|
|
|
| 649 |
|
|
rsqr = dx * dx + dy * dy + dz * dz; |
| 650 |
|
|
diagonal = sqrt(rsqr); |
| 651 |
|
|
diagonal *= 0.5; |
| 652 |
|
|
|
| 653 |
mmeineke |
515 |
// calculate the center |
| 654 |
|
|
|
| 655 |
|
|
dx = big_x + small_x; |
| 656 |
|
|
dy = big_y + small_y; |
| 657 |
|
|
dz = big_z + small_z; |
| 658 |
|
|
|
| 659 |
mmeineke |
60 |
dx /= 2.0; |
| 660 |
|
|
dy /= 2.0; |
| 661 |
|
|
dz /= 2.0; |
| 662 |
mmeineke |
515 |
|
| 663 |
mmeineke |
60 |
|
| 664 |
|
|
/*note the y and z axis is exchanged for the different coordinate |
| 665 |
|
|
system in pov-ray*/ |
| 666 |
|
|
|
| 667 |
|
|
|
| 668 |
|
|
out_file = fopen("pov_header.pov", "w"); |
| 669 |
|
|
|
| 670 |
|
|
fprintf(out_file, |
| 671 |
|
|
"// The following script was automatically generated by:\n" |
| 672 |
|
|
"// xyz2pov Copyright 2001 by MATTHEW A. MEINEKE\n" |
| 673 |
|
|
"\n" |
| 674 |
|
|
"\n" |
| 675 |
|
|
"background { rgb <1.0, 1.0, 1.0> }\n" |
| 676 |
|
|
"\n" |
| 677 |
|
|
"\n" |
| 678 |
|
|
); |
| 679 |
|
|
|
| 680 |
|
|
fprintf(out_file, |
| 681 |
|
|
"//******************************************************\n" |
| 682 |
|
|
"// Declare the resolution, camera, and light sources.\n" |
| 683 |
|
|
"//******************************************************\n" |
| 684 |
|
|
"\n" |
| 685 |
|
|
"// NOTE: if you plan to render at a different resoltion,\n" |
| 686 |
|
|
"// be sure to update the following two lines to maintain\n" |
| 687 |
|
|
"// the correct aspect ratio.\n" |
| 688 |
|
|
"\n" |
| 689 |
|
|
"#declare Width = 640.0;\n" |
| 690 |
|
|
"#declare Height = 480.0;\n" |
| 691 |
|
|
"#declare Ratio = Width / Height;\n" |
| 692 |
|
|
"\n" |
| 693 |
|
|
"#declare ATOM_SPHERE_FACTOR = 0.2;\n" |
| 694 |
|
|
"#declare BOND_RADIUS = 0.1;\n" |
| 695 |
gezelter |
864 |
"#declare VECTOR_SCALE = 1.0;\n" |
| 696 |
|
|
"#declare STICK_RADIUS = 0.5 * BOND_RADIUS;\n" |
| 697 |
|
|
"#declare CONE_RADIUS = 2.0 * STICK_RADIUS;\n" |
| 698 |
|
|
"#declare CONE_FRACTION = 0.15;\n" |
| 699 |
mmeineke |
60 |
"\n" |
| 700 |
mmeineke |
515 |
"// declare camera, light, and system variables\n" |
| 701 |
|
|
"\n" |
| 702 |
|
|
"#declare sysCenterX = %lf;\n" |
| 703 |
|
|
"#declare sysCenterY = %lf;\n" |
| 704 |
|
|
"#declare sysCenterZ = %lf;\n" |
| 705 |
|
|
"\n" |
| 706 |
|
|
"#declare zoom = %lf;\n" |
| 707 |
|
|
"\n", |
| 708 |
|
|
dx, dz, dy, |
| 709 |
|
|
diagonal ); |
| 710 |
|
|
|
| 711 |
|
|
fprintf(out_file, |
| 712 |
|
|
"#declare cameraLookX = sysCenterX;\n" |
| 713 |
|
|
"#declare cameraLookY = sysCenterY;\n" |
| 714 |
|
|
"#declare cameraLookZ = sysCenterZ;\n" |
| 715 |
|
|
"\n" |
| 716 |
gezelter |
868 |
"#declare rotatePointX = cameraLookX;\n" |
| 717 |
|
|
"#declare rotatePointY = cameraLookY;\n" |
| 718 |
|
|
"#declare rotatePointZ = cameraLookZ;\n" |
| 719 |
|
|
"\n" |
| 720 |
mmeineke |
515 |
"#declare cameraX = cameraLookX;\n" |
| 721 |
|
|
"#declare cameraY = cameraLookY;\n" |
| 722 |
|
|
"#declare cameraZ = cameraLookZ - zoom;\n" |
| 723 |
|
|
"\n" |
| 724 |
|
|
"#declare lightAx = cameraX;\n" |
| 725 |
|
|
"#declare lightAy = cameraY;\n" |
| 726 |
|
|
"#declare lightAz = cameraZ;\n" |
| 727 |
|
|
"\n" |
| 728 |
|
|
"#declare lightBx = cameraX - zoom;\n" |
| 729 |
|
|
"#declare lightBy = cameraY + zoom;\n" |
| 730 |
|
|
"#declare lightBz = cameraZ;\n" |
| 731 |
|
|
"\n" |
| 732 |
|
|
"#declare boxCenterX = cameraLookX;\n" |
| 733 |
|
|
"#declare boxCenterY = cameraLookY;\n" |
| 734 |
|
|
"#declare boxCenterZ = cameraLookZ;\n" |
| 735 |
|
|
"\n" |
| 736 |
|
|
"// declare the cameras and the light sources\n" |
| 737 |
|
|
"\n" |
| 738 |
mmeineke |
60 |
"camera{\n" |
| 739 |
mmeineke |
515 |
" location < cameraX, cameraY, cameraZ>\n" |
| 740 |
mmeineke |
60 |
" right < Ratio , 0, 0>\n" |
| 741 |
mmeineke |
515 |
" look_at < cameraLookX, cameraLookY, cameraLookZ >\n" |
| 742 |
mmeineke |
60 |
"}\n" |
| 743 |
mmeineke |
515 |
"\n" |
| 744 |
mmeineke |
60 |
"light_source{\n" |
| 745 |
mmeineke |
515 |
" < lightAx, lightAy, lightAz >\n" |
| 746 |
|
|
" rgb < 1.0, 1.0, 1.0 > }\n" |
| 747 |
|
|
"\n" |
| 748 |
mmeineke |
60 |
"light_source{\n" |
| 749 |
mmeineke |
515 |
" < lightBx, lightBy, lightBz >\n" |
| 750 |
mmeineke |
60 |
" rgb < 1.0, 1.0, 1.0 > }\n" |
| 751 |
|
|
"\n" |
| 752 |
mmeineke |
515 |
"\n" |
| 753 |
mmeineke |
60 |
"//************************************************************\n" |
| 754 |
|
|
"// Set whether or not to rotate the system.\n" |
| 755 |
|
|
"//\n" |
| 756 |
|
|
"// To Rotate, set ROTATE to 1.0 (true),\n" |
| 757 |
|
|
"// Then set the Euler Angles PHI, THETA, and PSI in degrees.\n" |
| 758 |
|
|
"//************************************************************\n" |
| 759 |
|
|
"\n" |
| 760 |
|
|
"#declare ROTATE = 0.0;\n" |
| 761 |
|
|
"#declare PHI = 0.0;\n" |
| 762 |
|
|
"#declare THETA = 0.0;\n" |
| 763 |
|
|
"#declare PSI = 0.0;\n" |
| 764 |
|
|
"\n" |
| 765 |
|
|
"#if(ROTATE)\n" |
| 766 |
|
|
" #declare phi_r = radians(PHI);\n" |
| 767 |
|
|
" #declare theta_r = radians(THETA);\n" |
| 768 |
|
|
" #declare psi_r = radians(PSI);\n" |
| 769 |
|
|
"\n" |
| 770 |
|
|
" #declare A11 = cos(phi_r) * cos(psi_r) - sin(phi_r) * cos(theta_r) * sin(psi_r);\n" |
| 771 |
|
|
" #declare A12 = sin(phi_r) * cos(psi_r) + cos(phi_r) * cos(theta_r) * sin(psi_r);\n" |
| 772 |
|
|
" #declare A13 = sin(theta_r) * sin(psi_r);\n" |
| 773 |
|
|
"\n" |
| 774 |
|
|
" #declare A21 = -cos(phi_r) * sin(psi_r) - sin(phi_r) * cos(theta_r) * cos(psi_r);\n" |
| 775 |
|
|
" #declare A22 = -sin(phi_r) * sin(psi_r) + cos(phi_r) * cos(theta_r) * cos(psi_r);\n" |
| 776 |
|
|
" #declare A23 = sin(theta_r) * cos(psi_r);\n" |
| 777 |
|
|
"\n" |
| 778 |
|
|
" #declare A31 = sin(phi_r) * sin(theta_r);\n" |
| 779 |
|
|
" #declare A32 = -cos(phi_r) * sin(theta_r);\n" |
| 780 |
|
|
" #declare A33 = cos(theta_r);\n" |
| 781 |
|
|
"\n" |
| 782 |
|
|
"#end\n" |
| 783 |
mmeineke |
515 |
"\n" |
| 784 |
|
|
"\n" |
| 785 |
|
|
"//************************************************************\n" |
| 786 |
|
|
"// declare the periodic box macro\n" |
| 787 |
|
|
"//************************************************************\n" |
| 788 |
|
|
"\n" |
| 789 |
gezelter |
625 |
"#macro makePeriodicBox( bx1, by1, bz1, bx2, by2, bz2, bx3, by3, bz3 )\n" |
| 790 |
mmeineke |
515 |
"\n" |
| 791 |
mmeineke |
629 |
" #local bcx = (bx1 + bx2 + bx3) / 2.0;\n" |
| 792 |
|
|
" #local bcy = (by1 + by2 + by3) / 2.0;\n" |
| 793 |
|
|
" #local bcz = (bz1 + bz2 + bz3) / 2.0;\n" |
| 794 |
mmeineke |
515 |
"\n" |
| 795 |
mmeineke |
629 |
" #local pAx = boxCenterX - bcx;\n" |
| 796 |
|
|
" #local pAy = boxCenterY - bcy;\n" |
| 797 |
|
|
" #local pAz = boxCenterZ - bcz;\n" |
| 798 |
|
|
" #local pBx = boxCenterX + bx1 - bcx;\n" |
| 799 |
|
|
" #local pBy = boxCenterY + by1 - bcy;\n" |
| 800 |
|
|
" #local pBz = boxCenterZ + bz1 - bcz;\n" |
| 801 |
|
|
" #local pCx = boxCenterX + bx2 - bcx;\n" |
| 802 |
|
|
" #local pCy = boxCenterY + by2 - bcy;\n" |
| 803 |
|
|
" #local pCz = boxCenterZ + bz2 - bcz;\n" |
| 804 |
|
|
" #local pDx = boxCenterX + bx3 - bcx;\n" |
| 805 |
|
|
" #local pDy = boxCenterY + by3 - bcy;\n" |
| 806 |
|
|
" #local pDz = boxCenterZ + bz3 - bcz;\n" |
| 807 |
|
|
" #local pEx = boxCenterX + bx1 + bx2 - bcx;\n" |
| 808 |
|
|
" #local pEy = boxCenterY + by1 + by2 - bcy;\n" |
| 809 |
|
|
" #local pEz = boxCenterZ + bz1 + bz2 - bcz;\n" |
| 810 |
|
|
" #local pFx = boxCenterX + bx1 + bx3 - bcx;\n" |
| 811 |
|
|
" #local pFy = boxCenterY + by1 + by3 - bcy;\n" |
| 812 |
|
|
" #local pFz = boxCenterZ + bz1 + bz3 - bcz;\n" |
| 813 |
|
|
" #local pGx = boxCenterX + bx2 + bx3 - bcx;\n" |
| 814 |
|
|
" #local pGy = boxCenterY + by2 + by3 - bcy;\n" |
| 815 |
|
|
" #local pGz = boxCenterZ + bz2 + bz3 - bcz;\n" |
| 816 |
|
|
" #local pHx = boxCenterX + bx1 + bx2 + bx3 - bcx;\n" |
| 817 |
|
|
" #local pHy = boxCenterY + by1 + by2 + by3 - bcy;\n" |
| 818 |
|
|
" #local pHz = boxCenterZ + bz1 + bz2 + bz3 - bcz;\n" |
| 819 |
gezelter |
868 |
"\n" |
| 820 |
|
|
" #if(ROTATE)\n" |
| 821 |
|
|
" #local pAx_new = rotatePointX + A11 * (pAx-rotatePointX) + A12 * (pAy-rotatePointY) + A13 * (pAz-rotatePointZ);\n" |
| 822 |
|
|
" #local pAy_new = rotatePointY + A21 * (pAx-rotatePointX) + A22 * (pAy-rotatePointY) + A23 * (pAz-rotatePointZ);\n" |
| 823 |
|
|
" #local pAz_new = rotatePointZ + A31 * (pAx-rotatePointX) + A32 * (pAy-rotatePointY) + A33 * (pAz-rotatePointZ);\n" |
| 824 |
mmeineke |
629 |
"\n" |
| 825 |
gezelter |
868 |
" #local pBx_new = rotatePointX + A11 * (pBx-rotatePointX) + A12 * (pBy-rotatePointY) + A13 * (pBz-rotatePointZ);\n" |
| 826 |
|
|
" #local pBy_new = rotatePointY + A21 * (pBx-rotatePointX) + A22 * (pBy-rotatePointY) + A23 * (pBz-rotatePointZ);\n" |
| 827 |
|
|
" #local pBz_new = rotatePointZ + A31 * (pBx-rotatePointX) + A32 * (pBy-rotatePointY) + A33 * (pBz-rotatePointZ);\n" |
| 828 |
|
|
"\n" |
| 829 |
|
|
" #local pCx_new = rotatePointX + A11 * (pCx-rotatePointX) + A12 * (pCy-rotatePointY) + A13 * (pCz-rotatePointZ);\n" |
| 830 |
|
|
" #local pCy_new = rotatePointY + A21 * (pCx-rotatePointX) + A22 * (pCy-rotatePointY) + A23 * (pCz-rotatePointZ);\n" |
| 831 |
|
|
" #local pCz_new = rotatePointZ + A31 * (pCx-rotatePointX) + A32 * (pCy-rotatePointY) + A33 * (pCz-rotatePointZ);\n" |
| 832 |
|
|
"\n" |
| 833 |
|
|
" #local pDx_new = rotatePointX + A11 * (pDx-rotatePointX) + A12 * (pDy-rotatePointY) + A13 * (pDz-rotatePointZ);\n" |
| 834 |
|
|
" #local pDy_new = rotatePointY + A21 * (pDx-rotatePointX) + A22 * (pDy-rotatePointY) + A23 * (pDz-rotatePointZ);\n" |
| 835 |
|
|
" #local pDz_new = rotatePointZ + A31 * (pDx-rotatePointX) + A32 * (pDy-rotatePointY) + A33 * (pDz-rotatePointZ);\n" |
| 836 |
|
|
"\n" |
| 837 |
|
|
" #local pEx_new = rotatePointX + A11 * (pEx-rotatePointX) + A12 * (pEy-rotatePointY) + A13 * (pEz-rotatePointZ);\n" |
| 838 |
|
|
" #local pEy_new = rotatePointY + A21 * (pEx-rotatePointX) + A22 * (pEy-rotatePointY) + A23 * (pEz-rotatePointZ);\n" |
| 839 |
|
|
" #local pEz_new = rotatePointZ + A31 * (pEx-rotatePointX) + A32 * (pEy-rotatePointY) + A33 * (pEz-rotatePointZ);\n" |
| 840 |
|
|
"\n" |
| 841 |
|
|
" #local pFx_new = rotatePointX + A11 * (pFx-rotatePointX) + A12 * (pFy-rotatePointY) + A13 * (pFz-rotatePointZ);\n" |
| 842 |
|
|
" #local pFy_new = rotatePointY + A21 * (pFx-rotatePointX) + A22 * (pFy-rotatePointY) + A23 * (pFz-rotatePointZ);\n" |
| 843 |
|
|
" #local pFz_new = rotatePointZ + A31 * (pFx-rotatePointX) + A32 * (pFy-rotatePointY) + A33 * (pFz-rotatePointZ);\n" |
| 844 |
|
|
"\n" |
| 845 |
|
|
" #local pGx_new = rotatePointX + A11 * (pGx-rotatePointX) + A12 * (pGy-rotatePointY) + A13 * (pGz-rotatePointZ);\n" |
| 846 |
|
|
" #local pGy_new = rotatePointY + A21 * (pGx-rotatePointX) + A22 * (pGy-rotatePointY) + A23 * (pGz-rotatePointZ);\n" |
| 847 |
|
|
" #local pGz_new = rotatePointZ + A31 * (pGx-rotatePointX) + A32 * (pGy-rotatePointY) + A33 * (pGz-rotatePointZ);\n" |
| 848 |
|
|
"\n" |
| 849 |
|
|
" #local pHx_new = rotatePointX + A11 * (pHx-rotatePointX) + A12 * (pHy-rotatePointY) + A13 * (pHz-rotatePointZ);\n" |
| 850 |
|
|
" #local pHy_new = rotatePointY + A21 * (pHx-rotatePointX) + A22 * (pHy-rotatePointY) + A23 * (pHz-rotatePointZ);\n" |
| 851 |
|
|
" #local pHz_new = rotatePointZ + A31 * (pHx-rotatePointX) + A32 * (pHy-rotatePointY) + A33 * (pHz-rotatePointZ);\n" |
| 852 |
|
|
"\n" |
| 853 |
|
|
" #else\n" |
| 854 |
|
|
" #local pAx_new = pAx;" |
| 855 |
|
|
" #local pAy_new = pAy;" |
| 856 |
|
|
" #local pAz_new = pAz;" |
| 857 |
|
|
"\n" |
| 858 |
|
|
" #local pBx_new = pBx;" |
| 859 |
|
|
" #local pBy_new = pBy;" |
| 860 |
|
|
" #local pBz_new = pBz;" |
| 861 |
|
|
"\n" |
| 862 |
|
|
" #local pCx_new = pCx;" |
| 863 |
|
|
" #local pCy_new = pCy;" |
| 864 |
|
|
" #local pCz_new = pCz;" |
| 865 |
|
|
"\n" |
| 866 |
|
|
" #local pDx_new = pDx;" |
| 867 |
|
|
" #local pDy_new = pDy;" |
| 868 |
|
|
" #local pDz_new = pDz;" |
| 869 |
|
|
"\n" |
| 870 |
|
|
" #local pEx_new = pEx;" |
| 871 |
|
|
" #local pEy_new = pEy;" |
| 872 |
|
|
" #local pEz_new = pEz;" |
| 873 |
|
|
"\n" |
| 874 |
|
|
" #local pFx_new = pFx;" |
| 875 |
|
|
" #local pFy_new = pFy;" |
| 876 |
|
|
" #local pFz_new = pFz;" |
| 877 |
|
|
"\n" |
| 878 |
|
|
" #local pGx_new = pGx;" |
| 879 |
|
|
" #local pGy_new = pGy;" |
| 880 |
|
|
" #local pGz_new = pGz;" |
| 881 |
|
|
"\n" |
| 882 |
|
|
" #local pHx_new = pHx;" |
| 883 |
|
|
" #local pHy_new = pHy;" |
| 884 |
|
|
" #local pHz_new = pHz;" |
| 885 |
|
|
"\n" |
| 886 |
|
|
" #end\n" |
| 887 |
|
|
" #local pAx = pAx_new;" |
| 888 |
|
|
" #local pAy = pAy_new;" |
| 889 |
|
|
" #local pAz = pAz_new;" |
| 890 |
|
|
"\n" |
| 891 |
|
|
" #local pBx = pBx_new;" |
| 892 |
|
|
" #local pBy = pBy_new;" |
| 893 |
|
|
" #local pBz = pBz_new;" |
| 894 |
|
|
"\n" |
| 895 |
|
|
" #local pCx = pCx_new;" |
| 896 |
|
|
" #local pCy = pCy_new;" |
| 897 |
|
|
" #local pCz = pCz_new;" |
| 898 |
|
|
"\n" |
| 899 |
|
|
" #local pDx = pDx_new;" |
| 900 |
|
|
" #local pDy = pDy_new;" |
| 901 |
|
|
" #local pDz = pDz_new;" |
| 902 |
|
|
"\n" |
| 903 |
|
|
" #local pEx = pEx_new;" |
| 904 |
|
|
" #local pEy = pEy_new;" |
| 905 |
|
|
" #local pEz = pEz_new;" |
| 906 |
|
|
"\n" |
| 907 |
|
|
" #local pFx = pFx_new;" |
| 908 |
|
|
" #local pFy = pFy_new;" |
| 909 |
|
|
" #local pFz = pFz_new;" |
| 910 |
|
|
"\n" |
| 911 |
|
|
" #local pGx = pGx_new;" |
| 912 |
|
|
" #local pGy = pGy_new;" |
| 913 |
|
|
" #local pGz = pGz_new;" |
| 914 |
|
|
"\n" |
| 915 |
|
|
" #local pHx = pHx_new;" |
| 916 |
|
|
" #local pHy = pHy_new;" |
| 917 |
|
|
" #local pHz = pHz_new;" |
| 918 |
|
|
"\n" |
| 919 |
mmeineke |
515 |
" #local colorR = 0.90;\n" |
| 920 |
|
|
" #local colorG = 0.91;\n" |
| 921 |
|
|
" #local colorB = 0.98;\n" |
| 922 |
|
|
"\n" |
| 923 |
|
|
" #local pipeWidth = 0.4;\n" |
| 924 |
|
|
"\n" |
| 925 |
|
|
" // 1\n" |
| 926 |
|
|
" cylinder{\n" |
| 927 |
gezelter |
625 |
" < pAx, pAy, pAz >,\n" |
| 928 |
|
|
" < pBx, pBy, pBz >,\n" |
| 929 |
mmeineke |
515 |
" pipeWidth\n" |
| 930 |
|
|
" texture{\n" |
| 931 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 932 |
|
|
" finish{\n" |
| 933 |
|
|
" ambient .2\n" |
| 934 |
|
|
" diffuse .6\n" |
| 935 |
|
|
" specular 1\n" |
| 936 |
|
|
" roughness .001\n" |
| 937 |
|
|
" metallic\n" |
| 938 |
|
|
" }\n" |
| 939 |
|
|
" }\n" |
| 940 |
|
|
" }\n" |
| 941 |
|
|
"\n" |
| 942 |
|
|
" // 2\n" |
| 943 |
|
|
" cylinder{\n" |
| 944 |
gezelter |
625 |
" < pAx, pAy, pAz >,\n" |
| 945 |
|
|
" < pCx, pCy, pCz >,\n" |
| 946 |
mmeineke |
515 |
" pipeWidth\n" |
| 947 |
|
|
" texture{\n" |
| 948 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 949 |
|
|
" finish{\n" |
| 950 |
|
|
" ambient .2\n" |
| 951 |
|
|
" diffuse .6\n" |
| 952 |
|
|
" specular 1\n" |
| 953 |
|
|
" roughness .001\n" |
| 954 |
|
|
" metallic\n" |
| 955 |
|
|
" }\n" |
| 956 |
|
|
" }\n" |
| 957 |
|
|
" }\n" |
| 958 |
|
|
"\n" |
| 959 |
|
|
" // 3\n" |
| 960 |
|
|
" cylinder{\n" |
| 961 |
gezelter |
625 |
" < pAx, pAy, pAz >,\n" |
| 962 |
|
|
" < pDx, pDy, pDz >,\n" |
| 963 |
mmeineke |
515 |
" pipeWidth\n" |
| 964 |
|
|
" texture{\n" |
| 965 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 966 |
|
|
" finish{\n" |
| 967 |
|
|
" ambient .2\n" |
| 968 |
|
|
" diffuse .6\n" |
| 969 |
|
|
" specular 1\n" |
| 970 |
|
|
" roughness .001\n" |
| 971 |
|
|
" metallic\n" |
| 972 |
|
|
" }\n" |
| 973 |
|
|
" }\n" |
| 974 |
|
|
" }\n" |
| 975 |
|
|
"\n" |
| 976 |
|
|
" // 4\n" |
| 977 |
|
|
" cylinder{\n" |
| 978 |
gezelter |
625 |
" < pBx, pBy, pBz >,\n" |
| 979 |
|
|
" < pEx, pEy, pEz >,\n" |
| 980 |
mmeineke |
515 |
" pipeWidth\n" |
| 981 |
|
|
" texture{\n" |
| 982 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 983 |
|
|
" finish{\n" |
| 984 |
|
|
" ambient .2\n" |
| 985 |
|
|
" diffuse .6\n" |
| 986 |
|
|
" specular 1\n" |
| 987 |
|
|
" roughness .001\n" |
| 988 |
|
|
" metallic\n" |
| 989 |
|
|
" }\n" |
| 990 |
|
|
" }\n" |
| 991 |
|
|
" }\n" |
| 992 |
|
|
"\n" |
| 993 |
|
|
" // 5\n" |
| 994 |
|
|
" cylinder{\n" |
| 995 |
gezelter |
625 |
" < pCx, pCy, pCz >,\n" |
| 996 |
|
|
" < pEx, pEy, pEz >,\n" |
| 997 |
mmeineke |
515 |
" pipeWidth\n" |
| 998 |
|
|
" texture{\n" |
| 999 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 1000 |
|
|
" finish{\n" |
| 1001 |
|
|
" ambient .2\n" |
| 1002 |
|
|
" diffuse .6\n" |
| 1003 |
|
|
" specular 1\n" |
| 1004 |
|
|
" roughness .001\n" |
| 1005 |
|
|
" metallic\n" |
| 1006 |
|
|
" }\n" |
| 1007 |
|
|
" }\n" |
| 1008 |
|
|
" }\n" |
| 1009 |
|
|
"\n" |
| 1010 |
|
|
" // 6\n" |
| 1011 |
|
|
" cylinder{\n" |
| 1012 |
gezelter |
625 |
" < pBx, pBy, pBz >,\n" |
| 1013 |
|
|
" < pFx, pFy, pFz >,\n" |
| 1014 |
mmeineke |
515 |
" pipeWidth\n" |
| 1015 |
|
|
" texture{\n" |
| 1016 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 1017 |
|
|
" finish{\n" |
| 1018 |
|
|
" ambient .2\n" |
| 1019 |
|
|
" diffuse .6\n" |
| 1020 |
|
|
" specular 1\n" |
| 1021 |
|
|
" roughness .001\n" |
| 1022 |
|
|
" metallic\n" |
| 1023 |
|
|
" }\n" |
| 1024 |
|
|
" }\n" |
| 1025 |
|
|
" }\n" |
| 1026 |
|
|
"\n" |
| 1027 |
|
|
" // 7\n" |
| 1028 |
|
|
" cylinder{\n" |
| 1029 |
gezelter |
625 |
" < pCx, pCy, pCz >,\n" |
| 1030 |
|
|
" < pGx, pGy, pGz >,\n" |
| 1031 |
mmeineke |
515 |
" pipeWidth\n" |
| 1032 |
|
|
" texture{\n" |
| 1033 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 1034 |
|
|
" finish{\n" |
| 1035 |
|
|
" ambient .2\n" |
| 1036 |
|
|
" diffuse .6\n" |
| 1037 |
|
|
" specular 1\n" |
| 1038 |
|
|
" roughness .001\n" |
| 1039 |
|
|
" metallic\n" |
| 1040 |
|
|
" }\n" |
| 1041 |
|
|
" }\n" |
| 1042 |
|
|
" }\n" |
| 1043 |
|
|
"\n" |
| 1044 |
|
|
" // 8\n" |
| 1045 |
|
|
" cylinder{\n" |
| 1046 |
gezelter |
625 |
" < pDx, pDy, pDz >,\n" |
| 1047 |
|
|
" < pGx, pGy, pGz >,\n" |
| 1048 |
mmeineke |
515 |
" pipeWidth\n" |
| 1049 |
|
|
" texture{\n" |
| 1050 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 1051 |
|
|
" finish{\n" |
| 1052 |
|
|
" ambient .2\n" |
| 1053 |
|
|
" diffuse .6\n" |
| 1054 |
|
|
" specular 1\n" |
| 1055 |
|
|
" roughness .001\n" |
| 1056 |
|
|
" metallic\n" |
| 1057 |
|
|
" }\n" |
| 1058 |
|
|
" }\n" |
| 1059 |
|
|
" }\n" |
| 1060 |
|
|
"\n" |
| 1061 |
|
|
" // 9\n" |
| 1062 |
|
|
" cylinder{\n" |
| 1063 |
gezelter |
625 |
" < pDx, pDy, pDz >,\n" |
| 1064 |
|
|
" < pFx, pFy, pFz >,\n" |
| 1065 |
mmeineke |
515 |
" pipeWidth\n" |
| 1066 |
|
|
" texture{\n" |
| 1067 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 1068 |
|
|
" finish{\n" |
| 1069 |
|
|
" ambient .2\n" |
| 1070 |
|
|
" diffuse .6\n" |
| 1071 |
|
|
" specular 1\n" |
| 1072 |
|
|
" roughness .001\n" |
| 1073 |
|
|
" metallic\n" |
| 1074 |
|
|
" }\n" |
| 1075 |
|
|
" }\n" |
| 1076 |
|
|
" }\n" |
| 1077 |
|
|
"\n" |
| 1078 |
|
|
" // 10\n" |
| 1079 |
|
|
" cylinder{\n" |
| 1080 |
gezelter |
625 |
" < pEx, pEy, pEz >,\n" |
| 1081 |
|
|
" < pHx, pHy, pHz >,\n" |
| 1082 |
mmeineke |
515 |
" pipeWidth\n" |
| 1083 |
|
|
" texture{\n" |
| 1084 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 1085 |
|
|
" finish{\n" |
| 1086 |
|
|
" ambient .2\n" |
| 1087 |
|
|
" diffuse .6\n" |
| 1088 |
|
|
" specular 1\n" |
| 1089 |
|
|
" roughness .001\n" |
| 1090 |
|
|
" metallic\n" |
| 1091 |
|
|
" }\n" |
| 1092 |
|
|
" }\n" |
| 1093 |
|
|
" }\n" |
| 1094 |
|
|
"\n" |
| 1095 |
|
|
" // 11\n" |
| 1096 |
|
|
" cylinder{\n" |
| 1097 |
gezelter |
625 |
" < pFx, pFy, pFz >,\n" |
| 1098 |
|
|
" < pHx, pHy, pHz >,\n" |
| 1099 |
mmeineke |
515 |
" pipeWidth\n" |
| 1100 |
|
|
" texture{\n" |
| 1101 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 1102 |
|
|
" finish{\n" |
| 1103 |
|
|
" ambient .2\n" |
| 1104 |
|
|
" diffuse .6\n" |
| 1105 |
|
|
" specular 1\n" |
| 1106 |
|
|
" roughness .001\n" |
| 1107 |
|
|
" metallic\n" |
| 1108 |
|
|
" }\n" |
| 1109 |
|
|
" }\n" |
| 1110 |
|
|
" }\n" |
| 1111 |
|
|
"\n" |
| 1112 |
|
|
" // 12\n" |
| 1113 |
|
|
" cylinder{\n" |
| 1114 |
gezelter |
625 |
" < pGx, pGy, pGz >,\n" |
| 1115 |
|
|
" < pHx, pHy, pHz >,\n" |
| 1116 |
mmeineke |
515 |
" pipeWidth\n" |
| 1117 |
|
|
" texture{\n" |
| 1118 |
|
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
| 1119 |
|
|
" finish{\n" |
| 1120 |
|
|
" ambient .2\n" |
| 1121 |
|
|
" diffuse .6\n" |
| 1122 |
|
|
" specular 1\n" |
| 1123 |
|
|
" roughness .001\n" |
| 1124 |
|
|
" metallic\n" |
| 1125 |
|
|
" }\n" |
| 1126 |
|
|
" }\n" |
| 1127 |
|
|
" }\n" |
| 1128 |
|
|
"\n" |
| 1129 |
|
|
"#end\n" |
| 1130 |
|
|
"\n" |
| 1131 |
mmeineke |
60 |
"\n"); |
| 1132 |
mmeineke |
515 |
|
| 1133 |
|
|
|
| 1134 |
|
|
|
| 1135 |
|
|
|
| 1136 |
mmeineke |
60 |
make_header_macros(out_file); |
| 1137 |
|
|
|
| 1138 |
|
|
fclose(out_file); |
| 1139 |
|
|
} |
| 1140 |
|
|
|
| 1141 |
|
|
return 0; |
| 1142 |
|
|
|
| 1143 |
|
|
} |
| 1144 |
|
|
|
| 1145 |
|
|
|
| 1146 |
|
|
|
| 1147 |
|
|
/*************************************************************************** |
| 1148 |
|
|
* prints out the usage for the command line arguments, then exits. |
| 1149 |
|
|
***************************************************************************/ |
| 1150 |
|
|
|
| 1151 |
|
|
void usage(){ |
| 1152 |
|
|
(void)fprintf(stderr, |
| 1153 |
|
|
"The proper usage is: %s [options] <xyz_file>\n" |
| 1154 |
|
|
"\n" |
| 1155 |
|
|
"Options:\n" |
| 1156 |
|
|
"\n" |
| 1157 |
|
|
" -o <prefix> the output file prefix\n" |
| 1158 |
|
|
" -H generate a pov-ray header file\n" |
| 1159 |
|
|
" -i <#> number of frames to interpolate\n" |
| 1160 |
|
|
" -h draw hydrogens\n" |
| 1161 |
|
|
" -b draw bonds\n" |
| 1162 |
|
|
" -a draw atoms\n" |
| 1163 |
gezelter |
864 |
" -v draw vectors\n" |
| 1164 |
mmeineke |
515 |
" -p draw periodic box\n" |
| 1165 |
mmeineke |
508 |
" -r regenerate bond\n" |
| 1166 |
mmeineke |
515 |
" -f <#> render frame <#> only\n" |
| 1167 |
|
|
" -s <#> begin at frame <#> (inclusive)\n" |
| 1168 |
|
|
" -e <#> end at frame <#> (inclusive)\n" |
| 1169 |
mmeineke |
60 |
"\n", |
| 1170 |
|
|
program_name); |
| 1171 |
|
|
exit(8); |
| 1172 |
|
|
} |
| 1173 |
gezelter |
864 |
|
| 1174 |
|
|
int count_tokens(line, delimiters) |
| 1175 |
|
|
/* PURPOSE: RETURN A COUNT OF THE NUMBER OF TOKENS ON THE LINE. */ |
| 1176 |
|
|
char *line; /* LINE CONTAINING TOKENS. */ |
| 1177 |
|
|
char *delimiters; /* POSSIBLE TOKEN DELIMITERS TO USE. */ |
| 1178 |
|
|
{ |
| 1179 |
|
|
char *working_line; /* WORKING COPY OF LINE. */ |
| 1180 |
|
|
int ntokens; /* NUMBER OF TOKENS FOUND IN LINE. */ |
| 1181 |
|
|
char *strtok_ptr; /* POINTER FOR STRTOK. */ |
| 1182 |
|
|
|
| 1183 |
|
|
strtok_ptr= working_line= strdup(line); |
| 1184 |
|
|
|
| 1185 |
|
|
ntokens=0; |
| 1186 |
|
|
while (strtok(strtok_ptr,delimiters)!=NULL) |
| 1187 |
|
|
{ |
| 1188 |
|
|
ntokens++; |
| 1189 |
|
|
strtok_ptr=NULL; |
| 1190 |
|
|
} |
| 1191 |
|
|
|
| 1192 |
|
|
free(working_line); |
| 1193 |
|
|
return(ntokens); |
| 1194 |
|
|
} |