city_generator2

Generated conformal 3D meshes representing a city
git clone git://git.meso-star.fr/city_generator2.git
Log | Files | Refs | README | LICENSE

commit f4b50557e1b05c19e8b9e2e2109795476db3c984
parent 79a99b05ebbc12eb00371665959805cb728717dd
Author: Benjamin Piaud <benjamin.piaud@meso-star.com>
Date:   Wed,  3 Aug 2022 11:31:55 +0200

Modify ground and footprint processing

Diffstat:
Msrc/building.c | 62+++++++++++++++++++++-----------------------------------------
Msrc/building.h | 2--
Msrc/ground.c | 16++++------------
3 files changed, 25 insertions(+), 55 deletions(-)

diff --git a/src/building.c b/src/building.c @@ -24,14 +24,15 @@ static res_T build_slab (const struct pg_polygon* pg, - struct building* b) + struct building* b, + struct scad_scene* scene, + struct scad_geometry** slab) { res_T res = RES_OK; size_t id; enum model model; double e; struct data_model0* data; - struct data_cad_model0* data_cad; struct scad_geometry* footprint; double d[3] = {0, 0, 0}; struct str name; @@ -39,7 +40,6 @@ build_slab id = b->id; model = b->model; data = (struct data_model0*)b->data; - data_cad = (struct data_cad_model0*)b->data_cad; e = data->slab; str_init(NULL, &name); @@ -50,7 +50,7 @@ build_slab ERR(str_append(&name, "_slab")); ERR(scad_scene_add_polygon - (b->scene, + (scene, NULL, /* Can be NULL */ pg->x, pg->y, @@ -63,7 +63,7 @@ build_slab (footprint, str_cget(&name), d, - &data_cad->slab)); + slab)); exit: return res; @@ -112,13 +112,15 @@ static res_T build_wall (const struct pg_polygon* pg, const struct pg_polygon* pg_int, - struct building* b) + struct building* b, + struct scad_scene* scene, + struct scad_geometry** wall) { res_T res = RES_OK; size_t id; enum model model; double height; - struct data_cad_model0* data_cad; + /*struct data_cad_model0* data_cad;*/ struct scad_geometry* polygon; struct scad_geometry* polygon_int; struct scad_geometry* footprint; @@ -128,7 +130,7 @@ build_wall id = b->id; model = b->model; height = b->height; - data_cad = (struct data_cad_model0*)b->data_cad; + /*data_cad = (struct data_cad_model0*)b->data_cad;*/ str_init(NULL, &name); ERR(str_set(&name, "building_")); @@ -138,7 +140,7 @@ build_wall ERR(str_append(&name, "_wall")); ERR(scad_scene_add_polygon - (b->scene, + (scene, NULL, pg->x, pg->y, @@ -147,7 +149,7 @@ build_wall &polygon)); ERR(scad_scene_add_polygon - (b->scene, + (scene, NULL, pg_int->x, pg_int->y, @@ -157,7 +159,7 @@ build_wall ERR(scad_scene_cut_geometries - (b->scene, + (scene, NULL, polygon, polygon_int, @@ -169,7 +171,7 @@ build_wall (footprint, str_cget(&name), d, - &data_cad->wall)); + wall)); exit: return res; @@ -370,13 +372,13 @@ build_cad_model0 ERR(pg_offset(&pg, e_wall, &pg_int, &pg_ext)); /* build slab with pg_int */ - ERR(build_slab(&pg_int, building)); + ERR(build_slab(&pg_int, building, building->scene, &data_cad->slab)); /* roof is a translated copy of slab */ ERR(build_roof(data_cad->slab, building)); /* build wall with pg and pg_int */ - ERR(build_wall(&pg, &pg_int, building)); + ERR(build_wall(&pg, &pg_int, building, building->scene, &data_cad->wall)); /* build cavity */ ERR(build_cavity(&pg_int, building)); @@ -409,40 +411,18 @@ build_footprint_model0 struct data_model0* data = (struct data_model0 *)building->data; double e_wall; struct scad_geometry* geom[2]; - struct scad_geometry* polygon; enum model model = building->model; size_t id = building->id; struct str name; + e_wall = data->wall; ERR(pg_offset(&pg, e_wall, &pg_int, &pg_ext)); - ERR(scad_scene_add_polygon - (scene, - NULL, - pg.x, - pg.y, - 0, - pg.n, - &polygon)); - - ERR(scad_scene_add_polygon - (scene, - NULL, - pg_int.x, - pg_int.y, - 0, - pg_int.n, - &geom[0])); - - - ERR(scad_scene_cut_geometries - (scene, - NULL, - polygon, - geom[0], - &geom[1], - 0)); + /* we simply add to the ground->scene the geometries in contact with ground */ + + ERR(build_slab(&pg_int, building, scene, &geom[0])); + ERR(build_wall(&pg, &pg_int, building, scene, &geom[1])); str_init(NULL, &name); ERR(str_set(&name, "building_")); diff --git a/src/building.h b/src/building.h @@ -38,8 +38,6 @@ struct building { /* each building has his own scene */ struct scad_scene* scene; - /* footprint for ground scene */ - struct scad_geometry* footprint; /* specific data depending model */ void* data; diff --git a/src/ground.c b/src/ground.c @@ -26,7 +26,6 @@ ground_build_cad ( struct ground* ground) { res_T res = RES_OK; - size_t i; double origin[3]; double extent[3]; struct str name; @@ -58,17 +57,10 @@ ground_build_cad origin, extent, &ground->geometry)); - - for (i=0; i<ground->n; ++i) { - ERR(scad_scene_geometries_fragment - (ground->scene, - NULL, - ground->geometry, - ground->footprint[i], - &ground->geometry, - 0)); - } - + + /* TODO: do something for building with foundation. + * without foundation, the mesh is conformal because ground->footprint include + * geometry in contact with ground. */ ERR(scad_scene_conformal_mesh(ground->scene)); exit: