Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLY #420

Merged
merged 2 commits into from
Dec 22, 2023
Merged

PLY #420

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public static void saveBinary( PlyWriter data, ByteOrder order, boolean saveAsFl

var indexes = new int[100];
bytes = ByteBuffer.allocate(1 + indexes.length*4);
bytes.order(order);
for (int i = 0; i < data.getPolygonCount(); i++) {
int size = data.getIndexes(i, indexes);
bytes.position(0);
Expand Down Expand Up @@ -467,6 +468,7 @@ private static void readCloudBinary( PlyReader output, InputStream reader, List<

final var polygonLine = new byte[4*10];
final ByteBuffer polygonBB = ByteBuffer.wrap(polygonLine);
polygonBB.order(order);
int[] indexes = new int[100];
for (int i = 0; i < triangleCount; i++) {
if (1 != reader.read(line, 0, 1))
Expand All @@ -482,7 +484,10 @@ private static void readCloudBinary( PlyReader output, InputStream reader, List<
throw new IOException("Read unexpected number of bytes. " + found + " vs " + lineLength);

for (int wordIndex = 0; wordIndex < count; wordIndex++) {
indexes[wordIndex] = polygonBB.getInt(wordIndex*4);
int foundIndex = polygonBB.getInt(wordIndex*4);
if (foundIndex < 0 || foundIndex > vertexCount)
throw new IOException("Negative index. word: " + wordIndex + " value: " + foundIndex + " count: " + vertexCount);
indexes[wordIndex] = foundIndex;
}

output.addPolygon(indexes, 0, count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void projectSurfaceOntoImage( VertexMesh mesh, Polygon2D_F64 polygon, int shapeI
// convex intersection or computing the depth at that pixel on this surface

// The entire surface will have one color
int color = surfaceColor.surfaceRgb(shapeIdx);
int color = surfaceColor.surfaceRgb(vertexIndex);

// Go through all pixels and see if the points are inside the polygon. If so
for (int pixelY = aabb.y0; pixelY < aabb.y1; pixelY++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,14 @@ class TestPlyCodec extends BoofStandardJUnit {
for (var endian : new ByteOrder[]{ByteOrder.LITTLE_ENDIAN, ByteOrder.BIG_ENDIAN}) {
var mesh = new VertexMesh();
mesh.offsets.add(0);
for (int i = 0; i < 10; i++) {
int numVertexes = 10;
for (int i = 0; i < numVertexes; i++) {
mesh.vertexes.append(i, 2, 3);
mesh.indexes.add(i*3);
mesh.indexes.add(i*3 + 1);
mesh.indexes.add(i*3 + 2);

// bound indexes to ensure they are in the valid range
mesh.indexes.add((i*3)%numVertexes);
mesh.indexes.add((i*3 + 1)%numVertexes);
mesh.indexes.add((i*3 + 2)%numVertexes);
mesh.offsets.add(mesh.indexes.size);
}
var colors = new DogArray_I32();
Expand Down
Loading