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_cuboid.c (2720B)


      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   (void)argc, (void)argv;
     26 
     27   CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK);
     28 
     29   CHK(s3dut_create_cuboid(NULL, 0, 0, 0, NULL) == RES_BAD_ARG);
     30   CHK(s3dut_create_cuboid(NULL, 1, 0, 0, NULL) == RES_BAD_ARG);
     31   CHK(s3dut_create_cuboid(NULL, 0, 1, 0, NULL) == RES_BAD_ARG);
     32   CHK(s3dut_create_cuboid(NULL, 1, 1, 0, NULL) == RES_BAD_ARG);
     33   CHK(s3dut_create_cuboid(NULL, 0, 0, 1, NULL) == RES_BAD_ARG);
     34   CHK(s3dut_create_cuboid(NULL, 1, 0, 1, NULL) == RES_BAD_ARG);
     35   CHK(s3dut_create_cuboid(NULL, 0, 1, 1, NULL) == RES_BAD_ARG);
     36   CHK(s3dut_create_cuboid(NULL, 1, 1, 1, NULL) == RES_BAD_ARG);
     37   CHK(s3dut_create_cuboid(NULL, 0, 0, 0, &msh) == RES_BAD_ARG);
     38   CHK(s3dut_create_cuboid(NULL, 1, 0, 0, &msh) == RES_BAD_ARG);
     39   CHK(s3dut_create_cuboid(NULL, 0, 1, 0, &msh) == RES_BAD_ARG);
     40   CHK(s3dut_create_cuboid(NULL, 1, 1, 0, &msh) == RES_BAD_ARG);
     41   CHK(s3dut_create_cuboid(NULL, 0, 0, 1, &msh) == RES_BAD_ARG);
     42   CHK(s3dut_create_cuboid(NULL, 1, 0, 1, &msh) == RES_BAD_ARG);
     43   CHK(s3dut_create_cuboid(NULL, 0, 1, 1, &msh) == RES_BAD_ARG);
     44   CHK(s3dut_create_cuboid(NULL, 1, 1, 1, &msh) == RES_OK);
     45 
     46   CHK(s3dut_mesh_ref_put(msh) == RES_OK);
     47 
     48   CHK(s3dut_create_cuboid(&allocator, 1, 1, 2, &msh) == RES_OK);
     49   CHK(s3dut_mesh_ref_put(msh) == RES_OK);
     50 
     51   CHK(s3dut_create_cuboid(&allocator,-1, 1, 2, &msh) == RES_BAD_ARG);
     52   CHK(s3dut_create_cuboid(&allocator, 1,-1, 2, &msh) == RES_BAD_ARG);
     53   CHK(s3dut_create_cuboid(&allocator, 1, 1,-2, &msh) == RES_BAD_ARG);
     54   CHK(s3dut_create_cuboid(&allocator, 1, 1, 2, &msh) == RES_OK);
     55 
     56   CHK(s3dut_mesh_get_data(msh, &data) == RES_OK);
     57   dump_mesh_data(stdout, &data);
     58   CHK(s3dut_mesh_ref_put(msh) == RES_OK);
     59 
     60   check_memory_allocator(&allocator);
     61   mem_shutdown_proxy_allocator(&allocator);
     62   CHK(mem_allocated_size() == 0);
     63   return 0;
     64 }
     65