示例#1
0
/**
 * gwy_process_type_init:
 *
 * Makes libgwyprocess types safe for deserialization and performs other
 * initialization.  You have to call this function before using objects
 * from libgwyprocess.
 *
 * Calls gwy_type_init() first to make sure libgwyddion is initialized.
 *
 * It is safe to call this function more than once, subsequent calls are no-op.
 **/
void
gwy_process_type_init(void)
{
    static gboolean types_initialized = FALSE;

    if (types_initialized)
        return;

    gwy_type_init();

    g_type_class_peek(GWY_TYPE_DATA_LINE);
    g_type_class_peek(GWY_TYPE_DATA_FIELD);
    g_type_class_peek(GWY_TYPE_BRICK);
    g_type_class_peek(GWY_TYPE_CDLINE);
    g_type_class_peek(GWY_TYPE_SPECTRA);
    g_type_class_peek(GWY_TYPE_SURFACE);
    g_type_class_peek(GWY_TYPE_CALDATA);
    g_type_class_peek(GWY_TYPE_TRIANGULATION);
    types_initialized = TRUE;

    _gwy_cdline_class_setup_presets();
    _gwy_grain_value_class_setup_presets();
    _gwy_shape_fit_preset_class_setup_presets();
    _gwy_calibration_class_setup_presets();
    gwy_process_import_fftw_wisdom();
}
示例#2
0
int
main(void)
{
    gwy_type_init();

    printf(file_prologue, generated, id, id, title, title);

    const gchar* const *names = gwy_fit_func_list_builtins();
    guint nfuncs = g_strv_length((gchar**)names);
    GwyFitFunc **fitfuncs = g_new(GwyFitFunc*, nfuncs);
    for (guint i = 0; i < nfuncs; i++) {
        fitfuncs[i] = gwy_fit_func_new(names[i]);
        g_assert(GWY_IS_FIT_FUNC(fitfuncs[i]));
    }
    qsort(fitfuncs, nfuncs, sizeof(GwyFitFunc*), compare);

    GString *str = g_string_new(NULL);
    const gchar *processing_group = "NONE";
    for (guint i = 0; i < nfuncs; i++) {
        GwyFitFunc *fitfunc = fitfuncs[i];
        const gchar *name = gwy_fit_func_get_name(fitfunc);
        const gchar *group = gwy_fit_func_get_group(fitfunc);
        if (!gwy_strequal(group, processing_group)) {
            if (!gwy_strequal(processing_group, "NONE"))
                printf(group_epilogue);
            g_string_assign(str, group);
            make_id(str);
            printf(group_prologue, id, str->str, group, group);
            processing_group = group;
        }
        g_string_assign(str, name);
        make_id(str);
        printf(function_prologue, id, str->str, name);
        g_string_assign(str, gwy_fit_func_formula(fitfunc));
        convert_pango_to_docbook(str);
        make_math(str);
        printf("<entry>%s</entry>\n", str->str);
        guint n = gwy_fit_func_n_params(fitfunc);
        printf("<entry>");
        for (guint j = 0; j < n; j++) {
            g_string_assign(str, gwy_fit_func_param_name(fitfunc, j));
            convert_pango_to_docbook(str);
            make_math(str);
            printf("%s %s", j ? "," : "", str->str);
        }
        printf("</entry>\n");
        printf(function_epilogue);
        g_object_unref(fitfunc);
    }
    if (!gwy_strequal(processing_group, "NONE"))
        printf(group_epilogue);

    printf(file_epilogue);

    return 0;
}
示例#3
0
int
main(void)
{
    gwy_type_init();

    printf(file_prologue, generated, id, id, title, title);

    const gchar* const *names = gwy_grain_value_list_builtins();
    guint nvalues = g_strv_length((gchar**)names);
    GwyGrainValue **grainvalues = g_new(GwyGrainValue*, nvalues);
    for (guint i = 0; i < nvalues; i++) {
        grainvalues[i] = gwy_grain_value_new(names[i]);
        g_assert(GWY_IS_GRAIN_VALUE(grainvalues[i]));
    }
    qsort(grainvalues, nvalues, sizeof(GwyGrainValue*), compare);

    GString *str = g_string_new(NULL);
    const gchar *processing_group = "NONE";
    for (guint i = 0; i < nvalues; i++) {
        GwyGrainValue *grainvalue = grainvalues[i];
        const gchar *name = gwy_grain_value_get_name(grainvalue);
        const gchar *group = gwy_grain_value_get_group(grainvalue);
        if (!gwy_strequal(group, processing_group)) {
            if (!gwy_strequal(processing_group, "NONE"))
                printf(group_epilogue);
            g_string_assign(str, group);
            make_id(str);
            printf(group_prologue, id, str->str, group, group);
            processing_group = group;
        }
        g_string_assign(str, name);
        make_id(str);
        printf(value_prologue, id, str->str, name);
        g_string_assign(str, gwy_grain_value_get_symbol(grainvalue));
        convert_pango_to_docbook(str);
        make_math(str);
        printf("<entry>%s</entry>\n", str->str);
        printf("<entry><code>%s</code></entry>",
               gwy_grain_value_get_ident(grainvalue));
        g_string_assign(str, "");
        if (gwy_grain_value_needs_same_units(grainvalue))
            append_separated(str, "needs same lateral and value units");
        if (gwy_grain_value_is_angle(grainvalue))
            append_separated(str, "represents angle in radians");
        printf("<entry>%s</entry>\n", str->str);
        printf(value_epilogue);
        g_object_unref(grainvalue);
    }
    if (!gwy_strequal(processing_group, "NONE"))
        printf(group_epilogue);

    printf(file_epilogue);

    return 0;
}
示例#4
0
/**
 * gwy_process_type_init:
 *
 * Initializes libgwyprocess types, making their deserialization safe.
 *
 * Eventually calls gwy_type_init().
 *
 * Since: 1.4.
 **/
void
gwy_process_type_init(void)
{
    if (types_initialized)
        return;

    gwy_type_init();

    types_initialized += gwy_data_field_get_type();
    types_initialized += gwy_data_line_get_type();
    types_initialized |= 1;
}
示例#5
0
/**
 * gwy_process_type_init:
 *
 * Makes libgwyprocess types safe for deserialization and performs other
 * initialization.  You have to call this function before using objects
 * from libgwyprocess.
 *
 * Calls gwy_type_init() first to make sure libgwyddion is initialized.
 *
 * It is safe to call this function more than once, subsequent calls are no-op.
 **/
void
gwy_process_type_init(void)
{
    static gboolean types_initialized = FALSE;

    if (types_initialized)
        return;

    gwy_type_init();

    g_type_class_peek(GWY_TYPE_DATA_LINE);
    g_type_class_peek(GWY_TYPE_DATA_FIELD);
    g_type_class_peek(GWY_TYPE_CDLINE);
    types_initialized = TRUE;

    _gwy_cdline_class_setup_presets();
}
示例#6
0
int
main(int argc, char *argv[])
{
    guint xres_min = 2, xres_max = 10000,
          rand_seed = 42;
    gdouble xres_step = 1.06;

    GOptionEntry entries[] = {
        { "xres-min",    's', 0, G_OPTION_ARG_INT,    &xres_min,  "Smallest field xres to test", "N",  },
        { "xres-max",    'S', 0, G_OPTION_ARG_INT,    &xres_max,  "Largest field xres to test",  "N",  },
        { "xres-step",   'q', 0, G_OPTION_ARG_DOUBLE, &xres_step, "Field xres step factor",      "Q",  },
        { "random-seed", 'r', 0, G_OPTION_ARG_INT,    &rand_seed, "Random seed",                 "R",  },
        { NULL,          0,   0, 0,                   NULL,       NULL,                          NULL, },
    };

    GError *error = NULL;
    GOptionContext *context = g_option_context_new("- measure distance transform speed");
    g_option_context_add_main_entries(context, entries, NULL);
    if (!g_option_context_parse(context, &argc, &argv, &error)) {
        g_printerr("Arguments parsing failed: %s\n", error->message);
        return 1;
    }
    g_option_context_free(context);
    gwy_type_init();
    setvbuf(stdout, (char*)NULL, _IOLBF, 0);

    GRand *rng = g_rand_new();
    g_rand_set_seed(rng, rand_seed);

    for (guint xres = xres_min;
         xres <= xres_max;
         xres = MAX(xres + 1, (guint)(xres_step*xres + 0.5))) {

        distance_transform(xres, rng);
    }

    g_rand_free(rng);

    return 0;
}