Skip to content

Commit 283e8a3

Browse files
committed
Adding the simplify method
1 parent 5d15c22 commit 283e8a3

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

bindings/c/include/manifold/manifoldc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ ManifoldManifold* manifold_refine_to_length(void* mem, ManifoldManifold* m,
173173
double length);
174174
ManifoldManifold* manifold_refine_to_tolerance(void* mem, ManifoldManifold* m,
175175
double tolerance);
176-
176+
ManifoldManifold* manifold_simplify(void* mem, ManifoldManifold* m,
177+
double tolerance);
177178
// Manifold Shapes / Constructors
178179

179180
ManifoldManifold* manifold_empty(void* mem);

bindings/c/manifoldc.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ ManifoldManifold* manifold_refine_to_tolerance(void* mem, ManifoldManifold* m,
321321
return to_c(new (mem) Manifold(refined));
322322
}
323323

324+
ManifoldManifold* manifold_simplify(void* mem, ManifoldManifold* m,
325+
double tolerance) {
326+
auto refined = from_c(m)->Simplify(tolerance);
327+
return to_c(new (mem) Manifold(refined));
328+
}
329+
324330
ManifoldManifold* manifold_empty(void* mem) {
325331
return to_c(new (mem) Manifold());
326332
}

bindings/java/src/main/java/com/cadoodlecad/manifold/ManifoldBindings.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,17 @@ public ManifoldBindings(File cacheDirectory) throws Exception {
225225
// ===== Refinement =====
226226

227227
// ManifoldManifold* manifold_refine(void* mem, ManifoldManifold* m, int refine);
228-
load("manifold_refine", ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT);
228+
load("manifold_refine", ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT);
229229

230230
// ManifoldManifold* manifold_refine_to_length(void* mem, ManifoldManifold* m, double length);
231-
load("manifold_refine_to_length", ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS,
231+
load("manifold_refine_to_length", ValueLayout.ADDRESS, ValueLayout.ADDRESS,
232232
ValueLayout.JAVA_DOUBLE);
233233

234234
// ManifoldManifold* manifold_refine_to_tolerance(void* mem, ManifoldManifold* m, double tolerance);
235-
load("manifold_refine_to_tolerance", ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS,
235+
load("manifold_refine_to_tolerance", ValueLayout.ADDRESS, ValueLayout.ADDRESS,
236+
ValueLayout.JAVA_DOUBLE);
237+
load("manifold_simplify", ValueLayout.ADDRESS, ValueLayout.ADDRESS,
236238
ValueLayout.JAVA_DOUBLE);
237-
238239
// ManifoldManifold* manifold_smooth_by_normals(void* mem, ManifoldManifold* m, int normal_idx);
239240
load("manifold_smooth_by_normals", ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS,
240241
ValueLayout.JAVA_INT);
@@ -719,7 +720,10 @@ public MemorySegment refineToTolerance(MemorySegment m, double tolerance) throws
719720
MemorySegment mem = (MemorySegment) functions.get("manifold_alloc_manifold").invoke();
720721
return (MemorySegment) functions.get("manifold_refine_to_tolerance").invoke(mem, m, tolerance);
721722
}
722-
723+
public MemorySegment simplify(MemorySegment m, double tolerance) throws Throwable {
724+
MemorySegment mem = (MemorySegment) functions.get("manifold_alloc_manifold").invoke();
725+
return (MemorySegment) functions.get("manifold_simplify").invoke(mem, m, tolerance);
726+
}
723727
public MemorySegment smoothByNormals(MemorySegment m, int normalIdx) throws Throwable {
724728
MemorySegment mem = (MemorySegment) functions.get("manifold_alloc_manifold").invoke();
725729
return (MemorySegment) functions.get("manifold_smooth_by_normals").invoke(mem, m, normalIdx);

0 commit comments

Comments
 (0)