From: daid Date: Thu, 26 Jul 2012 15:29:31 +0000 (+0200) Subject: Fix the save STL function after numpy upgrade. X-Git-Tag: 12.08~22 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=cfbe98b0f7124f69b02ab2a6d820adbad393ff86;p=cura.git Fix the save STL function after numpy upgrade. --- diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index f09d999a..521dce38 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -307,11 +307,16 @@ class projectPlanner(wx.Frame): dlg.Destroy() def _saveCombinedSTL(self, filename): + totalCount = 0 + for item in self.list: + totalCount += item.vertexCount output = mesh.mesh() + output._prepareVertexCount(totalCount) for item in self.list: - offset = util3d.Vector3(item.centerX, item.centerY, 0) - for f in item.faces: - output.addFace(f.v[0] * item.scale + offset, f.v[1] * item.scale + offset, f.v[2] * item.scale + offset) + offset = numpy.array([item.centerX, item.centerY, 0]) + for v in item.vertexes: + v0 = v * item.scale + offset + output.addVertex(v0[0], v0[1], v0[2]) stl.saveAsSTL(output, filename) def OnSaveProject(self, e): diff --git a/Cura/util/mesh.py b/Cura/util/mesh.py index 0a943b1e..0705b1b8 100644 --- a/Cura/util/mesh.py +++ b/Cura/util/mesh.py @@ -83,22 +83,24 @@ class mesh(object): print "%f: " % (time.time() - t0), "Splitting a model with %d vertexes." % (len(self.vertexes)) removeDict = {} tree = util3d.AABBTree() - off = util3d.Vector3(0.0001,0.0001,0.0001) + off = numpy.array([0.0001,0.0001,0.0001]) newVertexList = [] - for v in self.vertexes: + for idx in xrange(0, self.vertexCount): + v = self.vertexes[idx] e = util3d.AABB(v-off, v+off) q = tree.query(e) if len(q) < 1: - e.vector = v + e.idx = idx tree.insert(e) newVertexList.append(v) else: - removeDict[v] = q[0].vector + removeDict[idx] = q[0].idx print "%f: " % (time.time() - t0), "Marked %d duplicate vertexes for removal." % (len(removeDict)) #Make facelists so we can quickly remove all the vertexes. - for v in self.vertexes: - v.faceList = [] + vertexFaceList = [] + for idx in xrange(0, self.vertexCount): + vertexFaceList.append([]) for f in self.faces: f.v[0].faceList.append(f) f.v[1].faceList.append(f) diff --git a/Cura/util/stl.py b/Cura/util/stl.py index 7e422679..9689c030 100644 --- a/Cura/util/stl.py +++ b/Cura/util/stl.py @@ -49,17 +49,15 @@ def saveAsSTL(mesh, filename): #Write the STL binary header. This can contain any info, except for "SOLID" at the start. f.write(("CURA BINARY STL EXPORT. " + time.strftime('%a %d %b %Y %H:%M:%S')).ljust(80, '\000')) #Next follow 4 binary bytes containing the amount of faces, and then the face information. - f.write(struct.pack(" 0.0 or aabb.vMin.y - self.vMax.y > 0.0 or aabb.vMin.z - self.vMax.z > 0.0: + if aabb.vMin[0] - self.vMax[0] > 0.0 or aabb.vMin[1] - self.vMax[1] > 0.0 or aabb.vMin[2] - self.vMax[2] > 0.0: return False - if self.vMin.x - aabb.vMax.x > 0.0 or self.vMin.y - aabb.vMax.y > 0.0 or self.vMin.z - aabb.vMax.z > 0.0: + if self.vMin[0] - aabb.vMax[0] > 0.0 or self.vMin[1] - aabb.vMax[1] > 0.0 or self.vMin[2] - aabb.vMax[2] > 0.0: return False return True @@ -308,9 +309,9 @@ class AABBTree(object): if __name__ == '__main__': tree = AABBTree() - tree.insert(AABB(Vector3(0,0,0), Vector3(0,0,0))) - tree.insert(AABB(Vector3(1,1,1), Vector3(1,1,1))) - tree.insert(AABB(Vector3(0.5,0.5,0.5), Vector3(0.5,0.5,0.5))) + tree.insert(AABB(numpy.array([0,0,0]), numpy.array([0,0,0]))) + tree.insert(AABB(numpy.array([1,1,1]), numpy.array([1,1,1]))) + tree.insert(AABB(numpy.array([0.5,0.5,0.5]), numpy.array([0.5,0.5,0.5]))) print(tree) - print(tree.query(AABB(Vector3(0,0,0), Vector3(0,0,0)))) + print(tree.query(AABB(numpy.array([0,0,0]), numpy.array([0,0,0]))))