star-uvm

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

commit e4deda46c7500bf82249c0513d7b69e0fd63b0e2
parent 5f67824ce5520102ad2e852120b6eb6b4f6c0e92
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 18 Sep 2020 16:57:22 +0200

First draft of the public API

Diffstat:
Asrc/suvm.h | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 123 insertions(+), 0 deletions(-)

diff --git a/src/suvm.h b/src/suvm.h @@ -0,0 +1,123 @@ +/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef SUVM_H +#define SUVM_H + +#include <rsys/rsys.h> + +/* Library symbol management */ +#if defined(SUVM_SHARED_BUILD) /* Build shared library */ + #define SUVM_API extern EXPORT_SYM +#elif defined(SUVM_STATIC) /* Use/build static library */ + #define SUVM_API extern LOCAL_SYM +#else /* Use shared library */ + #define SUVM_API extern IMPORT_SYM +#endif + +/* Helper macro that asserts if the invocation of the suvm function `Func' + * returns an error. One should use this macro on suvm function calls for + * which no explicit error checking is performed */ +#ifndef NDEBUG + #define SUVM(Func) ASSERT(suvm_ ## Func == RES_OK) +#else + #define SUVM(Func) suvm_ ## Func +#endif + +/* Maximum number of vertices per volumetric primitive */ +#define SUVM_PRIMITIVE_MAX_VERTICES_COUNT 4 + +struct suvm_data { + void (*get)(const size_t id, void* data, void* ctx); /* Data getter */ + size_t size; /* Size of the data in bytes */ + size_t alignment; /* Alignment of the data */ +}; +static const struct suvm_data 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 iprim; /* Identifier of the primitive */ + size_t nvertices; /* #vertices of the primitive */ +}; + +/* Forward declaration of external data types */ +struct logger; +struct mem_allocator; + +/* Forwar declaration of opaque data types */ +struct suvm_device; +struct suvm_volume; + +BEGIN_DECLS + +/******************************************************************************* + * Device API + ******************************************************************************/ +SUVM_API res_T +suvm_device_create + (struct logger* logger, /* NULL <=> use default logger */ + struct mem_allocator* allocator, /* NULL <=> use default allocator */ + const int verbose, /* Verbosity */ + struct suvm_device** suvm); + +SUVM_API res_T +suvm_device_ref_get + (struct suvm_device* dev); + +SUVM_API res_T +suvm_device_ref_put + (struct suvm_device* dev); + +/******************************************************************************* + * Volume mesh API + ******************************************************************************/ +SUVM_API res_T +suvm_tetrahedral_mesh_create + (struct suvm_device* dev, + const size_t ntethras, /* #tetrahedrals */ + void (*get_indices)(const size_t itetha, size_t ids[4], void* ctx), + const struct suvm_data* tetra_data, /* NULL <=> no tetra data */ + const size_t nverts, /* #vertices */ + void (*get_position)(const size_t ivert, const double pos[3], void* ctx), + const struct suvm_data* vert_data, /* NULL <=> no vertex data */ + void* context, /* Client data set as the last param of the callbacks */ + struct suvm_volume** volume); + +SUVM_API res_T +suvm_volume_ref_get + (struct suvm_volume* volume); + +SUVM_API res_T +suvm_volume_ref_put + (struct suvm_volume* volume); + +SUVM_API res_T +suvm_volume_get_aabb + (struct suvm_volume* volume, + double lower[3], + double upper[3]); + +SUVM_API res_T +suvm_volume_at + (struct suvm_volume* volume, + const double pos[3], + struct suvm_primitive* prim, /* Geometric primitive where `pos' lies */ + double uvw[3]); /* Parametric coordinate of `pos' into the primitive */ + +END_DECLS + +#endif /* SUVM_H */ +