chiark / gitweb /
Better sanity checks in raft plugin.
authordaid <daid303@gmail.com>
Wed, 16 May 2012 10:41:16 +0000 (12:41 +0200)
committerdaid <daid303@gmail.com>
Wed, 16 May 2012 10:41:16 +0000 (12:41 +0200)
Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py
Cura/gui/projectPlanner.py

index cf15bd70cd29351978e14adcd9f14b49436ef7b2..230a5f3da620ddeea0850b9c22d05c5a60f8aada 100644 (file)
@@ -585,9 +585,6 @@ class RaftSkein:
 
        def addRaft(self):
                'Add the raft.'
-               if len(self.boundaryLayers) < 1:
-                       print('this should never happen, there are no boundary layers in addRaft')
-                       return
                self.baseLayerThicknessOverLayerThickness = self.repository.baseLayerThicknessOverLayerThickness.value
                baseExtrusionWidth = self.edgeWidth * self.baseLayerThicknessOverLayerThickness
                self.baseStep = baseExtrusionWidth / self.repository.baseInfillDensity.value
@@ -600,6 +597,9 @@ class RaftSkein:
                self.raftOutsetRadius = self.repository.raftMargin.value + self.repository.raftAdditionalMarginOverLengthPercent.value * 0.01 * max(originalExtent.real, originalExtent.imag)
                self.supportOutsetRadius = self.repository.supportMargin.value
                self.setBoundaryLayers()
+               if len(self.boundaryLayers) < 1:
+                       print('this should never happen, there are no boundary layers in addRaft')
+                       return
                outsetSeparateLoops = intercircle.getInsetSeparateLoopsFromLoops(self.boundaryLayers[0].loops, -self.raftOutsetRadius, 0.8)
                self.interfaceIntersectionsTable = {}
                euclidean.addXIntersectionsFromLoopsForTable(outsetSeparateLoops, self.interfaceIntersectionsTable, self.interfaceStep)
@@ -990,7 +990,7 @@ class RaftSkein:
                                if len(endpoints) < 1:
                                        temperatureChangeTimeBeforeNextLayers = self.getTemperatureChangeTime( self.objectNextLayersTemperature )
                                        self.addTemperatureLineIfDifferent( self.objectNextLayersTemperature )
-                                       if self.repository.addRaftElevateNozzleOrbitSetAltitude.value and len( boundaryLayer.loops ) > 0:
+                                       if self.repository.addRaftElevateNozzleOrbitSetAltitude.value and boundaryLayer != None and len( boundaryLayer.loops ) > 0:
                                                self.addOperatingOrbits( boundaryLayer.loops, euclidean.getXYComplexFromVector3( self.oldLocation ), temperatureChangeTimeBeforeNextLayers, layerZ )
                        if len(endpoints) > 0:
                                self.addSupportLayerTemperature( endpoints, layerZ )
index ea643b045b525f90ec95bb2e4eda1ff062cfb7cd..ae7b1dc3732f1c2f09b906577283651fe64b61f0 100644 (file)
@@ -66,6 +66,29 @@ class ProjectObject(stl.stlModel):
                self.centerX = -self.getMinimum().x + 5\r
                self.centerY = -self.getMinimum().y + 5\r
 \r
+       def isSameExceptForPosition(self, other):\r
+               if self.filename != other.filename:\r
+                       return False\r
+               if self.scale != other.scale:\r
+                       return False\r
+               if self.rotate != other.rotate:\r
+                       return False\r
+               if self.flipX != other.flipX:\r
+                       return False\r
+               if self.flipY != other.flipY:\r
+                       return False\r
+               if self.flipZ != other.flipZ:\r
+                       return False\r
+               if self.swapXZ != other.swapXZ:\r
+                       return False\r
+               if self.swapYZ != other.swapYZ:\r
+                       return False\r
+               if self.extruder != other.extruder:\r
+                       return False\r
+               if self.profile != other.profile:\r
+                       return False\r
+               return True\r
+\r
        def updateModelTransform(self):\r
                rotate = self.rotate / 180.0 * math.pi\r
                scaleX = 1.0\r
@@ -545,8 +568,14 @@ class projectPlanner(wx.Frame):
                        action.filename = item.filename\r
                        clearZ = max(clearZ, item.getMaximum().z * item.scale)\r
                        action.clearZ = clearZ\r
+                       action.leaveForNext = False\r
+                       action.usePrevious = False\r
                        actionList.append(action)\r
 \r
+                       if self.list.index(item) > 0 and item.isSameExceptForPosition(self.list[self.list.index(item)-1]):\r
+                               actionList[-2].leaveForNext = True\r
+                               actionList[-1].usePrevious = True\r
+\r
                        if item.profile != None:\r
                                profile.loadGlobalProfileFromString(oldProfile)\r
                \r
@@ -842,29 +871,30 @@ class ProjectSliceProgressWindow(wx.Frame):
                put = profile.setTempOverride\r
                for action in self.actionList:\r
                        wx.CallAfter(self.SetTitle, "Building: [%d/%d]"  % (self.actionList.index(action) + 1, len(self.actionList)))\r
-                       p = subprocess.Popen(action.sliceCmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)\r
-                       line = p.stdout.readline()\r
-               \r
-                       maxValue = 1\r
-                       self.progressLog = []\r
-                       while(len(line) > 0):\r
-                               line = line.rstrip()\r
-                               if line[0:9] == "Progress[" and line[-1:] == "]":\r
-                                       progress = line[9:-1].split(":")\r
-                                       if len(progress) > 2:\r
-                                               maxValue = int(progress[2])\r
-                                       wx.CallAfter(self.SetProgress, progress[0], int(progress[1]), maxValue)\r
-                               else:\r
-                                       print line\r
-                                       self.progressLog.append(line)\r
-                                       wx.CallAfter(self.statusText.SetLabel, line)\r
-                               if self.abort:\r
-                                       p.terminate()\r
-                                       wx.CallAfter(self.statusText.SetLabel, "Aborted by user.")\r
-                                       resultFile.close()\r
-                                       return\r
+                       if not action.usePrevious:\r
+                               p = subprocess.Popen(action.sliceCmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)\r
                                line = p.stdout.readline()\r
-                       self.returnCode = p.wait()\r
+               \r
+                               maxValue = 1\r
+                               self.progressLog = []\r
+                               while(len(line) > 0):\r
+                                       line = line.rstrip()\r
+                                       if line[0:9] == "Progress[" and line[-1:] == "]":\r
+                                               progress = line[9:-1].split(":")\r
+                                               if len(progress) > 2:\r
+                                                       maxValue = int(progress[2])\r
+                                               wx.CallAfter(self.SetProgress, progress[0], int(progress[1]), maxValue)\r
+                                       else:\r
+                                               print line\r
+                                               self.progressLog.append(line)\r
+                                               wx.CallAfter(self.statusText.SetLabel, line)\r
+                                       if self.abort:\r
+                                               p.terminate()\r
+                                               wx.CallAfter(self.statusText.SetLabel, "Aborted by user.")\r
+                                               resultFile.close()\r
+                                               return\r
+                                       line = p.stdout.readline()\r
+                               self.returnCode = p.wait()\r
                        \r
                        put('machine_center_x', action.centerX - self.extruderOffset[action.extruder].x)\r
                        put('machine_center_y', action.centerY - self.extruderOffset[action.extruder].y)\r
@@ -883,13 +913,21 @@ class ProjectSliceProgressWindow(wx.Frame):
                        resultFile.write(';PRINTNR:%d\n' % self.actionList.index(action))\r
                        profile.resetTempOverride()\r
                        \r
-                       f = open(action.filename[: action.filename.rfind('.')] + "_export.project_tmp", "r")\r
-                       data = f.read(4096)\r
-                       while data != '':\r
-                               resultFile.write(data)\r
+                       if not action.usePrevious:\r
+                               f = open(action.filename[: action.filename.rfind('.')] + "_export.project_tmp", "r")\r
                                data = f.read(4096)\r
-                       f.close()\r
-                       os.remove(action.filename[: action.filename.rfind('.')] + "_export.project_tmp")\r
+                               while data != '':\r
+                                       resultFile.write(data)\r
+                                       data = f.read(4096)\r
+                               f.close()\r
+                       else:\r
+                               f = open(action.filename[: action.filename.rfind('.')] + "_export.project_tmp", "r")\r
+                               for line in f:\r
+                                       resultFile.write(line)\r
+                               f.close()\r
+\r
+                       if not action.leaveForNext:\r
+                               os.remove(action.filename[: action.filename.rfind('.')] + "_export.project_tmp")\r
                        \r
                        wx.CallAfter(self.progressGauge.SetValue, 10000)\r
                        self.totalDoneFactor = 0.0\r