 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
30 if ( !
model )
return 0;
37 for ( n=0, link =
model->
link; link; link = link->
next, n++ ) {
38 comp1 = link->
comp[0];
39 comp2 = link->
comp[1];
40 for ( i=0; i<
MAXLINK && comp1->
link[i] && comp1->
link[i] != comp2; i++ ) ;
41 for ( j=0; j<
MAXLINK && comp2->
link[j] && comp2->
link[j] != comp1; j++ ) ;
42 if ( comp1->
link[i] == comp2 && comp2->
link[j] == comp1 ) {
44 cerr <<
"Error: " << comp1->
id <<
" already linked to " << comp2->
id <<
45 "! (" << i <<
" -" << j <<
")" << endl;
48 comp1->
link[i] = comp2;
49 comp2->
link[j] = comp1;
52 cerr <<
"Warning: Link count too large!" << endl;
72 if ( !
model )
return 0;
75 double linkrad(0.1*maxlength);
82 cout <<
"Generating a model link list with maximum link length " << maxlength << endl;
85 if ( link ) linkrad = link->
radius;
87 for ( comp2 = comp->
next; comp2; comp2 = comp2->
next )
if ( comp2->
sel ) {
89 if ( d <= maxlength ) {
90 link =
link_add(&link, comp, comp2, d, linkrad);
98 cout <<
"Number of links generated " << n << endl << endl;
114 if ( !
model )
return 0;
120 cout <<
"Setting reference link lengths to " << linklength << endl << endl;
123 link->
length = linklength;
141 if ( !
model )
return 0;
156 if ( !comp->
sel )
return NULL;
158 *avg_loc += comp->
loc;
211 cout <<
"Reducing models and writing sub-models to file " << submodname << endl << endl;
215 comp_list = comp_new = NULL;
217 for ( i=0, comp = mp->
comp; comp; comp = comp->
next )
if ( comp->
sel ) {
220 if ( !comp_list ) comp_list = comp_new;
229 comp_new->
loc /= comp_new->
sel;
233 cout <<
"Adding sub-model " << mpt->
type_id << endl;
234 if ( !model_sub ) model_sub = mps =
model_copy(mpt);
236 for ( mps = model_sub; mps->
next; mps = mps->
next ) ;
241 comp_new->
type->
num =
id.integer();
243 for ( comp_sub = mps->
comp; comp_sub; comp_sub = comp_sub->
next ) {
244 comp_sub->
vel = comp_sub->
loc;
255 for ( comp_sub = mps->
comp, comp_temp = mpt->
comp; comp_sub && comp_temp;
256 comp_sub = comp_sub->
next, comp_temp = comp_temp->
next ) {
257 comp_sub->
vel += comp_temp->
loc;
268 mp->
comp = comp_list;
272 for ( mps = model_sub; mps; mps = mps->
next )
273 for ( comp_sub = mps->
comp; comp_sub; comp_sub = comp_sub->
next )
274 if ( comp_sub->
sel ) comp_sub->
loc = comp_sub->
vel/comp_sub->
sel;
297 cerr <<
"Error: No model selected!" << endl << endl;
302 cout <<
"Generating links to ensure minimum valency of " << valency << endl;
Utility functions for matrices.
double matrix_find_cutoff_for_number(Matrix m, int n)
Calculates a cutoff to ensure that the given number of elements fall below it.
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.
long model_setup_links(Bmodel *model)
Set up the link list for each component.
Bcomponent * model_linked_submodel(Bcomponent *comp, Bmodel *model, int *n, Vector3< float > *avg_loc)
Bmodel * model_copy(Bmodel *model)
Copies a model.
Functions to compare models and components.
double model_compare(Bmodel *model1, Bmodel *model2)
Compares two models.
Library routines used for model link processing.
int component_list_kill(Bcomponent *comp)
Deallocates memory for a list of components.
double distance(const Vector3 &v)
long model_reduce_linked(Bmodel *model, Bstring &submodname, int flags)
Reduces a model to one component per linked set of components.
int model_kill(Bmodel *model)
Deallocates all memory in the list.
long model_set_link_length(Bmodel *model, double linklength)
Sets the reference link lengths.
Header file for general utilities.
int write_model(Bstring &filename, Bmodel *model)
Writes model parameters.
ostream & tab(ostream &out)
Matrix model_distance_matrix(Bmodel *model, int view_flag)
Calculates the distance matrix for a model.
long model_link_list_generate(Bmodel *model, double maxlength)
Generates a link list for a model based on vertex separation.
Header file for generalized linked list functions.
Bmodel * model_add(Bmodel **model, Bstring &id)
Adds a model to a linked list.
Library routines used for model processing.
long model_set_link_radius(Bmodel *model, double linkrad)
Set the display radius for all links to a specific value.
Bcomptype * model_add_type_by_id(Bmodel *model, Bstring &id)
Add a type to a model if the identifier does not exist already.
int component_copy(Bcomponent *fromcomp, Bcomponent *tocomp)
Copies all elements from one component to another.
long model_component_number_difference(Bmodel *model1, Bmodel *model2)
Compares the numbers of components in two models.
int model_link_list_kill(Bmodel *model)
Deallocates memory for a list of component links.
Bcomponent * link[MAXLINK]
long model_links_minimum_valency(Bmodel *model, long valency)
Generates links such that each component has at least the given valency.