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 dcac84e65e42d669730bb012f4061926528f3cb6
parent f6d82fe535493c3078b06c2006a3ce744a56e7ea
Author: Benjamin Piaud <benjamin.piaud@meso-star.com>
Date:   Wed, 22 Feb 2023 17:26:06 +0100

Bug fix and add example files for this branch

Diffstat:
Aexample/catalog0.yaml | 8++++++++
Aexample/catalog1.yaml | 30++++++++++++++++++++++++++++++
Aexample/city.yaml | 30++++++++++++++++++++++++++++++
Msrc/cg_building.c | 6+++---
Msrc/cg_building.h | 4++--
Msrc/cg_city.c | 23+++++++++++++----------
6 files changed, 86 insertions(+), 15 deletions(-)

diff --git a/example/catalog0.yaml b/example/catalog0.yaml @@ -0,0 +1,8 @@ +construction_mode: Construction_Mode_0 +datasets: + - name: b0a + wall_thickness: 0.2 + floor_thickness: 0.35 + - name: b0b + wall_thickness: 0.15 + floor_thickness: 0.2 diff --git a/example/catalog1.yaml b/example/catalog1.yaml @@ -0,0 +1,30 @@ +construction_mode: Construction_Mode_1 +datasets: + - name: b1a + inter_floor_count: 0 + wall_thickness: 0.2 + floor_thickness: 0.3 + inter_floor_thickness: 0.2 + roof_thickness: 0.3 + internal_insulation_thickness: 0.1 + external_insulation_thickness: 0 + floor_insulation_thickness: 0.1 + roof_insulation_thickness: 0.2 + foundation_depth: 2 + crawl_height: 0. + attic_height: 0.5 + glass_ratio: 0.5 + - name: b1b + inter_floor_count: 1 + wall_thickness: 0.3 + floor_thickness: 0.6 + inter_floor_thickness: 0.2 + roof_thickness: 0.3 + internal_insulation_thickness: 0. + external_insulation_thickness: 0.1 + floor_insulation_thickness: 0 + roof_insulation_thickness: 0.1 + foundation_depth: 2.5 + crawl_height: 1 + attic_height: 0 + glass_ratio: 0.6 diff --git a/example/city.yaml b/example/city.yaml @@ -0,0 +1,30 @@ +ground: + extent: [ -20, 40, -20, 20 ] + depth: 5 + +buildings: + - name: bat_0 + construction_mode: Construction_Mode_0 + dataset: b0a + footprint: [ [0, 0], [10, 0], [10, 10], [0, 10] ] + height: 5.52056 + - name: bat_1 + construction_mode: Construction_Mode_1 + dataset: b1a + footprint: [ [10, 0], [15, 0], [15, 15], [10, 15] ] + height: 4.66191 + - name: bat_2 + construction_mode: Construction_Mode_1 + dataset: b1b + footprint: [ [20, 0], [30, 0], [30, 10], [20, 10] ] + height: 8 + - name: bat_3 + construction_mode: Construction_Mode_0 + dataset: b0a + footprint: [ [20, 0], [20, -5], [25, -5], [25, 0] ] + height: 3.52056 + - name: bat_4 + construction_mode: Construction_Mode_0 + dataset: b0a + footprint: [ [5, 0], [5, -5], [10, -5], [10, 0] ] + height: 3.52056 diff --git a/src/cg_building.c b/src/cg_building.c @@ -33,7 +33,7 @@ static void unused_functions(void){ res_T build_adjoining - (const struct building* adjoining, + (struct building** adjoining, const size_t adjoining_n, struct scad_geometry** geom) { @@ -51,9 +51,9 @@ build_adjoining /* iterate over adjoining building */ for (i=0; i<adjoining_n; i++) { size_t nverts = 0; - double height = adjoining[i].height; + double height = adjoining[i]->height; double d[3] = {0, 0, 0}; - struct scpr_polygon* pg = adjoining[i].pg; + struct scpr_polygon* pg = adjoining[i]->pg; struct scad_geometry* envelop = NULL; struct scad_geometry* footprint = NULL; diff --git a/src/cg_building.h b/src/cg_building.h @@ -87,7 +87,7 @@ struct building { struct str name; double height; struct scpr_polygon* pg; - struct building* adjoining; + struct building** adjoining; size_t adjoining_n; /* specific data depending to the construction mode */ @@ -96,7 +96,7 @@ struct building { res_T build_adjoining - (const struct building* adjoining, + (struct building** adjoining, const size_t adjoining_n, struct scad_geometry** geom); diff --git a/src/cg_city.c b/src/cg_city.c @@ -178,16 +178,19 @@ city_cad_build(struct city* city) for(i = 0; i < city->buildings_count; i++) { struct building* building = city->buildings + i; struct data_cad_cmode_0* cad = NULL; - - if (i==0) { - city->buildings[i].adjoining = &city->buildings[1]; - city->buildings[i].adjoining_n = 1; - } - - if (i==1) { - city->buildings[i].adjoining = &city->buildings[0]; - city->buildings[i].adjoining_n = 1; - } + size_t j = 0; + size_t count = 0; + + /* TEMPORARY HARD CODED DATA */ + /* all building are considered as adjoining */ + building->adjoining_n = city->buildings_count - 1; + building->adjoining = malloc(building->adjoining_n * sizeof(struct building*)); + for (j=0; j < city->buildings_count; j++) { + if (i != j) { + building->adjoining[count] = city->buildings + j; + count++; + } + } /* create building */ ERR(building->functors->build_cad(city->scpr, city->allocator, city->logger,