commit 23fde3780f43bc6843e52781c193686ec2c50473
parent 415c77e375eff7f059df0a04c57e8492a3149ec0
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sun, 25 Apr 2021 18:07:37 +0200
Add the Sampling_Surface attribute to the output VTK
Diffstat:
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/sgs_geometry.c b/src/sgs_geometry.c
@@ -180,8 +180,9 @@ sgs_geometry_dump_vtk(const struct sgs_geometry* geom, FILE* stream)
FPRINTF("3 %lu %lu %lu\n", ARG3(ids[0], ids[1], ids[2]));
}
- /* Write the triangle type */
FPRINTF("CELL_DATA %lu\n", ARG1((unsigned long)ntris));
+
+ /* Write the triangle type */
FPRINTF("SCALARS Triangle_Type integer 1\n", ARG0());
FPRINTF("LOOKUP_TABLE default\n", ARG0());
FOR_EACH(i, 0, ntris) {
@@ -189,6 +190,17 @@ sgs_geometry_dump_vtk(const struct sgs_geometry* geom, FILE* stream)
FPRINTF("%i\n", ARG1(type));
}
+ /* Write the sampling type */
+ FPRINTF("SCALARS Sampling_Surface integer 1\n", ARG0());
+ FPRINTF("LOOKUP_TABLE Sampling_Type\n", ARG0());
+ FOR_EACH(i, 0, ntris) {
+ const int type = darray_int_cdata_get(&geom->tris_type)[i];
+ FPRINTF("%i\n", ARG1((type & geom->sampling_mask) != 0));
+ }
+ FPRINTF("LOOKUP_TABLE Sampling_Type 2\n", ARG0());
+ FPRINTF("0 0 1 1\n", ARG0());
+ FPRINTF("1 0 0 1\n", ARG0());
+
#undef FPRINTF
exit:
@@ -204,13 +216,15 @@ res_T
geometry_create
(struct sgs* sgs,
const enum sgs_geometry_type type,
+ const int sampling_mask,
struct sgs_geometry** out_geom)
{
struct sgs_geometry* geom = NULL;
struct mem_allocator* allocator = NULL;
res_T res = RES_OK;
ASSERT(sgs && (unsigned)type < SGS_GEOMETRY_TYPES_COUNT__ && out_geom);
-
+ ASSERT(sampling_mask != 0);
+
allocator = sgs_get_allocator(sgs);
geom = MEM_CALLOC(allocator, 1, sizeof(struct sgs_geometry));
if(!geom) {
@@ -224,6 +238,7 @@ geometry_create
darray_size_t_init(allocator, &geom->tris);
darray_int_init(allocator, &geom->tris_type);
geom->type = type;
+ geom->sampling_mask = sampling_mask;
exit:
*out_geom = geom;
diff --git a/src/sgs_geometry_box.c b/src/sgs_geometry_box.c
@@ -129,7 +129,7 @@ sgs_geometry_box_create
goto error;
}
- res = geometry_create(sgs, SGS_GEOMETRY_BOX, &geom);
+ res = geometry_create(sgs, SGS_GEOMETRY_BOX, args->sampling_mask, &geom);
if(res != RES_OK) goto error;
res = setup_box_mesh(geom, args);
if(res != RES_OK) goto error;
diff --git a/src/sgs_geometry_c.h b/src/sgs_geometry_c.h
@@ -38,6 +38,7 @@ struct sgs_geometry {
struct s3d_scene_view* view_sp;
enum sgs_geometry_type type;
+ int sampling_mask; /* Combination of enum sgs_surface_type */
struct sgs* sgs;
ref_T ref;
@@ -47,6 +48,7 @@ extern LOCAL_SYM res_T
geometry_create
(struct sgs* sgs,
const enum sgs_geometry_type type,
+ const int sampling_mask,
struct sgs_geometry** out_geom);
extern LOCAL_SYM res_T
diff --git a/src/sgs_geometry_slope.c b/src/sgs_geometry_slope.c
@@ -133,7 +133,7 @@ sgs_geometry_slope_create
goto error;
}
- res = geometry_create(sgs, SGS_GEOMETRY_SLOPE, &geom);
+ res = geometry_create(sgs, SGS_GEOMETRY_SLOPE, args->sampling_mask, &geom);
if(res != RES_OK) goto error;
res = setup_slope_mesh(geom, args);
if(res != RES_OK) goto error;