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 5d926a3709644da603a4ecc5a98d33a1ba8a3d7c
parent 460fb9bb0a856a877bb5ee235435d8bf43440f81
Author: Benjamin Piaud <benjamin.piaud@meso-star.com>
Date:   Thu,  1 Dec 2022 10:40:46 +0100

Merge remote-tracking branch 'refs/remotes/origin/main'

Diffstat:
Msrc/cg_building_model1.c | 114+++++++++++++++++++++++++++++++++++++++----------------------------------------
1 file changed, 56 insertions(+), 58 deletions(-)

diff --git a/src/cg_building_model1.c b/src/cg_building_model1.c @@ -61,7 +61,7 @@ build_floor double e_insulation = data->ext_insulation; double e_floor = data->floor; double offset = 0; - struct scpr_polygon* pg_int; + struct scpr_polygon* pg_int = NULL; size_t nverts = 0; struct scad_geometry* footprint = NULL; double d[3] = {0, 0, 0}; @@ -72,7 +72,7 @@ build_floor if (!prefix || !pg || !data || !floor) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -99,7 +99,7 @@ exit: error: goto exit; } - + static res_T build_wall (const char* prefix, @@ -113,8 +113,8 @@ build_wall double e_insulation = data->ext_insulation; double depth = data->foundation; double offset = 0; - struct scpr_polygon* pg_int; - struct scpr_polygon* pg_ext; + struct scpr_polygon* pg_int = NULL; + struct scpr_polygon* pg_ext = NULL; size_t nverts = 0; struct scad_geometry* footprint = NULL; struct scad_geometry* footprint_int = NULL; @@ -127,7 +127,7 @@ build_wall if (!prefix || !pg || !data || !wall) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -154,8 +154,8 @@ build_wall ERR(scad_cut_geometries( NULL, &footprint_ext, 1, &footprint_int, 1, &footprint)); - - d[2] = depth + height; + + d[2] = depth + height; ERR(scad_geometry_extrude(footprint, wallname, d, wall)); exit: @@ -187,8 +187,8 @@ build_int_insulation double e_ext_insulation = data->ext_insulation; double e_int_insulation = data->int_insulation; double offset = 0; - struct scpr_polygon* pg_int; - struct scpr_polygon* pg_ext; + struct scpr_polygon* pg_int = NULL; + struct scpr_polygon* pg_ext = NULL; size_t nverts = 0; struct scad_geometry* footprint = NULL; struct scad_geometry* footprint_int = NULL; @@ -202,7 +202,7 @@ build_int_insulation if (!prefix || !pg || !data || !insulation) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -229,17 +229,17 @@ build_int_insulation ERR(scad_cut_geometries( NULL, &footprint_ext, 1, &footprint_int, 1, &footprint)); - - d[2] = height - e_roof - attic - e_roof_insulation; + + d[2] = height - e_roof - attic - e_roof_insulation; ERR(scad_geometry_extrude(footprint, NULL, d, &geom)); - + if (inter_floor) { ERR(scad_cut_geometries( insulationname, &geom, 1, &inter_floor, 1, insulation)); } else { ERR(scad_geometry_copy(geom, insulationname, insulation)); } - + exit: scad_geometry_delete(footprint); @@ -253,7 +253,7 @@ exit: error: goto exit; } - + static res_T build_roof (const char* prefix, @@ -268,7 +268,7 @@ build_roof double e_roof = data->roof; double offset = 0; double z_roof = 0; - struct scpr_polygon* pg_int; + struct scpr_polygon* pg_int = NULL; size_t nverts = 0; struct scad_geometry* footprint = NULL; double d[3] = {0, 0, 0}; @@ -279,7 +279,7 @@ build_roof if (!prefix || !pg || !data || !roof) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -324,7 +324,7 @@ build_roof_insulation double e_roof_insulation = data->roof_insulation; double offset = 0; double z_insulation = 0; - struct scpr_polygon* pg_int; + struct scpr_polygon* pg_int = NULL; size_t nverts = 0; struct scad_geometry* footprint = NULL; double d[3] = {0, 0, 0}; @@ -335,7 +335,7 @@ build_roof_insulation if (!prefix || !pg || !data || !insulation) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -379,7 +379,7 @@ build_floor_insulation double e_floor_insulation = data->floor_insulation; double offset = 0; double z_insulation = 0; - struct scpr_polygon* pg_int; + struct scpr_polygon* pg_int = NULL; size_t nverts = 0; struct scad_geometry* footprint = NULL; double d[3] = {0, 0, 0}; @@ -390,7 +390,7 @@ build_floor_insulation if (!prefix || !pg || !data || !insulation) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -439,7 +439,7 @@ build_inter_floor double offset = 0; double z_floor = 0; double h_cavity = 0; - struct scpr_polygon* pg_int; + struct scpr_polygon* pg_int = NULL; size_t nverts = 0; struct scad_geometry** floor_list = NULL; double d[3] = {0, 0, 0}; @@ -450,7 +450,7 @@ build_inter_floor if (!prefix || !pg || !data || !inter_floor) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -480,7 +480,7 @@ build_inter_floor ERR(scad_fuse_geometries( floorname, - floor_list, sa_size(floor_list), + floor_list, sa_size(floor_list), floor_list, sa_size(floor_list), inter_floor)); @@ -491,7 +491,7 @@ exit: for (i=0; i< floor_n; ++i) { scad_geometry_delete(floor_list[i]); } - sa_release(floor_list); + sa_release(floor_list); } return res; error: @@ -508,8 +508,8 @@ build_ext_insulation res_T res = RES_OK; double e_insulation = data->ext_insulation; double offset = 0; - struct scpr_polygon* pg_int; - struct scpr_polygon* pg_ext; + struct scpr_polygon* pg_int = NULL; + struct scpr_polygon* pg_ext = NULL; size_t nverts = 0; struct scad_geometry* footprint = NULL; struct scad_geometry* footprint_int = NULL; @@ -522,7 +522,7 @@ build_ext_insulation if (!prefix || !pg || !data || !insulation) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -546,8 +546,8 @@ build_ext_insulation ERR(scad_cut_geometries( NULL, &footprint_ext, 1, &footprint_int, 1, &footprint)); - - d[2] = height; + + d[2] = height; ERR(scad_geometry_extrude(footprint, insulationname, d, insulation)); exit: @@ -577,7 +577,7 @@ build_crawlspace double e_floor_insulation = data->floor_insulation; double offset = 0; double z_crawl= 0; - struct scpr_polygon* pg_int; + struct scpr_polygon* pg_int = NULL; size_t nverts = 0; struct scad_geometry* footprint = NULL; double d[3] = {0, 0, 0}; @@ -588,7 +588,7 @@ build_crawlspace if (!prefix || !pg || !data || !crawlspace) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -635,7 +635,7 @@ build_habitable double e_roof_insulation = data->roof_insulation; double e_attic = data->attic; double offset = 0; - struct scpr_polygon* pg_int; + struct scpr_polygon* pg_int = NULL; size_t nverts = 0; struct scad_geometry* footprint = NULL; struct scad_geometry* geom = NULL; @@ -647,7 +647,7 @@ build_habitable if (!prefix || !pg || !data || !cavity) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -698,7 +698,7 @@ build_attic double e_attic = data->attic; double offset = 0; double z_attic = 0; - struct scpr_polygon* pg_int; + struct scpr_polygon* pg_int = NULL; size_t nverts = 0; struct scad_geometry* footprint = NULL; double d[3] = {0, 0, 0}; @@ -709,7 +709,7 @@ build_attic if (!prefix || !pg || !data || !attic) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -877,8 +877,6 @@ build_boundary { res_T res = RES_OK; struct scad_geometry** list = NULL; - struct scad_geometry* geom1 = NULL; - struct scad_geometry* geom2 = NULL; struct scad_geometry* bound = NULL; char* boundaryname = NULL; struct str name; @@ -887,11 +885,11 @@ build_boundary if (!prefix || !data_cad || !boundary) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; - + sa_push(list, data_cad->wall); sa_push(list, data_cad->roof); sa_push(list, data_cad->floor); @@ -925,16 +923,16 @@ build_boundary ERR(str_append(&name, "_boundary_glass")); boundaryname = str_get(&name); ERR(scad_geometries_common_boundaries(boundaryname, list, sa_size(list), - &data_cad->glass, 1, &bound)); + &data_cad->glass, 1, &bound)); sa_push(*boundary, bound); } - + if (data_cad->external_insulation) { ERR(str_set(&name, prefix)); ERR(str_append(&name, "_boundary_ext_insulation")); boundaryname = str_get(&name); ERR(scad_geometries_common_boundaries(boundaryname, list, sa_size(list), - &data_cad->external_insulation, 1, &bound)); + &data_cad->external_insulation, 1, &bound)); sa_push(*boundary, bound); } @@ -944,7 +942,7 @@ build_boundary ERR(str_append(&name, "_boundary_int_insulation")); boundaryname = str_get(&name); ERR(scad_geometries_common_boundaries(boundaryname, list, sa_size(list), - &data_cad->internal_insulation, 1, &bound)); + &data_cad->internal_insulation, 1, &bound)); ERR(scad_geometry_get_count(bound, &count)); if (count>0) sa_push(*boundary, bound); } @@ -952,8 +950,6 @@ build_boundary exit: if (is_init) str_release(&name); if (list) sa_release(list); - scad_geometry_delete(geom1); - scad_geometry_delete(geom2); return res; error: goto exit; @@ -967,7 +963,7 @@ build_connection { res_T res = RES_OK; struct scad_geometry* connect = NULL; - size_t count = 0; + size_t count = 0; char* cname = NULL; struct str name; int is_init = 0; @@ -975,7 +971,7 @@ build_connection if (!prefix || !data_cad || !connection) { res = RES_BAD_ARG; goto error; - } + } str_init(NULL, &name); is_init = 1; @@ -1023,7 +1019,7 @@ build_connection /* with intermediate floor */ if (data_cad->intermediate_floor) { CREATE_CONNECT(habitable_cavity,intermediate_floor,"_C_cavity_intermediate_floor"); - } + } /* -------------------------------------------------------------------------*/ /* crawlspace cavity connections */ @@ -1035,11 +1031,11 @@ build_connection CREATE_CONNECT(crawlspace_cavity, floor_insulation,"_C_crawlspace_insulation"); } else { /* with floor */ - CREATE_CONNECT(crawlspace_cavity, floor,"_C_crawlspace_floor"); + CREATE_CONNECT(crawlspace_cavity, floor,"_C_crawlspace_floor"); } /* with wall */ - CREATE_CONNECT(crawlspace_cavity, wall,"_C_crawlspace_wall"); + CREATE_CONNECT(crawlspace_cavity, wall,"_C_crawlspace_wall"); } /* -------------------------------------------------------------------------*/ @@ -1149,7 +1145,7 @@ build_cad_model1(struct building* building) data_cad->connection = NULL; building->data_cad = (struct data_cad_model1*)data_cad; - /* build mandatories elements : + /* build mandatories elements : - floor - wall - roof @@ -1161,10 +1157,10 @@ build_cad_model1(struct building* building) ERR(build_roof(str_cget(&prefix), pg, height, data, &data_cad->roof)); - /* build optionnal elements : + /* build optionnal elements : - intermediate floor - - external insulation - - internal insulation + - external insulation + - internal insulation - roof insulation - floor insulation */ @@ -1205,7 +1201,7 @@ build_cad_model1(struct building* building) data_cad->floor_insulation = NULL; } - /* build cavities : + /* build cavities : - attic - habitable - crawlspace @@ -1230,7 +1226,9 @@ build_cad_model1(struct building* building) } /* windows */ - if (data->glass_ratio > 0) ERR(build_windows(str_cget(&prefix), data, data_cad)); + if (data->glass_ratio > 0) { + ERR(build_windows(str_cget(&prefix), data, data_cad)); + } ERR(scad_scene_partition());