@Test(expected = IllegalArgumentException.class) public void testWriteBinarySTLFileNullNameThrowsIAE() throws Exception { final Mesh mesh = new NaiveFloatMesh(); SurfaceAreaWrapper.writeBinarySTLFile(null, mesh); }
static void writeBinarySTLFile(final String path, final Mesh mesh) throws IllegalArgumentException, IOException, NullPointerException { if (mesh == null) { throw new NullPointerException("Mesh cannot be null"); } if (StringUtils.isNullOrEmpty(path)) { throw new IllegalArgumentException("Filename cannot be null or empty"); } final Iterator<Triangle> triangles = mesh.triangles().iterator(); final int numTriangles = (int) mesh.triangles().size(); try (final FileOutputStream writer = new FileOutputStream(path)) { final byte[] header = STL_HEADER.getBytes(); writer.write(header); final byte[] facetBytes = ByteBuffer.allocate(4).order( ByteOrder.LITTLE_ENDIAN).putInt(numTriangles).array(); writer.write(facetBytes); final ByteBuffer buffer = ByteBuffer.allocate(50); buffer.order(ByteOrder.LITTLE_ENDIAN); while (triangles.hasNext()) { final Triangle triangle = triangles.next(); writeSTLFacet(buffer, triangle); writer.write(buffer.array()); buffer.clear(); } } }
SurfaceAreaWrapper extends BoneJCommand { static void writeBinarySTLFile(final String path, final Mesh mesh) throws IllegalArgumentException, IOException, NullPointerException { if (mesh == null) { throw new NullPointerException("Mesh cannot be null"); } if (StringUtils.isNullOrEmpty(path)) { throw new IllegalArgumentException("Filename cannot be null or empty"); } final Iterator<Triangle> triangles = mesh.triangles().iterator(); final int numTriangles = (int) mesh.triangles().size(); try (final FileOutputStream writer = new FileOutputStream(path)) { final byte[] header = STL_HEADER.getBytes(); writer.write(header); final byte[] facetBytes = ByteBuffer.allocate(4).order( ByteOrder.LITTLE_ENDIAN).putInt(numTriangles).array(); writer.write(facetBytes); final ByteBuffer buffer = ByteBuffer.allocate(50); buffer.order(ByteOrder.LITTLE_ENDIAN); while (triangles.hasNext()) { final Triangle triangle = triangles.next(); writeSTLFacet(buffer, triangle); writer.write(buffer.array()); buffer.clear(); } } } }
SurfaceAreaWrapper extends BoneJCommand { static void writeBinarySTLFile(final String path, final Mesh mesh) throws IllegalArgumentException, IOException, NullPointerException { if (mesh == null) { throw new NullPointerException("Mesh cannot be null"); } if (StringUtils.isNullOrEmpty(path)) { throw new IllegalArgumentException("Filename cannot be null or empty"); } final Iterator<Triangle> triangles = mesh.triangles().iterator(); final int numTriangles = (int) mesh.triangles().size(); try (final FileOutputStream writer = new FileOutputStream(path)) { final byte[] header = STL_HEADER.getBytes(); writer.write(header); final byte[] facetBytes = ByteBuffer.allocate(4).order( ByteOrder.LITTLE_ENDIAN).putInt(numTriangles).array(); writer.write(facetBytes); final ByteBuffer buffer = ByteBuffer.allocate(50); buffer.order(ByteOrder.LITTLE_ENDIAN); while (triangles.hasNext()) { final Triangle triangle = triangles.next(); writeSTLFacet(buffer, triangle); writer.write(buffer.array()); buffer.clear(); } } }  }
SurfaceAreaWrapper extends BoneJCommand { static void writeBinarySTLFile(final String path, final Mesh mesh) throws IllegalArgumentException, IOException, NullPointerException { if (mesh == null) { throw new NullPointerException("Mesh cannot be null"); } if (StringUtils.isNullOrEmpty(path)) { throw new IllegalArgumentException("Filename cannot be null or empty"); } final Iterator<Triangle> triangles = mesh.triangles().iterator(); final int numTriangles = (int) mesh.triangles().size(); try (final FileOutputStream writer = new FileOutputStream(path)) { final byte[] header = STL_HEADER.getBytes(); writer.write(header); final byte[] facetBytes = ByteBuffer.allocate(4).order( ByteOrder.LITTLE_ENDIAN).putInt(numTriangles).array(); writer.write(facetBytes); final ByteBuffer buffer = ByteBuffer.allocate(50); buffer.order(ByteOrder.LITTLE_ENDIAN); while (triangles.hasNext()) { final Triangle triangle = triangles.next(); writeSTLFacet(buffer, triangle); writer.write(buffer.array()); buffer.clear(); } } }  @Override void run(); }
SurfaceAreaWrapper extends BoneJCommand { static void writeBinarySTLFile(final String path, final Mesh mesh) throws IllegalArgumentException, IOException, NullPointerException { if (mesh == null) { throw new NullPointerException("Mesh cannot be null"); } if (StringUtils.isNullOrEmpty(path)) { throw new IllegalArgumentException("Filename cannot be null or empty"); } final Iterator<Triangle> triangles = mesh.triangles().iterator(); final int numTriangles = (int) mesh.triangles().size(); try (final FileOutputStream writer = new FileOutputStream(path)) { final byte[] header = STL_HEADER.getBytes(); writer.write(header); final byte[] facetBytes = ByteBuffer.allocate(4).order( ByteOrder.LITTLE_ENDIAN).putInt(numTriangles).array(); writer.write(facetBytes); final ByteBuffer buffer = ByteBuffer.allocate(50); buffer.order(ByteOrder.LITTLE_ENDIAN); while (triangles.hasNext()) { final Triangle triangle = triangles.next(); writeSTLFacet(buffer, triangle); writer.write(buffer.array()); buffer.clear(); } } }  @Override void run();  }