-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathelementosGL.py
executable file
·86 lines (71 loc) · 2.06 KB
/
elementosGL.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
NUM_ELEMENTOS = 0
tipo = dict()
tipo["circulo"] = '''010111010'''
tipo["xis"] = '''101010101'''
def salva (lstElemento):
arq = open("lstElementos.txt", "w")
saida = ""
for elemento in lstElemento:
saida += str(elemento) + "\n"
print saida
arq.write(saida)
arq.close()
class Ponto ():
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __repr__(self):
return "" + str(self.x) + "; " + str(self.y) + "; " + str(self.z)+ ""
class Orientacao ():
def __init__(self, x, y, z, w):
self.x = x
self.y = y
self.z = z
self.w = w
def __repr__(self):
return "" + str(self.x) + "; " + str(self.y) + "; " + str(self.z)+ "; " + str(self.w)+ ""
class Cor ():
def __init__(self, r, g, b):
self.r = r
self.g = g
self.b = b
def __repr__(self):
return "" + str(self.r) + "; " + str(self.g) + "; " + str(self.b)+ ""
class Elemento ():
def __init__(self, nome, cor, espessura, tipo, angulacao, lstPontos):
global NUM_ELEMENTOS
self.cod = NUM_ELEMENTOS
self.nome = nome
self.lstPontos = lstPontos
self.cor = cor
self.espessura = espessura
self.angulacao = angulacao
self.tipo = tipo
NUM_ELEMENTOS+=1
def __repr__(self):
saida = ""
for ponto in self.lstPontos:
saida += str(ponto) + ", "
return "" + str(self.cod) \
+ "; " + str(self.nome) \
+ "; " + str(self.cor) \
+ "; " + str(self.espessura) \
+ "; " + tipo[self.tipo] \
+ "; " + str(self.angulacao) \
+ "; " + saida + ""
lst = []
lst.append(Elemento("L", Cor(255,0,0), 0, "xis", Orientacao(90, 0, 0, 90), [Ponto(0, 0, 0), Ponto(3, 3, 0)]))
print len(lst)
salva (lst)
'''
'P': //Ponto
'L': //Linha
'C': //Circulo
'E': //Esfera
'T': //Triangulo
'R': //Retangulo
'c': //[c]one
't': //[t]órus
'''