Bsoft  2.1.0
Bernard's software package
model_color.cpp
Go to the documentation of this file.
1 
9 #include "rwmodel.h"
10 #include "model_poly.h"
11 #include "model_shell.h"
12 #include "model_views.h"
13 #include "model_util.h"
14 #include "Color.h"
15 #include "utilities.h"
16 
17 // Declaration of global variables
18 extern int verbose; // Level of output to the screen
19 
30 {
31  Bmodel* m;
32  Bcomponent* comp;
33  Blink* link;
34 
35  if ( verbose & VERB_PROCESS )
36  cout << "Coloring components uniformly: " << color[0] << " " <<
37  color[1] << " " << color[2] << " " << color[3] << endl << endl;
38 
39  for ( m = model; m; m = m->next ) {
40  for ( comp = m->comp; comp; comp = comp->next )
41  comp->color = color;
42  for ( link = m->link; link; link = link->next )
43  link->color = color;
44  }
45 
46  return 0;
47 }
48 
56 {
57  Bmodel* m;
58  Bcomponent* comp;
59  Blink* link;
60 
61  if ( verbose & VERB_PROCESS )
62  cout << "Coloring components by selection: " << color[0] << " " <<
63  color[1] << " " << color[2] << " " << color[3] << endl << endl;
64 
65  for ( m = model; m; m = m->next ) if ( m->sel ) {
66  for ( comp = m->comp; comp; comp = comp->next ) if ( comp->sel )
67  comp->color = color;
68  for ( link = m->link; link; link = link->next ) if ( link->sel ) {
69  if ( link->comp[0]->sel && link->comp[1]->sel )
70  link->color = (link->comp[0]->color + link->comp[1]->color)/2;
71  }
72  }
73 
74  return 0;
75 }
76 
83 {
84  int i, ncomp;
85  Bmodel* m;
86  Bcomponent* comp;
87  Blink* link;
88 
89  if ( verbose & VERB_PROCESS )
90  cout << "Coloring components by order" << endl << endl;
91 
92  for ( m = model; m; m = m->next ) if ( m->sel ) {
93  for ( ncomp = 0, comp = m->comp; comp; comp = comp->next ) if ( comp->sel ) ncomp++;
94  for ( i=0, comp = m->comp; comp; comp = comp->next ) if ( comp->sel ) {
95  comp->color.spectrum(i, 0, ncomp);
96  comp->color[3] = 1;
97  i++;
98  }
99  for ( link = m->link; link; link = link->next ) if ( link->sel ) {
100  link->color = (link->comp[0]->color + link->comp[1]->color)/2;
101  }
102  }
103 
104  return 0;
105 }
106 
119 {
120  double dmin = 1e30, dmax = -1e30;
121  Bmodel* m;
122  Bcomponent* comp;
123  Blink* link;
124 
125  for ( m = model; m; m = m->next ) if ( m->sel ) {
126  for ( comp = m->comp; comp; comp = comp->next ) if ( comp->sel ) {
127  if ( dmin > comp->density ) dmin = comp->density;
128  if ( dmax < comp->density ) dmax = comp->density;
129  }
130  }
131 
132  if ( verbose & VERB_PROCESS )
133  cout << "Coloring components by density (" << dmin << " - " << dmax << ")" << endl << endl;
134 
135  for ( m = model; m; m = m->next ) if ( m->sel ) {
136  for ( comp = m->comp; comp; comp = comp->next ) if ( comp->sel ) {
137  comp->color.spectrum(comp->density, dmin, dmax);
138  comp->color[3] = 1;
139  }
140  for ( link = m->link; link; link = link->next ) if ( link->sel ) {
141  link->color = (link->comp[0]->color + link->comp[1]->color)/2;
142  }
143  }
144 
145  return 0;
146 }
147 
160 {
161  double fmin = 1e30, fmax = -1e30;
162  Bmodel* m;
163  Bcomponent* comp;
164  Blink* link;
165 
166  for ( m = model; m; m = m->next ) if ( m->sel ) {
167  for ( comp = m->comp; comp; comp = comp->next ) if ( comp->sel ) {
168  if ( fmin > comp->fom ) fmin = comp->fom;
169  if ( fmax < comp->fom ) fmax = comp->fom;
170  }
171  }
172 
173  if ( verbose & VERB_PROCESS )
174  cout << "Coloring components by FOM (" << fmin << " - " << fmax << ")" << endl;
175 
176  for ( m = model; m; m = m->next ) if ( m->sel ) {
177  for ( comp = m->comp; comp; comp = comp->next ) if ( comp->sel ) {
178  comp->color.spectrum(comp->fom, fmin, fmax);
179  comp->color[3] = 1;
180  }
181  for ( link = m->link; link; link = link->next ) if ( link->sel ) {
182  link->color = (link->comp[0]->color + link->comp[1]->color)/2;
183  }
184  }
185 
186  return 0;
187 }
188 
202 {
203  Bmodel* m;
204  Bcomponent* comp;
205  Blink* link;
206 
207  if ( verbose & VERB_PROCESS )
208  cout << "Coloring selected component types" << endl << endl;
209 
210  for ( m = model; m; m = m->next ) if ( m->sel ) {
211  for ( comp = m->comp; comp; comp = comp->next ) if ( comp->sel ) {
212  if ( comp->type->sel )
213  comp->color = rgba;
214  }
215  for ( link = m->link; link; link = link->next ) if ( link->sel ) {
216  link->color = (link->comp[0]->color + link->comp[1]->color)/2;
217  }
218  }
219 
220  return 0;
221 }
222 
229 {
230  Bmodel* m;
231  Bcomponent* comp;
232  Blink* link;
233 
235 
236  if ( verbose & VERB_PROCESS )
237  cout << "Coloring based on curvature" << endl << endl;
238 
239  for ( m = model; m; m = m->next ) if ( m->sel ) {
240  for ( link = m->link; link; link = link->next ) if ( link->sel ) {
241  link->color.spectrum(link->fom, 0, M_PI_4);
242  }
243  for ( comp = m->comp; comp; comp = comp->next ) if ( comp->sel ) {
244  comp->color.spectrum(comp->fom, 0, M_PI_4);
245  }
246  }
247 
248  return 0;
249 }
250 
260 {
261  int h, n(0);
262  RGBA<float> red(1.0,0.0,0.0,1.0);
263  RGBA<float> blu(0.0,0.0,1.0,1.0);
264  Bmodel* m;
265  Bcomponent* comp;
266 
268 
269  if ( verbose & VERB_PROCESS )
270  cout << "Coloring based on chirality." << endl;
271 
272  for ( m = model; m; m = m->next ) if ( m->sel ) {
273  for ( comp = m->comp; comp; comp = comp->next ) if ( comp->sel ) {
274  h = component_hand(comp->type->id);
275  if ( h > 0 ) comp->color = blu;
276  else if ( h < 0 ) comp->color = red;
277  if ( h ) n++;
278  }
279  }
280 
281  if ( verbose )
282  cout << "Number of chiral vertices: " << n << endl << endl;
283 
284  return n;
285 }
Bcomponent::next
Bcomponent * next
Definition: rwmodel.h:52
Bcomponent
Definition: rwmodel.h:51
M_PI_4
#define M_PI_4
Definition: utilities.h:69
rwmodel.h
Header file for reading and writing atomic model files.
Bcomptype::sel
int sel
Definition: rwmodel.h:34
Bmodel::next
Bmodel * next
Definition: rwmodel.h:120
Bmodel::link
Blink * link
Definition: rwmodel.h:133
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:111
model_color_by_fom
int model_color_by_fom(Bmodel *model)
Colors model components by fom.
Definition: model_color.cpp:159
Color.h
Classes for color objects.
Bmodel::comp
Bcomponent * comp
Definition: rwmodel.h:132
component_hand
int component_hand(Bstring &s)
Determines the hand of a component.
Definition: model_views.cpp:466
verbose
int verbose
model_color_chiral_vertices
int model_color_chiral_vertices(Bmodel *model)
Colors model vertices as a function of chirality.
Definition: model_color.cpp:259
model_color_selected
int model_color_selected(Bmodel *model, RGBA< float > color)
Colors selected model components.
Definition: model_color.cpp:55
model_color_by_density
int model_color_by_density(Bmodel *model)
Colors model components by density.
Definition: model_color.cpp:118
Bmodel::sel
int sel
Definition: rwmodel.h:129
RGBA::spectrum
void spectrum(double value, double cmin, double cmax)
Definition: Color.h:221
Bmodel
Definition: rwmodel.h:119
Bcomponent::color
RGBA< float > color
Definition: rwmodel.h:63
utilities.h
Header file for general utilities.
RGBA< float >
model_curvature
int model_curvature(Bmodel *model)
Calculates the curvature associated with each link.
Definition: model_shell.cpp:279
model_extended_vertex_types
int model_extended_vertex_types(Bmodel *model)
Determines the vertex type based on adjacent and opposed polygons.
Definition: model_poly.cpp:396
Bcomponent::fom
float fom
Definition: rwmodel.h:65
model_color_selected_types
int model_color_selected_types(Bmodel *model, RGBA< float > rgba)
Colors model components by fom.
Definition: model_color.cpp:201
model_views.h
Library routines used for analysing model component views.
Bcomponent::type
Bcomptype * type
Definition: rwmodel.h:54
Bcomptype::id
Bstring id
Definition: rwmodel.h:27
model
Bmodel * model
Definition: bshow.cpp:34
model_color_uniformly
int model_color_uniformly(Bmodel *model, RGBA< float > color)
Colors model components uniformly.
Definition: model_color.cpp:29
model_color_by_order
int model_color_by_order(Bmodel *model)
Colors model components in order from red to blue.
Definition: model_color.cpp:82
model_poly.h
Functions to manipulate polyhedral coordinate files.
model_color_curvature
int model_color_curvature(Bmodel *model)
Colors model vertices and links as a function of curvature.
Definition: model_color.cpp:228
model_util.h
Library routines used for model processing.
Bcomponent::density
float density
Definition: rwmodel.h:64
model_shell.h
Library routines used for shell model processing.
Bcomponent::sel
int sel
Definition: rwmodel.h:66