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
self.selection = item\r
self._updateListbox()\r
self.OnListSelect(None)\r
+ pd.Destroy()\r
self.preview.Refresh()\r
dlg.Destroy()\r
\r
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))
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 = []
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])
#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]