star-uniq

Filter out repeated triangles
git clone git://git.meso-star.fr/star-uniq.git
Log | Files | Refs | README | LICENSE

suniq.h (2896B)


      1 /* Copyright (C) 2025 |Méso|Star> (contact@meso-star.com)
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 3 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     11  * GNU Lesser General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU Lesser General Public License
     14  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     15 
     16 #ifndef SUNIQ_H
     17 #define SUNIQ_H
     18 
     19 #include <rsys/rsys.h>
     20 
     21 /* Library symbol management */
     22 #if defined(SUNIQ_SHARED_BUILD)
     23   #define SUNIQ_API extern EXPORT_SYM
     24 #else
     25   #define SUNIQ_API extern IMPORT_SYM
     26 #endif
     27 
     28 /* Help macro which, in debug mode, stops execution when API functions fail
     29  * To be used when calling functions for which there is no error handling */
     30 #ifndef NDEBUG
     31   #define SUNIQ(Func) ASSERT(suniq_ ## Func == RES_OK)
     32 #else
     33   #define SUNIQ(Func) suniq_ ## Func
     34 #endif
     35 
     36 /* Forward declaration of opaque data types */
     37 struct logger;
     38 struct mem_allocator;
     39 
     40 struct suniq_triangle {
     41   double vertices[3][3];
     42 };
     43 #define SUNIQ_TRIANGLE_NULL__ {{{0,0,0},{0,0,0},{0,0,0}}}
     44 static const struct suniq_triangle SUNIQ_TRIANGLE_NULL = SUNIQ_TRIANGLE_NULL__;
     45 
     46 struct suniq_desc {
     47   const size_t* indices;
     48   const double* positions;
     49   size_t ntriangles;
     50   size_t nvertices;
     51 };
     52 #define SUNIQ_DESC_NULL__ {NULL,NULL,0,0}
     53 static const struct suniq_desc SUNIQ_DESC_NULL = SUNIQ_DESC_NULL__;
     54 
     55 /* Forward declaration of opaque data types */
     56 struct suniq;
     57 
     58 BEGIN_DECLS
     59 
     60 SUNIQ_API res_T
     61 suniq_create
     62   (struct mem_allocator* allocator, /* NULL <=> use default allocator */
     63    struct suniq** suniq);
     64 
     65 SUNIQ_API res_T
     66 suniq_ref_get
     67   (struct suniq* suniq);
     68 
     69 SUNIQ_API res_T
     70 suniq_ref_put
     71   (struct suniq* suniq);
     72 
     73 SUNIQ_API res_T
     74 suniq_register_triangle
     75   (struct suniq* suniq,
     76    const struct suniq_triangle* triangle,
     77    size_t* id); /* NULL <=> do not return the triangle identifier */
     78 
     79 SUNIQ_API res_T
     80 suniq_get_triangle
     81   (const struct suniq* suniq,
     82    const size_t id,
     83    struct suniq_triangle* triangle);
     84 
     85 SUNIQ_API res_T
     86 suniq_get_desc
     87   (const struct suniq* suniq,
     88    struct suniq_desc* desc);
     89 
     90 SUNIQ_API res_T
     91 suniq_desc_get_vertex
     92   (const struct suniq_desc* desc,
     93    const size_t ivertex,
     94    double vertex[3]);
     95 
     96 SUNIQ_API res_T
     97 suniq_desc_get_triangle_indices
     98   (const struct suniq_desc* desc,
     99    const size_t itriangle,
    100    size_t indices[3]);
    101 
    102 SUNIQ_API res_T
    103 suniq_desc_get_triangle
    104   (const struct suniq_desc* desc,
    105    const size_t itriangle,
    106    struct suniq_triangle* triangle);
    107 
    108 SUNIQ_API res_T
    109 suniq_clear
    110   (struct suniq* suniq);
    111 
    112 END_DECLS
    113 
    114 #endif /* SUNIQ_H */