开发者

Is there a Java library for writing out ply files?

I'm 开发者_开发问答looking for a Java library to write out ply files. If there isn't one, I'd like to look into writing one.


If you only want to write ply files then I would suggest to write your own code. the format is quite simple. So you'll probably be faster writing it yourself.

Here is an introduction to start with:

http://local.wasp.uwa.edu.au/~pbourke/dataformats/ply/


following is a simplified version of a PLY writer code snippet which you may change it to suit your needs.



        fos = new FileOutputStream(file);
        Writer writer= new OutputStreamWriter(fos, "UTF8");
        writer.write("ply\n");
        writer.write("format ");
        writer.write(isBinary() ? "binary_big_endian" : "ascii");
        writer.write(" 1.0\n");
        BufferedReader r=new BufferedReader(new StringReader(comment));
        String commentLine;
        while ((commentLine=r.readLine())!=null) {
            writer.write("comment ");
            writer.write(commentLine);
            writer.write('\n');
        }
        // lat,lon,alt as example
        writer.write("element vertex 3\n");
        writer.write("property double x\n");
        writer.write("property double y\n");
        writer.write("property double z\n");
        //writer.write("element face 0\n"); // no element like faces
        //writer.write("property list uchar int vertex_indices\n");
        writer.write("end_header\n");
        writer.flush();
        DataOutputStream dos=new DataOutputStream(fos);
        dos.writeDouble(x);
        dos.writeDouble(y);
        dos.writeDouble(z);
        dos.close();

    }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜