From 886dac57817dc570483863332e66c746fb06bd17 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 25 Jun 2015 13:54:36 +0200 Subject: [PATCH] Store the disallowed areas as polygons and use those to test for intersection This prevents issues when trying to print larger things Contributes to Asana issue 37107676459484 --- cura/CuraApplication.py | 15 +++------------ cura/PlatformPhysics.py | 13 +++++++++---- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 56a43dfc24..2d388ce78c 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -18,6 +18,7 @@ from UM.Preferences import Preferences from UM.Message import Message from UM.PluginRegistry import PluginRegistry from UM.JobQueue import JobQueue +from UM.Math.Polygon import Polygon from UM.Scene.BoxRenderer import BoxRenderer from UM.Scene.Selection import Selection @@ -466,23 +467,13 @@ class CuraApplication(QtApplication): disallowed_areas = machine.getSettingValueByKey("machine_disallowed_areas") areas = [] if disallowed_areas: - for area in disallowed_areas: - polygon = [] - polygon.append(Vector(area[0][0], 0.2, area[0][1])) - polygon.append(Vector(area[1][0], 0.2, area[1][1])) - polygon.append(Vector(area[2][0], 0.2, area[2][1])) - polygon.append(Vector(area[3][0], 0.2, area[3][1])) - areas.append(polygon) + areas.append(Polygon(numpy.array(area, numpy.float32))) + self._volume.setDisallowedAreas(areas) self._volume.rebuild() - if self.getController().getTool("ScaleTool"): - bbox = self._volume.getBoundingBox() - bbox.setBottom(0.0) - self.getController().getTool("ScaleTool").setMaximumBounds(bbox) - offset = machine.getSettingValueByKey("machine_platform_offset") if offset: self._platform.setPosition(Vector(offset[0], offset[1], offset[2])) diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index 444fe2d3cc..9dcd15ad54 100644 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -94,14 +94,19 @@ class PlatformPhysics: move_vector.setX(overlap[0] * 1.1) move_vector.setZ(overlap[1] * 1.1) + if hasattr(node, "_convex_hull"): + # Check for collisions between disallowed areas and the object + for area in self._build_volume.getDisallowedAreas(): + overlap = node._convex_hull.intersectsPolygon(area) + if overlap is None: + continue + + node._outside_buildarea = True + if move_vector != Vector(): op = PlatformPhysicsOperation.PlatformPhysicsOperation(node, move_vector) op.push() - if node.getBoundingBox().intersectsBox(self._build_volume.getBoundingBox()) == AxisAlignedBox.IntersectionResult.FullIntersection: - op = ScaleToBoundsOperation(node, self._build_volume.getBoundingBox()) - op.push() - def _onToolOperationStarted(self, tool): self._enabled = False