Ejemplo n.º 1
0
    def test_read_xyz_from_file(self):
        with self.assertRaises(ValueError):
            XYZReader.readXYZFile("does/not/exist.xyz")

        polyline = XYZReader.readXYZFile(self.polyline)

        self.assertEqual(polyline.name(), "pol11.xyz")
        self.assertEqual(len(polyline), 13)
        self.assertFalse(polyline.isClosed())
        self.assertEqual(polyline[0], (390271.843750, 6606121.334396, 1441.942627))  # first point
        self.assertEqual(polyline[12], (389789.263184, 6605784.945099, 1446.627808))  # last point

        polyline = XYZReader.readXYZFile(self.closed_polyline)

        self.assertEqual(polyline.name(), "pol8.xyz")
        self.assertEqual(len(polyline), 21)
        self.assertTrue(polyline.isClosed())
        self.assertEqual(polyline[0], (396202.413086, 6606091.935028, 1542.620972))  # first point
        self.assertEqual(polyline[20], (396202.413086, 6606091.935028, 1542.620972))  # last point
Ejemplo n.º 2
0
def readPolylines(root_path):
    polyline_files = ["pol1.xyz",
                      "pol2.xyz",
                      "pol3.xyz",
                      "pol4.xyz",
                      "pol5.xyz",
                      "pol6.xyz",
                      "pol7.xyz",
                      "pol8.xyz",
                      "pol9.xyz",
                      "pol10.xyz",
                      "pol11.xyz"]

    polylines = []

    if root_path is not None and os.path.exists(root_path):
        for polyline_file in polyline_files:
            path = os.path.join(root_path, polyline_file)
            polyline = XYZReader.readXYZFile(path)
            polylines.append(polyline)

    return polylines