[gegl/npd-squashed] libs: npd: remove unused functions and mark some functions as static
- From: Marek Dvoroznak <dvoromar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/npd-squashed] libs: npd: remove unused functions and mark some functions as static
- Date: Wed, 18 Dec 2013 03:33:41 +0000 (UTC)
commit eecebf6e94d187def550e67db764ab071b745ba8
Author: Marek Dvoroznak <dvoromar gmail com>
Date: Sun Dec 8 16:09:01 2013 +0100
libs: npd: remove unused functions and mark some functions as static
libs/npd/Makefile.am | 2 +-
libs/npd/npd_common.c | 162 ++++++++-----------------------------------------
libs/npd/npd_common.h | 3 +-
libs/npd/npd_debug.c | 5 ++
libs/npd/npd_debug.h | 8 +++
5 files changed, 41 insertions(+), 139 deletions(-)
---
diff --git a/libs/npd/Makefile.am b/libs/npd/Makefile.am
index f9247d8..37768b0 100644
--- a/libs/npd/Makefile.am
+++ b/libs/npd/Makefile.am
@@ -13,7 +13,7 @@ GEGL_NPD_public_HEADERS = \
graphics.h \
lattice_cut.h \
npd_gegl.h \
- npd_debug \
+ npd_debug.h \
npd.h
GEGL_NPD_SOURCES = \
diff --git a/libs/npd/npd_common.c b/libs/npd/npd_common.c
index 7766f2f..9025006 100644
--- a/libs/npd/npd_common.c
+++ b/libs/npd/npd_common.c
@@ -25,20 +25,6 @@
#include <glib.h>
#include <glib/gprintf.h>
-static NPDControlPoint *npd_get_control_point_at (NPDModel *model,
- NPDPoint *coord);
-
-#if 0
-static void add_point_to_suitable_cluster (GHashTable *coords_to_cluster,
- NPDPoint *point,
- GPtrArray *list_of_overlapping_points);
-#endif
-
-static void npd_set_overlapping_points_weight (NPDOverlappingPoints *op,
- gfloat weight);
-
-static void npd_reset_weights (NPDHiddenModel *hidden_model);
-
void
npd_init_model (NPDModel *model)
{
@@ -65,7 +51,7 @@ npd_init_model (NPDModel *model)
model->texture_visible = TRUE;
}
-void
+static void
npd_destroy_hidden_model (NPDHiddenModel *hm)
{
gint i;
@@ -247,11 +233,22 @@ npd_remove_all_control_points (NPDModel *model)
model->control_points->len);
}
+static void
+npd_set_overlapping_points_weight (NPDOverlappingPoints *op,
+ gfloat weight)
+{
+ gint i;
+ for (i = 0; i < op->num_of_points; i++)
+ {
+ (*op->points[i]->weight) = weight;
+ }
+}
+
void
npd_set_control_point_weight (NPDControlPoint *cp,
gfloat weight)
{
- npd_set_overlapping_points_weight(cp->overlapping_points, weight);
+ npd_set_overlapping_points_weight (cp->overlapping_points, weight);
}
static gboolean
@@ -299,7 +296,7 @@ npd_get_control_point_with_radius_at (NPDModel *model,
return NULL;
}
-static NPDControlPoint*
+NPDControlPoint*
npd_get_control_point_at (NPDModel *model,
NPDPoint *coord)
{
@@ -334,123 +331,27 @@ npd_create_square (NPDBone *square,
}
}
-#if 0
-static void
-npd_create_list_of_overlapping_points (NPDHiddenModel *hm)
+void
+npd_set_point_coordinates (NPDPoint *target,
+ NPDPoint *source)
{
- gint i, j, num_of_bones;
- NPDBone *bone;
- NPDPoint *point;
- GPtrArray *list_of_ops;
- GHashTable *coords_to_cluster;
-
- list_of_ops = g_ptr_array_new ();
- num_of_bones = hm->num_of_bones;
- coords_to_cluster = g_hash_table_new_full
- (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify) g_hash_table_destroy);
-
- for (i = 0; i < num_of_bones; i++)
- {
- bone = &hm->current_bones[i];
-
- for (j = 0; j < bone->num_of_points; j++)
- {
- point = &bone->points[j];
- add_point_to_suitable_cluster (coords_to_cluster,
- point,
- list_of_ops);
- }
- }
-
- hm->list_of_overlapping_points = g_new (NPDOverlappingPoints,
- list_of_ops->len);
- hm->num_of_overlapping_points = list_of_ops->len;
-
- for (i = 0; i < list_of_ops->len; i++)
- {
- GPtrArray *op = g_ptr_array_index (list_of_ops, i);
- hm->list_of_overlapping_points[i].points = (NPDPoint**) op->pdata;
- hm->list_of_overlapping_points[i].num_of_points = op->len;
- hm->list_of_overlapping_points[i].representative =
- hm->list_of_overlapping_points[i].points[0];
-
- for (j = 0; j < op->len; j++)
- {
- NPDPoint *p = hm->list_of_overlapping_points[i].points[j];
- p->overlapping_points = &hm->list_of_overlapping_points[i];
- p->counterpart->overlapping_points = &hm->list_of_overlapping_points[i];
- }
-
- g_ptr_array_free (op, FALSE); /* we want to preserve the underlying
- array */
- }
-
- /* free allocated memory */
- g_hash_table_destroy (coords_to_cluster);
- g_ptr_array_free (list_of_ops, TRUE);
+ target->x = source->x;
+ target->y = source->y;
}
-#define NPD_FLOAT_TO_STRING(name_of_string, value) \
-/* must be freed */ \
-name_of_string = g_new (gchar, 10); \
-g_ascii_dtostr (name_of_string, 10, value);
-
static void
-add_point_to_suitable_cluster (GHashTable *coords_to_cluster,
- NPDPoint *point,
- GPtrArray *list_of_overlapping_points)
+npd_reset_weights (NPDHiddenModel *hm)
{
- gchar *str_coord_x, *str_coord_y;
- GHashTable *coord_y;
- GPtrArray *op;
-
- NPD_FLOAT_TO_STRING (str_coord_x, point->x);
- NPD_FLOAT_TO_STRING (str_coord_y, point->y);
-
- coord_y = g_hash_table_lookup (coords_to_cluster, str_coord_x);
-
- if (coord_y == NULL)
- {
- /* coordinate doesn't exist */
- coord_y = g_hash_table_new_full (g_str_hash, /* is freed during */
- g_str_equal, /* destroying */
- g_free, /* coords_to_cluster */
- NULL); /* hash table */
- g_hash_table_insert (coords_to_cluster, str_coord_x, coord_y);
- }
-
- op = g_hash_table_lookup (coord_y, str_coord_y);
- if (op == NULL)
- {
- op = g_ptr_array_new ();
- g_hash_table_insert (coord_y, str_coord_y, op);
- g_ptr_array_add (list_of_overlapping_points, op);
- }
-
- g_ptr_array_add (op, point);
-}
-#endif
+ NPDOverlappingPoints *op;
+ gint i;
-static void
-npd_set_overlapping_points_weight (NPDOverlappingPoints *op,
- gfloat weight)
-{
- gint i;
- for (i = 0; i < op->num_of_points; i++)
+ for (i = 0; i < hm->num_of_overlapping_points; i++)
{
- (*op->points[i]->weight) = weight;
+ op = &hm->list_of_overlapping_points[i];
+ npd_set_overlapping_points_weight (op, 1.0);
}
}
-void
-npd_set_point_coordinates (NPDPoint *target,
- NPDPoint *source)
-{
- target->x = source->x;
- target->y = source->y;
-}
-
/**
* Sets type of deformation. The function doesn't perform anything if supplied
* deformation type doesn't differ from currently set one.
@@ -517,16 +418,3 @@ npd_compute_MLS_weights (NPDModel *model)
npd_set_overlapping_points_weight (op, MLS_weight);
}
}
-
-static void
-npd_reset_weights (NPDHiddenModel *hm)
-{
- NPDOverlappingPoints *op;
- gint i;
-
- for (i = 0; i < hm->num_of_overlapping_points; i++)
- {
- op = &hm->list_of_overlapping_points[i];
- npd_set_overlapping_points_weight (op, 1.0);
- }
-}
diff --git a/libs/npd/npd_common.h b/libs/npd/npd_common.h
index 04fae70..fe57697 100644
--- a/libs/npd/npd_common.h
+++ b/libs/npd/npd_common.h
@@ -100,7 +100,6 @@ npd_get_pixel_color = get_pixel; \
npd_draw_line = draw_line;
void npd_init_model (NPDModel *model);
-void npd_destroy_hidden_model (NPDHiddenModel *model);
void npd_destroy_model (NPDModel *model);
NPDControlPoint *npd_add_control_point (NPDModel *model,
@@ -112,6 +111,8 @@ void npd_remove_control_points (NPDModel *model,
void npd_remove_all_control_points (NPDModel *model);
void npd_set_control_point_weight (NPDControlPoint *cp,
gfloat weight);
+NPDControlPoint *npd_get_control_point_at (NPDModel *model,
+ NPDPoint *coord);
NPDControlPoint *npd_get_control_point_with_radius_at
(NPDModel *model,
NPDPoint *coord,
diff --git a/libs/npd/npd_debug.c b/libs/npd/npd_debug.c
index 9941494..4fcce66 100644
--- a/libs/npd/npd_debug.c
+++ b/libs/npd/npd_debug.c
@@ -19,6 +19,11 @@
* Copyright (C) 2013 Marek Dvoroznak <dvoromar gmail com>
*/
+#include "npd_debug.h"
+#include "npd_common.h"
+#include <glib.h>
+#include <glib/gprintf.h>
+
void
npd_print_model (NPDModel *model,
gboolean print_control_points)
diff --git a/libs/npd/npd_debug.h b/libs/npd/npd_debug.h
index 857872d..1c85581 100644
--- a/libs/npd/npd_debug.h
+++ b/libs/npd/npd_debug.h
@@ -19,6 +19,12 @@
* Copyright (C) 2013 Marek Dvoroznak <dvoromar gmail com>
*/
+#ifndef __NPD_DEBUG_H__
+#define __NPD_DEBUG_H__
+
+#include "npd_common.h"
+#include <glib.h>
+
void npd_print_model (NPDModel *model,
gboolean print_control_points);
void npd_print_hidden_model (NPDHiddenModel *hm,
@@ -28,3 +34,5 @@ void npd_print_bone (NPDBone *bone);
void npd_print_point (NPDPoint *point,
gboolean print_details);
void npd_print_overlapping_points (NPDOverlappingPoints *op);
+
+#endif /* __NPD_DEBUG_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]