commit d7baab343ba21feaf2a60b377cf8a8ac8df605d9
parent e121adaafbc10b5236569529b7bf2e8021f84d2b
Author: Benjamin Piaud <benjamin.piaud@meso-star.com>
Date: Thu, 20 Oct 2022 11:39:25 +0200
Minor bugfix
Diffstat:
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -78,7 +78,7 @@ add_executable(city_generator2
${CG2_FILES_SRC}
${CG2_FILES_INC})
-target_link_libraries(city_generator2 RSys StarCAD ${MATH_LIB})
+target_link_libraries(city_generator2 RSys StarCAD StarCPR ${MATH_LIB})
set_target_properties(city_generator2 PROPERTIES
VERSION ${VERSION})
diff --git a/src/cg_building_model0.c b/src/cg_building_model0.c
@@ -26,22 +26,26 @@
static res_T
polygon_to_xy
- (const struct scpr_polygon* pg, double x[], double y[], size_t* n)
+ (const struct scpr_polygon* pg, double** x, double** y, size_t* n)
{
res_T res = RES_OK;
+ double* xx;
+ double* yy;
size_t i;
ERR(scpr_polygon_get_vertices_count(pg, 0, n));
- x = (double*) malloc(*n * sizeof(double));
- y = (double*) malloc(*n * sizeof(double));
+ xx = (double*) malloc(*n * sizeof(double));
+ yy = (double*) malloc(*n * sizeof(double));
for (i=0; i<*n; ++i) {
double pos[2];
ERR(scpr_polygon_get_position(pg, 0, i, pos));
- x[i] = pos[0];
- y[i] = pos[1];
+ xx[i] = pos[0];
+ yy[i] = pos[1];
}
+ *x = xx;
+ *y = yy;
exit:
return res;
error:
@@ -58,7 +62,7 @@ build_floor_footprint
double* y = NULL;
size_t nverts;
- ERR(polygon_to_xy(pg, x, y, &nverts));
+ ERR(polygon_to_xy(pg, &x, &y, &nverts));
ERR(scad_add_polygon
(NULL, /* Can be NULL */
@@ -177,7 +181,7 @@ build_wall_footprint
double* y_int = NULL;
size_t nverts, nverts_int;
- ERR(polygon_to_xy(pg, x, y, &nverts));
+ ERR(polygon_to_xy(pg, &x, &y, &nverts));
ERR(scad_add_polygon
(NULL,
@@ -187,7 +191,7 @@ build_wall_footprint
nverts,
&polygon));
- ERR(polygon_to_xy(pg_int, x_int, y_int, &nverts_int));
+ ERR(polygon_to_xy(pg_int, &x_int, &y_int, &nverts_int));
ERR(scad_add_polygon
(NULL,
x_int,
@@ -291,7 +295,7 @@ build_cavity
cavityname = str_get(&name);
}
- ERR(polygon_to_xy(pg, x, y, &nverts));
+ ERR(polygon_to_xy(pg, &x, &y, &nverts));
ERR(scad_add_polygon
(NULL, /* Can be NULL */
@@ -390,7 +394,7 @@ build_ground
double* y = NULL;
size_t nverts;
- ERR(polygon_to_xy(pg, x, y, &nverts));
+ ERR(polygon_to_xy(pg, &x, &y, &nverts));
ERR(scad_add_polygon
(NULL,
@@ -535,7 +539,7 @@ build_cad_model0(struct building* building)
e_wall = data->wall;
ERR(scpr_polygon_create(NULL, &pg_int));
- /*ERR(polygon_copy(pg, &pg_int));*/
+ ERR(scpr_polygon_copy(pg, pg_int));
ERR(scpr_offset_polygon(pg_int, -e_wall, SCPR_JOIN_MITER));
/* build floor with pg_int */
@@ -586,7 +590,7 @@ build_footprint_model0
e_wall = data->wall;
ERR(scpr_polygon_create(NULL, &pg_int));
- /*ERR(polygon_copy(pg, &pg_int));*/
+ ERR(scpr_polygon_copy(pg, pg_int));
ERR(scpr_offset_polygon(pg_int, -e_wall, SCPR_JOIN_MITER));
ERR(build_wall_footprint(pg, pg_int, &geom[0]));