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

Comparing trunk/xyz2pov/src/pov_writer.c (file contents):
Revision 61 by mmeineke, Thu Aug 1 21:12:33 2002 UTC vs.
Revision 864 by gezelter, Tue Nov 18 17:04:25 2003 UTC

# Line 22 | Line 22 | void clean_bonds(void);
22    
23   void clean_bonds(void);
24  
25 + void initBondList(void){
26 +  bl_head = NULL;
27 + }
28  
29   void pov_write(FILE *out_file, struct coords *the_coords, int n_atoms,
30 <               int d_hydrogens, int d_bonds, int d_atoms){
30 >               int d_hydrogens, int d_bonds, int d_atoms, int d_vectors){
31  
32    int i,j; /*loop counters */
33    int skip_atom, skip_bond, test1, test2; /*booleans */
# Line 44 | Line 47 | void pov_write(FILE *out_file, struct coords *the_coor
47              "//************************************************************\n"
48              "\n"
49              "\n");
50 <
50 >    
51      for(i = 0; i < n_atoms; i++){
52        
53 <      skip_atom = 0;
53 >      skip_atom = 0;    
54        
55        if(!d_hydrogens){
56          skip_atom = !strcmp("H", the_coords[i].name);
57        }
58        
59 <      if(!skip_atom){
60 <        
59 >      if(!skip_atom){          
60 >        
61          fprintf(out_file,
62                  "make_%s_atom( %lf, %lf, %lf )\n",
63                  the_coords[i].name,
# Line 63 | Line 66 | void pov_write(FILE *out_file, struct coords *the_coor
66                  the_coords[i].y);
67        }
68      }
69 <    
69 >
70      fprintf(out_file,
71              "\n"
72              "\n");
73 +  }
74 +
75 +      
76 +  if (d_vectors) {
77 +
78 +    fprintf(out_file,
79 +            "//************************************************************\n"
80 +            "// The list of vectors\n"
81 +            "//************************************************************\n"
82 +            "\n"
83 +            "\n");
84      
85 +    for(i = 0; i < n_atoms; i++){
86 +      
87 +      if (the_coords[i].hasVector) {
88 +        fprintf(out_file,
89 +                "make_%s_vector(%lf, %lf, %lf, %lf, %lf, %lf)\n",
90 +                the_coords[i].name,
91 +                the_coords[i].x,
92 +                the_coords[i].z,
93 +                the_coords[i].y,
94 +                the_coords[i].ux,
95 +                the_coords[i].uz,
96 +                the_coords[i].uy);
97 +      }
98 +    }
99 +    
100 +    fprintf(out_file,
101 +            "\n"
102 +            "\n");
103    }
104 <  
104 >      
105    if(d_bonds){
106      
107      fprintf(out_file,
# Line 79 | Line 111 | void pov_write(FILE *out_file, struct coords *the_coor
111              "\n"
112              "\n");
113      
114 <    make_bonds(the_coords, n_atoms);
114 >    if( bl_head == NULL ) make_bonds(the_coords, n_atoms);
115      
116      current_bond = bl_head->next;
117      
# Line 130 | Line 162 | void pov_write(FILE *out_file, struct coords *the_coor
162        current_bond = current_bond->next;
163      }
164    
165 <    clean_bonds();
165 >    if( regenerateBonds )clean_bonds();
166    }
167   }
168  
# Line 209 | Line 241 | void clean_bonds(){
241      }
242      
243      bl_head->next = NULL;
244 +    free( bl_head );
245 +    bl_head = NULL;
246   }
247  
248  
# Line 321 | Line 355 | void make_header_macros(FILE *out_file){
355              "    }\n"
356              "  }\n"
357              "#end\n"
358 +            "#macro make_%s_vector "
359 +            "(center_x, center_y, center_z, ux, uy, uz)\n"
360              "\n"
361 +            "  #local vx = VECTOR_SCALE * ux;\n"
362 +            "  #local vy = VECTOR_SCALE * uy;\n"
363 +            "  #local vz = VECTOR_SCALE * uz;\n"
364 +            "  #local x1 = center_x - 0.5 * vx;\n"
365 +            "  #local y1 = center_y - 0.5 * vy;\n"
366 +            "  #local z1 = center_z - 0.5 * vz;\n"
367 +            "  #local x2 = center_x + 0.5 * vx;\n"
368 +            "  #local y2 = center_y + 0.5 * vy;\n"
369 +            "  #local z2 = center_z + 0.5 * vz;\n"
370 +            "  #local v2 = vx*vx + vy*vy + vz*vz;\n"
371 +            "  #local vl  = sqrt(v2);\n"
372 +            "  #local x3 = x1 + vx * (1.0 - CONE_FRACTION);\n"
373 +            "  #local y3 = y1 + vy * (1.0 - CONE_FRACTION);\n"
374 +            "  #local z3 = z1 + vz * (1.0 - CONE_FRACTION);\n"
375 +            "\n"
376 +            "  #if(ROTATE)\n"
377 +            "    #local x1_new = A11 * x1 + A12 * y1 + A13 * z1;\n"
378 +            "    #local y1_new = A21 * x1 + A22 * y1 + A23 * z1;\n"
379 +            "    #local z1_new = A31 * x1 + A32 * y1 + A33 * z1;\n"
380 +            "\n"
381 +            "    #local x2_new = A11 * x2 + A12 * y2 + A13 * z2;\n"
382 +            "    #local y2_new = A21 * x2 + A22 * y2 + A23 * z2;\n"
383 +            "    #local z2_new = A31 * x2 + A32 * y2 + A33 * z2;\n"
384 +            "\n"
385 +            "    #local x3_new = A11 * x3 + A12 * y3 + A13 * z3;\n"
386 +            "    #local y3_new = A21 * x3 + A22 * y3 + A23 * z3;\n"
387 +            "    #local z3_new = A31 * x3 + A32 * y3 + A33 * z3;\n"
388 +            "\n"
389 +            "  #else\n"
390 +            "    #local x1_new = x1;"
391 +            "    #local y1_new = y1;"
392 +            "    #local z1_new = z1;"
393 +            "\n"
394 +            "    #local x2_new = x2;"
395 +            "    #local y2_new = y2;"
396 +            "    #local z2_new = z2;"
397 +            "\n"
398 +            "    #local x3_new = x3;"
399 +            "    #local y3_new = y3;"
400 +            "    #local z3_new = z3;"
401 +            "\n"
402 +            "  #end\n"
403 +            "\n"
404 +            "  cylinder{\n"
405 +            "    < x1_new, y1_new, z1_new >,\n"
406 +            "    < x3_new, y3_new, z3_new >,\n"
407 +            "    STICK_RADIUS\n"
408 +            "    texture{\n"
409 +            "      pigment{ rgb < %lf, %lf, %lf > }\n"
410 +            "      finish{\n"
411 +            "        ambient .2\n"
412 +            "        diffuse .6\n"
413 +            "        specular 1\n"
414 +            "        roughness .001\n"
415 +            "        metallic\n"
416 +            "      }\n"
417 +            "    }\n"
418 +            "  }\n"
419 +            "  cone{\n"
420 +            "    < x2_new, y2_new, z2_new >, 0.0\n"
421 +            "    < x3_new, y3_new, z3_new >, CONE_RADIUS\n"
422 +            "    texture{\n"
423 +            "      pigment{ rgb < %lf, %lf, %lf > }\n"
424 +            "      finish{\n"
425 +            "        ambient .2\n"
426 +            "        diffuse .6\n"
427 +            "        specular 1\n"
428 +            "        roughness .001\n"
429 +            "        metallic\n"
430 +            "      }\n"
431 +            "    }\n"
432 +            "  }\n"
433 +            "#end\n"
434 +            "\n"
435              "\n",
436              name,
437              name,
438              red, green, blue,
439              name,
440              radius,
441 +            red, green, blue,
442 +            name,
443 +            red, green, blue,
444              red, green, blue);
445      
446      current_type = current_type->next;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines