Skip to content

Commit 4e35413

Browse files
committed
add unit test for import/export of the gl data
1 parent e393535 commit 4e35413

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

bindings/java/src/test/java/com/example/ManifoldBindingsTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.jupiter.api.io.TempDir;
66

77
import com.cadoodlecad.manifold.ManifoldBindings;
8+
import com.cadoodlecad.manifold.ManifoldBindings.MeshData64;
89

910
import java.io.File;
1011
import java.lang.foreign.MemorySegment;
@@ -130,6 +131,32 @@ private java.lang.foreign.MemorySegment assertStlRoundTrip(java.lang.foreign.Mem
130131

131132
return reimported;
132133
}
134+
135+
@Test
136+
public void testMeshGL64() throws Throwable{
137+
java.lang.foreign.MemorySegment cube = makeCube();
138+
MemorySegment loaded=null;
139+
try {
140+
assertMeshValid(cube, "Cube");
141+
// A cube has 8 vertices and 12 triangles (6 faces × 2)
142+
assertEquals(8, mb.numVert(cube), "Cube should have 8 vertices");
143+
assertEquals(12, mb.numTri(cube), "Cube should have 12 triangles");
144+
145+
MeshData64 meshgl = mb.exportMeshGL64(cube);
146+
double[] verts = meshgl.vertices(); // flat [x0,y0,z0, x1,y1,z1, ...]
147+
long[] tris = meshgl.triangles(); // flat [i0,i1,i2, i3,i4,i5, ...]
148+
int triCount = meshgl.triCount();
149+
loaded = mb.importMeshGL64(verts, tris, triCount, triCount);
150+
151+
MeshData64 meshglLoaded = mb.exportMeshGL64(loaded);
152+
double[] vertsl = meshglLoaded.vertices(); // flat [x0,y0,z0, x1,y1,z1, ...]
153+
long[] trisl = meshglLoaded.triangles(); // flat [i0,i1,i2, i3,i4,i5, ...]
154+
int triCountl = meshglLoaded.triCount();
155+
} finally {
156+
mb.safeDelete(cube);
157+
mb.safeDelete(loaded);
158+
}
159+
}
133160

134161
/**
135162
* Round-trip a manifold through 3MF:

0 commit comments

Comments
 (0)