From: Matthew Fernandez Date: Fri, 7 Jan 2022 03:27:50 +0000 (-0800) Subject: lib/mingle ink: pass point lists around as vectors instead of C arrays X-Git-Tag: 3.0.0~88^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e5c4a3219c636cd565bd2917360e383177de243;p=graphviz lib/mingle ink: pass point lists around as vectors instead of C arrays --- diff --git a/lib/mingle/ink.cpp b/lib/mingle/ink.cpp index 37b8779e3..e88cf2e3a 100644 --- a/lib/mingle/ink.cpp +++ b/lib/mingle/ink.cpp @@ -49,10 +49,10 @@ static const point_t Origin = {0, 0}; /* sumLengths: */ -static double sumLengths_avoid_bad_angle(point_t* points, int npoints, point_t end, point_t meeting, double angle_param) -{ +static double sumLengths_avoid_bad_angle(const std::vector &points, + point_t end, point_t meeting, + double angle_param) { /* avoid sharp turns, we want cos_theta to be as close to -1 as possible */ - int i; double len0, len, sum = 0; double diff_x, diff_y, diff_x0, diff_y0; double cos_theta, cos_max = -10; @@ -62,9 +62,9 @@ static double sumLengths_avoid_bad_angle(point_t* points, int npoints, point_t e len0 = sum = hypot(diff_x0, diff_y0); // distance form each of 'points' till 'meeting' - for (i=0; i &points, point_t end, + point_t meeting) { double sum = 0; double diff_x, diff_y; // distance form each of 'points' till 'meeting' - for (i=0; i &points, point_t begin, + point_t end, double prec, point_t *meet, + double angle_param) { point_t first, second, third, fourth, diff, meeting; double value1, value2, value3, value4; @@ -110,15 +110,15 @@ static double bestInk(point_t* points, int npoints, point_t begin, point_t end, third = addPoint(first,scalePoint(diff,2.0/3.0)); if (angle_param < 1){ - value1 = sumLengths(points, npoints, end, first); - value2 = sumLengths(points, npoints, end, second); - value3 = sumLengths(points, npoints, end, third); - value4 = sumLengths(points, npoints, end, fourth); + value1 = sumLengths(points, end, first); + value2 = sumLengths(points, end, second); + value3 = sumLengths(points, end, third); + value4 = sumLengths(points, end, fourth); } else { - value1 = sumLengths_avoid_bad_angle(points, npoints, end, first, angle_param); - value2 = sumLengths_avoid_bad_angle(points, npoints, end, second, angle_param); - value3 = sumLengths_avoid_bad_angle(points, npoints, end, third, angle_param); - value4 = sumLengths_avoid_bad_angle(points, npoints, end, fourth, angle_param); + value1 = sumLengths_avoid_bad_angle(points, end, first, angle_param); + value2 = sumLengths_avoid_bad_angle(points, end, second, angle_param); + value3 = sumLengths_avoid_bad_angle(points, end, third, angle_param); + value4 = sumLengths_avoid_bad_angle(points, end, fourth, angle_param); } if (value1