Skip to content

Commit

Permalink
refactor(1089): update index types from int to size_t
Browse files Browse the repository at this point in the history
refactor(1089): change NumProp getter type to int
  • Loading branch information
NickUfer committed Dec 3, 2024
1 parent fb29e85 commit af68c57
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions bindings/c/cross.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ size_t manifold_cross_section_vec_length(ManifoldCrossSectionVec *csv) {
}

ManifoldCrossSection *manifold_cross_section_vec_get(
void *mem, ManifoldCrossSectionVec *csv, int idx) {
void *mem, ManifoldCrossSectionVec *csv, size_t idx) {
auto cs = (*from_c(csv))[idx];
return to_c(new (mem) CrossSection(cs));
}

void manifold_cross_section_vec_set(ManifoldCrossSectionVec *csv, int idx,
void manifold_cross_section_vec_set(ManifoldCrossSectionVec *csv, size_t idx,
ManifoldCrossSection *cs) {
(*from_c(csv))[idx] = *from_c(cs);
}
Expand Down
20 changes: 10 additions & 10 deletions bindings/c/include/manifold/manifoldc.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ ManifoldPolygons *manifold_polygons(void *mem, ManifoldSimplePolygon **ps,
size_t length);
size_t manifold_simple_polygon_length(ManifoldSimplePolygon *p);
size_t manifold_polygons_length(ManifoldPolygons *ps);
size_t manifold_polygons_simple_length(ManifoldPolygons *ps, int idx);
size_t manifold_polygons_simple_length(ManifoldPolygons *ps, size_t idx);
ManifoldVec2 manifold_simple_polygon_get_point(ManifoldSimplePolygon *p,
int idx);
size_t idx);
ManifoldSimplePolygon *manifold_polygons_get_simple(void *mem,
ManifoldPolygons *ps,
int idx);
ManifoldVec2 manifold_polygons_get_point(ManifoldPolygons *ps, int simple_idx,
int pt_idx);
size_t idx);
ManifoldVec2 manifold_polygons_get_point(ManifoldPolygons *ps,
size_t simple_idx, size_t pt_idx);

// Mesh Construction

Expand Down Expand Up @@ -88,8 +88,8 @@ ManifoldManifoldVec *manifold_manifold_vec(void *mem, size_t sz);
void manifold_manifold_vec_reserve(ManifoldManifoldVec *ms, size_t sz);
size_t manifold_manifold_vec_length(ManifoldManifoldVec *ms);
ManifoldManifold *manifold_manifold_vec_get(void *mem, ManifoldManifoldVec *ms,
int idx);
void manifold_manifold_vec_set(ManifoldManifoldVec *ms, int idx,
size_t idx);
void manifold_manifold_vec_set(ManifoldManifoldVec *ms, size_t idx,
ManifoldManifold *m);
void manifold_manifold_vec_push_back(ManifoldManifoldVec *ms,
ManifoldManifold *m);
Expand Down Expand Up @@ -195,7 +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);
int 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 Expand Up @@ -243,8 +243,8 @@ void manifold_cross_section_vec_reserve(ManifoldCrossSectionVec *csv,
size_t sz);
size_t manifold_cross_section_vec_length(ManifoldCrossSectionVec *csv);
ManifoldCrossSection *manifold_cross_section_vec_get(
void *mem, ManifoldCrossSectionVec *csv, int idx);
void manifold_cross_section_vec_set(ManifoldCrossSectionVec *csv, int idx,
void *mem, ManifoldCrossSectionVec *csv, size_t idx);
void manifold_cross_section_vec_set(ManifoldCrossSectionVec *csv, size_t idx,
ManifoldCrossSection *cs);
void manifold_cross_section_vec_push_back(ManifoldCrossSectionVec *csv,
ManifoldCrossSection *cs);
Expand Down
16 changes: 8 additions & 8 deletions bindings/c/manifoldc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ size_t manifold_polygons_length(ManifoldPolygons *ps) {
return from_c(ps)->size();
}

size_t manifold_polygons_simple_length(ManifoldPolygons *ps, int idx) {
size_t manifold_polygons_simple_length(ManifoldPolygons *ps, size_t idx) {
return (*from_c(ps))[idx].size();
}

ManifoldVec2 manifold_simple_polygon_get_point(ManifoldSimplePolygon *p,
int idx) {
size_t idx) {
return to_c((*from_c(p))[idx]);
}

ManifoldSimplePolygon *manifold_polygons_get_simple(void *mem,
ManifoldPolygons *ps,
int idx) {
size_t idx) {
auto sp = (*from_c(ps))[idx];
return to_c(new (mem) SimplePolygon(sp));
}

ManifoldVec2 manifold_polygons_get_point(ManifoldPolygons *ps, int simple_idx,
int pt_idx) {
ManifoldVec2 manifold_polygons_get_point(ManifoldPolygons *ps,
size_t simple_idx, size_t pt_idx) {
return to_c((*from_c(ps))[simple_idx][pt_idx]);
}

Expand All @@ -111,12 +111,12 @@ size_t manifold_manifold_vec_length(ManifoldManifoldVec *ms) {
}

ManifoldManifold *manifold_manifold_vec_get(void *mem, ManifoldManifoldVec *ms,
int idx) {
size_t idx) {
auto m = (*from_c(ms))[idx];
return to_c(new (mem) Manifold(m));
}

void manifold_manifold_vec_set(ManifoldManifoldVec *ms, int idx,
void manifold_manifold_vec_set(ManifoldManifoldVec *ms, size_t idx,
ManifoldManifold *m) {
(*from_c(ms))[idx] = *from_c(m);
}
Expand Down Expand Up @@ -633,7 +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_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
2 changes: 1 addition & 1 deletion include/manifold/manifold.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class Manifold {
size_t NumVert() const;
size_t NumEdge() const;
size_t NumTri() const;
size_t NumProp() const;
int NumProp() const;
size_t NumPropVert() const;
Box BoundingBox() const;
int Genus() const;
Expand Down
2 changes: 1 addition & 1 deletion src/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ struct Manifold::Impl {
size_t NumVert() const { return vertPos_.size(); }
size_t NumEdge() const { return halfedge_.size() / 2; }
size_t NumTri() const { return halfedge_.size() / 3; }
size_t NumProp() const { return meshRelation_.numProp; }
int NumProp() const { return meshRelation_.numProp; }
size_t NumPropVert() const {
return NumProp() == 0 ? NumVert()
: meshRelation_.properties.size() / NumProp();
Expand Down
4 changes: 1 addition & 3 deletions src/manifold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,7 @@ size_t Manifold::NumTri() const { return GetCsgLeafNode().GetImpl()->NumTri(); }
/**
* The number of properties per vertex in the Manifold.
*/
size_t Manifold::NumProp() const {
return GetCsgLeafNode().GetImpl()->NumProp();
}
int Manifold::NumProp() const { return GetCsgLeafNode().GetImpl()->NumProp(); }
/**
* The number of property vertices in the Manifold. This will always be >=
* NumVert, as some physical vertices may be duplicated to account for different
Expand Down

0 comments on commit af68c57

Please sign in to comment.