diff --git a/tests/danesfield/data/octahedron.ply b/tests/danesfield/data/octahedron.ply new file mode 100644 index 000000000..c7235524e --- /dev/null +++ b/tests/danesfield/data/octahedron.ply @@ -0,0 +1,16 @@ +ply +format ascii 1.0 +element vertex 6 +property float64 x +property float64 y +property float64 z +property uint8 red +property uint8 green +property uint8 blue +end_header +-1.0 1.0 0.0 255 0 0 +-1.0 -1.0 0.0 0 255 0 +1.0 -1.0 0.0 0 0 255 +1.0 1.0 0.0 255 0 255 +0.0 0.0 0.7 255 255 255 +0.0 0.0 -0.7 0 0 0 diff --git a/tests/danesfield/tools/test_ply2txt.py b/tests/danesfield/tools/test_ply2txt.py new file mode 100644 index 000000000..5518454e0 --- /dev/null +++ b/tests/danesfield/tools/test_ply2txt.py @@ -0,0 +1,29 @@ +############################################################################### +# Copyright Kitware Inc. and Contributors +# Distributed under the Apache License, 2.0 (apache.org/licenses/LICENSE-2.0) +# See accompanying Copyright.txt and LICENSE files for details +############################################################################### + +from tools.ply2txt import convert +from os.path import dirname, join +from os import remove + +data_dir = join(dirname(dirname(__file__)), 'data') + + +def test_ply2txt(): + ply_source = join(data_dir, 'octahedron.ply') + txt_target = join(data_dir, 'octahedron.txt') + convert([ply_source, txt_target]) + + with open(txt_target, 'r') as f: + lines = f.readlines() + assert lines == ['-1.0 1.0 0.0\n', + '-1.0 -1.0 0.0\n', + '1.0 -1.0 0.0\n', + '1.0 1.0 0.0\n', + '0.0 0.0 0.7\n', + '0.0 0.0 -0.7\n'] + + # clean up temporary output + remove(txt_target)