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_truncated_sphere.c (2085B)


      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 #include <rsys/double3.h>
     20 #include <rsys/math.h>
     21 
     22 int
     23 main(int argc, char** argv)
     24 {
     25   struct mem_allocator allocator;
     26   struct s3dut_mesh* msh;
     27   struct s3dut_mesh_data data;
     28   double z_range[2];
     29   (void)argc, (void)argv;
     30 
     31   CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK);
     32 
     33   #define CR_TS s3dut_create_truncated_sphere
     34   z_range[0] = z_range[1] = 0;
     35   CHK(CR_TS(NULL, 1, 16, 8, z_range, 0, &msh) == RES_BAD_ARG);
     36   z_range[1] = -0.5;
     37   CHK(CR_TS(NULL, 1, 16, 8, z_range, 0, &msh) == RES_BAD_ARG);
     38   z_range[1] = +0.5;
     39   CHK(CR_TS(NULL, 1, 16, 8, z_range, 0, &msh) == RES_OK);
     40   CHK(s3dut_mesh_ref_put(msh) == RES_OK);
     41   CHK(CR_TS(NULL, 1, 16, 8, NULL, 0, &msh) == RES_OK);
     42   CHK(s3dut_mesh_ref_put(msh) == RES_OK);
     43 
     44   CHK(CR_TS(&allocator, 1, 16, 8, NULL, 0, &msh) == RES_OK);
     45   CHK(s3dut_mesh_ref_put(msh) == RES_OK);
     46 
     47   z_range[0] = 0;
     48   z_range[1] = 0.9;
     49   CHK(CR_TS(&allocator, 1, 16, 8, z_range, S3DUT_CAP_NEG_Z, &msh) == RES_OK);
     50 
     51   CHK(s3dut_mesh_get_data(msh, &data) == RES_OK);
     52   CHK(data.positions != NULL);
     53   CHK(data.indices != NULL);
     54   #undef CR_TS
     55 
     56   dump_mesh_data(stdout, &data);
     57 
     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