star-3dut

Generate meshes of simple geometric shapes
git clone git://git.meso-star.fr/star-3dut.git
Log | Files | Refs | README | LICENSE

test_s3dut_super_shape.c (7121B)


      1 /* Copyright (C) 2016, 2017, 2020, 2021, 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 #include "s3dut.h"
     17 #include "test_s3dut_utils.h"
     18 
     19 int
     20 main(int argc, char** argv)
     21 {
     22   struct mem_allocator allocator;
     23   struct s3dut_mesh* msh;
     24   struct s3dut_mesh_data data;
     25   struct s3dut_super_formula f0, f1;
     26   (void)argc, (void)argv;
     27 
     28   CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK);
     29 
     30   f0.A = 1; f0.B = 1; f0.M = 5; f0.N0 = 1; f0.N1 = 1; f0.N2 = 2;
     31   f1.A = 1; f1.B = 1; f1.M = 5; f1.N0 = 1; f1.N1 = 1; f1.N2 = 3;
     32 
     33   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 0, 0, 0, NULL) == RES_BAD_ARG);
     34   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 0, 0, 0, NULL) == RES_BAD_ARG);
     35   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 0, 0, 0, NULL) == RES_BAD_ARG);
     36   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 0, 0, 0, NULL) == RES_BAD_ARG);
     37   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 1, 0, 0, NULL) == RES_BAD_ARG);
     38   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 1, 0, 0, NULL) == RES_BAD_ARG);
     39   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 1, 0, 0, NULL) == RES_BAD_ARG);
     40   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 1, 0, 0, NULL) == RES_BAD_ARG);
     41   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 0, 3, 0, NULL) == RES_BAD_ARG);
     42   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 0, 3, 0, NULL) == RES_BAD_ARG);
     43   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 0, 3, 0, NULL) == RES_BAD_ARG);
     44   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 0, 3, 0, NULL) == RES_BAD_ARG);
     45   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 1, 3, 0, NULL) == RES_BAD_ARG);
     46   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 1, 3, 0, NULL) == RES_BAD_ARG);
     47   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 1, 3, 0, NULL) == RES_BAD_ARG);
     48   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 1, 3, 0, NULL) == RES_BAD_ARG);
     49   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 0, 0, 2, NULL) == RES_BAD_ARG);
     50   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 0, 0, 2, NULL) == RES_BAD_ARG);
     51   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 0, 0, 2, NULL) == RES_BAD_ARG);
     52   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 0, 0, 2, NULL) == RES_BAD_ARG);
     53   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 1, 0, 2, NULL) == RES_BAD_ARG);
     54   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 1, 0, 2, NULL) == RES_BAD_ARG);
     55   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 1, 0, 2, NULL) == RES_BAD_ARG);
     56   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 1, 0, 2, NULL) == RES_BAD_ARG);
     57   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 0, 3, 2, NULL) == RES_BAD_ARG);
     58   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 0, 3, 2, NULL) == RES_BAD_ARG);
     59   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 0, 3, 2, NULL) == RES_BAD_ARG);
     60   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 0, 3, 2, NULL) == RES_BAD_ARG);
     61   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 1, 3, 2, NULL) == RES_BAD_ARG);
     62   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 1, 3, 2, NULL) == RES_BAD_ARG);
     63   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 1, 3, 2, NULL) == RES_BAD_ARG);
     64   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 1, 3, 2, NULL) == RES_BAD_ARG);
     65   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 0, 0, 0, &msh) == RES_BAD_ARG);
     66   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 0, 0, 0, &msh) == RES_BAD_ARG);
     67   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 0, 0, 0, &msh) == RES_BAD_ARG);
     68   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 0, 0, 0, &msh) == RES_BAD_ARG);
     69   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 1, 0, 0, &msh) == RES_BAD_ARG);
     70   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 1, 0, 0, &msh) == RES_BAD_ARG);
     71   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 1, 0, 0, &msh) == RES_BAD_ARG);
     72   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 1, 0, 0, &msh) == RES_BAD_ARG);
     73   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 0, 3, 0, &msh) == RES_BAD_ARG);
     74   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 0, 3, 0, &msh) == RES_BAD_ARG);
     75   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 0, 3, 0, &msh) == RES_BAD_ARG);
     76   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 0, 3, 0, &msh) == RES_BAD_ARG);
     77   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 1, 3, 0, &msh) == RES_BAD_ARG);
     78   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 1, 3, 0, &msh) == RES_BAD_ARG);
     79   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 1, 3, 0, &msh) == RES_BAD_ARG);
     80   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 1, 3, 0, &msh) == RES_BAD_ARG);
     81   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 0, 0, 2, &msh) == RES_BAD_ARG);
     82   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 0, 0, 2, &msh) == RES_BAD_ARG);
     83   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 0, 0, 2, &msh) == RES_BAD_ARG);
     84   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 0, 0, 2, &msh) == RES_BAD_ARG);
     85   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 1, 0, 2, &msh) == RES_BAD_ARG);
     86   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 1, 0, 2, &msh) == RES_BAD_ARG);
     87   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 1, 0, 2, &msh) == RES_BAD_ARG);
     88   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 1, 0, 2, &msh) == RES_BAD_ARG);
     89   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 0, 3, 2, &msh) == RES_BAD_ARG);
     90   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 0, 3, 2, &msh) == RES_BAD_ARG);
     91   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 0, 3, 2, &msh) == RES_BAD_ARG);
     92   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 0, 3, 2, &msh) == RES_BAD_ARG);
     93   CHK(s3dut_create_super_shape(NULL, NULL, NULL, 1, 3, 2, &msh) == RES_BAD_ARG);
     94   CHK(s3dut_create_super_shape(NULL, &f0, NULL, 1, 3, 2, &msh) == RES_BAD_ARG);
     95   CHK(s3dut_create_super_shape(NULL, NULL, &f1, 1, 3, 2, &msh) == RES_BAD_ARG);
     96   CHK(s3dut_create_super_shape(NULL, &f0, &f1, 1, 3, 2, &msh) == RES_OK);
     97   CHK(s3dut_mesh_ref_put(msh) == RES_OK);
     98 
     99   CHK(s3dut_create_super_shape(&allocator, &f0, &f1, 1, 3, 2, &msh) == RES_OK);
    100   CHK(s3dut_mesh_ref_put(msh) == RES_OK);
    101 
    102   CHK(s3dut_create_super_shape(&allocator, &f0, &f1, 1, 2, 2, &msh) == RES_BAD_ARG);
    103   CHK(s3dut_create_super_shape(&allocator, &f0, &f1, 1, 3, 1, &msh) == RES_BAD_ARG);
    104   CHK(s3dut_create_super_shape(&allocator, &f0, &f1,-1, 3, 1, &msh) == RES_BAD_ARG);
    105   CHK(s3dut_create_super_shape(&allocator, &f0, &f1, 1, 32, 16, &msh) == RES_OK);
    106 
    107   CHK(s3dut_mesh_get_data(msh, &data) == RES_OK);
    108   CHK(data.positions != NULL);
    109   CHK(data.indices != NULL);
    110 
    111   dump_mesh_data(stdout, &data);
    112 
    113   CHK(s3dut_mesh_ref_put(msh) == RES_OK);
    114 
    115   check_memory_allocator(&allocator);
    116   mem_shutdown_proxy_allocator(&allocator);
    117   CHK(mem_allocated_size() == 0);
    118   return 0;
    119 }