21 this->infile_name = NULL;
22 this->outfile_prefix = NULL;
23 this->gnuplot =
false;
24 this->delimiter =
' ';
44 this->dmax_dnn =
false;
77 std::pair<double, bool> tmp;
79 for (
int i = 1; i < argc; i++) {
80 if (0 == strcmp(argv[i],
"-v")) {
81 if (this->verbose < 1)
83 }
else if (0 == strcmp(argv[i],
"-vv")) {
84 if (this->verbose < 2)
86 }
else if (0 == strcmp(argv[i],
"-s")) {
91 tmp = this->parse_argument(argv[i]);
93 this->sdnn = tmp.second;
94 }
else if (0 == strcmp(argv[i],
"-r")) {
99 tmp = this->parse_argument(argv[i]);
101 this->rdnn = tmp.second;
102 }
else if (0 == strcmp(argv[i],
"-k")) {
105 this->k = (int)
stod(argv[i]);
109 }
else if (0 == strcmp(argv[i],
"-n")) {
112 this->n = (int)
stod(argv[i]);
116 }
else if (0 == strcmp(argv[i],
"-a")) {
119 this->a =
stod(argv[i]);
123 }
else if (0 == strcmp(argv[i],
"-t")) {
126 if (strcmp(argv[i],
"auto") == 0 || strcmp(argv[i],
"automatic") == 0) {
129 this->t =
stod(argv[i]);
135 }
else if (0 == strcmp(argv[i],
"-m")) {
138 this->m = (int)
stod(argv[i]);
142 }
else if (0 == strcmp(argv[i],
"-delim")) {
145 if (strlen(argv[i]) > 1) {
146 std::cerr <<
"[Error] only a character as delimiter is allowed" << std::endl;
149 this->delimiter = *argv[i];
153 }
else if (0 == strcmp(argv[i],
"-dmax")) {
158 if (strcmp(argv[i],
"none") == 0) {
159 this->isdmax =
false;
161 tmp = this->parse_argument(argv[i]);
162 this->dmax = tmp.first;
163 this->dmax_dnn = tmp.second;
166 }
else if (0 == strcmp(argv[i],
"-link")) {
171 if (strcmp(argv[i],
"single") == 0) {
173 }
else if (strcmp(argv[i],
"complete") == 0) {
175 }
else if (strcmp(argv[i],
"average") == 0) {
178 std::cerr <<
"[Error] " << argv[i] <<
" is not a valide option!" << std::endl;
181 }
else if (0 == strcmp(argv[i],
"-skip")) {
184 int tmp2 = atoi(argv[i]);
186 std::cerr <<
"[Error] skip takes only positive integers. parameter "
190 this->skip = (size_t)tmp2;
195 }
else if (0 == strcmp(argv[i],
"-oprefix")) {
197 std::cerr <<
"[Error] not enough parameters" << std::endl;
199 }
else if (argv[i + 1][0] ==
'-') {
200 std::cerr <<
"[Error] please enter outfile name" << std::endl;
203 this->outfile_prefix = argv[++i];
204 }
else if (0 == strcmp(argv[i],
"-gnuplot")) {
205 this->gnuplot =
true;
206 }
else if (argv[i][0] ==
'-') {
209 this->infile_name = argv[i];
212 }
catch (std::invalid_argument e) {
213 std::cerr << e.what() << std::endl;
225 std::pair<double, bool> Opt::parse_argument(
const char *str)
230 size_t count = sscanf(str,
"%lf%3s", &result, buff);
232 if (std::strcmp(
"dnn", buff) && std::strcmp(
"dNN", buff))
233 throw std::invalid_argument(
"not a number");
235 }
else if (count == 0) {
236 throw std::invalid_argument(
"not a number");
238 return std::pair<double, bool>(result, dnn);
249 if (this->verbose > 0) {
250 std::cout <<
"[Info] computed smoothed radius: " << this->r << std::endl;
255 if (this->verbose > 0) {
256 std::cout <<
"[Info] computed distance scale: " << this->s << std::endl;
259 if (this->dmax_dnn) {
261 if (this->verbose > 0) {
262 std::cout <<
"[Info] computed max gap: " << this->dmax << std::endl;
270 return this->infile_name;
274 return this->outfile_prefix;
278 return this->rdnn || this->sdnn || this->dmax_dnn;
282 return this->gnuplot;
290 return this->delimiter;
294 return this->verbose;