| Bsoft 2.0.5 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
21 Bcomponent* component_add_if_not_exist(Vector3<double> loc, Bcomponent** comp, int &number)
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
43 Bmodel* read_model_bild(Bstring* file_list)
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
232 int write_model_bild(Bstring& filename, Bmodel* model)
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 bild_sphere(fbld, Vector3<double>(0,0,0), 1);
394
395 for ( comp = model->comp; comp; comp = comp->next ) if ( comp->sel ) {
396 vv = comp->view.vector3();
397 av = Vector3<double>(1,0,0);
398 mat = comp->view.matrix();
399 // mat = mat.transpose();
400 av = mat * av;
401 av *= 3*vrad;
402 if ( fomrange > 0 ) v1 = vv*(1 + vrad + (comp->fom - fommin)/fomrange);
403 else v1 = vv*(1 + 10*vrad);
404 v2 = vv*1.15;
405 v3 = v2 + av;
406 switch ( color_type ) {
407 case 1:
408 rgb.spectrum(comp->sel, 0, selmax);
409 break;
410 case 2:
411 rgb.spectrum(comp->density, dmin, dmax);
412 break;
413 case 3:
414 rgb.spectrum(comp->fom, fommin, fommax);
415 break;
416 }
417 bild_color(fbld, rgb);
418 // bild_arrow(fbld, vv, v1, vrad, vrad, 0.75);
419 bild_cylinder(fbld, vv, v1, vrad);
420 // bild_polygon_start(fbld, v1);
421 // bild_polygon_add(fbld, v2);
422 // bild_polygon_end(fbld, v3);
423 fbld << endl;
424 }
425
426 fbld << endl;
427
428 fbld.close();
429
430 return 0;
431 }
432
444 int model_to_bild_view_polygons(Bstring& filename, Bmodel* model, int order, int color_type)
445 {
446 int i, n, selmax;
447 double dmin(1e10), dmax(-1e10), fommin(1e10), fommax(-1e10);
448 RGB<float> rgb(1,1,1);
449 Vector3<double> av;
450 Matrix3 mat;
451 Bcomponent* comp;
452
453 double a(TWOPI*1.0L/order);
454 Vector3<double>* p = new Vector3<double>[order];
455
456 for ( i=0; i<order; i++ )
457 p[i] = Vector3<double>(cos(i*a), sin(i*a), 0);
458
459 for ( n=selmax=0, comp = model->comp; comp; comp = comp->next, n++ ) {
460 if ( dmin > comp->density ) dmin = comp->density;
461 if ( dmax < comp->density ) dmax = comp->density;
462 if ( fommin > comp->fom ) fommin = comp->fom;
463 if ( fommax < comp->fom ) fommax = comp->fom;
464 if ( selmax < comp->sel ) selmax = comp->sel;
465 }
466
467 if ( verbose ) {
468 cout << "Generating a bild view polygons file: " << filename << endl;
469 }
470
471 ofstream fbld(filename.c_str());
472 if ( fbld.fail() ) {
473 cerr << "Error: Unable to open " << filename << " for writing" << endl;
474 return -1;
475 }
476
477 fbld << endl;
478 fbld << ".color white" << endl;
479 for ( comp = model->comp; comp; comp = comp->next ) if ( comp->sel ) {
480 switch ( color_type ) {
481 case 1:
482 rgb.spectrum(comp->sel, 0, selmax);
483 break;
484 case 2:
485 rgb.spectrum(comp->density, dmin, dmax);
486 break;
487 case 3:
488 rgb.spectrum(comp->fom, fommin, fommax);
489 break;
490 }
491 bild_color(fbld, rgb);
492 mat = comp->view.matrix();
493 for ( i=0; i<order; i++ ) {
494 av = comp->loc + mat * p[i] * comp->radius;
495 if ( i == 0 ) bild_polygon_start(fbld, av);
496 else if ( i < order - 1 ) bild_polygon_add(fbld, av);
497 else bild_polygon_end(fbld, av);
498 }
499 fbld << endl;
500 }
501
502 fbld << endl;
503
504 fbld.close();
505
506 delete[] p;
507
508 return 0;
509 }
510
523 int model_to_bild_polygons(Bstring& filename, Bmodel* model, int color_type)
524 {
525 if ( !model->poly ) model_poly_generate(model);
526
527 int i, n, npoly;
528 double fom, fommin(1e10), fommax(-1e10);
529 RGB<float> rgb(1,1,1);
530 Bcomponent* comp;
531 Bpolygon* poly;
532
533 for ( comp = model->comp; comp; comp = comp->next ) {
534 if ( fommin > comp->fom ) fommin = comp->fom;
535 if ( fommax < comp->fom ) fommax = comp->fom;
536 }
537
538 for ( npoly=0, poly = model->poly; poly; poly = poly->next ) npoly++;
539
540 if ( verbose ) {
541 cout << "Generating a bild polygon file: " << filename << endl;
542 switch ( color_type ) {
543 case 1: cout << "Color spectrum range: 0 - " << npoly << endl; break;
544 case 2: cout << "FOM range: " << fommin << " - " << fommax << endl; break;
545 default: cout << "Homogeneous color" << endl;
546 }
547 }
548
549 ofstream fbld(filename.c_str());
550 if ( fbld.fail() ) {
551 cerr << "Error: Unable to open " << filename << " for writing" << endl;
552 return -1;
553 }
554
555 fbld << endl;
556 fbld << ".color white" << endl;
557 for ( n=0, poly = model->poly; poly; poly = poly->next, n++ ) {
558 for ( i=0, fom=0; i<MAXLINK && poly->comp[i]; i++ ) fom += poly->comp[i]->fom;
559 if ( i ) fom /= i;
560 switch ( color_type ) {
561 case 1:
562 rgb.spectrum(n, 0, npoly);
563 break;
564 case 2:
565 rgb.spectrum(fom, fommin, fommax);
566 break;
567 }
568 bild_color(fbld, rgb);
569 fbld << ".polygon";
570 for ( i=0; i<MAXLINK && poly->comp[i]; i++ )
571 bild_polygon_add(fbld, poly->comp[i]->loc);
572 fbld << endl;
573 }
574 fbld << endl;
575
576 fbld.close();
577
578 return 0;
579 }
580
593 int model_to_bild_neighbor_planes(Bstring& filename, Bmodel* model, int color_type)
594 {
595 model_set_neighbors(model, 8, 50);
596
597 int i, n, ncomp;
598 double fom, fommin(1e10), fommax(-1e10);
599 RGB<float> rgb;
600 Bcomponent* comp;
601
602 for ( ncomp=0, comp = model->comp; comp; comp = comp->next, ncomp++ ) {
603 if ( fommin > comp->fom ) fommin = comp->fom;
604 if ( fommax < comp->fom ) fommax = comp->fom;
605 }
606
607 if ( verbose ) {
608 cout << "Generating a bild neighbor plane file: " << filename << endl;
609 switch ( color_type ) {
610 case 1: cout << "Color spectrum range: 0 - " << ncomp << endl; break;
611 case 2: cout << "FOM range: " << fommin << " - " << fommax << endl; break;
612 default: cout << "Homogeneous color" << endl;
613 }
614 }
615
616 ofstream fbld(filename.c_str());
617 if ( fbld.fail() ) {
618 cerr << "Error: Unable to open " << filename << " for writing" << endl;
619 return -1;
620 }
621
622 fbld << endl;
623 fbld << ".color white" << endl;
624 for ( n=0, comp = model->comp; comp; comp = comp->next, n++ ) {
625 for ( i=0, fom=0; i<MAXLINK && comp->neighbor[i]; i++ ) fom += comp->neighbor[i]->fom;
626 if ( i ) fom /= i;
627 switch ( color_type ) {
628 case 1:
629 rgb.spectrum(n, 0, ncomp);
630 break;
631 case 2:
632 rgb.spectrum(fom, fommin, fommax);
633 break;
634 }
635 bild_color(fbld, rgb);
636 fbld << ".polygon";
637 for ( i=0; i<MAXLINK && comp->neighbor[i]; i++ )
638 bild_polygon_add(fbld, comp->neighbor[i]->loc);
639 fbld << endl;
640 }
641 fbld << endl;
642
643 fbld.close();
644
645 return 0;
646 }
647
648 /*
649 BILD format
650
651 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
652
653 This file type is indicated by the filename suffix .bild or .bld, or by using bild:filename in the command line.
654
655 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.
656
657 BILD Commands
658
659 Square brackets denote optional parameters.
660
661 .arrow x1 y1 z1 x2 y2 z2 [r1 [r2 [rho]]]
662 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).
663 .box x1 y1 z1 x2 y2 z2
664 Draw a box with opposite corners at (x1, y1, z1) and (x2, y2, z2).
665 .color name
666 or
667 .color r g b
668 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.
669 .cmov x y z
670 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.
671 .comment text
672 User comment line (ignored during object creation).
673 .cone x1 y1 z1 x2 y2 z2 r [open]
674 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.
675 .cylinder x1 y1 z1 x2 y2 z2 r [open]
676 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.
677 .dotat x y z
678 or
679 .dot x y z
680 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.
681 .draw x y z
682 or
683 .d x y z
684 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).
685 .drawrel dx dy dz
686 or
687 .dr dx dy dz
688 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).
689 .font fontname pointsize [fontstyle]
690 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.
691 .marker x y z
692 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.
693 .move x y z
694 or
695 .m x y z
696 Start a new set of line segments whose first vertex is at (x, y, z).
697 .moverel dx dy dz
698 or
699 .mr dx dy dz
700 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.
701 .polygon x1 y1 z1 x2 y2 z2 ... xN yN zN
702 Draw a flat polygon with vertices at (x1, y1, z1), (x2, y2, z2), ..., (xN, yN, zN).
703 .pop
704 Discard the most recent transformation (rotation, scaling, or translation) from the transformation stack.
705 .rotate angle axis
706 or
707 .rot angle axis
708 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.
709 .scale xscale [yscale [zscale]]
710 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.
711 .sphere x y z r
712 Draw a sphere centered at (x, y, z) with radius r.
713 .translate dx dy dz
714 or
715 .tran dx dy dz
716 Translate all subsequent coordinates by the specified amount. This transformation is added to the top of the transformation stack.
717 .transparency value
718 Set the transparency of subsequently defined items. The value can range from 0.0 (not transparent) to 1.0 (completely transparent).
719 .vector x1 y1 z1 x2 y2 z2
720 or
721 .v x1 y1 z1 x2 y2 z2
722 Draw a line segment from (x1, y1, z1) to (x2, y2, z2). This command is a shorthand for
723 .m x1 y1 z1
724 .d x2 y2 z2
725 UCSF Computer Graphics Laboratory / October 2013
726 */
MAXLINK
#define MAXLINK
Definition: rwmodel.h:14
Bstring::real
double real()
Definition: Bstring.cpp:545
Blink
Definition: rwmodel.h:82
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:444
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
Bmodel::poly
Bpolygon * poly
Definition: rwmodel.h:134
bild_sphere
void bild_sphere(ofstream &fbld, Vector3< double > loc, double radius)
Definition: rwmodel_bild.cpp:194
utilities.h
Header file for general utilities.
Blink::color
RGBA< float > color
Definition: rwmodel.h:88
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:112
RGBA< float >
Bpolygon::comp
Bcomponent * comp[MAXLINK]
Definition: rwmodel.h:105
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:593
Bpolygon
Definition: rwmodel.h:102
Matrix3
Definition: Matrix3.h:17
Bstring::length
long length() const
Definition: Bstring.cpp:263
Bmodel::comment
Bstring comment
Definition: rwmodel.h:126
component_add
Bcomponent * component_add(Bcomponent **comp, Bstring &id)
Adds a component to a linked list.
Definition: rwmodel.cpp:267
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:315
Bcomponent::neighbor
Bcomponent * neighbor[MAXLINK]
Definition: rwmodel.h:56
Bcomponent::vel
Vector3< float > vel
Definition: rwmodel.h:61
Blink::comp
Bcomponent * comp[2]
Definition: rwmodel.h:84
Vector3::distance
double distance(const Vector3 &v)
Definition: Vector3.h:227
timer.h
Utilities for timing functions.
write_model_bild
int write_model_bild(Bstring &filename, Bmodel *model)
Writes Chimera BILD model parameters.
Definition: rwmodel_bild.cpp:232
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
bild_polygon_start
void bild_polygon_start(ofstream &fbld, Vector3< double > vertex)
Definition: rwmodel_bild.cpp:206
bild_polygon_end
void bild_polygon_end(ofstream &fbld, Vector3< double > vertex)
Definition: rwmodel_bild.cpp:214
bild_polygon_add
void bild_polygon_add(ofstream &fbld, Vector3< double > vertex)
Definition: rwmodel_bild.cpp:210
read_model_bild
Bmodel * read_model_bild(Bstring *file_list)
Reads Chimera BILD model parameters.
Definition: rwmodel_bild.cpp:43
Bcomponent::view
View view
Definition: rwmodel.h:59
Blink::next
Blink * next
Definition: rwmodel.h:83
Bcomponent::fom
float fom
Definition: rwmodel.h:65
Bstring::next
Bstring * next
Definition: Bstring.h:31
bild_color
void bild_color(ofstream &fbld, RGB< float > rgb)
Definition: rwmodel_bild.cpp:184
Blink::radius
float radius
Definition: rwmodel.h:87
RGB
Definition: Color.h:24
Bcomponent::density
float density
Definition: rwmodel.h:64
Bpolygon::next
Bpolygon * next
Definition: rwmodel.h:103
model_poly_generate
int model_poly_generate(Bmodel *model)
Generates polygons based on a vertex network.
Definition: model_poly.cpp:145
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:523
View::vector3
Vector3< double > vector3()
Definition: View.h:126
model_poly.h
Functions to manipulate polyhedral coordinate files.
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
verbose
int verbose
Bmodel::next
Bmodel * next
Definition: rwmodel.h:120
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:428
Bcomponent::sel
int sel
Definition: rwmodel.h:66
Bcomponent::radius
float radius
Definition: rwmodel.h:62
model
Bmodel * model
Definition: bshow.cpp:32
Bstring
Definition: Bstring.h:29
bild_arrow
void bild_arrow(ofstream &fbld, Vector3< double > start, Vector3< double > end, double cylrad, double conerad, double rho)
Definition: rwmodel_bild.cpp:219
View::matrix
Matrix3 matrix()
Definition: View.h:150
Bmodel::link
Blink * link
Definition: rwmodel.h:133
model_add
Bmodel * model_add(Bmodel **model, Bstring &id)
Adds a model to a linked list.
Definition: rwmodel.cpp:178
Bcomponent::vec
Vector3< float > vec
Definition: rwmodel.h:60
Bcomponent::next
Bcomponent * next
Definition: rwmodel.h:52
rwmodel.h
Header file for reading and writing atomic model files.
Vector3< double >
RGB::spectrum
void spectrum(double value, double cmin, double cmax)
Definition: Color.h:89
Color.h
Classes for color objects.
Bmodel
Definition: rwmodel.h:119
model_neighbors.h
Functions to manipulate model component neighbors.
Bmodel::comp
Bcomponent * comp
Definition: rwmodel.h:132
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:413
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
VERB_LABEL
#define VERB_LABEL
Definition: utilities.h:106
Bcomponent::loc
Vector3< float > loc
Definition: rwmodel.h:58
bild_cylinder
void bild_cylinder(ofstream &fbld, Vector3< double > start, Vector3< double > end, double radius)
Definition: rwmodel_bild.cpp:199
TWOPI
#define TWOPI
Definition: utilities.h:68
Bcomponent::color
RGBA< float > color
Definition: rwmodel.h:63
component_add_if_not_exist
Bcomponent * component_add_if_not_exist(Vector3< double > loc, Bcomponent **comp, int &number)
Definition: rwmodel_bild.cpp:21
Bstring::split
Bstring * split()
Definition: Bstring.cpp:597
Bcomponent
Definition: rwmodel.h:51