38 static int test_hough_create(cpl_plugin *);
39 static int test_hough_exec(cpl_plugin *);
40 static int test_hough_destroy(cpl_plugin *);
41 static int test_hough(cpl_parameterlist *, cpl_frameset *);
43 static char test_hough_description[] =
44 "This recipe is used to test the Hough transformation on any table.\n\n"
46 " DO category: Type: Explanation:\n"
47 " TABLE Raw Table with at least 2 numerical columns.\n\n"
49 " DO category: Data type: Explanation:\n"
50 " TRANSFORMED FITS table Table with estimates.\n\n";
52 #define test_hough_exit(message) \
54 if (message) cpl_msg_error(recipe, message); \
55 cpl_table_delete(table); \
56 cpl_table_delete(output); \
57 cpl_msg_indent_less(); \
61 #define test_hough_exit_memcheck(message) \
63 if (message) cpl_msg_info(recipe, message); \
64 cpl_table_delete(table); \
65 cpl_table_delete(output); \
66 cpl_msg_indent_less(); \
84 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe );
85 cpl_plugin *plugin = &recipe->interface;
87 cpl_plugin_init(plugin,
90 CPL_PLUGIN_TYPE_RECIPE,
92 "Test Hough transform on any table of points",
93 test_hough_description,
96 "This file is currently part of the FORS Instrument Pipeline\n"
97 "Copyright (C) 2002-2010 European Southern Observatory\n\n"
98 "This program is free software; you can redistribute it and/or modify\n"
99 "it under the terms of the GNU General Public License as published by\n"
100 "the Free Software Foundation; either version 2 of the License, or\n"
101 "(at your option) any later version.\n\n"
102 "This program is distributed in the hope that it will be useful,\n"
103 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
104 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
105 "GNU General Public License for more details.\n\n"
106 "You should have received a copy of the GNU General Public License\n"
107 "along with this program; if not, write to the Free Software Foundation,\n"
108 "Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n",
113 cpl_pluginlist_append(list, plugin);
129 static int test_hough_create(cpl_plugin *plugin)
139 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
140 recipe = (cpl_recipe *)plugin;
148 recipe->parameters = cpl_parameterlist_new();
155 p = cpl_parameter_new_value(
"fors.test_hough.xcolumn",
157 "Table column with x coordinate",
160 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"xcolumn");
161 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
162 cpl_parameterlist_append(recipe->parameters, p);
168 p = cpl_parameter_new_value(
"fors.test_hough.ycolumn",
170 "Table column with y coordinate",
173 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"ycolumn");
174 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
175 cpl_parameterlist_append(recipe->parameters, p);
189 static int test_hough_exec(cpl_plugin *plugin)
193 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
194 recipe = (cpl_recipe *)plugin;
198 return test_hough(recipe->parameters, recipe->frames);
210 static int test_hough_destroy(cpl_plugin *plugin)
214 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
215 recipe = (cpl_recipe *)plugin;
219 cpl_parameterlist_delete(recipe->parameters);
234 static int test_hough(cpl_parameterlist *parlist, cpl_frameset *frameset)
237 const char *recipe =
"test_hough";
251 cpl_table *table = NULL;
252 cpl_table *output = NULL;
260 cpl_msg_set_indentation(2);
267 cpl_msg_info(recipe,
"Recipe %s configuration parameters:", recipe);
268 cpl_msg_indent_more();
271 "fors.test_hough.xcolumn", NULL);
273 "fors.test_hough.ycolumn", NULL);
275 if (cpl_error_get_code())
276 test_hough_exit(
"Failure getting the configuration parameters");
282 cpl_msg_indent_less();
283 cpl_msg_info(recipe,
"Check input set-of-frames:");
284 cpl_msg_indent_more();
286 nframes = cpl_frameset_count_tags(frameset,
"TABLE");
289 test_hough_exit(
"Missing input table");
292 cpl_msg_error(recipe,
"Too many input tables found (%d). "
293 "Just one is required.", nframes);
294 test_hough_exit(NULL);
297 cpl_msg_info(recipe,
"Load %s frame...",
"TABLE");
298 cpl_msg_indent_more();
302 output = mos_hough_table(table, xcolumn, ycolumn);
303 cpl_table_delete(table); table = NULL;
306 parlist, recipe,
"test_version"))
307 test_hough_exit(NULL);
309 cpl_table_delete(output); output = NULL;
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
const char * dfs_get_parameter_string(cpl_parameterlist *parlist, const char *name, const cpl_table *defaults)
Reading a recipe string parameter value.
cpl_table * dfs_load_table(cpl_frameset *frameset, const char *category, int ext)
Loading table data of given category.
int dfs_save_table(cpl_frameset *frameset, const cpl_table *table, const char *category, cpl_propertylist *header, const cpl_parameterlist *parlist, const char *recipename, const char *version)
Saving table data of given category.