star-geometry-2d

Cleaning and decorating 2D geometries
git clone git://git.meso-star.fr/star-geometry-2d.git
Log | Files | Refs | README | LICENSE

sg2d_sencXd_helper.h (2357B)


      1 /* Copyright (C) 2019, 2020, 2023 |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 General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     15 
     16 #ifndef SG2D_SENC2D_HELPER_H__
     17 #define SG2D_SENC2D_HELPER_H__
     18 
     19 #include "sg2d.h"
     20 #include <star/senc2d.h>
     21 
     22 #include <rsys/rsys.h>
     23 
     24  /* Get vertex indices for the iseg_th segment.
     25   * Suitable for use as get_indices callback in senc2d_scene_create calls. */
     26 static FINLINE void
     27 sg2d_sencXd_geometry_get_indices
     28   (const size_t iseg,
     29    size_t indices[SG2D_GEOMETRY_DIMENSION],
     30    void* ctx)
     31 {
     32   const struct sg2d_geometry* geometry = ctx;
     33   ASSERT(indices && geometry);
     34   SG2D(geometry_get_unique_segment_vertices(geometry, iseg, indices));
     35 }
     36 
     37 /* Get vertex indices for the iseg_th segment.
     38  * Suitable for use as get_media callback in senc2d_scene_create calls. */
     39 static FINLINE void
     40 sg2d_sencXd_geometry_get_media
     41   (const size_t iseg,
     42    size_t media[2],
     43    void* ctx)
     44 {
     45   const struct sg2d_geometry* geometry = ctx;
     46   size_t tmp[SG2D_PROP_TYPES_COUNT__];
     47   ASSERT(media && geometry);
     48   SG2D(geometry_get_unique_segment_properties(geometry, iseg, tmp));
     49   media[SENC2D_FRONT] = (tmp[SG2D_FRONT] == SG2D_UNSPECIFIED_PROPERTY)
     50     ? SENC2D_UNSPECIFIED_MEDIUM : tmp[SG2D_FRONT];
     51   media[SENC2D_BACK] = (tmp[SG2D_BACK] == SG2D_UNSPECIFIED_PROPERTY)
     52     ? SENC2D_UNSPECIFIED_MEDIUM : tmp[SG2D_BACK];
     53 }
     54 
     55 /* Get vertex indices for the iseg_th segment.
     56  * Suitable for use as get_position callback in senc2d_scene_create calls. */
     57 static FINLINE void
     58 sg2d_sencXd_geometry_get_position
     59   (const size_t ivert,
     60    double coord[SG2D_GEOMETRY_DIMENSION],
     61    void* ctx)
     62 {
     63   const struct sg2d_geometry* geometry = ctx;
     64   ASSERT(coord && geometry);
     65   SG2D(geometry_get_unique_vertex(geometry, ivert, coord));
     66 }
     67 
     68 #endif /* SG2D_SENC2D_HELPER_H__ */