chiark / gitweb /
Fix the mesh splitter after bug introduced by numpy update.
authordaid <daid303@gmail.com>
Mon, 30 Jul 2012 12:21:49 +0000 (14:21 +0200)
committerdaid <daid303@gmail.com>
Mon, 30 Jul 2012 12:21:49 +0000 (14:21 +0200)
Cura/gui/projectPlanner.py
Cura/util/mesh.py
Cura/util/stl.py

index 35bed71fc8fdcf9f13b81e30fc6b31c1ecb38c41..fa01ff7604885e4a73c6db8981f552cb4f1678d5 100644 (file)
@@ -271,7 +271,9 @@ class projectPlanner(wx.Frame):
                dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")\r
                if dlg.ShowModal() == wx.ID_OK:\r
                        filename = dlg.GetPath()\r
-                       parts = stl.stlModel().load(filename).splitToParts()\r
+                       model = stl.stlModel().load(filename)\r
+                       pd = wx.ProgressDialog('Splitting model.', 'Splitting model into multiple parts.', model.vertexCount, self, wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME | wx.PD_SMOOTH)\r
+                       parts = model.splitToParts(pd.Update)\r
                        for part in parts:\r
                                partFilename = filename[:filename.rfind('.')] + "_part%d.stl" % (parts.index(part))\r
                                stl.saveAsSTL(part, partFilename)\r
@@ -280,6 +282,7 @@ class projectPlanner(wx.Frame):
                                self.selection = item\r
                                self._updateListbox()\r
                                self.OnListSelect(None)\r
+                       pd.Destroy()\r
                self.preview.Refresh()\r
                dlg.Destroy()\r
        \r
index 799551f870f8b387ee8e2459d03ae3daf8d036b1..aed74b792461eada066bef6b5252792a1b535632 100644 (file)
@@ -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])
index 1ae17fad11744d550652ef29969220a53c65b8cd..e416c033e7f44569f022d1d636b74d78ae872431 100644 (file)
@@ -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("<I", int(mesh.vertexCount/ 3)))
+       f.write(struct.pack("<I", int(mesh.vertexCount / 3)))
        for idx in xrange(0, mesh.vertexCount, 3):
                v1 = mesh.origonalVertexes[idx]
                v2 = mesh.origonalVertexes[idx+1]