def __init__(self, in_stream): for line in in_stream: if not line.isspace(): v0, v1, v2, r, e = SEARCH(line).groups() self.vertexs = map(Vector3f, [v0, v1, v2]) self.edge0 = Vector3f(v1) - Vector3f(v0) self.edge3 = Vector3f(v2) - Vector3f(v0) self.reflectivity = Vector3f(r).clamped(ZERO, ONE) self.emitivity = Vector3f(e).clamped(ZERO, MAX) edge1 = Vector3f(v2) - Vector3f(v1) self.tangent = self.edge0.unitize() self.normal = self.tangent.cross(edge1).unitize() pa2 = self.edge0.cross(edge1) self.area = sqrt(pa2.dot(pa2)) * 0.5 return raise StopIteration def get_bound(self): bound = list(self.vertexs[2]) + list(self.vertexs[2]) print (bound) for i in range(3): v = self.vertexs[i] for j in range(6): d, m = -1 if (j >= 3) else 1, j % 3 a = v[m] - (d * TOLERANCE) if ((a - bound[j]) * d) < 0.0: bound[j] = a return bound
for i in range(3): v = self.vertexs[i]
for v in self.vertexs:
В Python 3 map() возвращает итератор, а не лист.Замени:Кодfor i in range(3): v = self.vertexs[i]на:Кодfor v in self.vertexs:
bound = list(self.vertexs[2]) + list(self.vertexs[2])
self.vertexs = list(map(Vector3f, [v0, v1, v2]))
А как быть с bound?
TypeError: 'str' does not support the buffer interface
Это при записи в файл? Скорее всего требуется что-то типа your_str_object.encode('some-codepage') или bytes(your_str_object, 'some-codepage')