commit 1104bf4b4f4a8146bde0b1f48168ce09826b0225
parent 3f78583426ba0c08dc342b84de08974347be1fc6
Author: Benjamin Piaud <benjamin.piaud@meso-star.com>
Date: Fri, 2 Dec 2022 17:47:23 +0100
Rework on ground. Add Boundary of ground
Diffstat:
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/src/cg_city.c b/src/cg_city.c
@@ -96,9 +96,12 @@ res_T
city_cad_build(struct logger* logger, struct city* city)
{
res_T res = RES_OK;
+ struct scad_options options = SCAD_DEFAULT_OPTIONS__;
size_t i,n;
ERR(scad_initialize(logger, NULL, 0));
+ options.Mesh.MeshSizeFromPoints = 0;
+ ERR(scad_set_options(&options));
/* iterate on building */
n = city->n;
@@ -121,9 +124,13 @@ res_T
city_ground_build(struct logger* logger, struct city* city)
{
res_T res = RES_OK;
+ struct scad_options options = SCAD_DEFAULT_OPTIONS__;
size_t i,n;
ERR(scad_initialize(logger, NULL, 0));
+ options.Mesh.MeshSizeFromPoints = 0;
+ ERR(scad_set_options(&options));
+
/* iterate on building */
n = city->n;
city->ground.n = n;
diff --git a/src/cg_ground.c b/src/cg_ground.c
@@ -23,6 +23,38 @@
#include <rsys/str.h>
#include <star/scad.h>
+static res_T
+build_ground_boundary
+ (struct scad_geometry* geom,
+ struct scad_geometry** footprint,
+ size_t n,
+ struct scad_geometry** boundary)
+{
+ res_T res = RES_OK;
+ struct scad_geometry* interface = NULL;
+ struct scad_geometry* bound = NULL;
+
+ if (!geom || !footprint || !boundary) {
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ ERR(scad_geometries_common_boundaries
+ (NULL, &geom, 1, footprint, n,
+ &interface));
+
+ ERR(scad_geometry_boundary(NULL, &geom, 1, &bound));
+
+ ERR(scad_cut_geometries(NULL, &bound, 1, &interface, 1, boundary));
+
+exit:
+ if (interface) scad_geometry_delete(interface);
+ if (bound) scad_geometry_delete(bound);
+ return res;
+error:
+ goto exit;
+}
+
res_T
ground_build_cad
(struct ground* ground)
@@ -31,7 +63,6 @@ ground_build_cad
double origin[3];
double extent[3];
struct scad_geometry* ground_box = NULL;
- struct scad_geometry* boundary = NULL;
struct str name;
int is_init = 0;
@@ -69,6 +100,12 @@ ground_build_cad
ground->footprint, ground->n,
&ground->geometry));
+ ERR(build_ground_boundary
+ (ground->geometry,
+ ground->footprint, ground->n,
+ &ground->boundary));
+
+
exit:
if (is_init) str_release(&name);
if (ground_box) scad_geometry_delete(ground_box);
@@ -83,7 +120,7 @@ ground_export_stl(const struct ground* ground, const int binary)
res_T res = RES_OK;
ERR(scad_stl_export(ground->geometry, "S_ground", binary));
- /*ERR(scad_stl_export(ground->boundary, "B_ground", binary));*/
+ ERR(scad_stl_export(ground->boundary, "B_ground", binary));
exit:
return res;