Skip to content

Commit

Permalink
feat: add C binding for Manifold::NumProp() (#1078)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NickUfer authored Nov 27, 2024
1 parent f8c9dc9 commit ddc0a18
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions bindings/c/include/manifold/manifoldc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions bindings/c/manifoldc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions test/manifoldc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ddc0a18

Please sign in to comment.