solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

solparser_material.h (3815B)


      1 /* Copyright (C) 2018-2026 |Meso|Star> (contact@meso-star.com)
      2  * Copyright (C) 2016-2018 CNRS
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU General Public License as published by
      6  * the Free Software Foundation, either version 3 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     12  * GNU General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU General Public License
     15  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     16 
     17 #ifndef SOLPARSER_MATERIAL_H
     18 #define SOLPARSER_MATERIAL_H
     19 
     20 #include "solparser_image.h"
     21 #include "solparser_medium.h"
     22 #include <stddef.h>
     23 
     24 enum solparser_material_type {
     25   SOLPARSER_MATERIAL_DIELECTRIC,
     26   SOLPARSER_MATERIAL_MATTE,
     27   SOLPARSER_MATERIAL_MIRROR,
     28   SOLPARSER_MATERIAL_THIN_DIELECTRIC,
     29   SOLPARSER_MATERIAL_VIRTUAL
     30 };
     31 
     32 enum solparser_microfacet_distribution {
     33   SOLPARSER_MICROFACET_BECKMANN,
     34   SOLPARSER_MICROFACET_PILLBOX
     35 };
     36 
     37 struct solparser_material_dielectric {
     38   struct solparser_medium_id medium_i; /* Medium the material "looks at" */
     39   struct solparser_medium_id medium_t; /* Opposite medium */
     40   struct solparser_image_id normal_map;
     41 };
     42 struct solparser_material_dielectric_id { size_t i; };
     43 
     44 static INLINE void
     45 solparser_material_dielectric_init
     46   (struct mem_allocator* allocator,
     47    struct solparser_material_dielectric* dielectric)
     48 {
     49   ASSERT(dielectric);
     50   (void)allocator;
     51   dielectric->normal_map.i = SIZE_MAX;
     52 }
     53 
     54 struct solparser_material_matte {
     55   struct solparser_mtl_data reflectivity; /* In [0, 1] */
     56   struct solparser_image_id normal_map;
     57 };
     58 
     59 struct solparser_material_matte_id { size_t i; };
     60 
     61 static INLINE void
     62 solparser_material_matte_init
     63   (struct mem_allocator* allocator,
     64    struct solparser_material_matte* matte)
     65 {
     66   ASSERT(matte);
     67   (void)allocator;
     68   matte->normal_map.i = SIZE_MAX;
     69 }
     70 
     71 struct solparser_material_mirror {
     72   struct solparser_mtl_data slope_error; /* In [0, 1] */
     73   struct solparser_mtl_data reflectivity; /* In [0, 1] */
     74   enum solparser_microfacet_distribution ufacet_distrib;
     75   struct solparser_image_id normal_map;
     76 };
     77 
     78 struct solparser_material_mirror_id { size_t i; };
     79 
     80 static INLINE void
     81 solparser_material_mirror_init
     82   (struct mem_allocator* allocator,
     83    struct solparser_material_mirror* mirror)
     84 {
     85   ASSERT(mirror);
     86   (void)allocator;
     87   mirror->slope_error.type = SOLPARSER_MTL_DATA_REAL;
     88   mirror->slope_error.value.real = 0;
     89   mirror->ufacet_distrib = SOLPARSER_MICROFACET_BECKMANN;
     90   mirror->normal_map.i = SIZE_MAX;
     91 }
     92 
     93 struct solparser_material_thin_dielectric {
     94   struct solparser_medium_id medium_i; /* Outside medium */
     95   struct solparser_medium_id medium_t; /* Medium of the slab */
     96   struct solparser_image_id normal_map;
     97   double thickness;
     98 };
     99 
    100 struct solparser_material_thin_dielectric_id { size_t i; };
    101 
    102 static INLINE void
    103 solparser_material_thin_dielectric_init
    104   (struct mem_allocator* allocator,
    105    struct solparser_material_thin_dielectric* thin)
    106 {
    107   ASSERT(thin);
    108   (void)allocator;
    109   thin->normal_map.i = SIZE_MAX;
    110 }
    111 
    112 struct solparser_material {
    113   enum solparser_material_type type;
    114   union {
    115     struct solparser_material_dielectric_id dielectric;
    116     struct solparser_material_matte_id matte;
    117     struct solparser_material_mirror_id mirror;
    118     struct solparser_material_thin_dielectric_id thin_dielectric;
    119   } data;
    120 };
    121 
    122 struct solparser_material_id { size_t i; };
    123 
    124 struct solparser_material_double_sided {
    125   struct solparser_material_id front;
    126   struct solparser_material_id back;
    127 };
    128 
    129 struct solparser_material_double_sided_id { size_t i; };
    130 
    131 #endif /* SOLPARSER_MATERIAL_H */