Bsoft  2.1.0
Bernard's software package
rwmodel_bild.cpp
Go to the documentation of this file.
1 
10 #include "rwmodel.h"
11 #include "model_neighbors.h"
12 #include "model_poly.h"
13 #include "Color.h"
14 #include "utilities.h"
15 #include "timer.h"
16 #include <fstream>
17 
18 // Declaration of global variables
19 extern int verbose; // Level of output to the screen
20 
22 {
23  Bstring id;
24  Bcomponent* comp1 = NULL;
25 
26  for ( comp1 = *comp; comp1; comp1 = comp1->next )
27  if ( comp1->loc.distance(loc) < 0.001 ) break;
28 
29  if ( !comp1 ) {
30  id = Bstring(++number, "%d");
31  comp1 = component_add(comp, id);
32  comp1->loc = loc;
33  }
34 
35  return comp1;
36 }
37 
44 {
45  int i, j, nc, first_comment;
46  Bmodel* model = NULL;
47  Bmodel* mp = NULL;
48  Bcomponent* comp = NULL;
49  Bcomponent* comp1 = NULL;
50  Bcomponent* comp2 = NULL;
51  Blink* link = NULL;
52  Bstring id, line;
53  Bstring* filename;
54  Bstring *tokens, *token;
55  ifstream fmod;
56  char aline[1024];
57  RGBA<float> rgba(1,1,1,1);
58  Vector3<double> loc, vec;
59 
60  for ( i=1, filename = file_list; filename; filename = filename->next, i++ ) {
61  if ( verbose & VERB_LABEL )
62  cout << "Reading file: " << *filename << endl;
63  first_comment = 1;
64  fmod.open(filename->c_str());
65  if ( fmod.fail() ) return NULL;
66  id = Bstring(i, "%d");
67  mp = model_add(&mp, id);
68  if ( !model ) model = mp;
69  link = NULL;
70  comp = NULL;
71  nc = 0;
72  while ( fmod.getline(aline, 1024) ) {
73  line = aline;
74  if ( verbose & VERB_DEBUG )
75  cout << "DEBUG read_model_bild: " << line << endl;
76  tokens = line.split();
77  if ( tokens ) {
78  if ( verbose & VERB_DEBUG )
79  cout << "DEBUG read_model_bild: " << *tokens;
80  if ( *tokens == ".comment" ) {
81  if ( first_comment ) {
82  for ( token = tokens->next; token; token = token->next )
83  mp->comment += *token + " ";
84  first_comment = 0;
85  }
86  } else if ( *tokens == ".color" ) {
87  if ( verbose & VERB_DEBUG )
88  cout << " " << *(tokens->next);
89  if ( isdigit((*tokens)[0]) )
90  for ( j=0, token = tokens->next; token && j<3; token = token->next, j++ )
91  rgba[j] = token->real();
92  else
93  ;
94  } else if ( *tokens == ".transparency" ) {
95  rgba[3] = tokens->next->real();
96  } else if ( *tokens == ".dot" || *tokens == ".dotat" ) {
97  for ( j=0, token = tokens->next; token && j<3; token = token->next, j++ )
98  loc[j] = token->real();
99  comp = component_add_if_not_exist(loc, &mp->comp, nc);
100  comp->radius = 1;
101  comp->color = rgba;
102  } else if ( *tokens == ".sphere" ) {
103  for ( j=0, token = tokens->next; token && j<3; token = token->next, j++ )
104  loc[j] = token->real();
105  comp = component_add_if_not_exist(loc, &mp->comp, nc);
106  if ( token ) comp->radius = token->real();
107  comp->color = rgba;
108  } else if ( *tokens == ".m" || *tokens == ".move" ) {
109  for ( j=0, token = tokens->next; token && j<3; token = token->next, j++ )
110  loc[j] = token->real();
111  comp = component_add_if_not_exist(loc, &mp->comp, nc);
112  comp->color = rgba;
113  } else if ( *tokens == ".mr" || *tokens == ".moverel" ) {
114  for ( j=0, token = tokens->next; token && j<3; token = token->next, j++ )
115  vec[j] = token->real();
116  loc += vec;
117  comp = component_add_if_not_exist(loc, &mp->comp, nc);
118  comp->color = rgba;
119  } else if ( *tokens == ".d" || *tokens == ".draw" ) {
120  for ( j=0, token = tokens->next; token && j<3; token = token->next, j++ )
121  loc[j] = token->real();
122  comp = component_add_if_not_exist(loc, &mp->comp, nc);
123  comp->color = rgba;
124  if ( comp && comp2 ) {
125  link = link_add(&link, comp, comp2, 0, 1);
126  if ( !mp->link ) mp->link = link;
127  link->color = rgba;
128  }
129  } else if ( *tokens == ".dr" || *tokens == ".drawrel" ) {
130  for ( j=0, token = tokens->next; token && j<3; token = token->next, j++ )
131  vec[j] = token->real();
132  loc += vec;
133  comp = component_add_if_not_exist(loc, &mp->comp, nc);
134  comp->color = rgba;
135  if ( comp && comp2 ) {
136  link = link_add(&link, comp, comp2, 0, 1);
137  if ( !mp->link ) mp->link = link;
138  link->color = rgba;
139  }
140  } else if ( *tokens == ".v" || *tokens == ".vector" || *tokens == ".cylinder" ) {
141  for ( j=0, token = tokens->next; token && j<3; token = token->next, j++ )
142  loc[j] = token->real();
143  comp = component_add_if_not_exist(loc, &mp->comp, nc);
144  comp->color = rgba;
145  for ( j=0; token && j<3; token = token->next, j++ )
146  loc[j] = token->real();
147  comp1 = component_add_if_not_exist(loc, &mp->comp, nc);
148  comp1->color = rgba;
149  if ( comp && comp1 ) {
150  link = link_add(&link, comp, comp1, 0, 1);
151  if ( !mp->link ) mp->link = link;
152  link->color = rgba;
153  if ( token ) link->radius = token->real();
154  if ( link->radius < 0.001 ) link->radius = 1;
155  }
156  } else if ( *tokens == ".polygon" ) {
157  comp1 = NULL;
158  for ( j=0, token = tokens->next; token; token = token->next ) {
159  loc[j++] = token->real();
160  if ( j > 2 ) {
161  j = 0;
162  comp = component_add_if_not_exist(loc, &mp->comp, nc);
163  comp->color = rgba;
164  if ( comp && comp1 ) {
165  link = link_add(&link, comp, comp1, 0, 1);
166  if ( !mp->link ) mp->link = link;
167  link->color = rgba;
168  }
169  comp1 = comp;
170  }
171  }
172  }
173  if ( verbose & VERB_DEBUG )
174  cout << endl;
175  }
176  comp2 = comp; // Previous component
177  }
178  fmod.close();
179  }
180 
181  return model;
182 }
183 
184 void bild_color(ofstream& fbld, RGB<float> rgb)
185 {
186  fbld << ".color " << rgb[0] << " " << rgb[1] << " " << rgb[2] << endl;
187 }
188 
189 void bild_color(ofstream& fbld, RGBA<float> rgba)
190 {
191  fbld << ".color " << rgba[0] << " " << rgba[1] << " " << rgba[2] << endl;
192 }
193 
194 void bild_sphere(ofstream& fbld, Vector3<double> loc, double radius)
195 {
196  fbld << ".sphere " << loc[0] << " " << loc[1] << " " << loc[2] << " " << radius << endl;
197 }
198 
199 void bild_cylinder(ofstream& fbld, Vector3<double> start, Vector3<double> end, double radius)
200 {
201  fbld << ".cylinder " << start[0] << " " << start[1] << " " << start[2]
202  << " " << end[0] << " " << end[1] << " " << end[2]
203  << " " << radius << endl;
204 }
205 
206 void bild_polygon_start(ofstream& fbld, Vector3<double> vertex)
207 {
208  fbld << ".polygon " << vertex[0] << " " << vertex[1] << " " << vertex[2];
209 }
210 void bild_polygon_add(ofstream& fbld, Vector3<double> vertex)
211 {
212  fbld << " " << vertex[0] << " " << vertex[1] << " " << vertex[2];
213 }
214 void bild_polygon_end(ofstream& fbld, Vector3<double> vertex)
215 {
216  fbld << " " << vertex[0] << " " << vertex[1] << " " << vertex[2] << endl;
217 }
218 
219 void bild_arrow(ofstream& fbld, Vector3<double> start, Vector3<double> end, double cylrad, double conerad, double rho)
220 {
221  fbld << ".arrow " << start[0] << " " << start[1] << " " << start[2]
222  << " " << end[0] << " " << end[1] << " " << end[2]
223  << " " << cylrad << " " << conerad << " " << rho << endl;
224 }
225 
233 {
234  int n;
235  Bmodel* mp = NULL;
236  Bcomponent* comp = NULL;
237  Blink* link = NULL;
238  Bstring onename;
239 
240  ofstream fmod;
241 
242  for ( n=1, mp = model; mp; mp = mp->next, n++ ) {
243  if ( model->next )
244  onename = filename.pre_rev('.') + Bstring(n, "_%04d.") + filename.post_rev('.');
245  else
246  onename = filename;
247  fmod.open(onename.c_str());
248  if ( mp->comment.length() )
249  fmod << ".comment " << mp->comment << endl;
250  for ( comp = mp->comp; comp; comp = comp->next ) {
251  bild_color(fmod, comp->color);
252  bild_sphere(fmod, comp->loc, comp->radius);
253  }
254  for ( link = mp->link; link; link = link->next ) {
255  bild_color(fmod, link->color);
256  bild_cylinder(fmod, link->comp[0]->loc, link->comp[1]->loc, link->radius);
257  }
258  fmod.close();
259  }
260 
261  return n;
262 }
263 
275 int model_to_bild_orientations(Bstring& filename, Bmodel* model, int vec_type, int color_type)
276 {
277  int n, selmax;
278  double vlen, vrad, dmin(1e10), dmax(-1e10), fommin(1e10), fommax(-1e10);
279  RGB<float> rgb(1,1,1);
280  Vector3<double> vv, av, v1, v2, v3;
281  Matrix3 mat;
282  Bcomponent* comp;
283 
284  for ( n=selmax=0, comp = model->comp; comp; comp = comp->next, n++ ) {
285  if ( dmin > comp->density ) dmin = comp->density;
286  if ( dmax < comp->density ) dmax = comp->density;
287  if ( fommin > comp->fom ) fommin = comp->fom;
288  if ( fommax < comp->fom ) fommax = comp->fom;
289  if ( selmax < comp->sel ) selmax = comp->sel;
290  }
291 
292  if ( verbose ) {
293  cout << "Generating a bild views file: " << filename << endl;
294  }
295 
296  ofstream fbld(filename.c_str());
297  if ( fbld.fail() ) {
298  cerr << "Error: Unable to open " << filename << " for writing" << endl;
299  return -1;
300  }
301 
302  fbld << endl;
303  fbld << ".color white" << endl;
304  for ( comp = model->comp; comp; comp = comp->next ) if ( comp->sel ) {
305  vlen = comp->radius*2;
306  vrad = comp->radius/5;
307  switch ( vec_type ) {
308  case 1: vv = Vector3<double>(comp->view[0], comp->view[1], comp->view[2]); break;
309  case 2: vv = comp->vec; break;
310  case 3: vv = comp->vel; break;
311  }
312  vv *= vlen;
313  if ( vec_type < 2 ) {
314  av = Vector3<double>(1,0,0);
315  mat = comp->view.matrix();
316 // mat = mat.transpose();
317  av = mat * av;
318  av *= 3*vrad;
319  }
320  v1 = comp->loc + vv;
321  v2 = comp->loc + vv*0.75;
322  v3 = v2 + av;
323  switch ( color_type ) {
324  case 1:
325  rgb.spectrum(comp->sel, 0, selmax);
326  break;
327  case 2:
328  rgb.spectrum(comp->density, dmin, dmax);
329  break;
330  case 3:
331  rgb.spectrum(comp->fom, fommin, fommax);
332  break;
333  }
334  bild_color(fbld, rgb);
335  bild_sphere(fbld, comp->loc, comp->radius);
336  bild_arrow(fbld, comp->loc, v1, vrad, vrad, 0.75);
337  if ( vec_type < 2 ) {
338  bild_polygon_start(fbld, v1);
339  bild_polygon_add(fbld, v2);
340  bild_polygon_end(fbld, v3);
341  }
342  fbld << endl;
343  }
344 
345  fbld << endl;
346 
347  fbld.close();
348 
349  return 0;
350 }
351 
362 int model_to_bild_view_sphere(Bstring& filename, Bmodel* model, int color_type)
363 {
364  int n, selmax;
365  double vrad(TWOPI/360), dmin(1e10), dmax(-1e10), fommin(1e10), fommax(-1e10), fomrange(1);
366  RGB<float> rgb(1,1,1);
367  Vector3<double> vv, av, v1, v2, v3;
368  Matrix3 mat;
369  Bcomponent* comp;
370 
371  for ( n=selmax=0, comp = model->comp; comp; comp = comp->next, n++ ) {
372  if ( dmin > comp->density ) dmin = comp->density;
373  if ( dmax < comp->density ) dmax = comp->density;
374  if ( fommin > comp->fom ) fommin = comp->fom;
375  if ( fommax < comp->fom ) fommax = comp->fom;
376  if ( selmax < comp->sel ) selmax = comp->sel;
377  }
378 
379  fomrange = 5*(fommax - fommin);
380 
381  if ( verbose ) {
382  cout << "Generating a bild views file: " << filename << endl;
383  }
384 
385  ofstream fbld(filename.c_str());
386  if ( fbld.fail() ) {
387  cerr << "Error: Unable to open " << filename << " for writing" << endl;
388  return -1;
389  }
390 
391  fbld << endl;
392  fbld << ".color white" << endl;
393  fbld << ".transparency 0.5" << endl;
394  bild_sphere(fbld, Vector3<double>(0,0,0), 1);
395  fbld << ".transparency 0.0" << endl;
396 
397  for ( comp = model->comp; comp; comp = comp->next ) if ( comp->sel ) {
398  vv = comp->view.vector3();
399  av = Vector3<double>(1,0,0);
400  mat = comp->view.matrix();
401 // mat = mat.transpose();
402  av = mat * av;
403  av *= 3*vrad;
404  if ( fomrange > 0 ) v1 = vv*(1 + vrad + (comp->fom - fommin)/fomrange);
405  else v1 = vv*(1 + 10*vrad);
406  v2 = vv*1.15;
407  v3 = v2 + av;
408  switch ( color_type ) {
409  case 1:
410  rgb.spectrum(comp->sel, 0, selmax);
411  break;
412  case 2:
413  rgb.spectrum(comp->density, dmin, dmax);
414  break;
415  case 3:
416  rgb.spectrum(comp->fom, fommin, fommax);
417  break;
418  }
419  bild_color(fbld, rgb);
420 // bild_arrow(fbld, vv, v1, vrad, vrad, 0.75);
421  bild_cylinder(fbld, vv, v1, vrad);
422 // bild_polygon_start(fbld, v1);
423 // bild_polygon_add(fbld, v2);
424 // bild_polygon_end(fbld, v3);
425  fbld << endl;
426  }
427 
428  fbld << endl;
429 
430  fbld.close();
431 
432  return 0;
433 }
434 
446 int model_to_bild_view_polygons(Bstring& filename, Bmodel* model, int order, int color_type)
447 {
448  int i, n, selmax;
449  double dmin(1e10), dmax(-1e10), fommin(1e10), fommax(-1e10);
450  RGB<float> rgb(1,1,1);
451  Vector3<double> av;
452  Matrix3 mat;
453  Bcomponent* comp;
454 
455  double a(TWOPI*1.0L/order);
456  Vector3<double>* p = new Vector3<double>[order];
457 
458  for ( i=0; i<order; i++ )
459  p[i] = Vector3<double>(cos(i*a), sin(i*a), 0);
460 
461  for ( n=selmax=0, comp = model->comp; comp; comp = comp->next, n++ ) {
462  if ( dmin > comp->density ) dmin = comp->density;
463  if ( dmax < comp->density ) dmax = comp->density;
464  if ( fommin > comp->fom ) fommin = comp->fom;
465  if ( fommax < comp->fom ) fommax = comp->fom;
466  if ( selmax < comp->sel ) selmax = comp->sel;
467  }
468 
469  if ( verbose ) {
470  cout << "Generating a bild view polygons file: " << filename << endl;
471  }
472 
473  ofstream fbld(filename.c_str());
474  if ( fbld.fail() ) {
475  cerr << "Error: Unable to open " << filename << " for writing" << endl;
476  return -1;
477  }
478 
479  fbld << endl;
480  fbld << ".color white" << endl;
481  for ( comp = model->comp; comp; comp = comp->next ) if ( comp->sel ) {
482  switch ( color_type ) {
483  case 1:
484  rgb.spectrum(comp->sel, 0, selmax);
485  break;
486  case 2:
487  rgb.spectrum(comp->density, dmin, dmax);
488  break;
489  case 3:
490  rgb.spectrum(comp->fom, fommin, fommax);
491  break;
492  }
493  bild_color(fbld, rgb);
494  mat = comp->view.matrix();
495  for ( i=0; i<order; i++ ) {
496  av = comp->loc + mat * p[i] * comp->radius;
497  if ( i == 0 ) bild_polygon_start(fbld, av);
498  else if ( i < order - 1 ) bild_polygon_add(fbld, av);
499  else bild_polygon_end(fbld, av);
500  }
501  fbld << endl;
502  }
503 
504  fbld << endl;
505 
506  fbld.close();
507 
508  delete[] p;
509 
510  return 0;
511 }
512 
525 int model_to_bild_polygons(Bstring& filename, Bmodel* model, int color_type)
526 {
528 
529  int i, n, npoly;
530  double fom, fommin(1e10), fommax(-1e10);
531  RGB<float> rgb(1,1,1);
532  Bcomponent* comp;
533  Bpolygon* poly;
534 
535  for ( comp = model->comp; comp; comp = comp->next ) {
536  if ( fommin > comp->fom ) fommin = comp->fom;
537  if ( fommax < comp->fom ) fommax = comp->fom;
538  }
539 
540  for ( npoly=0, poly = model->poly; poly; poly = poly->next ) npoly++;
541 
542  if ( verbose ) {
543  cout << "Generating a bild polygon file: " << filename << endl;
544  switch ( color_type ) {
545  case 1: cout << "Color spectrum range: 0 - " << npoly << endl; break;
546  case 2: cout << "FOM range: " << fommin << " - " << fommax << endl; break;
547  default: cout << "Homogeneous color" << endl;
548  }
549  }
550 
551  ofstream fbld(filename.c_str());
552  if ( fbld.fail() ) {
553  cerr << "Error: Unable to open " << filename << " for writing" << endl;
554  return -1;
555  }
556 
557  fbld << endl;
558  fbld << ".color white" << endl;
559  for ( n=0, poly = model->poly; poly; poly = poly->next, n++ ) {
560  for ( i=0, fom=0; i<MAXLINK && poly->comp[i]; i++ ) fom += poly->comp[i]->fom;
561  if ( i ) fom /= i;
562  switch ( color_type ) {
563  case 1:
564  rgb.spectrum(n, 0, npoly);
565  break;
566  case 2:
567  rgb.spectrum(fom, fommin, fommax);
568  break;
569  }
570  bild_color(fbld, rgb);
571  fbld << ".polygon";
572  for ( i=0; i<MAXLINK && poly->comp[i]; i++ )
573  bild_polygon_add(fbld, poly->comp[i]->loc);
574  fbld << endl;
575  }
576  fbld << endl;
577 
578  fbld.close();
579 
580  return 0;
581 }
582 
595 int model_to_bild_neighbor_planes(Bstring& filename, Bmodel* model, int color_type)
596 {
597  model_set_neighbors(model, 8, 50);
598 
599  int i, n, ncomp;
600  double fom, fommin(1e10), fommax(-1e10);
601  RGB<float> rgb;
602  Bcomponent* comp;
603 
604  for ( ncomp=0, comp = model->comp; comp; comp = comp->next, ncomp++ ) {
605  if ( fommin > comp->fom ) fommin = comp->fom;
606  if ( fommax < comp->fom ) fommax = comp->fom;
607  }
608 
609  if ( verbose ) {
610  cout << "Generating a bild neighbor plane file: " << filename << endl;
611  switch ( color_type ) {
612  case 1: cout << "Color spectrum range: 0 - " << ncomp << endl; break;
613  case 2: cout << "FOM range: " << fommin << " - " << fommax << endl; break;
614  default: cout << "Homogeneous color" << endl;
615  }
616  }
617 
618  ofstream fbld(filename.c_str());
619  if ( fbld.fail() ) {
620  cerr << "Error: Unable to open " << filename << " for writing" << endl;
621  return -1;
622  }
623 
624  fbld << endl;
625  fbld << ".color white" << endl;
626  for ( n=0, comp = model->comp; comp; comp = comp->next, n++ ) {
627  for ( i=0, fom=0; i<MAXLINK && comp->neighbor[i]; i++ ) fom += comp->neighbor[i]->fom;
628  if ( i ) fom /= i;
629  switch ( color_type ) {
630  case 1:
631  rgb.spectrum(n, 0, ncomp);
632  break;
633  case 2:
634  rgb.spectrum(fom, fommin, fommax);
635  break;
636  }
637  bild_color(fbld, rgb);
638  fbld << ".polygon";
639  for ( i=0; i<MAXLINK && comp->neighbor[i]; i++ )
640  bild_polygon_add(fbld, comp->neighbor[i]->loc);
641  fbld << endl;
642  }
643  fbld << endl;
644 
645  fbld.close();
646 
647  return 0;
648 }
649 
650 /*
651 BILD format
652 
653 BILD is a simple text format that describes lines, polygons, and geometric primitives such as spheres, boxes, cylinders, and cones with commands (see example.bild and XYZ-axes.bild). Character strings can also be included. The commands are used to generate a VRML model in Chimera. The objects can be specified in absolute coordinates and/or transformed and scaled coordinates. See also: shape, define, geometric objects
654 
655 This file type is indicated by the filename suffix .bild or .bld, or by using bild:filename in the command line.
656 
657 Curved objects (spheres, cones, and cylinders) read from BILD format are described as perfectly smooth in exported files, but display within Chimera uses planar facets. The number of facets and the apparent smoothness can be increased by raising the subdivision level with the Effects tool or the set command.
658 
659 BILD Commands
660 
661 Square brackets denote optional parameters.
662 
663 .arrow x1 y1 z1 x2 y2 z2 [r1 [r2 [rho]]]
664 Draw an arrow from (x1, y1, z1) to (x2, y2, z2). An arrow consists of a cylinder stretching from the initial point to an intermediary junction, and a cone stretching from the junction to the final point. The radius of the cylinder is r1 (default 0.1), the radius of the base of the cone is r2 (default 4*r1), and the fraction of the total distance taken up by the cylinder is rho (default 0.75).
665 .box x1 y1 z1 x2 y2 z2
666 Draw a box with opposite corners at (x1, y1, z1) and (x2, y2, z2).
667 .color name
668 or
669 .color r g b
670 Set the color of subsequently defined items. The name can be a built-in name, a name defined previously with colordef, or an integer that refers to the old BILD color wheel (0-65, inclusive). Alternatively, a color can be described by its red (r), green (g), and blue (b) components, each in the range 0-1, inclusive. Any transparency in the color is ignored, but transparency can be set separately.
671 .cmov x y z
672 Define the starting location of the next character string. Lines in the BILD file that do not start with a period (.) are character strings to be displayed. See also .font.
673 .comment text
674 User comment line (ignored during object creation).
675 .cone x1 y1 z1 x2 y2 z2 r [open]
676 Draw a cone with a base of radius r centered at (x1, y1, z1) and a tip at (x2, y2, z2). If the keyword open is present, the base of the cone will be invisible.
677 .cylinder x1 y1 z1 x2 y2 z2 r [open]
678 Draw a cylinder with radius r and bases centered at (x1, y1, z1) and (x2, y2, z2). If the keyword open is present, the bases of the cylinder will be invisible.
679 .dotat x y z
680 or
681 .dot x y z
682 Draw a sphere of unit radius centered at (x, y, z). The sphere center is treated as a vertex if there is a subsequent .draw, .drawrel, or .moverel command.
683 .draw x y z
684 or
685 .d x y z
686 Add another vertex to the current set of line segments. A line will be drawn from the previous vertex to this vertex at (x, y, z). There should be a prior .move, .moverel, .dotat, or .marker command (these initiate sets of line segments).
687 .drawrel dx dy dz
688 or
689 .dr dx dy dz
690 Add another vertex to the current set of line segments. A line will be drawn from the previous vertex at (x, y, z) to this vertex at (x + dx, y + dy, z + dz).
691 .font fontname pointsize [fontstyle]
692 Set the font, font size, and font style of subsequent character strings. Lines in the BILD file that do not start with a period (.) are character strings to be displayed. Options for fontname include: Times, Helvetica, Courier, SERIF, SANS, TYPEWRITER. Options for fontstyle: plain, bold, italic, bold italic. See also .cmov.
693 .marker x y z
694 Draw a box of unit cubic diagonal centered at (x, y, z), i.e., a box with opposite corners at (x – 0.5, y – 0.5, z – 0.5) and (x + 0.5, y + 0.5, z + 0.5). The box center is treated as a vertex if there is a subsequent .draw, .drawrel, or .moverel command.
695 .move x y z
696 or
697 .m x y z
698 Start a new set of line segments whose first vertex is at (x, y, z).
699 .moverel dx dy dz
700 or
701 .mr dx dy dz
702 Start a new set of line segments whose first vertex is at (x + dz, y + dy, z + dz), where (x, y, z) is the coordinate of the last vertex defined.
703 .polygon x1 y1 z1 x2 y2 z2 ... xN yN zN
704 Draw a flat polygon with vertices at (x1, y1, z1), (x2, y2, z2), ..., (xN, yN, zN).
705 .pop
706 Discard the most recent transformation (rotation, scaling, or translation) from the transformation stack.
707 .rotate angle axis
708 or
709 .rot angle axis
710 Rotate all subsequent coordinates by angle degrees about the given axis. The axis can be given as a single letter (x, y, or z) or as three numbers defining an arbitrary vector: xa ya za. This transformation is added to the top of the transformation stack.
711 .scale xscale [yscale [zscale]]
712 Scale all subsequent coordinates by the given factor(s). The x coordinates will be scaled by xscale, y coordinates by yscale (equal to xscale by default), and z coordinates by zscale (equal to xscale by default). This transformation is added to the top of the transformation stack.
713 .sphere x y z r
714 Draw a sphere centered at (x, y, z) with radius r.
715 .translate dx dy dz
716 or
717 .tran dx dy dz
718 Translate all subsequent coordinates by the specified amount. This transformation is added to the top of the transformation stack.
719 .transparency value
720 Set the transparency of subsequently defined items. The value can range from 0.0 (not transparent) to 1.0 (completely transparent).
721 .vector x1 y1 z1 x2 y2 z2
722 or
723 .v x1 y1 z1 x2 y2 z2
724 Draw a line segment from (x1, y1, z1) to (x2, y2, z2). This command is a shorthand for
725 .m x1 y1 z1
726 .d x2 y2 z2
727 UCSF Computer Graphics Laboratory / October 2013
728 */
Bcomponent::next
Bcomponent * next
Definition: rwmodel.h:52
Bcomponent
Definition: rwmodel.h:51
Bpolygon::next
Bpolygon * next
Definition: rwmodel.h:103
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:116
bild_arrow
void bild_arrow(ofstream &fbld, Vector3< double > start, Vector3< double > end, double cylrad, double conerad, double rho)
Definition: rwmodel_bild.cpp:219
model_to_bild_orientations
int model_to_bild_orientations(Bstring &filename, Bmodel *model, int vec_type, int color_type)
Converts a model into a representation with views.
Definition: rwmodel_bild.cpp:275
rwmodel.h
Header file for reading and writing atomic model files.
Bcomponent::loc
Vector3< float > loc
Definition: rwmodel.h:58
Bstring
Definition: Bstring.h:29
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:436
bild_polygon_add
void bild_polygon_add(ofstream &fbld, Vector3< double > vertex)
Definition: rwmodel_bild.cpp:210
component_add
Bcomponent * component_add(Bcomponent **comp, Bstring &id)
Adds a component to a linked list.
Definition: rwmodel.cpp:270
Vector3< double >
link_add
Blink * link_add(Blink **link, Bcomponent *comp1, Bcomponent *comp2, double length, double radius)
Adds a component link to a linked list.
Definition: rwmodel.cpp:318
Bmodel::next
Bmodel * next
Definition: rwmodel.h:120
Bstring::real
double real()
Definition: Bstring.cpp:553
RGB
Definition: Color.h:24
Bmodel::link
Blink * link
Definition: rwmodel.h:133
verbose
int verbose
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
bild_sphere
void bild_sphere(ofstream &fbld, Vector3< double > loc, double radius)
Definition: rwmodel_bild.cpp:194
Vector3::distance
double distance(const Vector3 &v)
Definition: Vector3.h:227
Color.h
Classes for color objects.
Bmodel::comp
Bcomponent * comp
Definition: rwmodel.h:132
Matrix3
Definition: Matrix3.h:18
RGB::spectrum
void spectrum(double value, double cmin, double cmax)
Definition: Color.h:89
Bcomponent::vec
Vector3< float > vec
Definition: rwmodel.h:60
Bcomponent::vel
Vector3< float > vel
Definition: rwmodel.h:61
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:421
model_to_bild_view_polygons
int model_to_bild_view_polygons(Bstring &filename, Bmodel *model, int order, int color_type)
Converts a model into a representation with view polygons.
Definition: rwmodel_bild.cpp:446
timer.h
Utilities for timing functions.
Bmodel
Definition: rwmodel.h:119
Bmodel::poly
Bpolygon * poly
Definition: rwmodel.h:134
Bcomponent::color
RGBA< float > color
Definition: rwmodel.h:63
bild_polygon_end
void bild_polygon_end(ofstream &fbld, Vector3< double > vertex)
Definition: rwmodel_bild.cpp:214
utilities.h
Header file for general utilities.
RGBA< float >
View::vector3
Vector3< double > vector3()
Definition: View.h:129
Bstring::length
long length() const
Definition: Bstring.cpp:263
Bpolygon::comp
Bcomponent * comp[MAXLINK]
Definition: rwmodel.h:105
Bcomponent::view
View view
Definition: rwmodel.h:59
Bcomponent::fom
float fom
Definition: rwmodel.h:65
Bpolygon
Definition: rwmodel.h:102
model_set_neighbors
int model_set_neighbors(Bmodel *model, int number)
Sets the desired number of components as neighbors for each component.
Definition: model_neighbors.cpp:28
model
Bmodel * model
Definition: bshow.cpp:34
model_to_bild_view_sphere
int model_to_bild_view_sphere(Bstring &filename, Bmodel *model, int color_type)
Converts a model into a representation with views.
Definition: rwmodel_bild.cpp:362
Bstring::next
Bstring * next
Definition: Bstring.h:31
model_poly.h
Functions to manipulate polyhedral coordinate files.
model_neighbors.h
Functions to manipulate model component neighbors.
bild_color
void bild_color(ofstream &fbld, RGB< float > rgb)
Definition: rwmodel_bild.cpp:184
Bstring::split
Bstring * split()
Definition: Bstring.cpp:605
model_add
Bmodel * model_add(Bmodel **model, Bstring &id)
Adds a model to a linked list.
Definition: rwmodel.cpp:181
model_to_bild_neighbor_planes
int model_to_bild_neighbor_planes(Bstring &filename, Bmodel *model, int color_type)
Converts a model into a bild neighbor plane representation.
Definition: rwmodel_bild.cpp:595
model_poly_generate
int model_poly_generate(Bmodel *model)
Generates polygons based on a vertex network.
Definition: model_poly.cpp:145
View::matrix
Matrix3 matrix()
Definition: View.h:153
Bcomponent::radius
float radius
Definition: rwmodel.h:62
write_model_bild
int write_model_bild(Bstring &filename, Bmodel *model)
Writes Chimera BILD model parameters.
Definition: rwmodel_bild.cpp:232
MAXLINK
#define MAXLINK
Definition: rwmodel.h:14
Bcomponent::density
float density
Definition: rwmodel.h:64
VERB_LABEL
#define VERB_LABEL
Definition: utilities.h:110
component_add_if_not_exist
Bcomponent * component_add_if_not_exist(Vector3< double > loc, Bcomponent **comp, int &number)
Definition: rwmodel_bild.cpp:21
Bcomponent::neighbor
Bcomponent * neighbor[MAXLINK]
Definition: rwmodel.h:56
Bmodel::comment
Bstring comment
Definition: rwmodel.h:126
bild_cylinder
void bild_cylinder(ofstream &fbld, Vector3< double > start, Vector3< double > end, double radius)
Definition: rwmodel_bild.cpp:199
bild_polygon_start
void bild_polygon_start(ofstream &fbld, Vector3< double > vertex)
Definition: rwmodel_bild.cpp:206
TWOPI
#define TWOPI
Definition: utilities.h:72
model_to_bild_polygons
int model_to_bild_polygons(Bstring &filename, Bmodel *model, int color_type)
Converts a model into a bild polygon representation.
Definition: rwmodel_bild.cpp:525
Bcomponent::sel
int sel
Definition: rwmodel.h:66
read_model_bild
Bmodel * read_model_bild(Bstring *file_list)
Reads Chimera BILD model parameters.
Definition: rwmodel_bild.cpp:43