Esempio n. 1
0
    def test_read_xyz_from_file(self):
        with self.assertRaises(IOError):
            XYZIo.readXYZFile("does/not/exist.xyz")

        polyline = XYZIo.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 = XYZIo.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
Esempio n. 2
0
    def test_save(self):
        with TestAreaContext("polyline/fwrite") as work_area:
            p1 = Polyline(init_points=[(1, 0), (1, 1), (1, 2)])
            p2 = Polyline(init_points=[(1, 0), (1, 1), (1, 2)])
            self.assertTrue(p1 == p2)

            XYZIo.saveXYFile(p1, "poly.xy")

            p2 = XYZIo.readXYFile("poly.xy")
            self.assertTrue(p1 == p2)
Esempio n. 3
0
    def test_save(self):
        with TestAreaContext("polyline/fwrite") as work_area:
            p1 = Polyline( init_points = [(1,0) , (1,1) , (1,2)])
            p2 = Polyline( init_points = [(1,0) , (1,1) , (1,2)])
            self.assertTrue( p1 == p2 )

            XYZIo.saveXYFile(p1 , "poly.xy")
            
            p2 = XYZIo.readXYFile("poly.xy")
            self.assertTrue( p1 == p2 )
Esempio n. 4
0
    def test_read_xyz_from_file(self):
        with self.assertRaises(IOError):
            XYZIo.readXYZFile("does/not/exist.xyz")

        polyline = XYZIo.readXYZFile(self.polyline)

        self.assertEqual(polyline.getName(), "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 = XYZIo.readXYZFile(self.closed_polyline)

        self.assertEqual(polyline.getName(), "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
Esempio n. 5
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 = XYZIo.readXYZFile(path)
            polylines.append(polyline)

    return polylines
Esempio n. 6
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 = XYZIo.readXYZFile(path)
            polylines.append(polyline)

    return polylines