From ddc0a18d87f9da40781bd160fc4122d113877ec9 Mon Sep 17 00:00:00 2001 From: Nick Ufer Date: Wed, 27 Nov 2024 20:26:22 +0100 Subject: [PATCH] feat: add C binding for Manifold::NumProp() (#1078) Introduced a new function to the C bindings: `manifold_num_prop`. This function retrieves the number of properties associated with a Manifold object. Added corresponding tests to validate its integration. --- bindings/c/include/manifold/manifoldc.h | 1 + bindings/c/manifoldc.cpp | 1 + test/manifoldc_test.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/bindings/c/include/manifold/manifoldc.h b/bindings/c/include/manifold/manifoldc.h index ce66f20cd..054f353a9 100644 --- a/bindings/c/include/manifold/manifoldc.h +++ b/bindings/c/include/manifold/manifoldc.h @@ -195,6 +195,7 @@ ManifoldError manifold_status(ManifoldManifold *m); size_t manifold_num_vert(ManifoldManifold *m); size_t manifold_num_edge(ManifoldManifold *m); size_t manifold_num_tri(ManifoldManifold *m); +size_t manifold_num_prop(ManifoldManifold *m); ManifoldBox *manifold_bounding_box(void *mem, ManifoldManifold *m); double manifold_epsilon(ManifoldManifold *m); int manifold_genus(ManifoldManifold *m); diff --git a/bindings/c/manifoldc.cpp b/bindings/c/manifoldc.cpp index ec0f1786e..d4dbe3bff 100644 --- a/bindings/c/manifoldc.cpp +++ b/bindings/c/manifoldc.cpp @@ -633,6 +633,7 @@ ManifoldError manifold_status(ManifoldManifold *m) { size_t manifold_num_vert(ManifoldManifold *m) { return from_c(m)->NumVert(); } size_t manifold_num_edge(ManifoldManifold *m) { return from_c(m)->NumEdge(); } size_t manifold_num_tri(ManifoldManifold *m) { return from_c(m)->NumTri(); } +size_t manifold_num_prop(ManifoldManifold *m) { return from_c(m)->NumProp(); }; int manifold_genus(ManifoldManifold *m) { return from_c(m)->Genus(); } double manifold_surface_area(ManifoldManifold *m) { diff --git a/test/manifoldc_test.cpp b/test/manifoldc_test.cpp index 608fff1f1..32b6e5e2c 100644 --- a/test/manifoldc_test.cpp +++ b/test/manifoldc_test.cpp @@ -294,10 +294,15 @@ TEST(CBIND, properties) { ManifoldManifold *cube = manifold_cube(alloc_manifold_buffer(), 1.0, 1.0, 1.0, 1); + EXPECT_EQ(manifold_num_prop(cube), 0); + ManifoldManifold *cube_props = manifold_set_properties(alloc_manifold_buffer(), cube, 1, props, NULL); + EXPECT_EQ(manifold_num_prop(cube_props), 1); + ManifoldManifold *cube_props_context = manifold_set_properties( alloc_manifold_buffer(), cube, 1, propscontext, context); + EXPECT_EQ(manifold_num_prop(cube_props_context), 1); manifold_destruct_manifold(cube); manifold_destruct_manifold(cube_props);