|
@@ -3,7 +3,7 @@
|
|
|
#include <grass/vector.h>
|
|
|
|
|
|
static struct line_pnts *Points_wall, *Points_roof, *Points_floor;
|
|
|
-static struct line_cats *Cats_roof;
|
|
|
+static struct line_cats *Cats_floor;
|
|
|
|
|
|
/**
|
|
|
\brief Extrude 2D vector feature to 3D
|
|
@@ -35,7 +35,7 @@ int extrude(struct Map_info *In, struct Map_info *Out,
|
|
|
int k; /* Points->n_points */
|
|
|
int nlines;
|
|
|
|
|
|
- double voffset_dem; /* minimal offset */
|
|
|
+ double voffset_dem; /* minimal offset */
|
|
|
double voffset_curr; /* offset of current point */
|
|
|
double voffset_next; /* offset of next point */
|
|
|
|
|
@@ -48,13 +48,13 @@ int extrude(struct Map_info *In, struct Map_info *Out,
|
|
|
Points_wall = Vect_new_line_struct();
|
|
|
Points_roof = Vect_new_line_struct();
|
|
|
Points_floor = Vect_new_line_struct();
|
|
|
- Cats_roof = Vect_new_cats_struct();
|
|
|
+ Cats_floor = Vect_new_cats_struct();
|
|
|
}
|
|
|
else {
|
|
|
Vect_reset_line(Points_wall);
|
|
|
Vect_reset_line(Points_roof);
|
|
|
Vect_reset_line(Points_floor);
|
|
|
- Vect_reset_cats(Cats_roof);
|
|
|
+ Vect_reset_cats(Cats_floor);
|
|
|
}
|
|
|
|
|
|
voffset_dem = 0.0;
|
|
@@ -81,7 +81,6 @@ int extrude(struct Map_info *In, struct Map_info *Out,
|
|
|
for (k = 0; ; k++) {
|
|
|
voffset_curr = voffset_next = 0.0;
|
|
|
|
|
|
- /* trace */
|
|
|
if (fdrast >= 0 && trace) {
|
|
|
voffset_curr = Rast_get_sample(fdrast, window, NULL,
|
|
|
Points->y[k], Points->x[k], 0, /* north, east */
|
|
@@ -97,50 +96,42 @@ int extrude(struct Map_info *In, struct Map_info *Out,
|
|
|
|
|
|
if (Rast_is_d_null_value(&voffset_curr) ||
|
|
|
Rast_is_d_null_value(&voffset_next)) {
|
|
|
- if (type == GV_POINT)
|
|
|
- break;
|
|
|
- else if (type == GV_LINE) {
|
|
|
- if (k >= Points->n_points - 1)
|
|
|
- break;
|
|
|
- }
|
|
|
- else if (type == GV_AREA) {
|
|
|
- if (k >= Points->n_points - 2)
|
|
|
- break;
|
|
|
- }
|
|
|
- continue;
|
|
|
+ if (k >= Points->n_points - 2)
|
|
|
+ break;
|
|
|
+ else
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
- if (trace) {
|
|
|
- voffset_curr += voffset;
|
|
|
- voffset_next += voffset;
|
|
|
- }
|
|
|
- else {
|
|
|
- voffset_curr = voffset_dem + voffset;
|
|
|
- voffset_next = voffset_dem + voffset;
|
|
|
- }
|
|
|
+ if (trace) {
|
|
|
+ voffset_curr += voffset;
|
|
|
+ voffset_next += voffset;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ voffset_curr = voffset_dem + voffset;
|
|
|
+ voffset_next = voffset_dem + voffset;
|
|
|
+ }
|
|
|
|
|
|
if (type == GV_POINT) {
|
|
|
/* point -> 3d line (vertical) */
|
|
|
Vect_append_point(Points_wall, Points->x[k], Points->y[k],
|
|
|
Points->z[k] + voffset_curr);
|
|
|
Vect_append_point(Points_wall, Points->x[k], Points->y[k],
|
|
|
- Points->z[k] + objheight + voffset_curr);
|
|
|
- break;
|
|
|
+ Points->z[k] + objheight + (trace ? voffset_curr : 0.));
|
|
|
}
|
|
|
|
|
|
if (type & (GV_LINE | GV_AREA)) {
|
|
|
/* reset */
|
|
|
Vect_reset_line(Points_wall);
|
|
|
|
|
|
- /* boundary -> face */
|
|
|
+ /* line/boundary segment -> face */
|
|
|
Vect_append_point(Points_wall, Points->x[k], Points->y[k],
|
|
|
Points->z[k] + voffset_curr);
|
|
|
Vect_append_point(Points_wall, Points->x[k + 1], Points->y[k + 1],
|
|
|
Points->z[k + 1] + voffset_next);
|
|
|
Vect_append_point(Points_wall, Points->x[k + 1], Points->y[k + 1],
|
|
|
- Points->z[k + 1] + objheight + voffset_next);
|
|
|
+ Points->z[k + 1] + objheight + (trace ? voffset_next : 0.));
|
|
|
Vect_append_point(Points_wall, Points->x[k], Points->y[k],
|
|
|
- Points->z[k] + objheight + voffset_curr);
|
|
|
+ Points->z[k] + objheight + (trace ? voffset_curr : 0.));
|
|
|
Vect_append_point(Points_wall, Points->x[k], Points->y[k],
|
|
|
Points->z[k] + voffset_curr);
|
|
|
|
|
@@ -150,23 +141,20 @@ int extrude(struct Map_info *In, struct Map_info *Out,
|
|
|
if (type == GV_AREA) {
|
|
|
/* roof */
|
|
|
Vect_append_point(Points_roof, Points->x[k], Points->y[k],
|
|
|
- Points->z[k] + objheight + voffset_curr);
|
|
|
+ Points->z[k] + objheight + (trace ? voffset_curr : 0.));
|
|
|
/* floor */
|
|
|
Vect_append_point(Points_floor, Points->x[k], Points->y[k],
|
|
|
Points->z[k] + voffset_curr);
|
|
|
}
|
|
|
-
|
|
|
- if (k >= Points->n_points - 2)
|
|
|
- break;
|
|
|
}
|
|
|
+ if (k >= Points->n_points - 2)
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
if (type == GV_POINT) {
|
|
|
Vect_write_line(Out, GV_LINE, Points_wall, Cats);
|
|
|
- return 1;
|
|
|
}
|
|
|
-
|
|
|
- if (type == GV_AREA && Points_roof->n_points > 3) {
|
|
|
+ else if (type == GV_AREA && Points_roof->n_points > 3) {
|
|
|
/* close roof and floor */
|
|
|
Vect_append_point(Points_roof,
|
|
|
Points_roof->x[0], Points_roof->y[0],
|
|
@@ -177,14 +165,13 @@ int extrude(struct Map_info *In, struct Map_info *Out,
|
|
|
/* write roof and floor */
|
|
|
Vect_write_line(Out, GV_FACE, Points_roof, Cats);
|
|
|
Vect_write_line(Out, GV_FACE, Points_floor, Cats);
|
|
|
-
|
|
|
- nlines++;
|
|
|
+ nlines += 2;
|
|
|
|
|
|
if (centroid > 0) {
|
|
|
/* centroid -> kernel */
|
|
|
- Vect_read_line(In, Points_roof, Cats_roof, centroid);
|
|
|
- Points->z[0] = Points_roof->z[0] / 2.0; /* TODO: do it better */
|
|
|
- Vect_write_line(Out, GV_KERNEL, Points_roof, Cats_roof);
|
|
|
+ Vect_read_line(In, Points_floor, Cats_floor, centroid);
|
|
|
+ Points_floor->z[0] = Points_roof->z[0] / 2.0; /* TODO: do it better */
|
|
|
+ Vect_write_line(Out, GV_KERNEL, Points_floor, Cats_floor);
|
|
|
nlines++;
|
|
|
}
|
|
|
}
|