Esempio n. 1
0
class PointConverterTest(unittest.TestCase):
    def setUp(self):
        self.stub_point_thinner = StubPointThinner()
        self.writer = PLYWriter(GLConverter(), self.stub_point_thinner)

    def test_header_is_correct(self):
        data = np.array([[10, 10], [10, 10]])
        expected_header = """ply
format ascii 1.0
comment made by Peachy Scanner
comment Date Should Go Here
element vertex 4
property float x
property float y
property float z
end_header\n"""
        result = StringIO()
        self.writer.write_polar_points(result, data)

        self.assertTrue(result.getvalue().startswith(expected_header))

    def test_simple_data_set_is_correct(self):
        data = np.array([[10.0, 10.0, 10.0], [20.0, 20.0, 20.0]])
        a_file = StringIO()
        expected_data = [[10, 0, 0], [10, 0, 1], [10, 0, 2], [-20, 0, 0],
                         [-20, 0, 1], [-20, 0, 2]]
        self.writer.write_polar_points(a_file, data)
        result = self.stringIO2float(a_file)
        self.assertEquals(result, expected_data)

    def test_write_cartisien_points_should_thin_data(self):
        data = np.array([[10.0, 10.0, 10.0], [20.0, 20.0, 20.0]])
        expected = np.array([[10.0, 10.0, 10.0]])
        expected_data = [[10.0, 10.0, 10.0]]
        self.stub_point_thinner.return_object = expected

        a_file = StringIO()
        self.writer.write_cartisien_points(a_file, data)
        result = self.stringIO2float(a_file)
        self.assertEquals(result, expected_data)

    def stringIO2float(self, text):
        string = text.getvalue()
        lines = string.split('\n')[9:-1]
        return [[int(float(number)) for number in line.split(' ')]
                for line in lines]
Esempio n. 2
0
class PointConverterTest(unittest.TestCase):
    def setUp(self):
        self.stub_point_thinner = StubPointThinner()
        self.writer = PLYWriter(GLConverter(), self.stub_point_thinner)

    def test_header_is_correct(self):
        data = np.array([[10, 10], [10, 10]])
        expected_header = """ply
format ascii 1.0
comment made by Peachy Scanner
comment Date Should Go Here
element vertex 4
property float x
property float y
property float z
end_header\n"""
        result = StringIO()
        self.writer.write_polar_points(result, data)

        self.assertTrue(result.getvalue().startswith(expected_header))

    def test_simple_data_set_is_correct(self):
        data = np.array([[10.0, 10.0, 10.0], [20.0, 20.0, 20.0]])
        a_file = StringIO()
        expected_data = [[10, 0, 0], [10, 0, 1], [10, 0, 2], [-20, 0, 0], [-20, 0, 1], [-20, 0, 2]]
        self.writer.write_polar_points(a_file, data)
        result = self.stringIO2float(a_file)
        self.assertEquals(result, expected_data)

    def test_write_cartisien_points_should_thin_data(self):
        data = np.array([[10.0, 10.0, 10.0], [20.0, 20.0, 20.0]])
        expected = np.array([[10.0, 10.0, 10.0]])
        expected_data = [[10.0, 10.0, 10.0]]
        self.stub_point_thinner.return_object = expected

        a_file = StringIO()
        self.writer.write_cartisien_points(a_file, data)
        result = self.stringIO2float(a_file)
        self.assertEquals(result, expected_data)

    def stringIO2float(self, text):
        string = text.getvalue()
        lines = string.split('\n')[9:-1]
        return [[int(float(number)) for number in line.split(' ')] for line in lines]  
Esempio n. 3
0
 def setUp(self):
     self.stub_point_thinner = StubPointThinner()
     self.writer = PLYWriter(GLConverter(), self.stub_point_thinner)
Esempio n. 4
0
 def setUp(self):
     self.stub_point_thinner = StubPointThinner()
     self.writer = PLYWriter(GLConverter(), self.stub_point_thinner)
Esempio n. 5
0
 def save_points(self, path, filename):
     with open(os.path.join(path, filename), 'w') as afile:
         thinner = PointThinner()
         converter = GLConverter()
         PLYWriter(converter, thinner).write_cartisien_points(afile, self.raw_points_xyz)
     self.dismiss_popup()