Commit d7714277 authored by Barak Itkin's avatar Barak Itkin
Browse files

Make the refinement limitation a function argument

Instead of using the environment variable p2t_refine_steps, the limit is
now a parameter to all the functions, and is also a parameter of the
gegl operation itself. It won't crash now if the environment variable is
missing (that was the state previously).
parent e58c57f1
......@@ -238,7 +238,8 @@ sc_mesh_sampling_free (ScMeshSampling *self)
*/
P2tRTriangulation*
sc_make_fine_mesh (ScOutline *outline,
GeglRectangle *mesh_bounds)
GeglRectangle *mesh_bounds,
int max_refine_steps)
{
GPtrArray *realOutline = (GPtrArray*) outline;
gint i, N = realOutline->len;
......@@ -268,7 +269,7 @@ sc_make_fine_mesh (ScOutline *outline,
mesh_bounds->width = max_x + 1 - min_x;
mesh_bounds->height = max_y + 1 - min_y;
T = p2tr_triangulate_and_refine (mesh_points);
T = p2tr_triangulate_and_refine (mesh_points, max_refine_steps);
for (i = 0; i < N; i++)
{
......
......@@ -34,7 +34,7 @@ void sc_sample_list_free (ScSampleList *self);
ScMeshSampling* sc_mesh_sampling_compute (ScOutline *outline, P2tRTriangulation *mesh);
void sc_mesh_sampling_free (ScMeshSampling *self);
P2tRTriangulation* sc_make_fine_mesh (ScOutline *outline, GeglRectangle *mesh_bounds);
P2tRTriangulation* sc_make_fine_mesh (ScOutline *outline, GeglRectangle *mesh_bounds, int max_refine_steps);
#endif
......@@ -217,7 +217,7 @@ gint main (int argc, char *argv[])
read_points_file (input_file, &pts, &colors);
T = p2tr_triangulate_and_refine (pts);
T = p2tr_triangulate_and_refine (pts, refine_max_steps);
p2tr_plot_svg (T,out);
......
......@@ -501,16 +501,21 @@ SplitPermitted (P2tREdge *s, gdouble d)
#define MIN_MAX_EDGE_LEN 0
void
DelaunayTerminator (P2tRTriangulation *T, GList *XEs, gdouble theta, deltafunc delta)
DelaunayTerminator (P2tRTriangulation *T,
GList *XEs,
gdouble theta,
deltafunc delta,
int max_refine_steps)
{
const gint STEPS = atoi (g_getenv ("p2t_refine_steps"));
const gint STEPS = max_refine_steps;
GSequence *Qt;
GQueue Qs;
GList *Liter, Liter2;
P2trHashSetIter Hiter;
p2tr_debug("Max refine point count is %d\n", max_refine_steps);
p2tr_validate_triangulation (T);
P2tRTriangle *t;
......@@ -518,8 +523,6 @@ DelaunayTerminator (P2tRTriangulation *T, GList *XEs, gdouble theta, deltafunc d
g_queue_init (&Qs);
Qt = g_sequence_new (NULL);
p2tr_debug ("Now we have %d triangles\n", g_hash_table_size (T->tris));
if (STEPS == 0)
return;
......@@ -674,7 +677,7 @@ DelaunayTerminator (P2tRTriangulation *T, GList *XEs, gdouble theta, deltafunc d
* Input must be a GPtrArray of P2tRPoint*
*/
P2tRTriangulation*
p2tr_triangulate_and_refine (GPtrArray *pts)
p2tr_triangulate_and_refine (GPtrArray *pts, int max_refine_steps)
{
gint i, N = pts->len;
GList *XEs = NULL, *iter;
......@@ -689,7 +692,7 @@ p2tr_triangulate_and_refine (GPtrArray *pts)
}
T = p2tr_triangulateA ((P2tRPoint**)pts->pdata ,pts->len);
DelaunayTerminator (T,XEs,M_PI/6,p2tr_false_delta);
DelaunayTerminator (T,XEs,M_PI/6,p2tr_false_delta, max_refine_steps);
foreach (iter, XEs)
{
......@@ -700,4 +703,4 @@ p2tr_triangulate_and_refine (GPtrArray *pts)
g_list_free (XEs);
return T;
}
\ No newline at end of file
}
......@@ -17,7 +17,7 @@ extern "C"
#endif
P2tRTriangulation*
p2tr_triangulate_and_refine (GPtrArray *pts);
p2tr_triangulate_and_refine (GPtrArray *pts, int max_refine_steps);
......
......@@ -28,6 +28,8 @@
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_pointer (result, _("result"),
_("A pointer to a pointer (gpointer*) to store the result in"))
gegl_chant_int (max_refine_steps, _("Refinement Steps"), 0, 100000.0, 2000,
_("Maximal amount of refinement points to be used for the interpolation mesh"))
#else
#define GEGL_CHANT_TYPE_SINK
......@@ -78,7 +80,7 @@ process (GeglOperation *operation,
result->outline = sc_outline_find_ccw (roi, input);
/* Then, Generate the mesh */
result->mesh = sc_make_fine_mesh (result->outline, &result->mesh_bounds);
result->mesh = sc_make_fine_mesh (result->outline, &result->mesh_bounds, GEGL_CHANT_PROPERTIES (operation) -> max_refine_steps);
/* Finally, Generate the mesh sample list for each point */
result->sampling = sc_mesh_sampling_compute (result->outline, result->mesh);
......
......@@ -18,6 +18,9 @@
*/
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_int (max_refine_steps, _("Refinement Steps"), 0, 100000.0, 2000,
_("Maximal amount of refinement points to be used for the interpolation mesh"))
#else
#define GEGL_CHANT_TYPE_COMPOSER
......@@ -155,6 +158,7 @@ process (GeglOperation *operation,
P2tRImageConfig imcfg;
Babl *format = babl_format("R'G'B'A float");
int max_refine_steps = GEGL_CHANT_PROPERTIES (operation)->max_refine_steps;
g_debug ("seamless-clone.c::process");
printf ("The aux_rect is: ");
......@@ -170,8 +174,8 @@ process (GeglOperation *operation,
g_debug ("Finish making outline");
/* Then, Generate the mesh */
g_debug ("Start making fine mesh");
mesh = sc_make_fine_mesh (outline, &mesh_bounds);
g_debug ("Start making fine mesh with at most %d points", max_refine_steps);
mesh = sc_make_fine_mesh (outline, &mesh_bounds, max_refine_steps);
g_debug ("Finish making fine mesh");
/* Finally, Generate the mesh sample list for each point */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment