chiark / gitweb /
Add support angle setting.
[cura.git] / Cura / util / sliceEngine.py
index 9cd8fc31a8b3a17ca290080adb2339891bd88a17..e968009cda6d170815e9a1ba3204d4fb4c2c093a 100644 (file)
@@ -113,12 +113,14 @@ class Slicer(object):
                return '%0.2f meter %0.0f gram' % (float(self._filamentMM[e]) / 1000.0, self.getFilamentWeight(e) * 1000.0)
 
        def runSlicer(self, scene):
+               if len(scene.objects()) < 1:
+                       return
                extruderCount = 1
                for obj in scene.objects():
                        if scene.checkPlatform(obj):
                                extruderCount = max(extruderCount, len(obj._meshList))
-               if profile.getProfileSetting('support_dual_extrusion') == 'Second extruder':
-                       extruderCount = max(extruderCount, 2)
+
+               extruderCount = max(extruderCount, profile.minimalExtruderCount())
 
                commandList = [getEngineFilename(), '-vv']
                for k, v in self._engineSettings(extruderCount).iteritems():
@@ -148,23 +150,26 @@ class Slicer(object):
                                pos += (objMin + objMax) / 2.0 * 1000
                                commandList += ['-s', 'posx=%d' % int(pos[0]), '-s', 'posy=%d' % int(pos[1])]
 
-                               vertexTotal = 0
+                               vertexTotal = [0] * 4
+                               meshMax = 1
                                for obj in scene.objects():
                                        if scene.checkPlatform(obj):
-                                               for mesh in obj._meshList:
-                                                       vertexTotal += mesh.vertexCount
+                                               meshMax = max(meshMax, len(obj._meshList))
+                                               for n in xrange(0, len(obj._meshList)):
+                                                       vertexTotal[n] += obj._meshList[n].vertexCount
 
-                               f.write(numpy.array([vertexTotal], numpy.int32).tostring())
-                               for obj in scene.objects():
-                                       if scene.checkPlatform(obj):
-                                               for mesh in obj._meshList:
-                                                       vertexes = (numpy.matrix(mesh.vertexes, copy = False) * numpy.matrix(obj._matrix, numpy.float32)).getA()
-                                                       vertexes -= obj._drawOffset
-                                                       vertexes += numpy.array([obj.getPosition()[0], obj.getPosition()[1], 0.0])
-                                                       f.write(vertexes.tostring())
-                                                       hash.update(mesh.vertexes.tostring())
+                               for n in xrange(0, meshMax):
+                                       f.write(numpy.array([vertexTotal[n]], numpy.int32).tostring())
+                                       for obj in scene.objects():
+                                               if scene.checkPlatform(obj):
+                                                       if n < len(obj._meshList):
+                                                               vertexes = (numpy.matrix(obj._meshList[n].vertexes, copy = False) * numpy.matrix(obj._matrix, numpy.float32)).getA()
+                                                               vertexes -= obj._drawOffset
+                                                               vertexes += numpy.array([obj.getPosition()[0], obj.getPosition()[1], 0.0])
+                                                               f.write(vertexes.tostring())
+                                                               hash.update(obj._meshList[n].vertexes.tostring())
 
-                               commandList += ['#']
+                               commandList += ['#' * meshMax]
                                self._objCount = 1
                        else:
                                for n in order:
@@ -275,12 +280,12 @@ class Slicer(object):
                        'moveSpeed': int(profile.getProfileSettingFloat('travel_speed')),
                        'fanSpeedMin': int(profile.getProfileSettingFloat('fan_speed')) if profile.getProfileSetting('fan_enabled') == 'True' else 0,
                        'fanSpeedMax': int(profile.getProfileSettingFloat('fan_speed_max')) if profile.getProfileSetting('fan_enabled') == 'True' else 0,
-                       'supportAngle': int(-1) if profile.getProfileSetting('support') == 'None' else int(60),
+                       'supportAngle': int(-1) if profile.getProfileSetting('support') == 'None' else int(profile.getProfileSettingFloat('support_angle')),
                        'supportEverywhere': int(1) if profile.getProfileSetting('support') == 'Everywhere' else int(0),
                        'supportLineDistance': int(100 * profile.calculateEdgeWidth() * 1000 / profile.getProfileSettingFloat('support_fill_rate')) if profile.getProfileSettingFloat('support_fill_rate') > 0 else -1,
                        'supportXYDistance': int(1000 * profile.getProfileSettingFloat('support_xy_distance')),
                        'supportZDistance': int(1000 * profile.getProfileSettingFloat('support_z_distance')),
-                       'supportExtruder': 0 if profile.getProfileSetting('support_dual_extrusion') == 'First extruder' else (1 if profile.getProfileSetting('support_dual_extrusion') == 'Second extruder' else -1),
+                       'supportExtruder': 0 if profile.getProfileSetting('support_dual_extrusion') == 'First extruder' else (1 if profile.getProfileSetting('support_dual_extrusion') == 'Second extruder' and profile.minimalExtruderCount() > 1 else -1),
                        'retractionAmount': int(profile.getProfileSettingFloat('retraction_amount') * 1000) if profile.getProfileSetting('retraction_enable') == 'True' else 0,
                        'retractionSpeed': int(profile.getProfileSettingFloat('retraction_speed')),
                        'retractionMinimalDistance': int(profile.getProfileSettingFloat('retraction_min_travel') * 1000),
@@ -351,7 +356,7 @@ class Slicer(object):
                if profile.getProfileSetting('spiralize') == 'True':
                        settings['spiralizeMode'] = 1
                if profile.getProfileSetting('wipe_tower') == 'True':
-                       settings['enableWipeTower'] = 1
+                       settings['wipeTowerSize'] = int(math.sqrt(profile.getProfileSettingFloat('wipe_tower_volume') * 1000 * 1000 * 1000 / settings['layerThickness']))
                if profile.getProfileSetting('ooze_shield') == 'True':
                        settings['enableOozeShield'] = 1
                return settings