Adding a mesh representing a plane that is aligned to the x, y or z axis can cause NegativeArraySizeException. For example:
Image3DUniverse universe = new Image3DUniverse();
// Mesh of a plane perpendicular to the z axis
float length = 1000;
float zpos = -100;
ArrayList<Point3f> triangles = new ArrayList<>();
triangles.add(new Point3f(-length/2, length/2, zpos));
triangles.add(new Point3f(length/2, length/2, zpos));
triangles.add(new Point3f(-length/2, -length/2, zpos));
triangles.add(new Point3f(length/2, length/2, zpos));
triangles.add(new Point3f(-length/2, -length/2, zpos));
triangles.add(new Point3f(length/2, -length/2, zpos));
CustomTriangleMesh mesh = new CustomTriangleMesh( triangles );
universe.addCustomMesh( mesh, "test-plane" );
universe.show();
results in:
Exception in thread "main" java.lang.NegativeArraySizeException
at ij3d.shapes.BoundingBox.makeLine(BoundingBox.java:209)
at ij3d.shapes.BoundingBox.<init>(BoundingBox.java:122)
at ij3d.shapes.BoundingBox.<init>(BoundingBox.java:54)
at ij3d.shapes.BoundingBox.<init>(BoundingBox.java:50)
at ij3d.ContentInstant.display(ContentInstant.java:236)
at ij3d.ContentCreator.createContent(ContentCreator.java:132)
at ij3d.ContentCreator.createContent(ContentCreator.java:119)
at ij3d.Image3DUniverse.createContent(Image3DUniverse.java:1175)
at ij3d.Image3DUniverse.addCustomMesh(Image3DUniverse.java:1143)
at develop.MinimalPlaneError.main(MinimalPlaneError.java:27)
This is an issue with drawing the BoundingBox, where it tries to draw lines that have a length of zero. This can result in n inside makeLinebecoming negative.
I'd be happy to submit a PR with small changes to BoundingBox to account for this edge case.
Adding a mesh representing a plane that is aligned to the x, y or z axis can cause
NegativeArraySizeException
. For example:results in:
This is an issue with drawing the
BoundingBox
, where it tries to draw lines that have a length of zero. This can result inn
insidemakeLine
becoming negative.I'd be happy to submit a PR with small changes to
BoundingBox
to account for this edge case.