city_generator2

Generated conformal 3D meshes representing a city
git clone git://git.meso-star.fr/city_generator2.git
Log | Files | Refs | README | LICENSE

cg_construction_mode_1_parsing_schemas.h (5071B)


      1 /* Copyright (C) 2022 Université de Pau et des Pays de l'Adour UPPA
      2  * Copyright (C) 2022 CNRS
      3  * Copyright (C) 2022 Sorbonne Université
      4  * Copyright (C) 2022 Université Paul Sabatier
      5  * Copyright (C) 2022 |Meso|Star> (contact@meso-star.com)
      6  *
      7  * This program is free software: you can redistribute it and/or modify
      8  * it under the terms of the GNU General Public License as published by
      9  * the Free Software Foundation, either version 3 of the License, or
     10  * (at your option) any later version.
     11  *
     12  * This program is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     15  * GNU General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU General Public License
     18  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     19 
     20 #ifndef FG_MODE1_PARSING_SCHEMAS__
     21 #define FG_MODE1_PARSING_SCHEMAS__
     22 
     23 #include "cg_cyaml.h"
     24 
     25 #include <rsys/str.h>
     26 
     27 struct parsed_dataset_cmode_1 {
     28   char* name;
     29   size_t inter_floor_count; /* can be 0 */
     30   double wall_thickness; /* must be > 0 */
     31   double floor_thickness; /* must be > 0 */
     32   double inter_floor_thickness; /* must be > 0 */
     33   double roof_thickness; /* must be > 0 */
     34   double internal_insulation_thickness; /* can be 0 */
     35   double external_insulation_thickness; /* can be 0 */
     36   double floor_insulation_thickness; /* can be 0 */
     37   double roof_insulation_thickness; /* can be 0 */
     38   double foundation_depth; /* can be 0 */
     39   double crawl_height; /* can be 0 */
     40   double attic_height; /* can be 0 */
     41   double glass_ratio; /* in [0, 1] */
     42 };
     43 
     44 /********************************************************/
     45 /* Types used for parsing and to define parsing schemas */
     46 /********************************************************/
     47 
     48 struct parsed_catalog_cmode_1 {
     49   struct parsed_dataset_cmode_1* datasets;
     50   size_t datasets_count;
     51 };
     52 
     53 static const cyaml_schema_field_t dataset_cmode_1_fields_schema[] = {
     54   CYAML_FIELD_STRING_PTR("name", CYAML_FLAG_POINTER,
     55       struct parsed_dataset_cmode_1, name, 0, CYAML_UNLIMITED),
     56   CYAML_FIELD_INT("inter_floor_count", CYAML_FLAG_DEFAULT,
     57       struct parsed_dataset_cmode_1, inter_floor_count),
     58   CYAML_FIELD_FLOAT("wall_thickness", CYAML_FLAG_DEFAULT,
     59       struct parsed_dataset_cmode_1, wall_thickness),
     60   CYAML_FIELD_FLOAT("floor_thickness", CYAML_FLAG_DEFAULT,
     61       struct parsed_dataset_cmode_1, floor_thickness),
     62   CYAML_FIELD_FLOAT("inter_floor_thickness", CYAML_FLAG_DEFAULT,
     63       struct parsed_dataset_cmode_1, inter_floor_thickness),
     64   CYAML_FIELD_FLOAT("roof_thickness", CYAML_FLAG_DEFAULT,
     65       struct parsed_dataset_cmode_1, roof_thickness),
     66   CYAML_FIELD_FLOAT("internal_insulation_thickness", CYAML_FLAG_DEFAULT,
     67       struct parsed_dataset_cmode_1, internal_insulation_thickness),
     68   CYAML_FIELD_FLOAT("external_insulation_thickness", CYAML_FLAG_DEFAULT,
     69       struct parsed_dataset_cmode_1, external_insulation_thickness),
     70   CYAML_FIELD_FLOAT("floor_insulation_thickness", CYAML_FLAG_DEFAULT,
     71       struct parsed_dataset_cmode_1, floor_insulation_thickness),
     72   CYAML_FIELD_FLOAT("roof_insulation_thickness", CYAML_FLAG_DEFAULT,
     73       struct parsed_dataset_cmode_1, roof_insulation_thickness),
     74   CYAML_FIELD_FLOAT("foundation_depth", CYAML_FLAG_DEFAULT,
     75       struct parsed_dataset_cmode_1, foundation_depth),
     76   CYAML_FIELD_FLOAT("crawl_height", CYAML_FLAG_DEFAULT,
     77       struct parsed_dataset_cmode_1, crawl_height),
     78   CYAML_FIELD_FLOAT("attic_height", CYAML_FLAG_DEFAULT,
     79       struct parsed_dataset_cmode_1, attic_height),
     80   CYAML_FIELD_FLOAT("glass_ratio", CYAML_FLAG_DEFAULT,
     81       struct parsed_dataset_cmode_1, glass_ratio),
     82   CYAML_FIELD_END
     83 };
     84 
     85 static const struct cyaml_schema_value p_dataset_cmode_1_schema = {
     86   CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, struct parsed_dataset_cmode_1,
     87       dataset_cmode_1_fields_schema),
     88 };
     89 
     90 static const struct cyaml_schema_value dataset_cmode_1_schema = {
     91   CYAML_VALUE_MAPPING(CYAML_FLAG_DEFAULT, struct parsed_dataset_cmode_1,
     92       dataset_cmode_1_fields_schema),
     93 };
     94 
     95 static const cyaml_schema_field_t cmode_1_fields_schemas[] = {
     96   CYAML_FIELD_IGNORE("construction_mode", CYAML_FLAG_DEFAULT),
     97   {
     98     .key = "datasets",
     99     .value = {
    100       .type = CYAML_SEQUENCE,
    101       .flags = CYAML_FLAG_POINTER,
    102       .data_size = sizeof(struct parsed_dataset_cmode_1),
    103       .sequence = {
    104         .entry = &dataset_cmode_1_schema,
    105         .min = 1,
    106         .max = CYAML_UNLIMITED,
    107       }
    108     },
    109     .data_offset = offsetof(struct parsed_catalog_cmode_1, datasets),
    110     .count_size = sizeof(((struct parsed_catalog_cmode_1*)0)->datasets_count),
    111     .count_offset = offsetof(struct parsed_catalog_cmode_1, datasets_count),
    112   },
    113   CYAML_FIELD_END
    114 };
    115 
    116 /* Top-level schema. The top level value for the construction mode is a mapping.
    117  * Its fields are defined in cmode_1_fields_schemas.
    118  */
    119 static const cyaml_schema_value_t construction_mode_1_schema = {
    120   CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, struct parsed_catalog_cmode_1,
    121       cmode_1_fields_schemas),
    122 };
    123 
    124 #endif