mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 03:35:56 +08:00
Fix the mesh splitter after bug introduced by numpy update.
This commit is contained in:
parent
f21062e575
commit
a25b954204
@ -271,7 +271,9 @@ class projectPlanner(wx.Frame):
|
|||||||
dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
|
dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
filename = dlg.GetPath()
|
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:
|
for part in parts:
|
||||||
partFilename = filename[:filename.rfind('.')] + "_part%d.stl" % (parts.index(part))
|
partFilename = filename[:filename.rfind('.')] + "_part%d.stl" % (parts.index(part))
|
||||||
stl.saveAsSTL(part, partFilename)
|
stl.saveAsSTL(part, partFilename)
|
||||||
@ -280,6 +282,7 @@ class projectPlanner(wx.Frame):
|
|||||||
self.selection = item
|
self.selection = item
|
||||||
self._updateListbox()
|
self._updateListbox()
|
||||||
self.OnListSelect(None)
|
self.OnListSelect(None)
|
||||||
|
pd.Destroy()
|
||||||
self.preview.Refresh()
|
self.preview.Refresh()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class mesh(object):
|
|||||||
|
|
||||||
self.getMinimumZ()
|
self.getMinimumZ()
|
||||||
|
|
||||||
def splitToParts(self):
|
def splitToParts(self, callback = None):
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
|
|
||||||
print "%f: " % (time.time() - t0), "Splitting a model with %d vertexes." % (len(self.vertexes))
|
print "%f: " % (time.time() - t0), "Splitting a model with %d vertexes." % (len(self.vertexes))
|
||||||
@ -95,6 +95,8 @@ class mesh(object):
|
|||||||
tree.insert(e)
|
tree.insert(e)
|
||||||
else:
|
else:
|
||||||
removeDict[idx] = q[0].idx
|
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))
|
print "%f: " % (time.time() - t0), "Marked %d duplicate vertexes for removal." % (len(removeDict))
|
||||||
|
|
||||||
faceList = []
|
faceList = []
|
||||||
@ -144,8 +146,8 @@ class mesh(object):
|
|||||||
def _partAddFacewalk(self, part, faceIdx, doneSet, todoList):
|
def _partAddFacewalk(self, part, faceIdx, doneSet, todoList):
|
||||||
f = self._faceList[faceIdx]
|
f = self._faceList[faceIdx]
|
||||||
v0 = self.vertexes[f[0]]
|
v0 = self.vertexes[f[0]]
|
||||||
v1 = self.vertexes[f[0]]
|
v1 = self.vertexes[f[1]]
|
||||||
v2 = self.vertexes[f[0]]
|
v2 = self.vertexes[f[2]]
|
||||||
part.addVertex(v0[0], v0[1], v0[2])
|
part.addVertex(v0[0], v0[1], v0[2])
|
||||||
part.addVertex(v1[0], v1[1], v1[2])
|
part.addVertex(v1[0], v1[1], v1[2])
|
||||||
part.addVertex(v2[0], v2[1], v2[2])
|
part.addVertex(v2[0], v2[1], v2[2])
|
||||||
|
@ -49,7 +49,7 @@ def saveAsSTL(mesh, filename):
|
|||||||
#Write the STL binary header. This can contain any info, except for "SOLID" at the start.
|
#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'))
|
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.
|
#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):
|
for idx in xrange(0, mesh.vertexCount, 3):
|
||||||
v1 = mesh.origonalVertexes[idx]
|
v1 = mesh.origonalVertexes[idx]
|
||||||
v2 = mesh.origonalVertexes[idx+1]
|
v2 = mesh.origonalVertexes[idx+1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user