|
@@ -54,6 +54,7 @@ static void norm_vector(double x1, double y1, double x2, double y2, double *x,
|
|
|
l = LENGTH(dx, dy);
|
|
|
*x = dx / l;
|
|
|
*y = dy / l;
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -62,6 +63,7 @@ static void rotate_vector(double x, double y, double cosa, double sina,
|
|
|
{
|
|
|
*nx = x * cosa - y * sina;
|
|
|
*ny = x * sina + y * cosa;
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -73,7 +75,6 @@ static void elliptic_transform(double x, double y, double da, double db,
|
|
|
double dalpha, double *nx, double *ny)
|
|
|
{
|
|
|
double cosa = cos(dalpha);
|
|
|
-
|
|
|
double sina = sin(dalpha);
|
|
|
|
|
|
/* double cc = cosa*cosa;
|
|
@@ -90,6 +91,7 @@ static void elliptic_transform(double x, double y, double da, double db,
|
|
|
vb = (x * (-sina) + y * cosa) * db;
|
|
|
*nx = va * cosa + vb * (-sina);
|
|
|
*ny = va * sina + vb * cosa;
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -103,9 +105,7 @@ static void elliptic_tangent(double x, double y, double da, double db,
|
|
|
double dalpha, double *px, double *py)
|
|
|
{
|
|
|
double cosa = cos(dalpha);
|
|
|
-
|
|
|
double sina = sin(dalpha);
|
|
|
-
|
|
|
double u, v, len;
|
|
|
|
|
|
/* rotate (x,y) -dalpha radians */
|
|
@@ -118,6 +118,7 @@ static void elliptic_tangent(double x, double y, double da, double db,
|
|
|
u *= len;
|
|
|
v *= len;
|
|
|
rotate_vector(u, v, cosa, sina, px, py);
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -131,6 +132,7 @@ static void line_coefficients(double x1, double y1, double x2, double y2,
|
|
|
*a = y2 - y1;
|
|
|
*b = x1 - x2;
|
|
|
*c = x2 * y1 - x1 * y2;
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -164,6 +166,7 @@ static double angular_tolerance(double tol, double da, double db)
|
|
|
|
|
|
if (tol > a)
|
|
|
tol = a;
|
|
|
+
|
|
|
return 2 * acos(1 - tol / a);
|
|
|
}
|
|
|
|
|
@@ -495,7 +498,6 @@ static void extract_contour(struct planar_graph *pg, struct pg_edge *first,
|
|
|
int v0;
|
|
|
int eside; /* side of the current edge */
|
|
|
double eangle; /* current edge angle with Ox (according to the current direction) */
|
|
|
-
|
|
|
struct pg_vertex *vert; /* current vertex */
|
|
|
struct pg_vertex *vert0; /* last vertex */
|
|
|
struct pg_edge *edge; /* current edge; must be edge of vert */
|
|
@@ -630,15 +632,10 @@ static void extract_outer_contour(struct planar_graph *pg, int side,
|
|
|
struct line_pnts *nPoints)
|
|
|
{
|
|
|
int i;
|
|
|
-
|
|
|
int flag;
|
|
|
-
|
|
|
int v;
|
|
|
-
|
|
|
struct pg_vertex *vert;
|
|
|
-
|
|
|
struct pg_edge *edge;
|
|
|
-
|
|
|
double min_x, min_angle;
|
|
|
|
|
|
G_debug(3, "extract_outer_contour()");
|
|
@@ -785,6 +782,7 @@ static int point_in_buf(struct line_pnts *Points, double px, double py, double d
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -808,6 +806,7 @@ static int get_polygon_orientation(const double *x, const double *y, int n)
|
|
|
|
|
|
area += (y2 + y1) * (x2 - x1);
|
|
|
}
|
|
|
+
|
|
|
return (area > 0);
|
|
|
}
|
|
|
|
|
@@ -823,6 +822,7 @@ static void add_line_to_array(struct line_pnts *Points,
|
|
|
}
|
|
|
(*arrPoints)[*count] = Points;
|
|
|
(*count)++;
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -847,7 +847,6 @@ static void buffer_lines(struct line_pnts *area_outer, struct line_pnts **area_i
|
|
|
struct planar_graph *pg2;
|
|
|
struct line_pnts *sPoints, *cPoints;
|
|
|
struct line_pnts **arrPoints;
|
|
|
-
|
|
|
int i, count = 0;
|
|
|
int res, winding;
|
|
|
int auto_side;
|
|
@@ -964,7 +963,6 @@ void Vect_line_buffer2(const struct line_pnts *Points, double da, double db,
|
|
|
struct planar_graph *pg;
|
|
|
struct line_pnts *tPoints, *outer;
|
|
|
struct line_pnts **isles;
|
|
|
-
|
|
|
int isles_count = 0;
|
|
|
int res, winding;
|
|
|
int more = 8;
|
|
@@ -1023,9 +1021,7 @@ void Vect_area_buffer2(const struct Map_info *Map, int area, double da, double d
|
|
|
{
|
|
|
struct line_pnts *tPoints, *outer;
|
|
|
struct line_pnts **isles;
|
|
|
-
|
|
|
int isles_count = 0, n_isles;
|
|
|
-
|
|
|
int i, isle;
|
|
|
int more = 8;
|
|
|
int isles_allocated = 0;
|
|
@@ -1041,7 +1037,8 @@ void Vect_area_buffer2(const struct Map_info *Map, int area, double da, double d
|
|
|
/* outer contour */
|
|
|
outer = Vect_new_line_struct();
|
|
|
Vect_get_area_points(Map, area, outer);
|
|
|
- Vect_append_point(outer, outer->x[0], outer->y[0], outer->z[0]);
|
|
|
+ /* does not work with zero length line segments */
|
|
|
+ Vect_line_prune(outer);
|
|
|
|
|
|
/* inner contours */
|
|
|
for (i = 0; i < n_isles; i++) {
|
|
@@ -1053,8 +1050,8 @@ void Vect_area_buffer2(const struct Map_info *Map, int area, double da, double d
|
|
|
if (Vect_line_length(tPoints) < 2*PI*max)
|
|
|
continue;
|
|
|
*/
|
|
|
- Vect_append_point(tPoints, tPoints->x[0], tPoints->y[0],
|
|
|
- tPoints->z[0]);
|
|
|
+ /* does not work with zero length line segments */
|
|
|
+ Vect_line_prune(tPoints);
|
|
|
add_line_to_array(tPoints, &isles, &isles_count, &isles_allocated,
|
|
|
more);
|
|
|
tPoints = Vect_new_line_struct();
|
|
@@ -1087,9 +1084,7 @@ void Vect_point_buffer2(double px, double py, double da, double db,
|
|
|
struct line_pnts **oPoints)
|
|
|
{
|
|
|
double tx, ty;
|
|
|
-
|
|
|
double angular_tol, angular_step, phi1;
|
|
|
-
|
|
|
int j, nsegments;
|
|
|
|
|
|
G_debug(2, "Vect_point_buffer()");
|