Fix the mesh splitter after bug introduced by numpy update.

master
daid 2012-07-30 14:21:49 +02:00
parent f21062e575
commit a25b954204
3 changed files with 10 additions and 5 deletions

View File

@ -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()

View 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])

View 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]