commit 582c23ab75fdc47c01005dac784bb318443235aa
parent 38eac9d4227b52ebedb20b5f06a771f72dd4526a
Author: Eduardo Fontana Lazzari <edufonlaz@gmail.com>
Date: Tue, 27 May 2025 16:17:04 +0200
Use suniq library for associative structure construction
When the associative structure construction was first implemented (see
commit 59f137b), the suniq library did not exist. This library now
abstracts most of the functions and data structures used during the
construction phase, allowing this logic to be centralized and reused in
other projects.
As a result, the code in star-phor is now simplified, since these
functions are exposed by the library with the same functionality as
before. Additionally, support data structures (such as hash tables and
dynamic arrays), which were previously implemented specifically for this
processing step, are now fully handled by suniq.
Diffstat:
7 files changed, 102 insertions(+), 231 deletions(-)
diff --git a/Makefile b/Makefile
@@ -60,6 +60,7 @@ $(LIBNAME): $(OBJ_LIB)
$(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
$(PKG_CONFIG) --atleast-version $(SPHIN_VERSION) sphin
$(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
+ $(PKG_CONFIG) --atleast-version $(SUNIQ_VERSION) suniq
echo "config done" > $@
.SUFFIXES: .c .d .o
@@ -115,6 +116,7 @@ pkg:
-e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\
-e 's#@SPHIN_VERSION@#$(SPHIN_VERSION)#g'\
-e 's#@S3D_VERSION@#$(S3D_VERSION)#g'\
+ -e 's#@SUNIQ_VERSION@#$(SUNIQ_VERSION)#g'\
sphor.pc.in > sphor.pc
star-phor.1: doc/star-phor.scd
diff --git a/README.md b/README.md
@@ -10,6 +10,7 @@ Solver for radiative transfer in photoreactors.
- rsys
- star-phor-input
- star-3d
+- star-uniq
## Installation
diff --git a/config.mk b/config.mk
@@ -25,9 +25,10 @@ RANLIB = ranlib
SPHIN_VERSION=0.0
RSYS_VERSION=0.14
S3D_VERSION=0.10
+SUNIQ_VERSION=0.0
-INCS = $$($(PKG_CONFIG) --cflags rsys sphin s3d)
-LIBS = $$($(PKG_CONFIG) --libs rsys sphin s3d)
+INCS = $$($(PKG_CONFIG) --cflags rsys sphin s3d suniq)
+LIBS = $$($(PKG_CONFIG) --libs rsys sphin s3d suniq)
################################################################################
# Compilation options
diff --git a/src/sphor.c b/src/sphor.c
@@ -101,7 +101,7 @@ sphor_create
}
darray_interface_init(sphor->allocator, &sphor->interfaces);
- /* TODO load the system and build data structure for Monte Carlo */
+ /* Load the system and build data structure for Monte Carlo */
res = setup_config(sphor, args);
if (RES_OK != res) { goto error; }
diff --git a/src/sphor_c.h b/src/sphor_c.h
@@ -66,48 +66,6 @@ struct sphor {
ref_T ref;
};
-struct triangle {
- double v0[3];
- double v1[3];
- double v2[3];
-};
-#define TRIANGLE_NULL__ {0}
-static const struct triangle TRIANGLE_NULL = TRIANGLE_NULL__;
-
-/* Define the dynamic array for the struct triangle as a type */
-#define DARRAY_NAME triangle
-#define DARRAY_DATA struct triangle
-#include <rsys/dynamic_array.h>
-
-struct triangle_key {
- double v0[3];
- double v1[3];
- double v2[3];
-};
-#define TRIANGLE_KEY_NULL__ {0}
-static const struct triangle_key TRIANGLE_KEY_NULL = TRIANGLE_KEY_NULL__;
-
-static INLINE char
-triangle_key_eq
- (const struct triangle_key* a,
- const struct triangle_key* b)
-{
- ASSERT(NULL != a);
- ASSERT(NULL != b);
-
- return d3_eq(a->v0, b->v0)
- && d3_eq(a->v1, b->v1)
- && d3_eq(a->v2, b->v2);
-}
-
-/* Define the hash table that maps triangle_key to an index used to access the
- * triangle's properties (coordinates and interface) */
-#define HTABLE_NAME tri2id
-#define HTABLE_KEY struct triangle_key
-#define HTABLE_DATA size_t
-#define HTABLE_KEY_FUNCTOR_EQ triangle_key_eq
-#include <rsys/hash_table.h>
-
extern LOCAL_SYM res_T
setup_config
(struct sphor* sphor,
diff --git a/src/sphor_config.c b/src/sphor_config.c
@@ -27,6 +27,7 @@
#include <star/sphin.h>
#include <star/s3d.h>
+#include <star/suniq.h>
/*******************************************************************************
* Helper functions
@@ -52,78 +53,28 @@ vec3_cmp
return 0;
}
-static INLINE void
-vec3_swap
- (double v0[3],
- double v1[3])
-{
- double v[3] = {0};
- ASSERT(NULL != v0);
- ASSERT(NULL != v1);
-
- d3_set(v, v0);
- d3_set(v0,v1);
- d3_set(v1, v);
-}
-
-static void
-triangle_key_setup
- (struct triangle_key* key,
- const struct triangle* tri)
-{
- ASSERT(NULL != key);
- ASSERT(NULL != tri);
-
- d3_set(key->v0, tri->v0);
- d3_set(key->v1, tri->v1);
- d3_set(key->v2, tri->v2);
-
- /* Sort tri vertices lexicographically using the bubble sort algorithm
- * (https://en.wikipedia.org/wiki/Bubble_sort) */
- if (vec3_cmp(key->v0, key->v1) < 0) vec3_swap(key->v0, key->v1);
- if (vec3_cmp(key->v1, key->v2) < 0) vec3_swap(key->v1, key->v2);
- if (vec3_cmp(key->v0, key->v1) < 0) vec3_swap(key->v0, key->v1);
-}
-
static int
are_triangles_reversed
- (const struct triangle* tri0,
- const struct triangle* tri1)
+ (const struct suniq_triangle* tri0,
+ const struct suniq_triangle* tri1)
{
- const double* tri1_verts[3] = { NULL, NULL, NULL};
int i = 0;
ASSERT(NULL != tri0);
ASSERT(NULL != tri1);
-#ifndef NDEBUG
- /* In debug check that the triangles are geometrically the same */
- {
- struct triangle_key k0 = TRIANGLE_KEY_NULL;
- struct triangle_key k1 = TRIANGLE_KEY_NULL;
-
- triangle_key_setup(&k0, tri0);
- triangle_key_setup(&k1, tri1);
- ASSERT(triangle_key_eq(&k0, &k1));
- }
-#endif /* NDEBUG */
-
- /* Match tri0->v0 with one of the vertices of tri1. */
- tri1_verts[0] = tri1->v0;
- tri1_verts[1] = tri1->v1;
- tri1_verts[2] = tri1->v2;
-
FOR_EACH(i, 0, 3) {
- if(0 == vec3_cmp(tri0->v0, tri1_verts[i])) { break; }
+ if(0 == vec3_cmp(tri0->vertices[0], tri1->vertices[i])) { break; }
}
ASSERT(i<3);
/* Check the order of the next vertex:
* If tri0->v1 matches the next vertex in tri1 (cyclically),
* the triangles have the same orientation (not reversed).
* Otherwise, the vertex order has been reversed. */
- if(0 == vec3_cmp(tri0->v1, tri1_verts[(i+1)%3])) {
+ if(0 == vec3_cmp(tri0->vertices[1], tri1->vertices[(i+1)%3])) {
return 0; /* Same orientation */
} else {
+ ASSERT(0 == vec3_cmp(tri0->vertices[1], tri1->vertices[(i+2)%3]));
return 1; /* Reversed orientation */
}
}
@@ -132,7 +83,7 @@ static void
setup_triangle
(const struct sphin_geometry_descriptor* geom_desc,
const size_t itri,
- struct triangle* tri)
+ struct suniq_triangle* tri)
{
const double* coords[3] = {NULL, NULL, NULL};
size_t ids[3] = {0, 0, 0};
@@ -167,91 +118,65 @@ setup_triangle
coords[2] = geom_desc->mesh.coords + ids[2]*3/*#coords per vertex*/;
/* Set the retrieved coords to the triangle struct */
- d3_set(tri->v0, coords[0]);
- d3_set(tri->v1, coords[1]);
- d3_set(tri->v2, coords[2]);
+ d3_set(tri->vertices[0], coords[0]);
+ d3_set(tri->vertices[1], coords[1]);
+ d3_set(tri->vertices[2], coords[2]);
}
-/* Return the triangle id if it already exists, append it to the dynamic array
- * and create an equivalent interface in the interface dynamic array otherwise
- * and return the newly created id */
static res_T
-register_triangle
+register_interface
(struct sphor* sphor,
- const struct triangle* triangle,
- struct htable_tri2id* tri2id,
- struct darray_triangle* triangles,
- size_t* out_id)
+ const size_t id,
+ struct interface** interface)
{
- size_t* p_id = NULL;
- size_t new_id;
- struct triangle_key tri_key = TRIANGLE_KEY_NULL;
res_T res = RES_OK;
ASSERT(NULL != sphor);
- ASSERT(NULL != triangle);
- ASSERT(NULL != tri2id);
- ASSERT(NULL != triangles);
- ASSERT(NULL != out_id);
-
- /* Reorder tri vertices to get the tri_key */
- triangle_key_setup(&tri_key, triangle);
-
- /* Get the triangle id */
- p_id = htable_tri2id_find(tri2id, &tri_key);
-
- /* If not in the hash table, add it */
- if (NULL == p_id) {
- new_id = darray_triangle_size_get(triangles);
- p_id = &new_id;
- res = darray_triangle_push_back(triangles, triangle);
- if (RES_OK != res) { goto error; }
+ ASSERT(NULL != interface);
+ ASSERT(id <= darray_interface_size_get(&sphor->interfaces));
+
+ if (id == darray_interface_size_get(&sphor->interfaces)) {
res = darray_interface_push_back(&sphor->interfaces, &INTERFACE_NULL);
- if (RES_OK != res) { goto error; }
- res = htable_tri2id_set(tri2id, &tri_key, p_id);
- if (RES_OK != res) { goto error; }
+ if (RES_OK != res) { return RES_BAD_ARG; }
}
+ *interface = darray_interface_data_get(&sphor->interfaces) + id;
-exit:
- *out_id = *p_id;
return res;
-error:
- goto exit;
}
-
/*******************************************************************************
* Volume setup
******************************************************************************/
static res_T
setup_interface_volume_geometry_triangle
(struct sphor* sphor,
- struct htable_tri2id* tri2id,
- struct darray_triangle* triangles,
+ struct suniq* suniq,
const struct sphin_geometry_descriptor* geom_desc,
const size_t ivolume,
const size_t itri)
{
- size_t itri_sphor = 0; /* Triangle index used internally by sphor */
- struct triangle tri = TRIANGLE_NULL;
- const struct triangle* tri_sphor = NULL;
+ size_t itri_suniq = 0; /* Triangle index used internally by suniq */
+ struct suniq_triangle tri = SUNIQ_TRIANGLE_NULL;
+ struct suniq_triangle tri_suniq = SUNIQ_TRIANGLE_NULL;
struct interface* interface = NULL;
enum sphin_side side = SPHIN_SIDE_NONE__;
int flip = 0;
res_T res = RES_OK;
ASSERT(NULL != sphor);
- ASSERT(NULL != tri2id);
- ASSERT(NULL != triangles);
+ ASSERT(NULL != suniq);
ASSERT(NULL != geom_desc);
setup_triangle(geom_desc, itri, &tri);
- res = register_triangle(sphor, &tri, tri2id, triangles, &itri_sphor);
+ res = suniq_register_triangle(suniq, &tri, &itri_suniq);
if (RES_OK != res) { goto error; }
/* Retrieve the registered triangle and its properties */
- tri_sphor = darray_triangle_cdata_get(triangles) + itri_sphor;
- interface = darray_interface_data_get(&sphor->interfaces) + itri_sphor;
+ res = suniq_get_triangle(suniq, itri_suniq, &tri_suniq);
+ if (RES_OK != res) { goto error; }
+
+ res = register_interface(sphor, itri_suniq, &interface);
+ if (RES_OK != res) { goto error; }
/* Determine the side to append the surface based on whether the geometry is
* flipped and knowing the input side using the xor (^) operator.
@@ -267,13 +192,16 @@ setup_interface_volume_geometry_triangle
* | back | 1 | 1 | 0 |
* +------+-----+-----+-----+ */
- flip = are_triangles_reversed(&tri, tri_sphor);
+ flip = are_triangles_reversed(&tri, &tri_suniq);
side = (size_t) flip ^ geom_desc->side;
+
if(INVALID_ID != interface->volumes[side]) {
ERROR(sphor,
"Redefinition of volume side in triangle from file '%s'.\n",
geom_desc->filename);
+ res = RES_BAD_ARG;
+ goto error;
}
interface->volumes[side] = ivolume;
@@ -286,8 +214,7 @@ error:
static res_T
setup_interfaces_volume_geometry
(struct sphor* sphor,
- struct htable_tri2id* tri2id,
- struct darray_triangle* triangles,
+ struct suniq* suniq,
const size_t ivolume,
const size_t igeom)
{
@@ -299,8 +226,7 @@ setup_interfaces_volume_geometry
res_T res = RES_OK;
ASSERT(NULL != sphor);
- ASSERT(NULL != tri2id);
- ASSERT(NULL != triangles);
+ ASSERT(NULL != suniq);
ASSERT(RES_OK == sphin_config_get_volume_count(sphor->config, &n));
ASSERT(ivolume < n);
@@ -319,7 +245,7 @@ setup_interfaces_volume_geometry
n = geom_desc.mesh.triangle_count;
FOR_EACH(itri, 0, n) {
res = setup_interface_volume_geometry_triangle
- (sphor, tri2id, triangles, &geom_desc, ivolume, itri);
+ (sphor, suniq, &geom_desc, ivolume, itri);
if (RES_OK != res) { goto error; }
}
@@ -332,8 +258,7 @@ error:
static res_T
setup_interfaces_volume
(struct sphor* sphor,
- struct htable_tri2id* tri2id,
- struct darray_triangle* triangles,
+ struct suniq* suniq,
const size_t ivolume)
{
struct sphin_volume* volume = NULL;
@@ -342,8 +267,7 @@ setup_interfaces_volume
res_T res = RES_OK;
ASSERT(NULL != sphor);
- ASSERT(NULL != tri2id);
- ASSERT(NULL != triangles);
+ ASSERT(NULL != suniq);
ASSERT(RES_OK == sphin_config_get_volume_count(sphor->config, &n));
ASSERT(ivolume < n);
@@ -355,7 +279,7 @@ setup_interfaces_volume
FOR_EACH(igeom, 0, n) {
res = setup_interfaces_volume_geometry
- (sphor, tri2id, triangles, ivolume, igeom);
+ (sphor, suniq, ivolume, igeom);
if (RES_OK != res) { goto error; }
}
exit:
@@ -370,15 +294,14 @@ error:
static res_T
setup_interface_surface_geometry_triangle
(struct sphor* sphor,
- struct htable_tri2id* tri2id,
- struct darray_triangle* triangles,
+ struct suniq* suniq,
const struct sphin_geometry_descriptor* geom_desc,
const size_t isurface,
const size_t itri)
{
- size_t itri_sphor = 0; /* Triangle index used internally by sphor */
- struct triangle tri = TRIANGLE_NULL;
- const struct triangle* tri_sphor = NULL;
+ size_t itri_suniq = 0; /* Triangle index used internally by suniq */
+ struct suniq_triangle tri = SUNIQ_TRIANGLE_NULL;
+ struct suniq_triangle tri_suniq = SUNIQ_TRIANGLE_NULL;
struct interface* interface = NULL;
int flip = 0;
short surf_count = 0;
@@ -386,18 +309,20 @@ setup_interface_surface_geometry_triangle
res_T res = RES_OK;
ASSERT(NULL != sphor);
- ASSERT(NULL != tri2id);
- ASSERT(NULL != triangles);
+ ASSERT(NULL != suniq);
ASSERT(NULL != geom_desc);
setup_triangle(geom_desc, itri, &tri);
- res = register_triangle(sphor, &tri, tri2id, triangles, &itri_sphor);
+ res = suniq_register_triangle(suniq, &tri, &itri_suniq);
if (RES_OK != res) { goto error; }
/* Retrieve the registered triangle and its properties */
- tri_sphor = darray_triangle_cdata_get(triangles) + itri_sphor;
- interface = darray_interface_data_get(&sphor->interfaces) + itri_sphor;
+ res = suniq_get_triangle(suniq, itri_suniq, &tri_suniq);
+ if (RES_OK != res) { goto error; }
+
+ res = register_interface(sphor, itri_suniq, &interface);
+ if (RES_OK != res) { goto error; }
/* Determine the side to append the surface based on whether the geometry is
* flipped and knowing the input side using the xor (^) operator.
@@ -413,9 +338,9 @@ setup_interface_surface_geometry_triangle
* | back | 1 | 1 | 0 |
* +------+-----+-----+-----+ */
- flip = are_triangles_reversed(&tri, tri_sphor);
+ flip = are_triangles_reversed(&tri, &tri_suniq);
- side = (size_t) flip ^ geom_desc->side;
+ side = (size_t)flip ^ geom_desc->side;
surf_count = interface->surface_count[side];
@@ -437,8 +362,7 @@ error:
static res_T
setup_interfaces_surface_geometry
(struct sphor* sphor,
- struct htable_tri2id* tri2id,
- struct darray_triangle* triangles,
+ struct suniq* suniq,
const size_t isurface,
const size_t igeom)
{
@@ -450,8 +374,7 @@ setup_interfaces_surface_geometry
res_T res = RES_OK;
ASSERT(NULL != sphor);
- ASSERT(NULL != tri2id);
- ASSERT(NULL != triangles);
+ ASSERT(NULL != suniq);
ASSERT(RES_OK == sphin_config_get_surface_count(sphor->config, &n));
ASSERT(isurface < n);
@@ -470,7 +393,7 @@ setup_interfaces_surface_geometry
n = geom_desc.mesh.triangle_count;
FOR_EACH(itri, 0, n) {
res = setup_interface_surface_geometry_triangle
- (sphor, tri2id, triangles, &geom_desc, isurface, itri);
+ (sphor, suniq, &geom_desc, isurface, itri);
if (RES_OK != res) { goto error; }
}
@@ -483,8 +406,7 @@ error:
static res_T
setup_interfaces_surface
(struct sphor* sphor,
- struct htable_tri2id* tri2id,
- struct darray_triangle* triangles,
+ struct suniq* suniq,
const size_t isurface)
{
struct sphin_surface* surface = NULL;
@@ -493,8 +415,7 @@ setup_interfaces_surface
res_T res = RES_OK;
ASSERT(NULL != sphor);
- ASSERT(NULL != tri2id);
- ASSERT(NULL != triangles);
+ ASSERT(NULL != suniq);
ASSERT(RES_OK == sphin_config_get_surface_count(sphor->config, &n));
ASSERT(isurface < n);
@@ -506,7 +427,7 @@ setup_interfaces_surface
FOR_EACH(igeom, 0, n) {
res = setup_interfaces_surface_geometry
- (sphor, tri2id, triangles, isurface, igeom);
+ (sphor, suniq, isurface, igeom);
if (RES_OK != res) { goto error; }
}
exit:
@@ -518,19 +439,15 @@ error:
static res_T
setup_interfaces
(struct sphor* sphor,
- struct htable_tri2id* tri2id,
- struct darray_triangle* triangles)
+ struct suniq* suniq)
{
size_t id = 0;
size_t volume_count = 0;
size_t surface_count = 0;
res_T res = RES_OK;
- (void) triangles;
-
ASSERT(NULL != sphor);
- ASSERT(NULL != tri2id);
- ASSERT(NULL != triangles);
+ ASSERT(NULL != suniq);
/* Assumes that config is already loaded */
ASSERT(NULL != sphor->config);
@@ -540,12 +457,12 @@ setup_interfaces
if (RES_OK != res) { goto error; }
FOR_EACH(id, 0, volume_count) {
- res = setup_interfaces_volume(sphor, tri2id, triangles, id);
+ res = setup_interfaces_volume(sphor, suniq, id);
if (RES_OK != res) { goto error; }
}
FOR_EACH(id, 0, surface_count) {
- res = setup_interfaces_surface(sphor, tri2id, triangles, id);
+ res = setup_interfaces_surface(sphor, suniq, id);
if (RES_OK != res) { goto error; }
}
@@ -562,17 +479,17 @@ get_triangle_indices
unsigned indices[3],
void* data)
{
- struct darray_triangle* triangles = data;
+ struct suniq_desc* desc = data;
+ size_t ids[3];
ASSERT(NULL != data);
ASSERT(NULL != indices);
- ASSERT(tri_id < darray_triangle_size_get(triangles));
- (void) triangles;
+ SUNIQ(desc_get_triangle_indices(desc, tri_id, ids));
- indices[0] = tri_id*3+0;
- indices[1] = tri_id*3+1;
- indices[2] = tri_id*3+2;
+ indices[0] = (unsigned)ids[0];
+ indices[1] = (unsigned)ids[1];
+ indices[2] = (unsigned)ids[2];
}
static void
@@ -581,32 +498,25 @@ get_vertex_coords
float coords[3],
void* data)
{
- struct darray_triangle* triangles = data;
- const struct triangle* tri = NULL;
- unsigned tri_id = vertex_id/3;
- unsigned tri_vertex_id = vertex_id%3;
- const double *vertices[3] = {NULL, NULL, NULL};
+ struct suniq_desc* desc = data;
+ double pos[3];
- ASSERT(NULL != coords);
ASSERT(NULL != data);
- ASSERT(tri_id < darray_triangle_size_get(triangles));
-
- tri = darray_triangle_cdata_get(triangles) + tri_id;
- vertices[0] = tri->v0;
- vertices[1] = tri->v1;
- vertices[2] = tri->v2;
- coords[0] = (float)vertices[tri_vertex_id][0];
- coords[1] = (float)vertices[tri_vertex_id][1];
- coords[2] = (float)vertices[tri_vertex_id][2];
+ ASSERT(NULL != coords);
+
+ SUNIQ(desc_get_vertex(desc, vertex_id, pos));
+
+ coords[0] = (float)pos[0];
+ coords[1] = (float)pos[1];
+ coords[2] = (float)pos[2];
}
static res_T
setup_geometry_accel_struct
(struct sphor* sphor,
- struct darray_triangle* triangles)
+ struct suniq* suniq)
{
- size_t triangle_count = 0;
- size_t vertex_count = 0;
+ struct suniq_desc desc = SUNIQ_DESC_NULL;
struct s3d_vertex_data vertex_data;
struct s3d_device* device = NULL;
struct s3d_scene* scene = NULL;
@@ -615,12 +525,12 @@ setup_geometry_accel_struct
res_T res = RES_OK;
ASSERT(NULL != sphor);
- ASSERT(NULL != triangles);
+ ASSERT(NULL != suniq);
- triangle_count = darray_triangle_size_get(triangles);
- vertex_count = triangle_count*3;
+ res = suniq_get_desc(suniq, &desc);
+ if (RES_OK != res) { goto error; }
- if (0 == triangle_count) {
+ if (0 == desc.ntriangles) {
ERROR(sphor,
"Could not start simulation: no geometries found in the input file.\n");
res = RES_BAD_ARG;
@@ -638,8 +548,8 @@ setup_geometry_accel_struct
vertex_data.type = S3D_FLOAT3;
vertex_data.get = get_vertex_coords;
res = s3d_mesh_setup_indexed_vertices
- (shape, (unsigned)triangle_count, get_triangle_indices,
- (unsigned)vertex_count, &vertex_data, 1, triangles);
+ (shape, (unsigned)desc.ntriangles, get_triangle_indices,
+ (unsigned)desc.nvertices, &vertex_data, 1, &desc);
if (RES_OK != res) { goto error; }
res = s3d_scene_create(device, &scene);
@@ -715,31 +625,30 @@ setup_config
(struct sphor* sphor,
const struct sphor_create_args* args)
{
- struct darray_triangle triangles;
- struct htable_tri2id tri2id;
+ struct suniq* suniq = NULL;
+
res_T res = RES_OK;
ASSERT(NULL != sphor);
ASSERT(NULL != args);
- darray_triangle_init(sphor->allocator, &triangles);
- htable_tri2id_init(sphor->allocator, &tri2id);
+ res = suniq_create(sphor->allocator, &suniq);
+ if (RES_OK != res) { goto error; }
/* Parse input file */
res = load_config(sphor, args);
if (RES_OK != res) { goto error; }
/* Attach physical properties to primitives */
- res = setup_interfaces(sphor, &tri2id, &triangles);
+ res = setup_interfaces(sphor, suniq);
if (RES_OK != res) { goto error; }
/* Build accelerating structure for geometrical data */
- res = setup_geometry_accel_struct(sphor, &triangles);
+ res = setup_geometry_accel_struct(sphor, suniq);
if (RES_OK != res) { goto error; }
exit:
- darray_triangle_release(&triangles);
- htable_tri2id_release(&tri2id);
+ if (NULL != suniq) { SUNIQ(ref_put(suniq)); }
return res;
error:
goto exit;
diff --git a/src/sphor_interface.h b/src/sphor_interface.h
@@ -42,8 +42,8 @@ struct interface {
};
#define INTERFACE_NULL__ { \
{INVALID_ID, INVALID_ID}, /* volumes */ \
- {{INVALID_ID}, {INVALID_ID}}, /* surfaces*/ \
- {0, 0} /* surface_count*/ \
+ {{INVALID_ID}, {INVALID_ID}}, /* surfaces */ \
+ {0, 0} /* surface_count */ \
}
static const struct interface INTERFACE_NULL = INTERFACE_NULL__;