commit a7663999fad151c6901070425cdecb145b7d86e2
parent 58ad56309088d1ea5b0572f874e58e65ec041c01
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 27 Jan 2025 17:52:07 +0100
Create stardis description for mode 2 buildings
Diffstat:
1 file changed, 75 insertions(+), 1 deletion(-)
diff --git a/src/cg_construction_mode_2.c b/src/cg_construction_mode_2.c
@@ -27,6 +27,7 @@
#include "cg_construction_mode.h"
#include "cg_construction_mode_2.h"
#include "cg_vertex_denoiser.h"
+#include "cg_stardis_model.h"
#include <rsys/rsys.h>
#include <rsys/str.h>
@@ -2026,16 +2027,39 @@ export_stl_cmode_2
struct scad_geometry** list = NULL;
struct mem_allocator* allocator = NULL;
struct city* city;
+ struct building* building;
struct vertex_denoiser* denoiser;
+ FILE* model = NULL;
+ FILE* vars = NULL;
+ fpos_t model_pos, vars_pos;
+ long model_count = 0;
+ const char* n;
+ static int fst = 1;
if(!cad) {
res = RES_BAD_ARG;
goto error;
}
- city = data_cad->building->city;
+ building = data_cad->building;
+ city = building->city;
allocator = city->allocator;
denoiser = city->denoiser;
+ model = city->stardis_model;
+ vars = city->set_vars;
+
+ if(!fst) fprintf(model, "\n");
+ fst = 0;
+ fprintf(model,
+ "# Building '%s' construction mode 2, dataset '%s', %g m tall\n",
+ str_cget(&building->name), str_cget(&building->dataset_name),
+ building->total_height);
+ fgetpos(model, &model_pos);
+ fprintf(vars,
+ "\n# Building '%s' construction mode 2, dataset '%s', %g m tall\n",
+ str_cget(&building->name), str_cget(&building->dataset_name),
+ building->total_height);
+ fgetpos(vars, &vars_pos);
if(darray_geometries_size_get(&data_cad->adj_walls) == 0) {
/* wall export */
@@ -2103,64 +2127,92 @@ export_stl_cmode_2
binary));
}
+ STARDIS_SOLID(wall);
+
+ if(data_cad->external_insulation) {
+ STARDIS_SOLID(external_insulation);
+ }
+
/* floor export */
ERR(stl_export_denoised_geometry(denoiser, data_cad->floor,
Scad_force_normals_outward, binary));
+ STARDIS_SOLID(floor);
+
/* roof export */
ERR(stl_export_denoised_geometry(denoiser, data_cad->roof,
Scad_force_normals_outward, binary));
+ STARDIS_SOLID(roof);
+
/* foundation export */
if(data_cad->foundation) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->foundation,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(foundation);
}
/* glass export */
if(data_cad->glazing) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->glazing,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(glazing);
}
/* intermediate floor export*/
if(data_cad->intermediate_floor) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->intermediate_floor,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(intermediate_floor);
}
/* internal insulation export*/
if(data_cad->internal_insulation) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->internal_insulation,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(internal_insulation);
}
/* roof insulation export*/
if(data_cad->roof_insulation) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->roof_insulation,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(roof_insulation);
}
/* floor insulation export*/
if(data_cad->floor_insulation) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->floor_insulation,
Scad_force_normals_outward, binary));
+
+ STARDIS_SOLID(floor_insulation);
}
/* attic cavity export*/
if(data_cad->attic_cavity) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->attic_cavity,
Scad_force_normals_outward, binary));
+
+ STARDIS_FLUID(attic_cavity);
}
/* habitable cavity export*/
ERR(stl_export_denoised_geometry(denoiser, data_cad->habitable_cavity,
Scad_force_normals_outward, binary));
+ STARDIS_FLUID(habitable_cavity);
+
/* crawlspace cavity export*/
if(data_cad->crawlspace_cavity) {
ERR(stl_export_denoised_geometry(denoiser, data_cad->crawlspace_cavity,
Scad_force_normals_outward, binary));
+
+ STARDIS_FLUID(crawlspace_cavity);
}
/* boundary export*/
@@ -2168,6 +2220,9 @@ export_stl_cmode_2
struct scad_geometry* b = darray_geometries_data_get(&data_cad->boundary)[i];
ERR(stl_export_denoised_geometry(denoiser, b, Scad_keep_normals_unchanged,
binary));
+
+ ERR(scad_geometry_get_name(b, &n));
+ STARDIS_H_BOUND_2(SFC, n);
}
/* connections export*/
@@ -2175,12 +2230,18 @@ export_stl_cmode_2
struct scad_geometry* c = darray_geometries_data_get(&data_cad->connection)[i];
ERR(stl_export_denoised_geometry(denoiser, c, Scad_keep_normals_unchanged,
binary));
+
+ ERR(scad_geometry_get_name(c, &n));
+ STARDIS_SFC_2(SFC, n);
}
/* ground/building connection export*/
ERR(stl_export_denoised_geometry(denoiser, data_cad->ground_connection,
Scad_keep_normals_unchanged, binary));
+ /* No need to describe solid-solid connections until there is a contact
+ * resistance */
+
exit:
for(j = 0; j < common_n; j++) {
if(list[j]) SCAD(geometry_ref_put(list[j]));
@@ -2197,6 +2258,19 @@ error:
"Internal error '"__FILE__"': creating STL for building '%s'.\n",
str_cget(&data_cad->building->name));
}
+ /* Reset stardis model file */
+ if(model) {
+ long l;
+ fsetpos(model, &model_pos);
+ for(l = 0; l < model_count; l += 40)
+ fprintf(model, " \n");
+ fprintf(model, "# Building '%s' construction cancelled\n",
+ str_cget(&building->name));
+ }
+ if(vars) {
+ fprintf(vars, "# Building '%s' construction cancelled\n",
+ str_cget(&building->name));
+ }
goto exit;
}