star-uvm

Spatial structuring of unstructured volumetric meshes
git clone git://git.meso-star.fr/star-uvm.git
Log | Files | Refs | README | LICENSE

commit 71ea7b375ba5bf22bd25e031252ea5a224623aa0
parent 92ab8fe9483159c087a6a222e1097284caec480f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 12 Jan 2021 14:39:09 +0100

Add the "indices" member variable to the primitive structure

This variable stores the vertex indices of the primitive.

Diffstat:
Msrc/suvm.h | 2++
Msrc/suvm_volume.h | 17+++++++++++++++++
Msrc/test_suvm_volume.c | 4++++
3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/suvm.h b/src/suvm.h @@ -51,6 +51,7 @@ static const struct suvm_data SUVM_DATA_NULL = SUVM_DATA_NULL__; struct suvm_primitive { const void* data; /* Data of the primitive */ const void* vertex_data[SUVM_PRIMITIVE_MAX_VERTICES_COUNT]; /* Vertex data */ + size_t indices[SUVM_PRIMITIVE_MAX_VERTICES_COUNT]; /* Vertex indices */ size_t iprim; /* Identifier of the primitive */ size_t nvertices; /* #vertices of the primitive */ @@ -60,6 +61,7 @@ struct suvm_primitive { #define SUVM_PRIMITIVE_NULL__ { \ NULL, /* Primitive data */ \ {NULL}, /* Vertex data */ \ + {0}, /* Vertex indices */ \ SIZE_MAX, /* Primitive id */ \ SIZE_MAX, /* #vertices */ \ NULL /* Pointer toward its associated volume */ \ diff --git a/src/suvm_volume.h b/src/suvm_volume.h @@ -121,6 +121,22 @@ volume_get_vertices_count(const struct suvm_volume* vol) return sz / 3; } +static FINLINE size_t* +volume_primitive_get_indices + (const struct suvm_volume* vol, + const size_t iprim, + size_t indices[4]) +{ + const uint32_t* ids; + ASSERT(vol && indices && iprim < volume_get_primitives_count(vol)); + ids = darray_u32_cdata_get(&vol->indices) + iprim*4/*#vertices per tetra*/; + indices[0] = (size_t)ids[0]; + indices[1] = (size_t)ids[1]; + indices[2] = (size_t)ids[2]; + indices[3] = (size_t)ids[3]; + return indices; +} + static FINLINE float* volume_primitive_get_vertex_position (const struct suvm_volume* vol, @@ -237,6 +253,7 @@ volume_primitive_setup prim->nvertices = 4; prim->iprim = iprim; prim->volume__ = vol; + volume_primitive_get_indices(vol, prim->iprim, prim->indices); if(vol->has_prim_data) { prim->data = volume_primitive_get_data(vol, prim->iprim); } diff --git a/src/test_suvm_volume.c b/src/test_suvm_volume.c @@ -301,6 +301,10 @@ check_prim /* Fetch tetrahedron vertices */ get_indices(prim->iprim, ids, msh); + CHK(prim->indices[0] == ids[0]); + CHK(prim->indices[1] == ids[1]); + CHK(prim->indices[2] == ids[2]); + CHK(prim->indices[3] == ids[3]); get_position(ids[0], verts[0], msh); get_position(ids[1], verts[1], msh); get_position(ids[2], verts[2], msh);