1 |
+ |
#define _FILE_OFFSET_BITS 64 |
2 |
+ |
|
3 |
|
#include <stdio.h> |
4 |
|
#include <stdlib.h> |
5 |
|
#include <string.h> |
18 |
|
|
19 |
|
struct linked_xyz{ |
20 |
|
struct coords *r; |
21 |
< |
double boxX, boxY, boxZ; |
21 |
> |
double Hmat[3][3]; |
22 |
|
struct linked_xyz *next; |
23 |
|
}; |
24 |
|
|
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 |
+ |
int draw_vectors = 0; /*boolean to draw vectors */ |
30 |
|
int draw_box = 0; // boolean to draw the periodic Box |
31 |
|
int regenerateBonds = 0; // boolean to regenearate bonds each frame |
32 |
|
|
33 |
|
void usage(void); |
34 |
+ |
int count_tokens(char *line, char *delimiters); |
35 |
|
|
36 |
|
int main(argc, argv) |
37 |
|
int argc; |
41 |
|
|
42 |
|
struct coords *out_coords; |
43 |
|
|
44 |
< |
int i,j; /* loop counters */ |
44 |
> |
int i,j,k; /* loop counters */ |
45 |
|
mode_t dir_mode = S_IRWXU; |
46 |
|
|
47 |
|
int generate_header = 0; /* boolean for generating the pov ray header */ |
51 |
|
double small_x = 0; |
52 |
|
double small_y = 0; /* lets me know the smallest x, y, z */ |
53 |
|
double small_z = 0; |
54 |
+ |
int extremaSet = 0; |
55 |
|
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 |
< |
char read_buffer[120]; /*the line buffer for reading */ |
59 |
> |
char read_buffer[2000]; /*the line buffer for reading */ |
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 */ |
71 |
|
char current_flag; |
72 |
|
int nFrames; |
73 |
|
int nZeroes; |
74 |
+ |
int nTokens; |
75 |
|
double count; |
76 |
|
|
77 |
|
int startFrame = 1; |
85 |
|
|
86 |
|
unsigned int n_interpolate = 0; /* number of frames to interpolate */ |
87 |
|
double dx, dy, dz; /* temp variables for interpolating distances */ |
88 |
+ |
double dm[3][3]; |
89 |
|
|
90 |
|
|
91 |
|
char pov_dir[500]; /* the pov_dir */ |
188 |
|
draw_atoms = 1; |
189 |
|
break; |
190 |
|
|
191 |
+ |
case 'v': |
192 |
+ |
// -v => draw the vectors |
193 |
+ |
|
194 |
+ |
draw_vectors = 1; |
195 |
+ |
break; |
196 |
+ |
|
197 |
|
case 'r': |
198 |
|
// -r => regenerate bonds |
199 |
|
|
283 |
|
out_prefix = strtok(in_name, "."); |
284 |
|
} |
285 |
|
|
286 |
< |
sprintf( out_format, "%s%s%%0%dd.pov", pov_dir, out_prefix, nZeroes ); |
286 |
> |
sprintf( out_format, "%s%s-%%0%dd.pov", pov_dir, out_prefix, nZeroes ); |
287 |
|
|
288 |
|
// start reading the first frame |
289 |
|
|
315 |
|
if( draw_box ){ |
316 |
|
foo = strtok(read_buffer, " ,;\t"); |
317 |
|
if(foo == NULL){ |
318 |
< |
printf("error in reading file\n"); |
318 |
> |
printf("error in reading file time\n"); |
319 |
|
exit(8); |
320 |
|
} |
321 |
|
|
322 |
|
foo = strtok(NULL, " ,;\t"); |
323 |
|
if(foo == NULL){ |
324 |
< |
printf("error in reading file\n"); |
324 |
> |
printf("error in reading file h00\n"); |
325 |
|
exit(8); |
326 |
|
} |
327 |
< |
current_frame->boxX = atof( foo ); |
327 |
> |
current_frame->Hmat[0][0] = atof( foo ); |
328 |
|
|
329 |
|
foo = strtok(NULL, " ,;\t"); |
330 |
|
if(foo == NULL){ |
331 |
< |
printf("error in reading file\n"); |
331 |
> |
printf("error in reading file h10\n"); |
332 |
|
exit(8); |
333 |
|
} |
334 |
< |
current_frame->boxY = atof( foo ); |
334 |
> |
current_frame->Hmat[1][0] = atof( foo ); |
335 |
|
|
336 |
|
foo = strtok(NULL, " ,;\t"); |
337 |
|
if(foo == NULL){ |
338 |
< |
printf("error in reading file\n"); |
338 |
> |
printf("error in reading file h20\n"); |
339 |
|
exit(8); |
340 |
|
} |
341 |
< |
current_frame->boxZ = atof( foo ); |
329 |
< |
} |
341 |
> |
current_frame->Hmat[2][0] = atof( foo ); |
342 |
|
|
343 |
< |
for( i=0; i < n_atoms; i++){ |
344 |
< |
|
345 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), in_file); |
334 |
< |
if(eof_test == NULL){ |
335 |
< |
printf("error in reading file\n"); |
343 |
> |
foo = strtok(NULL, " ,;\t"); |
344 |
> |
if(foo == NULL){ |
345 |
> |
printf("error in reading file h01\n"); |
346 |
|
exit(8); |
347 |
|
} |
348 |
+ |
current_frame->Hmat[0][1] = atof( foo ); |
349 |
|
|
350 |
< |
foo = strtok(read_buffer, " ,;\t"); |
350 |
> |
foo = strtok(NULL, " ,;\t"); |
351 |
|
if(foo == NULL){ |
352 |
< |
printf("error in reading file\n"); |
352 |
> |
printf("error in reading file h11\n"); |
353 |
|
exit(8); |
354 |
|
} |
355 |
< |
(void)strcpy(current_frame->r[i].name, foo); /*copy the atom name */ |
355 |
> |
current_frame->Hmat[1][1] = atof( foo ); |
356 |
|
|
346 |
– |
/* next we grab the positions */ |
347 |
– |
|
357 |
|
foo = strtok(NULL, " ,;\t"); |
358 |
|
if(foo == NULL){ |
359 |
< |
printf("error in reading file\n"); |
359 |
> |
printf("error in reading file h21\n"); |
360 |
|
exit(8); |
361 |
|
} |
362 |
< |
(void)sscanf(foo, "%lf",¤t_frame->r[i].x); |
363 |
< |
if(current_frame->r[i].x > big_x) big_x = current_frame->r[i].x; |
355 |
< |
if(current_frame->r[i].x < small_x) small_x = current_frame->r[i].x; |
356 |
< |
|
357 |
< |
|
362 |
> |
current_frame->Hmat[2][1] = atof( foo ); |
363 |
> |
|
364 |
|
foo = strtok(NULL, " ,;\t"); |
365 |
|
if(foo == NULL){ |
366 |
< |
printf("error in reading file\n"); |
366 |
> |
printf("error in reading file h02\n"); |
367 |
|
exit(8); |
368 |
|
} |
369 |
< |
(void)sscanf(foo, "%lf", ¤t_frame->r[i].y); |
364 |
< |
if(current_frame->r[i].y > big_y) big_y = current_frame->r[i].y; |
365 |
< |
if(current_frame->r[i].y < small_y) small_y = current_frame->r[i].y; |
369 |
> |
current_frame->Hmat[0][2] = atof( foo ); |
370 |
|
|
371 |
+ |
foo = strtok(NULL, " ,;\t"); |
372 |
+ |
if(foo == NULL){ |
373 |
+ |
printf("error in reading file h12\n"); |
374 |
+ |
exit(8); |
375 |
+ |
} |
376 |
+ |
current_frame->Hmat[1][2] = atof( foo ); |
377 |
|
|
378 |
|
foo = strtok(NULL, " ,;\t"); |
379 |
|
if(foo == NULL){ |
380 |
< |
printf("error in reading file\n"); |
380 |
> |
printf("error in reading file h22\n"); |
381 |
|
exit(8); |
382 |
|
} |
383 |
+ |
current_frame->Hmat[2][2] = atof( foo ); |
384 |
+ |
|
385 |
+ |
} |
386 |
+ |
|
387 |
+ |
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 |
+ |
printf("error in reading file line at atom %d\n", i); |
392 |
+ |
exit(8); |
393 |
+ |
} |
394 |
+ |
|
395 |
+ |
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 |
+ |
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 |
+ |
foo = strtok(NULL, " ,;\t"); |
410 |
|
(void)sscanf(foo, "%lf", ¤t_frame->r[i].z); |
374 |
– |
if(current_frame->r[i].z > big_z) big_z = current_frame->r[i].z; |
375 |
– |
if(current_frame->r[i].z < small_z) small_z = current_frame->r[i].z; |
411 |
|
|
412 |
+ |
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 |
+ |
|
431 |
+ |
extremaSet = 1; |
432 |
+ |
|
433 |
+ |
} |
434 |
+ |
|
435 |
+ |
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 |
+ |
|
456 |
+ |
if (nTokens >= 10) { |
457 |
+ |
foo = strtok(NULL, " ,;\t"); |
458 |
+ |
(void)sscanf(foo, "%lf", ¤t_frame->r[i].vx); |
459 |
+ |
foo = strtok(NULL, " ,;\t"); |
460 |
+ |
(void)sscanf(foo, "%lf", ¤t_frame->r[i].vy); |
461 |
+ |
foo = strtok(NULL, " ,;\t"); |
462 |
+ |
(void)sscanf(foo, "%lf", ¤t_frame->r[i].vz); |
463 |
+ |
current_frame->r[i].hasSecondVector = 1; |
464 |
+ |
} else { |
465 |
+ |
current_frame->r[i].hasSecondVector = 0; |
466 |
+ |
} |
467 |
+ |
|
468 |
+ |
|
469 |
+ |
|
470 |
|
} |
471 |
|
currentCount++; |
472 |
|
|
494 |
|
"#include \"pov_header.pov\"\n" |
495 |
|
"\n"); |
496 |
|
if( draw_box ){ |
497 |
< |
dx = current_frame->boxX - temp_frame->boxX; |
498 |
< |
dy = current_frame->boxY - temp_frame->boxY; |
499 |
< |
dz = current_frame->boxZ - temp_frame->boxZ; |
500 |
< |
|
501 |
< |
dx /= (double)(n_interpolate + 1); |
502 |
< |
dy /= (double)(n_interpolate + 1); |
503 |
< |
dz /= (double)(n_interpolate + 1); |
504 |
< |
|
497 |
> |
|
498 |
> |
for (j = 0; j < 3; j++) { |
499 |
> |
for (k = 0; k < 3; k++) { |
500 |
> |
dm[j][k] = current_frame->Hmat[j][k] - temp_frame->Hmat[j][k]; |
501 |
> |
dm[j][k] /= (double)(n_interpolate + 1); |
502 |
> |
} |
503 |
> |
} |
504 |
> |
|
505 |
|
fprintf( out_file, |
506 |
< |
"makePeriodicBox( %lf, %lf, %lf )\n" |
506 |
> |
"makePeriodicBox( %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf)\n" |
507 |
|
"\n", |
508 |
< |
temp_frame->boxX + dx * (i+1), |
509 |
< |
temp_frame->boxZ + dz * (i+1), |
510 |
< |
temp_frame->boxY + dy * (i+1) ); |
508 |
> |
temp_frame->Hmat[0][0] + dm[0][0] * (i+1), |
509 |
> |
temp_frame->Hmat[2][0] + dm[2][0] * (i+1), |
510 |
> |
temp_frame->Hmat[1][0] + dm[1][0] * (i+1), |
511 |
> |
temp_frame->Hmat[0][1] + dm[0][1] * (i+1), |
512 |
> |
temp_frame->Hmat[2][1] + dm[2][1] * (i+1), |
513 |
> |
temp_frame->Hmat[1][1] + dm[1][1] * (i+1), |
514 |
> |
temp_frame->Hmat[0][2] + dm[0][2] * (i+1), |
515 |
> |
temp_frame->Hmat[2][2] + dm[2][2] * (i+1), |
516 |
> |
temp_frame->Hmat[1][2] + dm[1][2] * (i+1) ); |
517 |
|
} |
518 |
|
|
519 |
|
|
533 |
|
out_coords[j].x = temp_frame->r[j].x + dx * (i+1); |
534 |
|
out_coords[j].y = temp_frame->r[j].y + dy * (i+1); |
535 |
|
out_coords[j].z = temp_frame->r[j].z + dz * (i+1); |
536 |
+ |
|
537 |
+ |
if (current_frame->r[j].hasVector) { |
538 |
+ |
dx = current_frame->r[j].ux - temp_frame->r[j].ux; |
539 |
+ |
dy = current_frame->r[j].uy - temp_frame->r[j].uy; |
540 |
+ |
dz = current_frame->r[j].uz - temp_frame->r[j].uz; |
541 |
+ |
|
542 |
+ |
dx /= (double)(n_interpolate + 1); |
543 |
+ |
dy /= (double)(n_interpolate + 1); |
544 |
+ |
dz /= (double)(n_interpolate + 1); |
545 |
+ |
|
546 |
+ |
out_coords[j].hasVector = current_frame->r[j].hasVector; |
547 |
+ |
out_coords[j].ux = temp_frame->r[j].ux + dx * (i+1); |
548 |
+ |
out_coords[j].uy = temp_frame->r[j].uy + dy * (i+1); |
549 |
+ |
out_coords[j].uz = temp_frame->r[j].uz + dz * (i+1); |
550 |
+ |
} |
551 |
+ |
|
552 |
+ |
if (current_frame->r[j].hasSecondVector) { |
553 |
+ |
dx = current_frame->r[j].vx - temp_frame->r[j].vx; |
554 |
+ |
dy = current_frame->r[j].vy - temp_frame->r[j].vy; |
555 |
+ |
dz = current_frame->r[j].vz - temp_frame->r[j].vz; |
556 |
+ |
|
557 |
+ |
dx /= (double)(n_interpolate + 1); |
558 |
+ |
dy /= (double)(n_interpolate + 1); |
559 |
+ |
dz /= (double)(n_interpolate + 1); |
560 |
+ |
|
561 |
+ |
out_coords[j].hasVector = current_frame->r[j].hasSecondVector; |
562 |
+ |
out_coords[j].vx = temp_frame->r[j].vx + dx * (i+1); |
563 |
+ |
out_coords[j].vy = temp_frame->r[j].vy + dy * (i+1); |
564 |
+ |
out_coords[j].vz = temp_frame->r[j].vz + dz * (i+1); |
565 |
+ |
} |
566 |
+ |
|
567 |
+ |
if (current_frame->r[j].hasCharge) { |
568 |
+ |
dx = current_frame->r[j].charge - temp_frame->r[j].charge; |
569 |
+ |
|
570 |
+ |
dx /= (double)(n_interpolate + 1); |
571 |
+ |
|
572 |
+ |
out_coords[j].hasCharge = current_frame->r[j].hasCharge; |
573 |
+ |
out_coords[j].charge = temp_frame->r[j].charge + dx * (i+1); |
574 |
+ |
} |
575 |
+ |
|
576 |
|
} |
577 |
|
|
578 |
|
pov_write(out_file, out_coords, n_atoms, draw_hydrogens, draw_bonds, |
579 |
< |
draw_atoms); |
579 |
> |
draw_atoms, draw_vectors); |
580 |
|
free(out_coords); |
581 |
|
(void)fclose(out_file); |
582 |
|
} |
600 |
|
if( draw_box ){ |
601 |
|
|
602 |
|
fprintf( out_file, |
603 |
< |
"makePeriodicBox( %lf, %lf, %lf )\n" |
603 |
> |
"makePeriodicBox( %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf )\n" |
604 |
|
"\n", |
605 |
< |
current_frame->boxX, |
606 |
< |
current_frame->boxZ, |
607 |
< |
current_frame->boxY ); |
605 |
> |
current_frame->Hmat[0][0], |
606 |
> |
current_frame->Hmat[2][0], |
607 |
> |
current_frame->Hmat[1][0], |
608 |
> |
current_frame->Hmat[0][1], |
609 |
> |
current_frame->Hmat[2][1], |
610 |
> |
current_frame->Hmat[1][1], |
611 |
> |
current_frame->Hmat[0][2], |
612 |
> |
current_frame->Hmat[2][2], |
613 |
> |
current_frame->Hmat[1][2] ); |
614 |
|
} |
615 |
|
|
616 |
|
|
623 |
|
out_coords[i].x = current_frame->r[i].x; |
624 |
|
out_coords[i].y = current_frame->r[i].y; |
625 |
|
out_coords[i].z = current_frame->r[i].z; |
626 |
+ |
|
627 |
+ |
if (current_frame->r[i].hasVector) { |
628 |
+ |
out_coords[i].hasVector = current_frame->r[i].hasVector; |
629 |
+ |
out_coords[i].ux = current_frame->r[i].ux; |
630 |
+ |
out_coords[i].uy = current_frame->r[i].uy; |
631 |
+ |
out_coords[i].uz = current_frame->r[i].uz; |
632 |
+ |
} |
633 |
+ |
|
634 |
+ |
if (current_frame->r[i].hasSecondVector) { |
635 |
+ |
out_coords[i].hasSecondVector = current_frame->r[i].hasSecondVector; |
636 |
+ |
out_coords[i].vx = current_frame->r[i].vx; |
637 |
+ |
out_coords[i].vy = current_frame->r[i].vy; |
638 |
+ |
out_coords[i].vz = current_frame->r[i].vz; |
639 |
+ |
} |
640 |
+ |
|
641 |
+ |
if (current_frame->r[i].hasCharge) { |
642 |
+ |
out_coords[i].hasCharge = current_frame->r[i].hasCharge; |
643 |
+ |
out_coords[i].charge = current_frame->r[i].charge; |
644 |
+ |
} |
645 |
|
} |
646 |
|
pov_write(out_file, out_coords, n_atoms, draw_hydrogens, draw_bonds, |
647 |
< |
draw_atoms); |
647 |
> |
draw_atoms, draw_vectors); |
648 |
|
free(out_coords); |
649 |
|
|
650 |
|
(void)fclose(out_file); |
707 |
|
fprintf(out_file, |
708 |
|
"// The following script was automatically generated by:\n" |
709 |
|
"// xyz2pov Copyright 2001 by MATTHEW A. MEINEKE\n" |
710 |
+ |
"#include \"colors.inc\"\n" |
711 |
+ |
"#include \"math.inc\"\n" |
712 |
|
"\n" |
713 |
|
"\n" |
714 |
|
"background { rgb <1.0, 1.0, 1.0> }\n" |
731 |
|
"\n" |
732 |
|
"#declare ATOM_SPHERE_FACTOR = 0.2;\n" |
733 |
|
"#declare BOND_RADIUS = 0.1;\n" |
734 |
+ |
"#declare VECTOR_SCALE = 1.0;\n" |
735 |
+ |
"#declare STICK_RADIUS = 0.5 * BOND_RADIUS;\n" |
736 |
+ |
"#declare CONE_RADIUS = 2.0 * STICK_RADIUS;\n" |
737 |
+ |
"#declare CONE_FRACTION = 0.15;\n" |
738 |
|
"\n" |
739 |
|
"// declare camera, light, and system variables\n" |
740 |
|
"\n" |
752 |
|
"#declare cameraLookY = sysCenterY;\n" |
753 |
|
"#declare cameraLookZ = sysCenterZ;\n" |
754 |
|
"\n" |
755 |
+ |
"#declare rotatePointX = cameraLookX;\n" |
756 |
+ |
"#declare rotatePointY = cameraLookY;\n" |
757 |
+ |
"#declare rotatePointZ = cameraLookZ;\n" |
758 |
+ |
"\n" |
759 |
|
"#declare cameraX = cameraLookX;\n" |
760 |
|
"#declare cameraY = cameraLookY;\n" |
761 |
|
"#declare cameraZ = cameraLookZ - zoom;\n" |
771 |
|
"#declare boxCenterX = cameraLookX;\n" |
772 |
|
"#declare boxCenterY = cameraLookY;\n" |
773 |
|
"#declare boxCenterZ = cameraLookZ;\n" |
774 |
+ |
"#declare fn = function(x,y,z) {(y+1)/2}\n" |
775 |
+ |
"#declare grad1 = pigment { function { fn(x, y, z) } color_map {[0.0 rgb <0,0,0>] [1.0 rgb <3,0,0>]} };\n" |
776 |
+ |
"#declare grad2 = pigment { function { fn(x, y, z) } rotate 120*z color_map {[0.0 rgb <0,0,0>] [1.0 rgb <0,3,0>]} };\n" |
777 |
+ |
"#declare grad3 = pigment { function { fn(x, y, z) } rotate 240*z color_map {[0.0 rgb <0,0,0>] [1.0 rgb <0,0,3>]} };\n" |
778 |
+ |
"#declare fnz = function(x,y,z) {(z+1)/2}\n" |
779 |
+ |
"#declare gradz = pigment { function { fnz(x, y, z) } color_map {[0.0 rgb <0,0,0>] [1.0 rgb <1,1,1>]} };\n" |
780 |
|
"\n" |
781 |
|
"// declare the cameras and the light sources\n" |
782 |
|
"\n" |
831 |
|
"// declare the periodic box macro\n" |
832 |
|
"//************************************************************\n" |
833 |
|
"\n" |
834 |
< |
"#macro makePeriodicBox( lengthX, lengthY, lengthZ )\n" |
834 |
> |
"#macro makePeriodicBox( bx1, by1, bz1, bx2, by2, bz2, bx3, by3, bz3 )\n" |
835 |
|
"\n" |
836 |
< |
" #local addX = lengthX / 2.0;\n" |
837 |
< |
" #local addY = lengthY / 2.0;\n" |
838 |
< |
" #local addZ = lengthZ / 2.0;\n" |
836 |
> |
" #local bcx = (bx1 + bx2 + bx3) / 2.0;\n" |
837 |
> |
" #local bcy = (by1 + by2 + by3) / 2.0;\n" |
838 |
> |
" #local bcz = (bz1 + bz2 + bz3) / 2.0;\n" |
839 |
|
"\n" |
840 |
+ |
" #local pAx = boxCenterX - bcx;\n" |
841 |
+ |
" #local pAy = boxCenterY - bcy;\n" |
842 |
+ |
" #local pAz = boxCenterZ - bcz;\n" |
843 |
+ |
" #local pBx = boxCenterX + bx1 - bcx;\n" |
844 |
+ |
" #local pBy = boxCenterY + by1 - bcy;\n" |
845 |
+ |
" #local pBz = boxCenterZ + bz1 - bcz;\n" |
846 |
+ |
" #local pCx = boxCenterX + bx2 - bcx;\n" |
847 |
+ |
" #local pCy = boxCenterY + by2 - bcy;\n" |
848 |
+ |
" #local pCz = boxCenterZ + bz2 - bcz;\n" |
849 |
+ |
" #local pDx = boxCenterX + bx3 - bcx;\n" |
850 |
+ |
" #local pDy = boxCenterY + by3 - bcy;\n" |
851 |
+ |
" #local pDz = boxCenterZ + bz3 - bcz;\n" |
852 |
+ |
" #local pEx = boxCenterX + bx1 + bx2 - bcx;\n" |
853 |
+ |
" #local pEy = boxCenterY + by1 + by2 - bcy;\n" |
854 |
+ |
" #local pEz = boxCenterZ + bz1 + bz2 - bcz;\n" |
855 |
+ |
" #local pFx = boxCenterX + bx1 + bx3 - bcx;\n" |
856 |
+ |
" #local pFy = boxCenterY + by1 + by3 - bcy;\n" |
857 |
+ |
" #local pFz = boxCenterZ + bz1 + bz3 - bcz;\n" |
858 |
+ |
" #local pGx = boxCenterX + bx2 + bx3 - bcx;\n" |
859 |
+ |
" #local pGy = boxCenterY + by2 + by3 - bcy;\n" |
860 |
+ |
" #local pGz = boxCenterZ + bz2 + bz3 - bcz;\n" |
861 |
+ |
" #local pHx = boxCenterX + bx1 + bx2 + bx3 - bcx;\n" |
862 |
+ |
" #local pHy = boxCenterY + by1 + by2 + by3 - bcy;\n" |
863 |
+ |
" #local pHz = boxCenterZ + bz1 + bz2 + bz3 - bcz;\n" |
864 |
+ |
"\n" |
865 |
+ |
" #if(ROTATE)\n" |
866 |
+ |
" #local pAx_new = rotatePointX + A11 * (pAx-rotatePointX) + A12 * (pAy-rotatePointY) + A13 * (pAz-rotatePointZ);\n" |
867 |
+ |
" #local pAy_new = rotatePointY + A21 * (pAx-rotatePointX) + A22 * (pAy-rotatePointY) + A23 * (pAz-rotatePointZ);\n" |
868 |
+ |
" #local pAz_new = rotatePointZ + A31 * (pAx-rotatePointX) + A32 * (pAy-rotatePointY) + A33 * (pAz-rotatePointZ);\n" |
869 |
+ |
"\n" |
870 |
+ |
" #local pBx_new = rotatePointX + A11 * (pBx-rotatePointX) + A12 * (pBy-rotatePointY) + A13 * (pBz-rotatePointZ);\n" |
871 |
+ |
" #local pBy_new = rotatePointY + A21 * (pBx-rotatePointX) + A22 * (pBy-rotatePointY) + A23 * (pBz-rotatePointZ);\n" |
872 |
+ |
" #local pBz_new = rotatePointZ + A31 * (pBx-rotatePointX) + A32 * (pBy-rotatePointY) + A33 * (pBz-rotatePointZ);\n" |
873 |
+ |
"\n" |
874 |
+ |
" #local pCx_new = rotatePointX + A11 * (pCx-rotatePointX) + A12 * (pCy-rotatePointY) + A13 * (pCz-rotatePointZ);\n" |
875 |
+ |
" #local pCy_new = rotatePointY + A21 * (pCx-rotatePointX) + A22 * (pCy-rotatePointY) + A23 * (pCz-rotatePointZ);\n" |
876 |
+ |
" #local pCz_new = rotatePointZ + A31 * (pCx-rotatePointX) + A32 * (pCy-rotatePointY) + A33 * (pCz-rotatePointZ);\n" |
877 |
+ |
"\n" |
878 |
+ |
" #local pDx_new = rotatePointX + A11 * (pDx-rotatePointX) + A12 * (pDy-rotatePointY) + A13 * (pDz-rotatePointZ);\n" |
879 |
+ |
" #local pDy_new = rotatePointY + A21 * (pDx-rotatePointX) + A22 * (pDy-rotatePointY) + A23 * (pDz-rotatePointZ);\n" |
880 |
+ |
" #local pDz_new = rotatePointZ + A31 * (pDx-rotatePointX) + A32 * (pDy-rotatePointY) + A33 * (pDz-rotatePointZ);\n" |
881 |
+ |
"\n" |
882 |
+ |
" #local pEx_new = rotatePointX + A11 * (pEx-rotatePointX) + A12 * (pEy-rotatePointY) + A13 * (pEz-rotatePointZ);\n" |
883 |
+ |
" #local pEy_new = rotatePointY + A21 * (pEx-rotatePointX) + A22 * (pEy-rotatePointY) + A23 * (pEz-rotatePointZ);\n" |
884 |
+ |
" #local pEz_new = rotatePointZ + A31 * (pEx-rotatePointX) + A32 * (pEy-rotatePointY) + A33 * (pEz-rotatePointZ);\n" |
885 |
+ |
"\n" |
886 |
+ |
" #local pFx_new = rotatePointX + A11 * (pFx-rotatePointX) + A12 * (pFy-rotatePointY) + A13 * (pFz-rotatePointZ);\n" |
887 |
+ |
" #local pFy_new = rotatePointY + A21 * (pFx-rotatePointX) + A22 * (pFy-rotatePointY) + A23 * (pFz-rotatePointZ);\n" |
888 |
+ |
" #local pFz_new = rotatePointZ + A31 * (pFx-rotatePointX) + A32 * (pFy-rotatePointY) + A33 * (pFz-rotatePointZ);\n" |
889 |
+ |
"\n" |
890 |
+ |
" #local pGx_new = rotatePointX + A11 * (pGx-rotatePointX) + A12 * (pGy-rotatePointY) + A13 * (pGz-rotatePointZ);\n" |
891 |
+ |
" #local pGy_new = rotatePointY + A21 * (pGx-rotatePointX) + A22 * (pGy-rotatePointY) + A23 * (pGz-rotatePointZ);\n" |
892 |
+ |
" #local pGz_new = rotatePointZ + A31 * (pGx-rotatePointX) + A32 * (pGy-rotatePointY) + A33 * (pGz-rotatePointZ);\n" |
893 |
+ |
"\n" |
894 |
+ |
" #local pHx_new = rotatePointX + A11 * (pHx-rotatePointX) + A12 * (pHy-rotatePointY) + A13 * (pHz-rotatePointZ);\n" |
895 |
+ |
" #local pHy_new = rotatePointY + A21 * (pHx-rotatePointX) + A22 * (pHy-rotatePointY) + A23 * (pHz-rotatePointZ);\n" |
896 |
+ |
" #local pHz_new = rotatePointZ + A31 * (pHx-rotatePointX) + A32 * (pHy-rotatePointY) + A33 * (pHz-rotatePointZ);\n" |
897 |
+ |
"\n" |
898 |
+ |
" #else\n" |
899 |
+ |
" #local pAx_new = pAx;" |
900 |
+ |
" #local pAy_new = pAy;" |
901 |
+ |
" #local pAz_new = pAz;" |
902 |
+ |
"\n" |
903 |
+ |
" #local pBx_new = pBx;" |
904 |
+ |
" #local pBy_new = pBy;" |
905 |
+ |
" #local pBz_new = pBz;" |
906 |
+ |
"\n" |
907 |
+ |
" #local pCx_new = pCx;" |
908 |
+ |
" #local pCy_new = pCy;" |
909 |
+ |
" #local pCz_new = pCz;" |
910 |
+ |
"\n" |
911 |
+ |
" #local pDx_new = pDx;" |
912 |
+ |
" #local pDy_new = pDy;" |
913 |
+ |
" #local pDz_new = pDz;" |
914 |
+ |
"\n" |
915 |
+ |
" #local pEx_new = pEx;" |
916 |
+ |
" #local pEy_new = pEy;" |
917 |
+ |
" #local pEz_new = pEz;" |
918 |
+ |
"\n" |
919 |
+ |
" #local pFx_new = pFx;" |
920 |
+ |
" #local pFy_new = pFy;" |
921 |
+ |
" #local pFz_new = pFz;" |
922 |
+ |
"\n" |
923 |
+ |
" #local pGx_new = pGx;" |
924 |
+ |
" #local pGy_new = pGy;" |
925 |
+ |
" #local pGz_new = pGz;" |
926 |
+ |
"\n" |
927 |
+ |
" #local pHx_new = pHx;" |
928 |
+ |
" #local pHy_new = pHy;" |
929 |
+ |
" #local pHz_new = pHz;" |
930 |
+ |
"\n" |
931 |
+ |
" #end\n" |
932 |
+ |
" #local pAx = pAx_new;" |
933 |
+ |
" #local pAy = pAy_new;" |
934 |
+ |
" #local pAz = pAz_new;" |
935 |
+ |
"\n" |
936 |
+ |
" #local pBx = pBx_new;" |
937 |
+ |
" #local pBy = pBy_new;" |
938 |
+ |
" #local pBz = pBz_new;" |
939 |
+ |
"\n" |
940 |
+ |
" #local pCx = pCx_new;" |
941 |
+ |
" #local pCy = pCy_new;" |
942 |
+ |
" #local pCz = pCz_new;" |
943 |
+ |
"\n" |
944 |
+ |
" #local pDx = pDx_new;" |
945 |
+ |
" #local pDy = pDy_new;" |
946 |
+ |
" #local pDz = pDz_new;" |
947 |
+ |
"\n" |
948 |
+ |
" #local pEx = pEx_new;" |
949 |
+ |
" #local pEy = pEy_new;" |
950 |
+ |
" #local pEz = pEz_new;" |
951 |
+ |
"\n" |
952 |
+ |
" #local pFx = pFx_new;" |
953 |
+ |
" #local pFy = pFy_new;" |
954 |
+ |
" #local pFz = pFz_new;" |
955 |
+ |
"\n" |
956 |
+ |
" #local pGx = pGx_new;" |
957 |
+ |
" #local pGy = pGy_new;" |
958 |
+ |
" #local pGz = pGz_new;" |
959 |
+ |
"\n" |
960 |
+ |
" #local pHx = pHx_new;" |
961 |
+ |
" #local pHy = pHy_new;" |
962 |
+ |
" #local pHz = pHz_new;" |
963 |
+ |
"\n" |
964 |
|
" #local colorR = 0.90;\n" |
965 |
|
" #local colorG = 0.91;\n" |
966 |
|
" #local colorB = 0.98;\n" |
969 |
|
"\n" |
970 |
|
" // 1\n" |
971 |
|
" cylinder{\n" |
972 |
< |
" < boxCenterX-addX, boxCenterY-addY, boxCenterZ-addZ >,\n" |
973 |
< |
" < boxCenterX-addX, boxCenterY+addY, boxCenterZ-addZ >,\n" |
972 |
> |
" < pAx, pAy, pAz >,\n" |
973 |
> |
" < pBx, pBy, pBz >,\n" |
974 |
|
" pipeWidth\n" |
975 |
|
" texture{\n" |
976 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
986 |
|
"\n" |
987 |
|
" // 2\n" |
988 |
|
" cylinder{\n" |
989 |
< |
" < boxCenterX-addX, boxCenterY-addY, boxCenterZ+addZ >,\n" |
990 |
< |
" < boxCenterX-addX, boxCenterY+addY, boxCenterZ+addZ >,\n" |
989 |
> |
" < pAx, pAy, pAz >,\n" |
990 |
> |
" < pCx, pCy, pCz >,\n" |
991 |
|
" pipeWidth\n" |
992 |
|
" texture{\n" |
993 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1003 |
|
"\n" |
1004 |
|
" // 3\n" |
1005 |
|
" cylinder{\n" |
1006 |
< |
" < boxCenterX+addX, boxCenterY-addY, boxCenterZ-addZ >,\n" |
1007 |
< |
" < boxCenterX+addX, boxCenterY+addY, boxCenterZ-addZ >,\n" |
1006 |
> |
" < pAx, pAy, pAz >,\n" |
1007 |
> |
" < pDx, pDy, pDz >,\n" |
1008 |
|
" pipeWidth\n" |
1009 |
|
" texture{\n" |
1010 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1020 |
|
"\n" |
1021 |
|
" // 4\n" |
1022 |
|
" cylinder{\n" |
1023 |
< |
" < boxCenterX+addX, boxCenterY-addY, boxCenterZ+addZ >,\n" |
1024 |
< |
" < boxCenterX+addX, boxCenterY+addY, boxCenterZ+addZ >,\n" |
1023 |
> |
" < pBx, pBy, pBz >,\n" |
1024 |
> |
" < pEx, pEy, pEz >,\n" |
1025 |
|
" pipeWidth\n" |
1026 |
|
" texture{\n" |
1027 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1037 |
|
"\n" |
1038 |
|
" // 5\n" |
1039 |
|
" cylinder{\n" |
1040 |
< |
" < boxCenterX-addX, boxCenterY-addY, boxCenterZ-addZ >,\n" |
1041 |
< |
" < boxCenterX-addX, boxCenterY-addY, boxCenterZ+addZ >,\n" |
1040 |
> |
" < pCx, pCy, pCz >,\n" |
1041 |
> |
" < pEx, pEy, pEz >,\n" |
1042 |
|
" pipeWidth\n" |
1043 |
|
" texture{\n" |
1044 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1054 |
|
"\n" |
1055 |
|
" // 6\n" |
1056 |
|
" cylinder{\n" |
1057 |
< |
" < boxCenterX-addX, boxCenterY-addY, boxCenterZ+addZ >,\n" |
1058 |
< |
" < boxCenterX+addX, boxCenterY-addY, boxCenterZ+addZ >,\n" |
1057 |
> |
" < pBx, pBy, pBz >,\n" |
1058 |
> |
" < pFx, pFy, pFz >,\n" |
1059 |
|
" pipeWidth\n" |
1060 |
|
" texture{\n" |
1061 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1071 |
|
"\n" |
1072 |
|
" // 7\n" |
1073 |
|
" cylinder{\n" |
1074 |
< |
" < boxCenterX+addX, boxCenterY-addY, boxCenterZ+addZ >,\n" |
1075 |
< |
" < boxCenterX+addX, boxCenterY-addY, boxCenterZ-addZ >,\n" |
1074 |
> |
" < pCx, pCy, pCz >,\n" |
1075 |
> |
" < pGx, pGy, pGz >,\n" |
1076 |
|
" pipeWidth\n" |
1077 |
|
" texture{\n" |
1078 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1088 |
|
"\n" |
1089 |
|
" // 8\n" |
1090 |
|
" cylinder{\n" |
1091 |
< |
" < boxCenterX+addX, boxCenterY-addY, boxCenterZ-addZ >,\n" |
1092 |
< |
" < boxCenterX-addX, boxCenterY-addY, boxCenterZ-addZ >,\n" |
1091 |
> |
" < pDx, pDy, pDz >,\n" |
1092 |
> |
" < pGx, pGy, pGz >,\n" |
1093 |
|
" pipeWidth\n" |
1094 |
|
" texture{\n" |
1095 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1105 |
|
"\n" |
1106 |
|
" // 9\n" |
1107 |
|
" cylinder{\n" |
1108 |
< |
" < boxCenterX-addX, boxCenterY+addY, boxCenterZ-addZ >,\n" |
1109 |
< |
" < boxCenterX-addX, boxCenterY+addY, boxCenterZ+addZ >,\n" |
1108 |
> |
" < pDx, pDy, pDz >,\n" |
1109 |
> |
" < pFx, pFy, pFz >,\n" |
1110 |
|
" pipeWidth\n" |
1111 |
|
" texture{\n" |
1112 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1122 |
|
"\n" |
1123 |
|
" // 10\n" |
1124 |
|
" cylinder{\n" |
1125 |
< |
" < boxCenterX-addX, boxCenterY+addY, boxCenterZ+addZ >,\n" |
1126 |
< |
" < boxCenterX+addX, boxCenterY+addY, boxCenterZ+addZ >,\n" |
1125 |
> |
" < pEx, pEy, pEz >,\n" |
1126 |
> |
" < pHx, pHy, pHz >,\n" |
1127 |
|
" pipeWidth\n" |
1128 |
|
" texture{\n" |
1129 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1139 |
|
"\n" |
1140 |
|
" // 11\n" |
1141 |
|
" cylinder{\n" |
1142 |
< |
" < boxCenterX+addX, boxCenterY+addY, boxCenterZ+addZ >,\n" |
1143 |
< |
" < boxCenterX+addX, boxCenterY+addY, boxCenterZ-addZ >,\n" |
1142 |
> |
" < pFx, pFy, pFz >,\n" |
1143 |
> |
" < pHx, pHy, pHz >,\n" |
1144 |
|
" pipeWidth\n" |
1145 |
|
" texture{\n" |
1146 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1156 |
|
"\n" |
1157 |
|
" // 12\n" |
1158 |
|
" cylinder{\n" |
1159 |
< |
" < boxCenterX+addX, boxCenterY+addY, boxCenterZ-addZ >,\n" |
1160 |
< |
" < boxCenterX-addX, boxCenterY+addY, boxCenterZ-addZ >,\n" |
1159 |
> |
" < pGx, pGy, pGz >,\n" |
1160 |
> |
" < pHx, pHy, pHz >,\n" |
1161 |
|
" pipeWidth\n" |
1162 |
|
" texture{\n" |
1163 |
|
" pigment{ rgb < colorR, colorG, colorB > }\n" |
1205 |
|
" -h draw hydrogens\n" |
1206 |
|
" -b draw bonds\n" |
1207 |
|
" -a draw atoms\n" |
1208 |
+ |
" -v draw vectors\n" |
1209 |
|
" -p draw periodic box\n" |
1210 |
|
" -r regenerate bond\n" |
1211 |
|
" -f <#> render frame <#> only\n" |
1215 |
|
program_name); |
1216 |
|
exit(8); |
1217 |
|
} |
1218 |
+ |
|
1219 |
+ |
int count_tokens(line, delimiters) |
1220 |
+ |
/* PURPOSE: RETURN A COUNT OF THE NUMBER OF TOKENS ON THE LINE. */ |
1221 |
+ |
char *line; /* LINE CONTAINING TOKENS. */ |
1222 |
+ |
char *delimiters; /* POSSIBLE TOKEN DELIMITERS TO USE. */ |
1223 |
+ |
{ |
1224 |
+ |
char *working_line; /* WORKING COPY OF LINE. */ |
1225 |
+ |
int ntokens; /* NUMBER OF TOKENS FOUND IN LINE. */ |
1226 |
+ |
char *strtok_ptr; /* POINTER FOR STRTOK. */ |
1227 |
+ |
|
1228 |
+ |
strtok_ptr= working_line= strdup(line); |
1229 |
+ |
|
1230 |
+ |
ntokens=0; |
1231 |
+ |
while (strtok(strtok_ptr,delimiters)!=NULL) |
1232 |
+ |
{ |
1233 |
+ |
ntokens++; |
1234 |
+ |
strtok_ptr=NULL; |
1235 |
+ |
} |
1236 |
+ |
|
1237 |
+ |
free(working_line); |
1238 |
+ |
return(ntokens); |
1239 |
+ |
} |