ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/xyz2pov/src/xyz2pov.c
(Generate patch)

Comparing trunk/xyz2pov/src/xyz2pov.c (file contents):
Revision 625 by gezelter, Wed Jul 16 19:29:54 2003 UTC vs.
Revision 1095 by mmeineke, Mon Apr 5 19:34:21 2004 UTC

# Line 1 | Line 1
1 + #define _FILE_OFFSET_BITS 64
2 +
3   #include <stdio.h>
4   #include <stdlib.h>
5   #include <string.h>
# Line 24 | Line 26 | int draw_box = 0;  // boolean to draw the periodic Box
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;
# Line 47 | Line 51 | int main(argc, argv)
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 */
# Line 66 | Line 71 | int main(argc, argv)
71    char current_flag;
72    int nFrames;
73    int nZeroes;
74 +  int nTokens;
75    double count;
76  
77    int startFrame = 1;
# Line 180 | Line 186 | int main(argc, argv)
186              // -a => draw the atoms
187  
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':
# Line 271 | Line 283 | int main(argc, argv)
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  
# Line 303 | Line 315 | int main(argc, argv)
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->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->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->Hmat[2][0] = atof( foo );
342  
343        foo = strtok(NULL, " ,;\t");
344        if(foo == NULL){
345 <        printf("error in reading file\n");
345 >        printf("error in reading file h01\n");
346          exit(8);
347        }
348        current_frame->Hmat[0][1] = atof( foo );
349  
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        current_frame->Hmat[1][1] = atof( foo );
356  
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        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        current_frame->Hmat[0][2] = atof( foo );
370  
371        foo = strtok(NULL, " ,;\t");
372        if(foo == NULL){
373 <        printf("error in reading file\n");
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 );
# Line 376 | Line 388 | int main(argc, argv)
388        
389        eof_test = fgets(read_buffer, sizeof(read_buffer), in_file);
390        if(eof_test == NULL){
391 <        printf("error in reading file\n");
391 >        printf("error in reading file line at atom %d\n", i);
392          exit(8);
393        }
394  
395 <      foo = strtok(read_buffer, " ,;\t");
396 <      if(foo == NULL){
397 <        printf("error in reading file\n");
398 <        exit(8);
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  
390      /* next we grab the positions */
391      
405        foo = strtok(NULL, " ,;\t");
393      if(foo == NULL){
394        printf("error in reading file\n");
395        exit(8);
396      }
406        (void)sscanf(foo, "%lf",&current_frame->r[i].x);
398      if(current_frame->r[i].x > big_x) big_x = current_frame->r[i].x;
399      if(current_frame->r[i].x < small_x) small_x = current_frame->r[i].x;
400            
401  
407        foo = strtok(NULL, " ,;\t");
403      if(foo == NULL){
404        printf("error in reading file\n");
405        exit(8);
406      }
408        (void)sscanf(foo, "%lf", &current_frame->r[i].y);
408      if(current_frame->r[i].y > big_y) big_y = current_frame->r[i].y;
409      if(current_frame->r[i].y < small_y) small_y = current_frame->r[i].y;
410
411
409        foo = strtok(NULL, " ,;\t");
413      if(foo == NULL){
414        printf("error in reading file\n");
415        exit(8);
416      }
410        (void)sscanf(foo, "%lf", &current_frame->r[i].z);
418      if(current_frame->r[i].z > big_z) big_z = current_frame->r[i].z;
419      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", &current_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", &current_frame->r[i].ux);
447 +        foo = strtok(NULL, " ,;\t");
448 +        (void)sscanf(foo, "%lf", &current_frame->r[i].uy);
449 +        foo = strtok(NULL, " ,;\t");
450 +        (void)sscanf(foo, "%lf", &current_frame->r[i].uz);
451 +        current_frame->r[i].hasVector = 1;
452 +      } else {
453 +        current_frame->r[i].hasVector = 0;
454 +      }
455      }
456      currentCount++;
457      
# Line 457 | Line 491 | int main(argc, argv)
491                       "makePeriodicBox( %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf)\n"
492                       "\n",
493                       temp_frame->Hmat[0][0] + dm[0][0] * (i+1),
460                     temp_frame->Hmat[1][0] + dm[1][0] * (i+1),
494                       temp_frame->Hmat[2][0] + dm[2][0] * (i+1),
495 +                     temp_frame->Hmat[1][0] + dm[1][0] * (i+1),
496                       temp_frame->Hmat[0][1] + dm[0][1] * (i+1),
463                     temp_frame->Hmat[1][1] + dm[1][1] * (i+1),
497                       temp_frame->Hmat[2][1] + dm[2][1] * (i+1),
498 +                     temp_frame->Hmat[1][1] + dm[1][1] * (i+1),
499                       temp_frame->Hmat[0][2] + dm[0][2] * (i+1),
500 <                     temp_frame->Hmat[1][2] + dm[1][2] * (i+1),
501 <                     temp_frame->Hmat[2][2] + dm[2][2] * (i+1) );
500 >                     temp_frame->Hmat[2][2] + dm[2][2] * (i+1),
501 >                     temp_frame->Hmat[1][2] + dm[1][2] * (i+1) );
502            }
503            
504            
# Line 484 | Line 518 | int main(argc, argv)
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 +
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            }
547            
548            pov_write(out_file, out_coords, n_atoms, draw_hydrogens, draw_bonds,
549 <                    draw_atoms);
549 >                    draw_atoms, draw_vectors);
550            free(out_coords);
551            (void)fclose(out_file);
552          }
# Line 511 | Line 570 | int main(argc, argv)
570        if( draw_box ){
571          
572          fprintf( out_file,
573 <                 "makePeriodicBox( %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf %lf )\n"
573 >                 "makePeriodicBox( %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf, %lf )\n"
574                   "\n",
575                   current_frame->Hmat[0][0],
517                 current_frame->Hmat[1][0],
576                   current_frame->Hmat[2][0],
577 +                 current_frame->Hmat[1][0],
578                   current_frame->Hmat[0][1],
520                 current_frame->Hmat[1][1],
579                   current_frame->Hmat[2][1],
580 +                 current_frame->Hmat[1][1],
581                   current_frame->Hmat[0][2],
582 <                 current_frame->Hmat[1][2],
583 <                 current_frame->Hmat[2][2] );
582 >                 current_frame->Hmat[2][2],
583 >                 current_frame->Hmat[1][2] );
584        }
585        
586        
# Line 534 | Line 593 | int main(argc, argv)
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 +
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        }
609        pov_write(out_file, out_coords, n_atoms, draw_hydrogens, draw_bonds,
610 <                draw_atoms);
610 >                draw_atoms, draw_vectors);
611        free(out_coords);
612        
613        (void)fclose(out_file);
# Line 621 | Line 692 | int main(argc, argv)
692              "\n"
693              "#declare ATOM_SPHERE_FACTOR = 0.2;\n"
694              "#declare BOND_RADIUS = 0.1;\n"
695 +            "#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              "\n"
700              "// declare camera, light, and system variables\n"
701              "\n"
# Line 638 | Line 713 | int main(argc, argv)
713              "#declare cameraLookY = sysCenterY;\n"
714              "#declare cameraLookZ = sysCenterZ;\n"
715              "\n"
716 +            "#declare rotatePointX = cameraLookX;\n"
717 +            "#declare rotatePointY = cameraLookY;\n"
718 +            "#declare rotatePointZ = cameraLookZ;\n"
719 +            "\n"
720              "#declare cameraX = cameraLookX;\n"
721              "#declare cameraY = cameraLookY;\n"
722              "#declare cameraZ = cameraLookZ - zoom;\n"
# Line 709 | Line 788 | int main(argc, argv)
788              "\n"
789              "#macro makePeriodicBox( bx1, by1, bz1, bx2, by2, bz2, bx3, by3, bz3 )\n"
790              "\n"
791 <            "  #local pAx = -boxCenterX;\n"
792 <            "  #local pAy = -boxCenterY;\n"
793 <            "  #local pAz = -boxCenterZ;\n"
715 <            "  #local pBx = bx1 - boxCenterX;\n"
716 <            "  #local pBy = by1 - boxCenterY;\n"
717 <            "  #local pBz = bz1 - boxCenterZ;\n"
718 <            "  #local pCx = bx2 - boxCenterX;\n"
719 <            "  #local pCy = by2 - boxCenterY;\n"
720 <            "  #local pCz = bz2 - boxCenterZ;\n"
721 <            "  #local pDx = bx3 - boxCenterX;\n"
722 <            "  #local pDy = by3 - boxCenterY;\n"
723 <            "  #local pDz = bz3 - boxCenterZ;\n"
724 <            "  #local pEx = bx1 + bx2 - boxCenterX;\n"
725 <            "  #local pEy = by1 + by2 - boxCenterY;\n"
726 <            "  #local pEz = bz1 + bz2 - boxCenterZ;\n"
727 <            "  #local pFx = bx1 + bx3 - boxCenterX;\n"
728 <            "  #local pFy = by1 + by3 - boxCenterY;\n"
729 <            "  #local pFz = bz1 + bz3 - boxCenterZ;\n"
730 <            "  #local pGx = bx2 + bx3 - boxCenterX;\n"
731 <            "  #local pGy = by2 + by3 - boxCenterY;\n"
732 <            "  #local pGz = bz2 + bz3 - boxCenterZ;\n"
733 <            "  #local pHx = bx1 + bx2 + bx3 - boxCenterX;\n"
734 <            "  #local pHy = by1 + by2 + by3 - boxCenterY;\n"
735 <            "  #local pHz = bz1 + bz2 + bz3 - boxCenterZ;\n"
791 >            "  #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              "\n"
795 +            "  #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 +            "\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 +            "\n"
825 +            "    #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              "  #local colorR = 0.90;\n"
920              "  #local colorG = 0.91;\n"
921              "  #local colorB = 0.98;\n"
# Line 978 | Line 1160 | void usage(){
1160                  "   -h            draw hydrogens\n"
1161                  "   -b            draw bonds\n"
1162                  "   -a            draw atoms\n"
1163 +                "   -v            draw vectors\n"
1164                  "   -p            draw periodic box\n"
1165                  "   -r            regenerate bond\n"
1166                  "   -f <#>        render frame <#> only\n"
# Line 987 | Line 1170 | void usage(){
1170                  program_name);
1171    exit(8);
1172   }
1173 +
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 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines