commit ae716781ad0038c3a52e925d81a53e282a19c666
parent de40c5cf8fc7cb68c1d6f8a62df9da8a18220fad
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Fri, 25 Sep 2020 12:28:00 +0200
Add a new test
Diffstat:
2 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -150,6 +150,7 @@ if(NOT NO_TEST)
build_test(test_sg3d_cube_in_cube)
build_test(test_sg3d_cube_on_cube)
build_test(test_sg3d_invalid_models)
+ build_test(test_sg3d_multi_media)
build_test(test_sg3d_some_enclosures test_sg3d_utils2.h)
build_test(test_sg3d_some_triangles test_sg3d_utils2.h)
build_test(test_sg3d_unspecified_properties)
@@ -170,6 +171,7 @@ if(NOT NO_TEST)
rcmake_copy_runtime_libraries(test_sg3d_cube_in_cube)
rcmake_copy_runtime_libraries(test_sg3d_cube_on_cube)
rcmake_copy_runtime_libraries(test_sg3d_invalid_models)
+ rcmake_copy_runtime_libraries(test_sg3d_multi_media)
rcmake_copy_runtime_libraries(test_sg3d_some_enclosures)
rcmake_copy_runtime_libraries(test_sg3d_some_triangles)
rcmake_copy_runtime_libraries(test_sg3d_unspecified_properties)
@@ -182,6 +184,7 @@ if(NOT NO_TEST)
add_test(test_sg3d_cube_in_cube test_sg3d_cube_in_cube)
add_test(test_sg3d_cube_on_cube test_sg3d_cube_on_cube)
add_test(test_sg3d_invalid_models test_sg3d_invalid_models)
+ add_test(test_sg3d_multi_media test_sg3d_multi_media)
add_test(test_sg3d_some_enclosures test_sg3d_some_enclosures)
add_test(test_sg3d_some_triangles test_sg3d_some_triangles)
add_test(test_sg3d_unspecified_properties test_sg3d_unspecified_properties)
diff --git a/src/test_sg3d_multi_media.c b/src/test_sg3d_multi_media.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 2019-2020 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "sg3d.h"
+#include "test_sg3d_utils.h"
+
+#include <rsys/double3.h>
+
+#include <stdio.h>
+
+static const unsigned multi_media[12] = { 4, 4, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1 };
+static const unsigned multi_intface[12] = { 4, 4, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1 };
+
+int
+main(int argc, char** argv)
+{
+ struct mem_allocator allocator;
+ struct sg3d_device* dev;
+ struct sg3d_geometry* geom;
+ struct context ctx = CONTEXT_NULL__;
+ struct sg3d_geometry_add_callbacks callbacks = SG3D_ADD_CALLBACKS_NULL__;
+ unsigned count;
+ (void)argc, (void)argv;
+
+ OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
+ OK(sg3d_device_create(NULL, &allocator, 1, &dev));
+ OK(sg3d_geometry_create(dev, &geom));
+ SG3D(device_ref_put(dev));
+
+ callbacks.get_indices = get_indices;
+ callbacks.get_properties = get_properties;
+ callbacks.get_position = get_position;
+
+ ctx.positions = cube_vertices;
+ ctx.indices = cube_indices;
+ ctx.front_media = medium0;
+ ctx.back_media = multi_media;
+ ctx.intface = multi_intface;
+
+ OK(sg3d_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx));
+
+ OK(sg3d_geometry_get_unique_triangles_with_merge_conflict_count(geom, &count));
+ CHK(count == 0);
+ OK(sg3d_geometry_get_unique_triangles_with_unspecified_interface_count(geom, &count));
+ CHK(count == 0);
+ OK(sg3d_geometry_get_unique_triangles_with_unspecified_side_count(geom, &count));
+ CHK(count == 0);
+ OK(sg3d_geometry_dump_as_c_code(geom, stdout, "multi_media",
+ SG3D_C_DUMP_CONST | SG3D_C_DUMP_STATIC));
+
+ OK(sg3d_geometry_dump_as_vtk(geom, stdout));
+
+ SG3D(geometry_ref_put(geom));
+
+ check_memory_allocator(&allocator);
+ mem_shutdown_proxy_allocator(&allocator);
+ CHK(mem_allocated_size() == 0);
+ return 0;
+}
+\ No newline at end of file