Bsoft 2.1.4
Bernard's software package
model_select.cpp File Reference

Library routines used for model and component selection. More...

#include "rwmodel.h"
#include "model_poly.h"
#include "model_views.h"
#include "model_compare.h"
#include "model_util.h"
#include "rwimg.h"
#include "qsort_functions.h"
#include "linked_list.h"
#include "utilities.h"

Functions

long model_selection_stats (Bmodel *model)
 Calculates selection statistics. More...
 
long model_show_selection (Bmodel *model)
 Shows the distrubution of selections. More...
 
long model_select (Bmodel *model, Bstring &selstr)
 Selects models, components and component types. More...
 
long model_select (Bmodel *model, long number)
 Resets the selection to all models. More...
 
long model_select_all (Bmodel *model)
 Resets the selection to all models. More...
 
long model_select_unknowns (Bmodel *model)
 Resets the selection to all unknown models. More...
 
long model_reset_selection (Bmodel *model)
 Resets the selection to all components. More...
 
long model_unset_selection (Bmodel *model)
 Unsets the selection to all components but not models. More...
 
long model_invert_selection (Bmodel *model)
 Inverts the selection of all components. More...
 
long model_select_sets (Bmodel *model, int size, int flag)
 Selects sets of components, each set with the same size. More...
 
long models_select_within_bounds (Bmodel *model, Vector3< double > &start, Vector3< double > &end)
 Selects components within bounds for a list of models. More...
 
long model_select_number_of_components (Bmodel *model, int ncomp_min, int ncomp_max)
 Selects models within a range of the number of components. More...
 
int model_select_random (Bmodel *model, long number)
 Selects a random number of components. More...
 
long model_select_closed (Bmodel *model, int closure_rule, int val_order)
 Determines if a polyhedron is closed given a rule. More...
 
long model_select_fullerene (Bmodel *model)
 Selects fullerene type models. More...
 
long model_select_non_fullerene (Bmodel *model)
 Selects non-fullerene type models. More...
 
long model_select_valence (Bmodel *model, int valence)
 Selects fullerene type models. More...
 
long model_select_polygons (Bmodel *model, int order)
 Selects model polygons with a given order. More...
 
long model_select_first (Bmodel *model, int first)
 Selects the first number of components. More...
 
long model_select_within_shell (Bmodel *model, Vector3< double > center, double minrad, double maxrad)
 Selects components within a shell. More...
 
long model_select_in_mask (Bmodel *model, Bimage *pmask)
 Selects components within a mask. More...
 
long model_delete (Bmodel **model)
 Deletes tagged models, components and links. More...
 
long model_delete_comp_type (Bmodel *model, Bstring &comptype)
 Deletes components based on their types. More...
 
long model_delete_non_selected (Bmodel **model)
 Deletes selected components and associated links from the model. More...
 
long model_type_from_selection (Bmodel *model, Bstring *comp_type, Bstring &filename)
 Converts selection numbers to different types. More...
 
long model_fom_deselect (Bmodel *model, double fom_cutoff)
 Deselects components based on the FOM. More...
 
long model_fom_max_fraction_deselect (Bmodel *model, double fom_fraction)
 Deselects components based on the FOM relative to the maximum FOM. More...
 
long models_radius_deselect (Bmodel *model, double minrad, double maxrad)
 Deselects components based on the distance from the origin. More...
 
long model_fom_histogram (Bmodel *model, double fom_step)
 Selects components based on the FOM. More...
 
long model_fom_ranking (Bmodel *model, int nrank)
 Ranks components based on the FOM. More...
 
long model_delete_overlapped_components (Bmodel **model, double distance)
 Deletes components that are too close to others. More...
 
long model_average_overlapped_components (Bmodel *model, double distance)
 Averages components within a distance. More...
 
long model_prune_simple (Bmodel *model, double mindist)
 Prunes overlapping components based on a distance criterion. More...
 
long model_prune_fom_old (Bmodel *model, double distance)
 Deselects components based on overlap distance and the FOM. More...
 
long model_prune_fom (Bmodel *model, double distance)
 
long model_prune_similar (Bmodel *model)
 Averages similar components and reduces redundancy. More...
 
Bimage * model_composite_map (Bmodel *model, Vector3< int > size, Vector3< double > origin, Vector3< double > sampling)
 
long comp_select_one (Bcomponent *comp, long i, long n, double *ovm)
 
double * model_overlap_matrix (Bmodel *model, double distance)
 
long model_prune_fit (Bmodel *model, double distance)
 Deselects components based on overlap distance and the FOM. More...
 
long model_prune_large (Bmodel *model, double sampling)
 Deselects components based on overlap distance and the FOM. More...
 
long model_find_overlap (Bmodel *model, Bstring &reffile, double distance)
 Finds the components that overlap with the reference. More...
 

Variables

int verbose
 

Detailed Description

Library routines used for model and component selection.

Author
Bernard Heymann
Date
Created: 20060908
Modified: 20220323

Function Documentation

◆ comp_select_one()

long comp_select_one ( Bcomponent *  comp,
long  i,
long  n,
double *  ovm 
)

◆ model_average_overlapped_components()

long model_average_overlapped_components ( Bmodel *  model,
double  distance 
)

Averages components within a distance.

Parameters
*modelmodel.
distanceoverlap distance.
Returns
long 0.
Components within the given distance are averaged and the first
instance is retained while the others are deleted.

◆ model_composite_map()

Bimage * model_composite_map ( Bmodel *  model,
Vector3< int >  size,
Vector3< double >  origin,
Vector3< double >  sampling 
)

◆ model_delete()

long model_delete ( Bmodel **  model)

Deletes tagged models, components and links.

Parameters
**modelpointer to model parameters.
Returns
long remaining number of components.
A model, component or link is tagged for deletion by a negative selection flag.

◆ model_delete_comp_type()

long model_delete_comp_type ( Bmodel *  model,
Bstring &  comptype 
)

Deletes components based on their types.

Parameters
*modelmodel parameters.
&comptypecomponent type.
Returns
long number of components remaining.

◆ model_delete_non_selected()

long model_delete_non_selected ( Bmodel **  model)

Deletes selected components and associated links from the model.

Parameters
**modelpointer to model parameters.
Returns
long remaining number of components.

◆ model_delete_overlapped_components()

long model_delete_overlapped_components ( Bmodel **  model,
double  distance 
)

Deletes components that are too close to others.

Parameters
**modelmodel handle.
distancedistance to test for.
Returns
long 0.
If a component is too close to another, the component further down
in the list is deleted.

◆ model_find_overlap()

long model_find_overlap ( Bmodel *  model,
Bstring &  reffile,
double  distance 
)

Finds the components that overlap with the reference.

Parameters
*modelmodel parameters.
&reffilereference molecule file name.
distancedistance for overlap.
Returns
long number of components selected.
All components that are within the distance criterion of the components
in the reference model are deselected.

◆ model_fom_deselect()

long model_fom_deselect ( Bmodel *  model,
double  fom_cutoff 
)

Deselects components based on the FOM.

Parameters
*modelmodel parameters.
fom_cutoffFOM threshold.
Returns
long number of components selected.
The FOM is assumed to be a value from 0 to 1 and components with
FOM's below the given cutoff are deselected.

◆ model_fom_histogram()

long model_fom_histogram ( Bmodel *  model,
double  fom_step 
)

Selects components based on the FOM.

Parameters
*modelmodel parameters.
fom_stepFOM step size.
Returns
long number of components.
The FOM is assumed to represent energy and therefore values below
the given cutoff are selected.

◆ model_fom_max_fraction_deselect()

long model_fom_max_fraction_deselect ( Bmodel *  model,
double  fom_fraction 
)

Deselects components based on the FOM relative to the maximum FOM.

Parameters
*modelmodel parameters.
fom_fractionFOM threshold.
Returns
long number of components selected.
The FOM/FOMmax ratio is calculated and components with ratios below
the given fraction are deselected.

◆ model_fom_ranking()

long model_fom_ranking ( Bmodel *  model,
int  nrank 
)

Ranks components based on the FOM.

Parameters
*modelmodel parameters.
nranknumber of levels.
Returns
long number of selected components.
Each selected component is ranked into one of a number of levels.

◆ model_invert_selection()

long model_invert_selection ( Bmodel *  model)

Inverts the selection of all components.

Parameters
*modelmodel parameters.
Returns
long number of components selected.

◆ model_overlap_matrix()

double * model_overlap_matrix ( Bmodel *  model,
double  distance 
)

◆ model_prune_fit()

long model_prune_fit ( Bmodel *  model,
double  distance 
)

Deselects components based on overlap distance and the FOM.

Parameters
*modelmodel parameters.
distanceoverlap distance.
Returns
long number of components selected.
The selected component with the highest FOM is chosen as the first 
component in the solution set and all components within the distance 
criterion from it are deselected. The selected component with the next 
highest FOM is then chosen and again, all components within the distance 
criterion from it are deselected.
This is repeated until there are no more selected components to choose.
Only the first model is processed.

◆ model_prune_fom()

long model_prune_fom ( Bmodel *  model,
double  distance 
)

◆ model_prune_fom_old()

long model_prune_fom_old ( Bmodel *  model,
double  distance 
)

Deselects components based on overlap distance and the FOM.

Parameters
*modelmodel parameters.
distanceoverlap distance.
Returns
long number of components selected.
The selected component with the highest FOM is chosen as the first 
component in the solution set and all components within the distance 
criterion from it are deselected. The selected component with the next 
highest FOM is then chosen and again, all components within the distance 
criterion from it are deselected.
This is repeated until there are no more selected components to choose.
Only the first model is processed.

◆ model_prune_large()

long model_prune_large ( Bmodel *  model,
double  sampling 
)

Deselects components based on overlap distance and the FOM.

Parameters
*modelmodel parameters.
samplinggrid sampling.
Returns
long number of components selected.
Each component location is mapped to a grid point and the component FOM
is assigned to the grid point if it is larger.
Peaks are determined within each 3x3x3 kernel: a peak is defined as
having a higher value than any of its 26 neigbors.
The component associated with the value at a peak is selected.
Only the first model is processed.

◆ model_prune_similar()

long model_prune_similar ( Bmodel *  model)

Averages similar components and reduces redundancy.

Parameters
*modelmodel parameters.
Returns
lon number of clusters.
A view distance matrix is calculated for all the components.
All components within a small distance (~10% of model radius) are averaged
into the first component and the rest are deselected.
Only the first model is processed.

◆ model_prune_simple()

long model_prune_simple ( Bmodel *  model,
double  mindist 
)

Prunes overlapping components based on a distance criterion.

Parameters
*modelmodel structure to be modified.
mindistdistance criterion.
Returns
long number of remaining components.
The first component in any pair of overlapping components is kept.

◆ model_reset_selection()

long model_reset_selection ( Bmodel *  model)

Resets the selection to all components.

Parameters
*modelmodel parameters.
Returns
long number of components selected.
Only one model is modified.

◆ model_select() [1/2]

long model_select ( Bmodel *  model,
Bstring &  selstr 
)

Selects models, components and component types.

Parameters
*modelmodel parameters.
&selstrselection string.
Returns
long number of selections made.
The selection string can have one of the following formats:
    #model@component
    #model%comp_type
    ^model_type@component
    ^model_type%comp_type
Only elements originally selected is considered, except where the "." is used.

◆ model_select() [2/2]

long model_select ( Bmodel *  model,
long  number 
)

Resets the selection to all models.

Parameters
*modelmodel parameters.
numberselection number to select.
Returns
long number of components selected.

◆ model_select_all()

long model_select_all ( Bmodel *  model)

Resets the selection to all models.

Parameters
*modelmodel parameters.
Returns
long number of models selected.

◆ model_select_closed()

long model_select_closed ( Bmodel *  model,
int  closure_rule,
int  val_order 
)

Determines if a polyhedron is closed given a rule.

Parameters
*modelmodel parameters.
closure_rule1=valency, 2=order.
val_ordermagnitude of valency or order.
Returns
long number of models selected.
Polyhedron closure is arbitrarily decided by a rule:
1.  Fixed valency.
3.  Fixed polygon order.
Models that fail the given rule are deselected.
If the given valency or order is zero, it is set to the value for
the first component or polygon.

◆ model_select_first()

long model_select_first ( Bmodel *  model,
int  first 
)

Selects the first number of components.

Parameters
*modelmodel parameters.
firstfirst number of components to select.
Returns
long number of components selected.

◆ model_select_fullerene()

long model_select_fullerene ( Bmodel *  model)

Selects fullerene type models.

Parameters
*modelmodel structure.
Returns
long number of models selected.
Each model is tested for the presence of polygons that have orders
only of five or six.

◆ model_select_in_mask()

long model_select_in_mask ( Bmodel *  model,
Bimage *  pmask 
)

Selects components within a mask.

Parameters
*modelmodel parameters.
pmaskfirst number of components to select.
Returns
long number of components selected.

◆ model_select_non_fullerene()

long model_select_non_fullerene ( Bmodel *  model)

Selects non-fullerene type models.

Parameters
*modelmodel structure.
Returns
long number of models selected.
Each model is tested for the presence of polygons that have orders
different from five or six.

◆ model_select_number_of_components()

long model_select_number_of_components ( Bmodel *  model,
int  ncomp_min,
int  ncomp_max 
)

Selects models within a range of the number of components.

Parameters
*modelmodel parameters.
ncomp_minminimum number of components.
ncomp_maxmaximum number of components.
Returns
long number of models selected.

◆ model_select_polygons()

long model_select_polygons ( Bmodel *  model,
int  order 
)

Selects model polygons with a given order.

Parameters
*modelmodel to color.
orderpolygon order.
Returns
long 0.

◆ model_select_random()

int model_select_random ( Bmodel *  model,
long  number 
)

Selects a random number of components.

Parameters
*modelmodel parameters.
numbernumber of components.
Returns
int 0.

◆ model_select_sets()

long model_select_sets ( Bmodel *  model,
int  size,
int  flag 
)

Selects sets of components, each set with the same size.

Parameters
*modelparameter structure with all parameters.
sizenumber of components in each set.
flagflag to not count across model boundaries.
Returns
long number of components selected.
Sets up sets of components, each set identified as a number in the
selection array.

◆ model_select_unknowns()

long model_select_unknowns ( Bmodel *  model)

Resets the selection to all unknown models.

Parameters
*modelmodel parameters.
Returns
long number of models selected.

◆ model_select_valence()

long model_select_valence ( Bmodel *  model,
int  valence 
)

Selects fullerene type models.

Parameters
*modelmodel structure.
valencecomponent valence
Returns
long number of models selected.
Each model is tested for the presence of polygons that have orders
only of five or six.

◆ model_select_within_shell()

long model_select_within_shell ( Bmodel *  model,
Vector3< double >  center,
double  minrad,
double  maxrad 
)

Selects components within a shell.

Parameters
*modelmodel parameters.
centercenter of the shell.
minradminimum radius of the sphere.
maxradradius of the sphere.
Returns
long number of components selected.

◆ model_selection_stats()

long model_selection_stats ( Bmodel *  model)

Calculates selection statistics.

Parameters
*modelmodel parameters.
Returns
long number of components selected.
The FOM is assumed to be a value from 0 to 1.

◆ model_show_selection()

long model_show_selection ( Bmodel *  model)

Shows the distrubution of selections.

Parameters
*modelmodel parameters.
Returns
long number of selection levels.

◆ model_type_from_selection()

long model_type_from_selection ( Bmodel *  model,
Bstring *  comp_type,
Bstring &  filename 
)

Converts selection numbers to different types.

Parameters
*modelmodel parameters.
*comp_typelinked list of strings.
&filenamecomponent type file name.
Returns
long number of component types assigned.

◆ model_unset_selection()

long model_unset_selection ( Bmodel *  model)

Unsets the selection to all components but not models.

Parameters
*modelmodel parameters.
Returns
long number of components deselected.

◆ models_radius_deselect()

long models_radius_deselect ( Bmodel *  model,
double  minrad,
double  maxrad 
)

Deselects components based on the distance from the origin.

Parameters
*modelmodel parameters.
minradminimum distance from origin.
maxradmaximum distance from the origin.
Returns
long number of components selected.
All components inside a minmum radius and beyond a maximum radius are deselected.

◆ models_select_within_bounds()

long models_select_within_bounds ( Bmodel *  model,
Vector3< double > &  start,
Vector3< double > &  end 
)

Selects components within bounds for a list of models.

Parameters
*modellist of models.
&startminimum coordinates.
&endmaximum coordinates.
Returns
long number of components selected.

Variable Documentation

◆ verbose

int verbose
extern