Some modifs
This commit is contained in:
parent
43791483d8
commit
6ecc92786b
|
@ -148,6 +148,7 @@ class ModelParser:
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
line = line.rstrip()
|
line = line.rstrip()
|
||||||
|
if line != '':
|
||||||
self.parse_line(line)
|
self.parse_line(line)
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
@ -34,7 +34,7 @@ class PLYHeaderParser:
|
||||||
self.parent.elements.append(self.current_element)
|
self.parent.elements.append(self.current_element)
|
||||||
|
|
||||||
elif split[0] == 'property':
|
elif split[0] == 'property':
|
||||||
self.current_element.add_property(split[2], split[1])
|
self.current_element.add_property(split[-1], (split[1:][:-1]))
|
||||||
|
|
||||||
elif split[0] == 'end_header':
|
elif split[0] == 'end_header':
|
||||||
self.parent.inner_parser = PLYContentParser(self.parent)
|
self.parent.inner_parser = PLYContentParser(self.parent)
|
||||||
|
@ -49,6 +49,13 @@ class PLYElement:
|
||||||
def add_property(self, name, type):
|
def add_property(self, name, type):
|
||||||
self.properties.append((name, type))
|
self.properties.append((name, type))
|
||||||
|
|
||||||
|
class PLYVertex(Vertex):
|
||||||
|
def __init__(self, string):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def add_to_parser(self, parser):
|
||||||
|
pass
|
||||||
|
|
||||||
class PLYContentParser:
|
class PLYContentParser:
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
@ -63,7 +70,16 @@ class PLYContentParser:
|
||||||
if self.current_element.name == 'vertex':
|
if self.current_element.name == 'vertex':
|
||||||
self.parent.add_vertex(Vertex().from_array(split))
|
self.parent.add_vertex(Vertex().from_array(split))
|
||||||
elif self.current_element.name == 'face':
|
elif self.current_element.name == 'face':
|
||||||
self.parent.add_face(Face(FaceVertex(int(split[1])), FaceVertex(int(split[2])), FaceVertex(int(split[3]))))
|
|
||||||
|
faceVertexArray = []
|
||||||
|
|
||||||
|
# Analyse element
|
||||||
|
for property in self.current_element.properties:
|
||||||
|
if property[0] == 'vertex_indices':
|
||||||
|
for i in range(int(split[0])):
|
||||||
|
faceVertexArray.append(FaceVertex(int(split[i+1])))
|
||||||
|
|
||||||
|
self.parent.add_face(Face(*faceVertexArray))
|
||||||
|
|
||||||
self.counter += 1
|
self.counter += 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue