From: daid Date: Mon, 30 Jul 2012 12:21:49 +0000 (+0200) Subject: Fix the mesh splitter after bug introduced by numpy update. X-Git-Tag: 12.08~11 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a25b95420450b4adeaa17ef3a83ccad65945a1fb;p=cura.git Fix the mesh splitter after bug introduced by numpy update. --- diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index 35bed71f..fa01ff76 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -271,7 +271,9 @@ class projectPlanner(wx.Frame): dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL") if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() - parts = stl.stlModel().load(filename).splitToParts() + model = stl.stlModel().load(filename) + pd = wx.ProgressDialog('Splitting model.', 'Splitting model into multiple parts.', model.vertexCount, self, wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME | wx.PD_SMOOTH) + parts = model.splitToParts(pd.Update) for part in parts: partFilename = filename[:filename.rfind('.')] + "_part%d.stl" % (parts.index(part)) stl.saveAsSTL(part, partFilename) @@ -280,6 +282,7 @@ class projectPlanner(wx.Frame): self.selection = item self._updateListbox() self.OnListSelect(None) + pd.Destroy() self.preview.Refresh() dlg.Destroy() diff --git a/Cura/util/mesh.py b/Cura/util/mesh.py index 799551f8..aed74b79 100644 --- a/Cura/util/mesh.py +++ b/Cura/util/mesh.py @@ -79,7 +79,7 @@ class mesh(object): self.getMinimumZ() - def splitToParts(self): + def splitToParts(self, callback = None): t0 = time.time() print "%f: " % (time.time() - t0), "Splitting a model with %d vertexes." % (len(self.vertexes)) @@ -95,6 +95,8 @@ class mesh(object): tree.insert(e) else: removeDict[idx] = q[0].idx + if callback != None and (idx % 100) == 0: + callback(idx) print "%f: " % (time.time() - t0), "Marked %d duplicate vertexes for removal." % (len(removeDict)) faceList = [] @@ -144,8 +146,8 @@ class mesh(object): def _partAddFacewalk(self, part, faceIdx, doneSet, todoList): f = self._faceList[faceIdx] v0 = self.vertexes[f[0]] - v1 = self.vertexes[f[0]] - v2 = self.vertexes[f[0]] + v1 = self.vertexes[f[1]] + v2 = self.vertexes[f[2]] part.addVertex(v0[0], v0[1], v0[2]) part.addVertex(v1[0], v1[1], v1[2]) part.addVertex(v2[0], v2[1], v2[2]) diff --git a/Cura/util/stl.py b/Cura/util/stl.py index 1ae17fad..e416c033 100644 --- a/Cura/util/stl.py +++ b/Cura/util/stl.py @@ -49,7 +49,7 @@ 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("