| Bsoft 2.0.5 Bernard's software package

bmaskmod.cpp
Go to the documentation of this file.
1
9 #include "rwimg.h"
10 #include "rwmodel.h"
11 #include "model_mask.h"
12 #include "model_links.h"
13 #include "model_util.h"
14 #include "utilities.h"
15 #include "options.h"
16 #include "timer.h"
17
18 // Declaration of global variables
19 extern int verbose; // Level of output to the screen
20
21 /* Usage assistance */
22 const char* use[] = {
23 " ",
24 "Usage: bmaskmod [options] mask.tif",
25 "----------------------------------",
26 "Generates a model from a mask.",
27 " ",
28 //"Actions:",
29 //"-type hull Mask type: model, hull, shell, level.",
30 //"-invert Invert the mask after creation.",
31 //" ",
32 "Parameters:",
33 "-verbose 7 Verbose output.",
34 "-componentradius 8.4 Set display radius for all components.",
35 "-linkradius 5.1 Set display radius for all links.",
36 " ",
37 //"Input:",
38 //"-parameters param.star Input parameter file.",
39 //" ",
40 "Output:",
41 "-output file.star Output model file.",
42 " ",
43 NULL
44 };
45
46 int main(int argc, char **argv)
47 {
48 /* Initialize variables */
49 double comprad(0); // Component display radius
50 double linkrad(0); // Link display radius
51 Bstring outfile; // Output model file
52
53 int optind;
54 Boption* option = get_option_list(use, argc, argv, optind);
55 Boption* curropt;
56 for ( curropt = option; curropt; curropt = curropt->next ) {
57 if ( curropt->tag == "componentradius" )
58 if ( ( comprad = curropt->value.real() ) < 1 )
59 cerr << "-componentradius: A radius must be specified!" << endl;
60 if ( curropt->tag == "linkradius" )
61 if ( ( linkrad = curropt->value.real() ) < 1 )
62 cerr << "-linkradius: A radius must be specified!" << endl;
63 if ( curropt->tag == "output" )
64 outfile = curropt->filename();
65 }
66 option_kill(option);
67
68 double ti = timer_start();
69
70 Bimage* p = read_img(argv[optind++], 1, -1);
71
72 Bmodel* model = model_from_multilevel_mask(p);
73
74 if ( comprad ) models_process(model, comprad, model_set_component_radius);
75
76 if ( linkrad ) models_process(model, linkrad, model_set_link_radius);
77
78 // Write an output model file if a name is given
79 if ( outfile.length() && model ) {
80 model_update_comment(model, argc, argv);
81 write_model(outfile, model);
82 }
83
84 delete p;
85 model_kill(model);
86
87 if ( verbose & VERB_TIME )
88 timer_report(ti);
89
90 bexit(0);
91 }
92
model_from_multilevel_mask
Bmodel * model_from_multilevel_mask(Bimage *p)
Generates components at the center of mass of each mask level.
Definition: model_mask.cpp:452
Bstring::real
double real()
Definition: Bstring.cpp:545
model_set_component_radius
long model_set_component_radius(Bmodel *model, double comprad)
Set the display radius for all components to a specific value.
Definition: rwmodel.cpp:1264
main
int main(int argc, char **argv)
Definition: bmaskmod.cpp:46
utilities.h
Header file for general utilities.
model_util.h
Library routines used for model processing.
Boption::value
Bstring value
Definition: options.h:30
Boption::tag
Bstring tag
Definition: options.h:29
Bstring::length
long length() const
Definition: Bstring.cpp:263
model_links.h
Library routines used for model link processing.
get_option_list
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Definition: options.cpp:40
read_img
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Definition: rwimg.cpp:76
Boption::filename
Bstring filename()
Definition: options.h:85
timer.h
Utilities for timing functions.
Bimage
General image parameter class.
Definition: Bimage.h:163
verbose
int verbose
use
const char * use[]
Definition: bmaskmod.cpp:22
model_kill
int model_kill(Bmodel *model)
Deallocates all memory in the list.
Definition: rwmodel.cpp:1124
model_set_link_radius
long model_set_link_radius(Bmodel *model, double linkrad)
Set the display radius for all links to a specific value.
Definition: model_links.cpp:139
Boption
A class for a command line input option.
Definition: options.h:26
VERB_TIME
#define VERB_TIME
Definition: utilities.h:110
model_update_comment
int model_update_comment(Bmodel *model, int n, char **strings)
Puts a set of strings and time in the comment of a model.
Definition: rwmodel.cpp:1158
model
Bmodel * model
Definition: bshow.cpp:32
write_model
int write_model(Bstring &filename, Bmodel *model)
Writes model parameters.
Definition: rwmodel.cpp:91
Boption::next
Boption * next
Definition: options.h:28
Bstring
Definition: Bstring.h:29
rwmodel.h
Header file for reading and writing atomic model files.
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
model_mask.h
Functions to generate masks from models.
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
Bmodel
Definition: rwmodel.h:119
rwimg.h
Header file for 2D and 3D image I/O.
options.h
Header file for option handlers.
models_process
long models_process(Bmodel *model, long(modfunc)(Bmodel *))
Process a list of models using the specified function.
Definition: model_util.cpp:36
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:273
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:52