 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
26 for ( comp1 = *comp; comp1; comp1 = comp1->
next )
45 int i, j, nc, first_comment;
60 for ( i=1, filename = file_list; filename; filename = filename->
next, i++ ) {
62 cout <<
"Reading file: " << *filename << endl;
64 fmod.open(filename->
c_str());
65 if ( fmod.fail() )
return NULL;
72 while ( fmod.getline(aline, 1024) ) {
75 cout <<
"DEBUG read_model_bild: " << line << endl;
76 tokens = line.
split();
79 cout <<
"DEBUG read_model_bild: " << *tokens;
80 if ( *tokens ==
".comment" ) {
81 if ( first_comment ) {
82 for ( token = tokens->
next; token; token = token->
next )
86 }
else if ( *tokens ==
".color" ) {
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();
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();
102 }
else if ( *tokens ==
".sphere" ) {
103 for ( j=0, token = tokens->
next; token && j<3; token = token->next, j++ )
104 loc[j] = token->
real();
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();
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();
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();
124 if ( comp && comp2 ) {
125 link =
link_add(&link, comp, comp2, 0, 1);
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();
135 if ( comp && comp2 ) {
136 link =
link_add(&link, comp, comp2, 0, 1);
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();
145 for ( j=0; token && j<3; token = token->
next, j++ )
146 loc[j] = token->
real();
149 if ( comp && comp1 ) {
150 link =
link_add(&link, comp, comp1, 0, 1);
156 }
else if ( *tokens ==
".polygon" ) {
158 for ( j=0, token = tokens->
next; token; token = token->
next ) {
159 loc[j++] = token->
real();
164 if ( comp && comp1 ) {
165 link =
link_add(&link, comp, comp1, 0, 1);
186 fbld <<
".color " << rgb[0] <<
" " << rgb[1] <<
" " << rgb[2] << endl;
191 fbld <<
".color " << rgba[0] <<
" " << rgba[1] <<
" " << rgba[2] << endl;
196 fbld <<
".sphere " << loc[0] <<
" " << loc[1] <<
" " << loc[2] <<
" " << radius << endl;
201 fbld <<
".cylinder " << start[0] <<
" " << start[1] <<
" " << start[2]
202 <<
" " << end[0] <<
" " << end[1] <<
" " << end[2]
203 <<
" " << radius << endl;
208 fbld <<
".polygon " << vertex[0] <<
" " << vertex[1] <<
" " << vertex[2];
212 fbld <<
" " << vertex[0] <<
" " << vertex[1] <<
" " << vertex[2];
216 fbld <<
" " << vertex[0] <<
" " << vertex[1] <<
" " << vertex[2] << endl;
221 fbld <<
".arrow " << start[0] <<
" " << start[1] <<
" " << start[2]
222 <<
" " << end[0] <<
" " << end[1] <<
" " << end[2]
223 <<
" " << cylrad <<
" " << conerad <<
" " << rho << endl;
242 for ( n=1, mp =
model; mp; mp = mp->
next, n++ ) {
247 fmod.open(onename.
c_str());
249 fmod <<
".comment " << mp->
comment << endl;
250 for ( comp = mp->
comp; comp; comp = comp->
next ) {
254 for ( link = mp->
link; link; link = link->
next ) {
278 double vlen, vrad, dmin(1e10), dmax(-1e10), fommin(1e10), fommax(-1e10);
284 for ( n=selmax=0, comp =
model->
comp; comp; comp = comp->
next, n++ ) {
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;
293 cout <<
"Generating a bild views file: " << filename << endl;
296 ofstream fbld(filename.
c_str());
298 cerr <<
"Error: Unable to open " << filename <<
" for writing" << endl;
303 fbld <<
".color white" << endl;
307 switch ( vec_type ) {
309 case 2: vv = comp->
vec;
break;
310 case 3: vv = comp->
vel;
break;
313 if ( vec_type < 2 ) {
321 v2 = comp->
loc + vv*0.75;
323 switch ( color_type ) {
337 if ( vec_type < 2 ) {
365 double vrad(
TWOPI/360), dmin(1e10), dmax(-1e10), fommin(1e10), fommax(-1e10), fomrange(1);
371 for ( n=selmax=0, comp =
model->
comp; comp; comp = comp->
next, n++ ) {
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;
379 fomrange = 5*(fommax - fommin);
382 cout <<
"Generating a bild views file: " << filename << endl;
385 ofstream fbld(filename.
c_str());
387 cerr <<
"Error: Unable to open " << filename <<
" for writing" << endl;
392 fbld <<
".color white" << endl;
393 fbld <<
".transparency 0.5" << endl;
395 fbld <<
".transparency 0.0" << endl;
404 if ( fomrange > 0 ) v1 = vv*(1 + vrad + (comp->
fom - fommin)/fomrange);
405 else v1 = vv*(1 + 10*vrad);
408 switch ( color_type ) {
449 double dmin(1e10), dmax(-1e10), fommin(1e10), fommax(-1e10);
455 double a(
TWOPI*1.0L/order);
458 for ( i=0; i<order; i++ )
461 for ( n=selmax=0, comp =
model->
comp; comp; comp = comp->
next, n++ ) {
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;
470 cout <<
"Generating a bild view polygons file: " << filename << endl;
473 ofstream fbld(filename.
c_str());
475 cerr <<
"Error: Unable to open " << filename <<
" for writing" << endl;
480 fbld <<
".color white" << endl;
482 switch ( color_type ) {
495 for ( i=0; i<order; i++ ) {
496 av = comp->
loc + mat * p[i] * comp->
radius;
530 double fom, fommin(1e10), fommax(-1e10);
536 if ( fommin > comp->
fom ) fommin = comp->
fom;
537 if ( fommax < comp->fom ) fommax = comp->
fom;
540 for ( npoly=0, poly =
model->
poly; poly; poly = poly->
next ) npoly++;
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;
551 ofstream fbld(filename.
c_str());
553 cerr <<
"Error: Unable to open " << filename <<
" for writing" << endl;
558 fbld <<
".color white" << endl;
559 for ( n=0, poly =
model->
poly; poly; poly = poly->
next, n++ ) {
562 switch ( color_type ) {
600 double fom, fommin(1e10), fommax(-1e10);
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;
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;
618 ofstream fbld(filename.
c_str());
620 cerr <<
"Error: Unable to open " << filename <<
" for writing" << endl;
625 fbld <<
".color white" << endl;
626 for ( n=0, comp =
model->
comp; comp; comp = comp->
next, n++ ) {
629 switch ( color_type ) {
void bild_arrow(ofstream &fbld, Vector3< double > start, Vector3< double > end, double cylrad, double conerad, double rho)
int model_to_bild_orientations(Bstring &filename, Bmodel *model, int vec_type, int color_type)
Converts a model into a representation with views.
Header file for reading and writing atomic model files.
void bild_polygon_add(ofstream &fbld, Vector3< double > vertex)
Bcomponent * component_add(Bcomponent **comp, Bstring &id)
Adds a component to a linked list.
Blink * link_add(Blink **link, Bcomponent *comp1, Bcomponent *comp2, double length, double radius)
Adds a component link to a linked list.
void bild_sphere(ofstream &fbld, Vector3< double > loc, double radius)
double distance(const Vector3 &v)
Classes for color objects.
void spectrum(double value, double cmin, double cmax)
int model_to_bild_view_polygons(Bstring &filename, Bmodel *model, int order, int color_type)
Converts a model into a representation with view polygons.
Utilities for timing functions.
void bild_polygon_end(ofstream &fbld, Vector3< double > vertex)
Header file for general utilities.
Vector3< double > vector3()
Bcomponent * comp[MAXLINK]
int model_set_neighbors(Bmodel *model, int number)
Sets the desired number of components as neighbors for each component.
int model_to_bild_view_sphere(Bstring &filename, Bmodel *model, int color_type)
Converts a model into a representation with views.
Functions to manipulate polyhedral coordinate files.
Functions to manipulate model component neighbors.
void bild_color(ofstream &fbld, RGB< float > rgb)
Bmodel * model_add(Bmodel **model, Bstring &id)
Adds a model to a linked list.
int model_to_bild_neighbor_planes(Bstring &filename, Bmodel *model, int color_type)
Converts a model into a bild neighbor plane representation.
int model_poly_generate(Bmodel *model)
Generates polygons based on a vertex network.
int write_model_bild(Bstring &filename, Bmodel *model)
Writes Chimera BILD model parameters.
Bcomponent * component_add_if_not_exist(Vector3< double > loc, Bcomponent **comp, int &number)
Bcomponent * neighbor[MAXLINK]
void bild_cylinder(ofstream &fbld, Vector3< double > start, Vector3< double > end, double radius)
void bild_polygon_start(ofstream &fbld, Vector3< double > vertex)
int model_to_bild_polygons(Bstring &filename, Bmodel *model, int color_type)
Converts a model into a bild polygon representation.
Bmodel * read_model_bild(Bstring *file_list)
Reads Chimera BILD model parameters.