mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Move all Cura files into a src/ directory
This commit is contained in:
parent
ffbe66896d
commit
49210587ff
8 changed files with 0 additions and 0 deletions
32
src/ConvexHullJob.py
Normal file
32
src/ConvexHullJob.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
from UM.Job import Job
|
||||
from UM.Application import Application
|
||||
from UM.Math.Polygon import Polygon
|
||||
|
||||
import numpy
|
||||
|
||||
from ConvexHullNode import ConvexHullNode
|
||||
|
||||
class ConvexHullJob(Job):
|
||||
def __init__(self, node):
|
||||
super().__init__()
|
||||
|
||||
self._node = node
|
||||
|
||||
def run(self):
|
||||
if not self._node or not self._node.getMeshData():
|
||||
return
|
||||
|
||||
mesh = self._node.getMeshData()
|
||||
vertexData = mesh.getTransformed(self._node.getWorldTransformation()).getVertices()
|
||||
|
||||
hull = Polygon(numpy.rint(vertexData[:, [0, 2]]).astype(int))
|
||||
|
||||
# First, calculate the normal convex hull around the points
|
||||
hull = hull.getConvexHull()
|
||||
# Then, do a Minkowski hull with a simple 1x1 quad to outset and round the normal convex hull.
|
||||
hull = hull.getMinkowskiHull(Polygon(numpy.array([[-1, -1], [-1, 1], [1, 1], [1, -1]], numpy.float32)))
|
||||
|
||||
hull_node = ConvexHullNode(self._node, hull, Application.getInstance().getController().getScene().getRoot())
|
||||
|
||||
self._node._convex_hull = hull
|
||||
delattr(self._node, "_convex_hull_job")
|
Loading…
Add table
Add a link
Reference in a new issue