Skip to content

Instantly share code, notes, and snippets.

@krenz444
Created March 17, 2017 20:53
Show Gist options
  • Save krenz444/6846e08197fd2a91eb78b4241833c1ca to your computer and use it in GitHub Desktop.
Save krenz444/6846e08197fd2a91eb78b4241833c1ca to your computer and use it in GitHub Desktop.
class ListBuilder:
def __init__(self, file_path):
file = open(file_path, "r")
self.lines = file.readlines()
self.list_of_triangles = []
self.list_of_triangle_names = []
def return_list(self):
for line in lines:
triValue = line.split()
name = str(triValue[0])
#1st triangle
x1 = float(triValue[1])
y1 = float(triValue[2])
# 2nd triangle
x2 = float(triValue[3])
y2 = float(triValue[4])
# 3rd triangle
x3 = float(triValue[5])
y3 = float(triValue[6])
vertices = [[x1, y1], [x2, y2], [x3, y3]]
self.list_of_triangle_names.append(name)
self.list_of_triangles.append(vertices)
print("Name: ", name)
print("List of vertices: ", vertices)
print("Vertex 1: ", vertices[0])
print("Vertex 2: ", vertices[0])
print("Vertex 3: ", vertices[0])
myList = [self.list_of_triangle_names, self.list_of_triangles]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment