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 
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;
86 
87  if ( verbose & VERB_TIME )
88  timer_report(ti);
89 
90  bexit(0);
91 }
92 
Bmodel * model_from_multilevel_mask(Bimage *p)
Generates components at the center of mass of each mask level.
Definition: model_mask.cpp:452
double real()
Definition: Bstring.cpp:553
long model_set_component_radius(Bmodel *model, double comprad)
Set the display radius for all components to a specific value.
Definition: rwmodel.cpp:1264
int main(int argc, char **argv)
Definition: bmaskmod.cpp:46
Header file for general utilities.
Library routines used for model processing.
Bstring value
Definition: options.h:30
Bstring tag
Definition: options.h:29
long length() const
Definition: Bstring.cpp:263
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
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Definition: rwimg.cpp:76
Bstring filename()
Definition: options.h:85
Utilities for timing functions.
General image parameter class.
Definition: Bimage.h:176
int verbose
const char * use[]
Definition: bmaskmod.cpp:22
int model_kill(Bmodel *model)
Deallocates all memory in the list.
Definition: rwmodel.cpp:1124
A class for a command line input option.
Definition: options.h:26
#define VERB_TIME
Definition: utilities.h:113
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
Bmodel * model
Definition: bshow.cpp:32
int write_model(Bstring &filename, Bmodel *model)
Writes model parameters.
Definition: rwmodel.cpp:91
Boption * next
Definition: options.h:28
Header file for reading and writing atomic model files.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
Functions to generate masks from models.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
Header file for 2D and 3D image I/O.
Header file for option handlers.
long models_process(Bmodel *model, long(modfunc)(Bmodel *))
Process a list of models using the specified function.
Definition: model_util.cpp:36
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:273
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:52