Exemple #1
0
    def rebuild(self):
        if self._width == 0 or self._height == 0 or self._depth == 0:
            return

        minW = -self._width / 2
        maxW = self._width / 2
        minH = 0.0
        maxH = self._height
        minD = -self._depth / 2
        maxD = self._depth / 2

        mb = MeshBuilder()

        mb.addLine(Vector(minW, minH, minD), Vector(maxW, minH, minD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(minW, minH, minD), Vector(minW, maxH, minD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, minD), Vector(maxW, maxH, minD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, minD), Vector(maxW, maxH, minD), color = self.VolumeOutlineColor)

        mb.addLine(Vector(minW, minH, maxD), Vector(maxW, minH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(minW, minH, maxD), Vector(minW, maxH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, maxD), Vector(maxW, maxH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, maxD), Vector(maxW, maxH, maxD), color = self.VolumeOutlineColor)

        mb.addLine(Vector(minW, minH, minD), Vector(minW, minH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, minD), Vector(maxW, minH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, minD), Vector(minW, maxH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, maxH, minD), Vector(maxW, maxH, maxD), color = self.VolumeOutlineColor)

        self.setMeshData(mb.getData())

        mb = MeshBuilder()
        mb.addQuad(
            Vector(minW, minH, minD),
            Vector(maxW, minH, minD),
            Vector(maxW, minH, maxD),
            Vector(minW, minH, maxD)
        )
        self._grid_mesh = mb.getData()
        for n in range(0, 6):
            v = self._grid_mesh.getVertex(n)
            self._grid_mesh.setVertexUVCoordinates(n, v[0], v[2])

        if self._disallowed_areas:
            mb = MeshBuilder()
            for area in self._disallowed_areas:
                mb.addQuad(
                    area[0],
                    area[1],
                    area[2],
                    area[3],
                    color = Color(174, 174, 174, 255)
                )

            self._disallowed_area_mesh = mb.getData()
        else:
            self._disallowed_area_mesh = None

        self._aabb = AxisAlignedBox(minimum = Vector(minW, minH - 1.0, minD), maximum = Vector(maxW, maxH, maxD))
Exemple #2
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self._handle_width = 8
        self._handle_height = 14
        self._handle_position = 20

        mb = MeshBuilder()

        mb.addPyramid(width=self._handle_width,
                      height=self._handle_height,
                      depth=self._handle_width,
                      center=Vector(0, self._handle_position, 0),
                      color=ToolHandle.YAxisColor)

        mb.addPyramid(width=self._handle_width,
                      height=self._handle_height,
                      depth=self._handle_width,
                      center=Vector(0, -self._handle_position, 0),
                      color=ToolHandle.YAxisColor,
                      axis=Vector.Unit_X,
                      angle=180)

        mb.addPyramid(width=self._handle_width,
                      height=self._handle_height,
                      depth=self._handle_width,
                      center=Vector(self._handle_position, 0, 0),
                      color=ToolHandle.XAxisColor,
                      axis=Vector.Unit_Z,
                      angle=90)

        mb.addPyramid(width=self._handle_width,
                      height=self._handle_height,
                      depth=self._handle_width,
                      center=Vector(-self._handle_position, 0, 0),
                      color=ToolHandle.XAxisColor,
                      axis=Vector.Unit_Z,
                      angle=-90)

        mb.addPyramid(width=self._handle_width,
                      height=self._handle_height,
                      depth=self._handle_width,
                      center=Vector(0, 0, -self._handle_position),
                      color=ToolHandle.ZAxisColor,
                      axis=Vector.Unit_X,
                      angle=90)

        mb.addPyramid(width=self._handle_width,
                      height=self._handle_height,
                      depth=self._handle_width,
                      center=Vector(0, 0, self._handle_position),
                      color=ToolHandle.ZAxisColor,
                      axis=Vector.Unit_X,
                      angle=-90)

        self.setSolidMesh(mb.getData())
        self.setSelectionMesh(mb.getData())
Exemple #3
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self._inner_radius = 40
        self._outer_radius = 40.5
        self._line_width = 0.5
        self._active_inner_radius = 37
        self._active_outer_radius = 44
        self._active_line_width = 3

        #SOLIDMESH
        mb = MeshBuilder()

        mb.addDonut(inner_radius=self._inner_radius,
                    outer_radius=self._outer_radius,
                    width=self._line_width,
                    color=ToolHandle.ZAxisColor)

        mb.addDonut(inner_radius=self._inner_radius,
                    outer_radius=self._outer_radius,
                    width=self._line_width,
                    axis=Vector.Unit_X,
                    angle=math.pi / 2,
                    color=ToolHandle.YAxisColor)

        mb.addDonut(inner_radius=self._inner_radius,
                    outer_radius=self._outer_radius,
                    width=self._line_width,
                    axis=Vector.Unit_Y,
                    angle=math.pi / 2,
                    color=ToolHandle.XAxisColor)
        self.setSolidMesh(mb.getData())

        #SELECTIONMESH
        mb = MeshBuilder()

        mb.addDonut(inner_radius=self._active_inner_radius,
                    outer_radius=self._active_outer_radius,
                    width=self._active_line_width,
                    color=ToolHandle.ZAxisColor)

        mb.addDonut(inner_radius=self._active_inner_radius,
                    outer_radius=self._active_outer_radius,
                    width=self._active_line_width,
                    axis=Vector.Unit_X,
                    angle=math.pi / 2,
                    color=ToolHandle.YAxisColor)

        mb.addDonut(inner_radius=self._active_inner_radius,
                    outer_radius=self._active_outer_radius,
                    width=self._active_line_width,
                    axis=Vector.Unit_Y,
                    angle=math.pi / 2,
                    color=ToolHandle.XAxisColor)

        self.setSelectionMesh(mb.getData())
Exemple #4
0
    def __init__(self, parent = None):
        super().__init__(parent)

        mb = MeshBuilder()

        mb.addArc(
            radius = 20,
            axis = Vector.Unit_X,
            color = ToolHandle.XAxisColor
        )

        mb.addArc(
            radius = 20,
            axis = Vector.Unit_Y,
            color = ToolHandle.YAxisColor
        )

        mb.addArc(
            radius = 20,
            axis = Vector.Unit_Z,
            color = ToolHandle.ZAxisColor
        )

        self.setLineMesh(mb.getData())

        mb = MeshBuilder()

        mb.addDonut(
            inner_radius = 18,
            outer_radius = 21,
            width = 1,
            color = ToolHandle.ZAxisColor
        )

        mb.addDonut(
            inner_radius = 18,
            outer_radius = 21,
            width = 1,
            axis = Vector.Unit_X,
            angle = math.pi / 2,
            color = ToolHandle.YAxisColor
        )

        mb.addDonut(
            inner_radius = 18,
            outer_radius = 21,
            width = 1,
            axis = Vector.Unit_Y,
            angle = math.pi / 2,
            color = ToolHandle.XAxisColor
        )

        self.setSelectionMesh(mb.getData())
Exemple #5
0
    def createMeshOrJumps(self, make_mesh):
        builder = MeshBuilder()

        for polygon in self._polygons:
            if make_mesh and (polygon.type == Polygon.MoveCombingType or polygon.type == Polygon.MoveRetractionType):
                continue
            if not make_mesh and not (polygon.type == Polygon.MoveCombingType or polygon.type == Polygon.MoveRetractionType):
                continue
            
            poly_color = polygon.getColor()

            points = numpy.copy(polygon.data)
            if polygon.type == Polygon.InfillType or polygon.type == Polygon.SkinType or polygon.type == Polygon.SupportInfillType:
                points[:,1] -= 0.01
            if polygon.type == Polygon.MoveCombingType or polygon.type == Polygon.MoveRetractionType:
                points[:,1] += 0.01

            # Calculate normals for the entire polygon using numpy.
            normals = numpy.copy(points)
            normals[:,1] = 0.0 # We are only interested in 2D normals

            # Calculate the edges between points.
            # The call to numpy.roll shifts the entire array by one so that
            # we end up subtracting each next point from the current, wrapping
            # around. This gives us the edges from the next point to the current
            # point.
            normals[:] = normals[:] - numpy.roll(normals, -1, axis = 0)
            # Calculate the length of each edge using standard Pythagoras
            lengths = numpy.sqrt(normals[:,0] ** 2 + normals[:,2] ** 2)
            # The normal of a 2D vector is equal to its x and y coordinates swapped
            # and then x inverted. This code does that.
            normals[:,[0, 2]] = normals[:,[2, 0]]
            normals[:,0] *= -1

            # Normalize the normals.
            normals[:,0] /= lengths
            normals[:,2] /= lengths

            # Scale all by the line width of the polygon so we can easily offset.
            normals *= (polygon.lineWidth / 2)

            #TODO: Use numpy magic to perform the vertex creation to speed up things.
            for i in range(len(points)):
                start = points[i - 1]
                end = points[i]

                normal = normals[i - 1]

                point1 = Vector(data = start - normal)
                point2 = Vector(data = start + normal)
                point3 = Vector(data = end + normal)
                point4 = Vector(data = end - normal)

                builder.addQuad(point1, point2, point3, point4, color = poly_color)

        return builder.getData()
Exemple #6
0
    def createMesh(self):
        builder = MeshBuilder()

        for polygon in self._polygons:
            poly_color = polygon.getColor()

            points = numpy.copy(polygon.data)
            if polygon.type == Polygon.InfillType or polygon.type == Polygon.SkinType or polygon.type == Polygon.SupportInfillType:
                points[:, 1] -= 0.01

            # Calculate normals for the entire polygon using numpy.
            normals = numpy.copy(points)
            normals[:, 1] = 0.0  # We are only interested in 2D normals

            # Calculate the edges between points.
            # The call to numpy.roll shifts the entire array by one so that
            # we end up subtracting each next point from the current, wrapping
            # around. This gives us the edges from the next point to the current
            # point.
            normals[:] = normals[:] - numpy.roll(normals, -1, axis=0)
            # Calculate the length of each edge using standard Pythagoras
            lengths = numpy.sqrt(normals[:, 0]**2 + normals[:, 2]**2)
            # The normal of a 2D vector is equal to its x and y coordinates swapped
            # and then x inverted. This code does that.
            normals[:, [0, 2]] = normals[:, [2, 0]]
            normals[:, 0] *= -1

            # Normalize the normals.
            normals[:, 0] /= lengths
            normals[:, 2] /= lengths

            # Scale all by the line width of the polygon so we can easily offset.
            normals *= (polygon.lineWidth / 2)

            #TODO: Use numpy magic to perform the vertex creation to speed up things.
            for i in range(len(points)):
                start = points[i - 1]
                end = points[i]

                normal = normals[i - 1]

                point1 = Vector(data=start - normal)
                point2 = Vector(data=start + normal)
                point3 = Vector(data=end + normal)
                point4 = Vector(data=end - normal)

                builder.addQuad(point1,
                                point2,
                                point3,
                                point4,
                                color=poly_color)

        return builder.getData()
Exemple #7
0
    def createHullMesh(self, hull_points):
        # Input checking.
        if len(hull_points) < 3:
            return None

        mesh_builder = MeshBuilder()
        point_first = Vector(hull_points[0][0], self._mesh_height, hull_points[0][1])
        point_previous = Vector(hull_points[1][0], self._mesh_height, hull_points[1][1])
        for point in hull_points[2:]:  # Add the faces in the order of a triangle fan.
            point_new = Vector(point[0], self._mesh_height, point[1])
            mesh_builder.addFace(point_first, point_previous, point_new, color = self._color)
            point_previous = point_new  # Prepare point_previous for the next triangle.

        return mesh_builder.getData()
Exemple #8
0
    def createHullMesh(self, hull_points):
        #Input checking.
        if len(hull_points) < 3:
            return None

        mesh_builder = MeshBuilder()
        point_first = Vector(hull_points[0][0], self._mesh_height, hull_points[0][1])
        point_previous = Vector(hull_points[1][0], self._mesh_height, hull_points[1][1])
        for point in hull_points[2:]: #Add the faces in the order of a triangle fan.
            point_new = Vector(point[0], self._mesh_height, point[1])
            mesh_builder.addFace(point_first, point_previous, point_new, color = self._color)
            point_previous = point_new #Prepare point_previous for the next triangle.

        return mesh_builder.getData()
    def createMeshOrJumps(self, make_mesh):
        builder = MeshBuilder()

        for polygon in self._polygons:
            if make_mesh and (polygon.type == Polygon.MoveCombingType
                              or polygon.type == Polygon.MoveRetractionType):
                continue
            if not make_mesh and not (polygon.type == Polygon.MoveCombingType
                                      or polygon.type
                                      == Polygon.MoveRetractionType):
                continue

            poly_color = polygon.getColor()

            points = numpy.copy(polygon.data)
            if polygon.type == Polygon.InfillType or polygon.type == Polygon.SkinType or polygon.type == Polygon.SupportInfillType:
                points[:, 1] -= 0.01
            if polygon.type == Polygon.MoveCombingType or polygon.type == Polygon.MoveRetractionType:
                points[:, 1] += 0.01

            normals = polygon.getNormals()

            # Scale all by the line width of the polygon so we can easily offset.
            normals *= (polygon.lineWidth / 2)

            #TODO: Use numpy magic to perform the vertex creation to speed up things.
            for i in range(len(points)):
                start = points[i - 1]
                end = points[i]

                normal = normals[i - 1]

                point1 = Vector(data=start - normal)
                point2 = Vector(data=start + normal)
                point3 = Vector(data=end + normal)
                point4 = Vector(data=end - normal)

                builder.addQuad(point1,
                                point2,
                                point3,
                                point4,
                                color=poly_color)

        return builder.getData()
Exemple #10
0
    def createMeshOrJumps(self, make_mesh):
        builder = MeshBuilder()

        for polygon in self._polygons:
            if make_mesh and (polygon.type == LayerPolygon.MoveCombingType or polygon.type == LayerPolygon.MoveRetractionType):
                continue
            if not make_mesh and not (polygon.type == LayerPolygon.MoveCombingType or polygon.type == LayerPolygon.MoveRetractionType):
                continue

            poly_color = polygon.getColor()

            points = numpy.copy(polygon.data)
            if polygon.type == LayerPolygon.InfillType or polygon.type == LayerPolygon.SkinType or polygon.type == LayerPolygon.SupportInfillType:
                points[:,1] -= 0.01
            if polygon.type == LayerPolygon.MoveCombingType or polygon.type == LayerPolygon.MoveRetractionType:
                points[:,1] += 0.01

            normals = polygon.getNormals()

            # Scale all by the line width of the polygon so we can easily offset.
            normals *= (polygon.lineWidth / 2)

            #TODO: Use numpy magic to perform the vertex creation to speed up things.
            for i in range(len(points)):
                start = points[i - 1]
                end = points[i]

                normal = normals[i - 1]

                point1 = Vector(data = start - normal)
                point2 = Vector(data = start + normal)
                point3 = Vector(data = end + normal)
                point4 = Vector(data = end - normal)

                builder.addQuad(point1, point2, point3, point4, color = poly_color)

        return builder.getData()
Exemple #11
0
    def rebuild(self):
        if self._width == 0 or self._height == 0 or self._depth == 0:
            return

        minW = -self._width / 2
        maxW = self._width / 2
        minH = 0.0
        maxH = self._height
        minD = -self._depth / 2
        maxD = self._depth / 2

        mb = MeshBuilder()

        mb.addLine(Vector(minW, minH, minD),
                   Vector(maxW, minH, minD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(minW, minH, minD),
                   Vector(minW, maxH, minD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, minD),
                   Vector(maxW, maxH, minD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, minD),
                   Vector(maxW, maxH, minD),
                   color=self.VolumeOutlineColor)

        mb.addLine(Vector(minW, minH, maxD),
                   Vector(maxW, minH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(minW, minH, maxD),
                   Vector(minW, maxH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, maxD),
                   Vector(maxW, maxH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, maxD),
                   Vector(maxW, maxH, maxD),
                   color=self.VolumeOutlineColor)

        mb.addLine(Vector(minW, minH, minD),
                   Vector(minW, minH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, minD),
                   Vector(maxW, minH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, minD),
                   Vector(minW, maxH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, maxH, minD),
                   Vector(maxW, maxH, maxD),
                   color=self.VolumeOutlineColor)

        self.setMeshData(mb.getData())

        mb = MeshBuilder()
        mb.addQuad(Vector(minW, minH, minD), Vector(maxW, minH, minD),
                   Vector(maxW, minH, maxD), Vector(minW, minH, maxD))
        self._grid_mesh = mb.getData()
        for n in range(0, 6):
            v = self._grid_mesh.getVertex(n)
            self._grid_mesh.setVertexUVCoordinates(n, v[0], v[2])

        disallowed_area_height = 0.2
        disallowed_area_size = 0
        if self._disallowed_areas:
            mb = MeshBuilder()
            color = Color(0.0, 0.0, 0.0, 0.15)
            for polygon in self._disallowed_areas:
                points = polygon.getPoints()
                first = Vector(self._clamp(points[0][0], minW, maxW),
                               disallowed_area_height,
                               self._clamp(points[0][1], minD, maxD))
                previous_point = Vector(self._clamp(points[0][0], minW, maxW),
                                        disallowed_area_height,
                                        self._clamp(points[0][1], minD, maxD))
                for point in points:
                    new_point = Vector(self._clamp(point[0], minW, maxW),
                                       disallowed_area_height,
                                       self._clamp(point[1], minD, maxD))
                    mb.addFace(first, previous_point, new_point, color=color)
                    previous_point = new_point

                # Find the largest disallowed area to exclude it from the maximum scale bounds
                size = abs(numpy.max(points[:, 1]) - numpy.min(points[:, 1]))
                disallowed_area_size = max(size, disallowed_area_size)

            self._disallowed_area_mesh = mb.getData()
        else:
            self._disallowed_area_mesh = None

        self._aabb = AxisAlignedBox(minimum=Vector(minW, minH - 1.0, minD),
                                    maximum=Vector(maxW, maxH, maxD))

        skirt_size = 0.0

        profile = Application.getInstance().getMachineManager(
        ).getActiveProfile()
        if profile:
            skirt_size = self._getSkirtSize(profile)

        scale_to_max_bounds = AxisAlignedBox(
            minimum=Vector(minW + skirt_size, minH,
                           minD + skirt_size + disallowed_area_size),
            maximum=Vector(maxW - skirt_size, maxH,
                           maxD - skirt_size - disallowed_area_size))

        Application.getInstance().getController().getScene(
        )._maximum_bounds = scale_to_max_bounds
Exemple #12
0
    def __init__(self, parent = None):
        super().__init__(parent)

        mb = MeshBuilder()

        mb.addPyramid(
            width = 4,
            height = 7,
            depth = 4,
            center = Vector(0, 10, 0),
            color = ToolHandle.YAxisColor
        )

        mb.addPyramid(
            width = 4,
            height = 7,
            depth = 4,
            center = Vector(0, -10, 0),
            color = ToolHandle.YAxisColor,
            axis = Vector.Unit_X,
            angle = 180
        )

        mb.addPyramid(
            width = 4,
            height = 7,
            depth = 4,
            center = Vector(10, 0, 0),
            color = ToolHandle.XAxisColor,
            axis = Vector.Unit_Z,
            angle = 90
        )

        mb.addPyramid(
            width = 4,
            height = 7,
            depth = 4,
            center = Vector(-10, 0, 0),
            color = ToolHandle.XAxisColor,
            axis = Vector.Unit_Z,
            angle = -90
        )

        mb.addPyramid(
            width = 4,
            height = 7,
            depth = 4,
            center = Vector(0, 0, -10),
            color = ToolHandle.ZAxisColor,
            axis = Vector.Unit_X,
            angle = 90
        )

        mb.addPyramid(
            width = 4,
            height = 7,
            depth = 4,
            center = Vector(0, 0, 10),
            color = ToolHandle.ZAxisColor,
            axis = Vector.Unit_X,
            angle = -90
        )

        self.setSolidMesh(mb.getData())
        self.setSelectionMesh(mb.getData())
Exemple #13
0
    def rebuild(self):
        if self._width == 0 or self._height == 0 or self._depth == 0:
            return

        min_w = -self._width / 2
        max_w = self._width / 2
        min_h = 0.0
        max_h = self._height
        min_d = -self._depth / 2
        max_d = self._depth / 2

        mb = MeshBuilder()

        mb.addLine(Vector(min_w, min_h, min_d), Vector(max_w, min_h, min_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, min_h, min_d), Vector(min_w, max_h, min_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, max_h, min_d), Vector(max_w, max_h, min_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, min_h, min_d), Vector(max_w, max_h, min_d), color = self.VolumeOutlineColor)

        mb.addLine(Vector(min_w, min_h, max_d), Vector(max_w, min_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, min_h, max_d), Vector(min_w, max_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, max_h, max_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, min_h, max_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)

        mb.addLine(Vector(min_w, min_h, min_d), Vector(min_w, min_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, min_h, min_d), Vector(max_w, min_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, max_h, min_d), Vector(min_w, max_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, max_h, min_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)

        self.setMeshData(mb.getData())

        mb = MeshBuilder()
        mb.addQuad(
            Vector(min_w, min_h - 0.2, min_d),
            Vector(max_w, min_h - 0.2, min_d),
            Vector(max_w, min_h - 0.2, max_d),
            Vector(min_w, min_h - 0.2, max_d)
        )
        self._grid_mesh = mb.getData()
        for n in range(0, 6):
            v = self._grid_mesh.getVertex(n)
            self._grid_mesh.setVertexUVCoordinates(n, v[0], v[2])

        disallowed_area_height = 0.1
        disallowed_area_size = 0
        if self._disallowed_areas:
            mb = MeshBuilder()
            color = Color(0.0, 0.0, 0.0, 0.15)
            for polygon in self._disallowed_areas:
                points = polygon.getPoints()
                first = Vector(self._clamp(points[0][0], min_w, max_w), disallowed_area_height, self._clamp(points[0][1], min_d, max_d))
                previous_point = Vector(self._clamp(points[0][0], min_w, max_w), disallowed_area_height, self._clamp(points[0][1], min_d, max_d))
                for point in points:
                    new_point = Vector(self._clamp(point[0], min_w, max_w), disallowed_area_height, self._clamp(point[1], min_d, max_d))
                    mb.addFace(first, previous_point, new_point, color = color)
                    previous_point = new_point

                # Find the largest disallowed area to exclude it from the maximum scale bounds
                size = abs(numpy.max(points[:, 1]) - numpy.min(points[:, 1]))
                disallowed_area_size = max(size, disallowed_area_size)

            self._disallowed_area_mesh = mb.getData()
        else:
            self._disallowed_area_mesh = None

        self._aabb = AxisAlignedBox(minimum = Vector(min_w, min_h - 1.0, min_d), maximum = Vector(max_w, max_h, max_d))

        skirt_size = 0.0

        profile = Application.getInstance().getMachineManager().getActiveProfile()
        if profile:
            skirt_size = self._getSkirtSize(profile)

        scale_to_max_bounds = AxisAlignedBox(
            minimum = Vector(min_w + skirt_size, min_h, min_d + skirt_size + disallowed_area_size),
            maximum = Vector(max_w - skirt_size, max_h, max_d - skirt_size - disallowed_area_size)
        )

        Application.getInstance().getController().getScene()._maximum_bounds = scale_to_max_bounds
Exemple #14
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self._line_width = 0.5
        self._line_length = 40
        self._handle_position = 40
        self._handle_width = 4

        self._active_line_width = 0.8
        self._active_line_length = 40
        self._active_handle_position = 40
        self._active_handle_width = 15

        #SOLIDMESH -> LINES
        mb = MeshBuilder()

        mb.addCube(width=self._line_width,
                   height=self._line_length,
                   depth=self._line_width,
                   center=Vector(0, self._handle_position / 2, 0),
                   color=ToolHandle.YAxisColor)
        mb.addCube(width=self._line_length,
                   height=self._line_width,
                   depth=self._line_width,
                   center=Vector(self._handle_position / 2, 0, 0),
                   color=ToolHandle.XAxisColor)

        mb.addCube(width=self._line_width,
                   height=self._line_width,
                   depth=self._line_length,
                   center=Vector(0, 0, self._handle_position / 2),
                   color=ToolHandle.ZAxisColor)

        #SOLIDMESH -> HANDLES
        mb.addCube(width=self._handle_width,
                   height=self._handle_width,
                   depth=self._handle_width,
                   center=Vector(0, 0, 0),
                   color=ToolHandle.AllAxisColor)

        mb.addCube(width=self._handle_width,
                   height=self._handle_width,
                   depth=self._handle_width,
                   center=Vector(0, self._handle_position, 0),
                   color=ToolHandle.YAxisColor)

        mb.addCube(width=self._handle_width,
                   height=self._handle_width,
                   depth=self._handle_width,
                   center=Vector(self._handle_position, 0, 0),
                   color=ToolHandle.XAxisColor)

        mb.addCube(width=self._handle_width,
                   height=self._handle_width,
                   depth=self._handle_width,
                   center=Vector(0, 0, self._handle_position),
                   color=ToolHandle.ZAxisColor)
        self.setSolidMesh(mb.getData())

        #SELECTIONMESH -> LINES
        mb = MeshBuilder()
        mb.addCube(width=self._active_line_width,
                   height=self._active_line_length,
                   depth=self._active_line_width,
                   center=Vector(0, self._active_handle_position / 2, 0),
                   color=ToolHandle.YAxisColor)

        mb.addCube(width=self._active_line_length,
                   height=self._active_line_width,
                   depth=self._active_line_width,
                   center=Vector(self._active_handle_position / 2, 0, 0),
                   color=ToolHandle.XAxisColor)

        mb.addCube(width=self._active_line_width,
                   height=self._active_line_width,
                   depth=self._active_line_length,
                   center=Vector(0, 0, self._active_handle_position / 2),
                   color=ToolHandle.ZAxisColor)

        #SELECTIONMESH -> HANDLES
        mb.addCube(width=self._active_handle_width,
                   height=self._active_handle_width,
                   depth=self._active_handle_width,
                   center=Vector(0, 0, 0),
                   color=ToolHandle.AllAxisColor)

        mb.addCube(width=self._active_handle_width,
                   height=self._active_handle_width,
                   depth=self._active_handle_width,
                   center=Vector(0, self._active_handle_position, 0),
                   color=ToolHandle.YAxisColor)

        mb.addCube(width=self._active_handle_width,
                   height=self._active_handle_width,
                   depth=self._active_handle_width,
                   center=Vector(self._active_handle_position, 0, 0),
                   color=ToolHandle.XAxisColor)

        mb.addCube(width=self._active_handle_width,
                   height=self._active_handle_width,
                   depth=self._active_handle_width,
                   center=Vector(0, 0, self._active_handle_position),
                   color=ToolHandle.ZAxisColor)

        self.setSelectionMesh(mb.getData())
Exemple #15
0
    def rebuild(self):
        if self._width == 0 or self._height == 0 or self._depth == 0:
            return

        minW = -self._width / 2
        maxW = self._width / 2
        minH = 0.0
        maxH = self._height
        minD = -self._depth / 2
        maxD = self._depth / 2

        mb = MeshBuilder()

        mb.addLine(Vector(minW, minH, minD), Vector(maxW, minH, minD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(minW, minH, minD), Vector(minW, maxH, minD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, minD), Vector(maxW, maxH, minD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, minD), Vector(maxW, maxH, minD), color = self.VolumeOutlineColor)

        mb.addLine(Vector(minW, minH, maxD), Vector(maxW, minH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(minW, minH, maxD), Vector(minW, maxH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, maxD), Vector(maxW, maxH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, maxD), Vector(maxW, maxH, maxD), color = self.VolumeOutlineColor)

        mb.addLine(Vector(minW, minH, minD), Vector(minW, minH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, minD), Vector(maxW, minH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, minD), Vector(minW, maxH, maxD), color = self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, maxH, minD), Vector(maxW, maxH, maxD), color = self.VolumeOutlineColor)

        self.setMeshData(mb.getData())

        mb = MeshBuilder()
        mb.addQuad(
            Vector(minW, minH, minD),
            Vector(maxW, minH, minD),
            Vector(maxW, minH, maxD),
            Vector(minW, minH, maxD)
        )
        self._grid_mesh = mb.getData()
        for n in range(0, 6):
            v = self._grid_mesh.getVertex(n)
            self._grid_mesh.setVertexUVCoordinates(n, v[0], v[2])

        disallowed_area_size = 0
        if self._disallowed_areas:
            mb = MeshBuilder()
            for polygon in self._disallowed_areas:
                points = polygon.getPoints()
                mb.addQuad(
                    Vector(points[0, 0], 0.1, points[0, 1]),
                    Vector(points[1, 0], 0.1, points[1, 1]),
                    Vector(points[2, 0], 0.1, points[2, 1]),
                    Vector(points[3, 0], 0.1, points[3, 1]),
                    color = Color(174, 174, 174, 255)
                )
                # Find the largest disallowed area to exclude it from the maximum scale bounds
                size = abs(numpy.max(points[:, 1]) - numpy.min(points[:, 1]))
                disallowed_area_size = max(size, disallowed_area_size)

            self._disallowed_area_mesh = mb.getData()
        else:
            self._disallowed_area_mesh = None

        self._aabb = AxisAlignedBox(minimum = Vector(minW, minH - 1.0, minD), maximum = Vector(maxW, maxH, maxD))

        settings = Application.getInstance().getActiveMachine()

        skirt_size = 0.0
        if settings.getSettingValueByKey("adhesion_type") == "None":
            skirt_size = settings.getSettingValueByKey("skirt_line_count") * settings.getSettingValueByKey("skirt_line_width") + settings.getSettingValueByKey("skirt_gap")
        elif settings.getSettingValueByKey("adhesion_type") == "Brim":
            skirt_size = settings.getSettingValueByKey("brim_line_count") * settings.getSettingValueByKey("skirt_line_width")
        else:
            skirt_size = settings.getSettingValueByKey("skirt_line_width")

        skirt_size += settings.getSettingValueByKey("skirt_line_width")

        scale_to_max_bounds = AxisAlignedBox(
            minimum = Vector(minW + skirt_size, minH, minD + skirt_size + disallowed_area_size),
            maximum = Vector(maxW - skirt_size, maxH, maxD - skirt_size - disallowed_area_size)
        )

        Application.getInstance().getController().getScene()._maximum_bounds = scale_to_max_bounds
Exemple #16
0
    def _rebuild(self):
        mb = MeshBuilder()

        #SOLIDMESH -> LINES
        if self.YAxis in self._enabled_axis:
            mb.addCube(width=self._lineWidth,
                       height=self._lineLength,
                       depth=self._lineWidth,
                       center=Vector(0, self._handlePosition / 2, 0),
                       color=ToolHandle.YAxisColor)
        if self.XAxis in self._enabled_axis:
            mb.addCube(width=self._lineLength,
                       height=self._lineWidth,
                       depth=self._lineWidth,
                       center=Vector(self._handlePosition / 2, 0, 0),
                       color=ToolHandle.XAxisColor)

        if self.ZAxis in self._enabled_axis:
            mb.addCube(width=self._lineWidth,
                       height=self._lineWidth,
                       depth=self._lineLength,
                       center=Vector(0, 0, self._handlePosition / 2),
                       color=ToolHandle.ZAxisColor)

        #SOLIDMESH -> HANDLES
        if self.YAxis in self._enabled_axis:
            mb.addPyramid(width=self._handleWidth,
                          height=self._handleHeight,
                          depth=self._handleWidth,
                          center=Vector(0, self._handlePosition, 0),
                          color=ToolHandle.YAxisColor)

        if self.XAxis in self._enabled_axis:
            mb.addPyramid(width=self._handleWidth,
                          height=self._handleHeight,
                          depth=self._handleWidth,
                          center=Vector(self._handlePosition, 0, 0),
                          color=ToolHandle.XAxisColor,
                          axis=Vector.Unit_Z,
                          angle=90)

        if self.ZAxis in self._enabled_axis:
            mb.addPyramid(width=self._handleWidth,
                          height=self._handleHeight,
                          depth=self._handleWidth,
                          center=Vector(0, 0, self._handlePosition),
                          color=ToolHandle.ZAxisColor,
                          axis=Vector.Unit_X,
                          angle=-90)

        self.setSolidMesh(mb.getData())

        mb = MeshBuilder()
        #ACTIVEMESH -> LINES
        if self.YAxis in self._enabled_axis:
            mb.addCube(width=self._activeLineWidth,
                       height=self._activeLineLength,
                       depth=self._activeLineWidth,
                       center=Vector(0, self._activeHandlePosition / 2, 0),
                       color=ToolHandle.YAxisColor)
        if self.XAxis in self._enabled_axis:
            mb.addCube(width=self._activeLineLength,
                       height=self._activeLineWidth,
                       depth=self._activeLineWidth,
                       center=Vector(self._activeHandlePosition / 2, 0, 0),
                       color=ToolHandle.XAxisColor)

        if self.ZAxis in self._enabled_axis:
            mb.addCube(width=self._activeLineWidth,
                       height=self._activeLineWidth,
                       depth=self._activeLineLength,
                       center=Vector(0, 0, self._activeHandlePosition / 2),
                       color=ToolHandle.ZAxisColor)

        #SELECTIONMESH -> HANDLES
        mb.addCube(width=self._activeHandleWidth,
                   height=self._activeHandleWidth,
                   depth=self._activeHandleWidth,
                   center=Vector(0, 0, 0),
                   color=ToolHandle.AllAxisColor)

        mb.addCube(width=self._activeHandleWidth,
                   height=self._activeHandleWidth,
                   depth=self._activeHandleWidth,
                   center=Vector(0, self._activeHandlePosition, 0),
                   color=ToolHandle.YAxisColor)

        mb.addCube(width=self._activeHandleWidth,
                   height=self._activeHandleWidth,
                   depth=self._activeHandleWidth,
                   center=Vector(self._activeHandlePosition, 0, 0),
                   color=ToolHandle.XAxisColor)

        mb.addCube(width=self._activeHandleWidth,
                   height=self._activeHandleWidth,
                   depth=self._activeHandleWidth,
                   center=Vector(0, 0, self._activeHandlePosition),
                   color=ToolHandle.ZAxisColor)
        self.setSelectionMesh(mb.getData())
Exemple #17
0
    def __init__(self, parent = None):
        super().__init__(parent)

        lines = MeshData()
        lines.addVertex(0, 0, 0)
        lines.addVertex(0, 20, 0)
        lines.addVertex(0, 0, 0)
        lines.addVertex(20, 0, 0)
        lines.addVertex(0, 0, 0)
        lines.addVertex(0, 0, 20)

        lines.setVertexColor(0, ToolHandle.YAxisColor)
        lines.setVertexColor(1, ToolHandle.YAxisColor)
        lines.setVertexColor(2, ToolHandle.XAxisColor)
        lines.setVertexColor(3, ToolHandle.XAxisColor)
        lines.setVertexColor(4, ToolHandle.ZAxisColor)
        lines.setVertexColor(5, ToolHandle.ZAxisColor)

        self.setLineMesh(lines)

        mb = MeshBuilder()

        mb.addCube(
            width = 2,
            height = 2,
            depth = 2,
            center = Vector(0, 0, 0),
            color = ToolHandle.AllAxisColor
        )

        mb.addCube(
            width = 2,
            height = 2,
            depth = 2,
            center = Vector(0, 20, 0),
            color = ToolHandle.YAxisColor
        )

        mb.addCube(
            width = 2,
            height = 2,
            depth = 2,
            center = Vector(20, 0, 0),
            color = ToolHandle.XAxisColor
        )

        mb.addCube(
            width = 2,
            height = 2,
            depth = 2,
            center = Vector(0, 0, 20),
            color = ToolHandle.ZAxisColor
        )

        self.setSolidMesh(mb.getData())

        mb = MeshBuilder()

        mb.addCube(
            width = 4,
            height = 20,
            depth = 4,
            center = Vector(0, 10, 0),
            color = ToolHandle.YAxisColor
        )

        mb.addCube(
            width = 4,
            height = 4,
            depth = 4,
            center = Vector(0, 20, 0),
            color = ToolHandle.YAxisColor
        )

        mb.addCube(
            width = 20,
            height = 4,
            depth = 4,
            center = Vector(10, 0, 0),
            color = ToolHandle.XAxisColor
        )

        mb.addCube(
            width = 4,
            height = 4,
            depth = 4,
            center = Vector(20, 0, 0),
            color = ToolHandle.XAxisColor
        )

        mb.addCube(
            width = 4,
            height = 4,
            depth = 20,
            center = Vector(0, 0, 10),
            color = ToolHandle.ZAxisColor
        )

        mb.addCube(
            width = 4,
            height = 4,
            depth = 4,
            center = Vector(0, 0, 20),
            color = ToolHandle.ZAxisColor
        )

        mb.addCube(
            width = 8,
            height = 8,
            depth = 8,
            center = Vector(0, 0, 0),
            color = ToolHandle.AllAxisColor
        )

        self.setSelectionMesh(mb.getData())
    def __init__(self, parent = None):
        super().__init__(parent)
        self._innerRadius = 40
        self._outerRadius = 40.5
        self._lineWidth = 0.5
        self._activeInnerRadius = 37
        self._activeOuterRadius = 44
        self._activeLineWidth = 3

        #SOLIDMESH
        mb = MeshBuilder()

        mb.addDonut(
            inner_radius = self._innerRadius,
            outer_radius = self._outerRadius,
            width = self._lineWidth,
            color = ToolHandle.ZAxisColor
        )

        mb.addDonut(
            inner_radius = self._innerRadius,
            outer_radius = self._outerRadius,
            width = self._lineWidth,
            axis = Vector.Unit_X,
            angle = math.pi / 2,
            color = ToolHandle.YAxisColor
        )

        mb.addDonut(
            inner_radius = self._innerRadius,
            outer_radius = self._outerRadius,
            width = self._lineWidth,
            axis = Vector.Unit_Y,
            angle = math.pi / 2,
            color = ToolHandle.XAxisColor
        )
        self.setSolidMesh(mb.getData())

        #SELECTIONMESH
        mb = MeshBuilder()

        mb.addDonut(
            inner_radius = self._activeInnerRadius,
            outer_radius = self._activeOuterRadius,
            width = self._activeLineWidth,
            color = ToolHandle.ZAxisColor
        )

        mb.addDonut(
            inner_radius = self._activeInnerRadius,
            outer_radius = self._activeOuterRadius,
            width = self._activeLineWidth,
            axis = Vector.Unit_X,
            angle = math.pi / 2,
            color = ToolHandle.YAxisColor
        )

        mb.addDonut(
            inner_radius = self._activeInnerRadius,
            outer_radius = self._activeOuterRadius,
            width = self._activeLineWidth,
            axis = Vector.Unit_Y,
            angle = math.pi / 2,
            color = ToolHandle.XAxisColor
        )

        self.setSelectionMesh(mb.getData())
    def _rebuild(self):
        lines = MeshData()

        offset = 0
        if self.YAxis in self._enabled_axis:
            lines.addVertex(0, 0, 0)
            lines.addVertex(0, 20, 0)
            lines.setVertexColor(offset, ToolHandle.YAxisColor)
            lines.setVertexColor(offset + 1, ToolHandle.YAxisColor)
            offset += 2

        if self.XAxis in self._enabled_axis:
            lines.addVertex(0, 0, 0)
            lines.addVertex(20, 0, 0)
            lines.setVertexColor(offset, ToolHandle.XAxisColor)
            lines.setVertexColor(offset + 1, ToolHandle.XAxisColor)
            offset += 2

        if self.ZAxis in self._enabled_axis:
            lines.addVertex(0, 0, 0)
            lines.addVertex(0, 0, 20)
            lines.setVertexColor(offset, ToolHandle.ZAxisColor)
            lines.setVertexColor(offset + 1, ToolHandle.ZAxisColor)
            offset += 2

        self.setLineMesh(lines)

        mb = MeshBuilder()

        if self.YAxis in self._enabled_axis:
            mb.addPyramid(
                width = 2,
                height = 4,
                depth = 2,
                center = Vector(0, 20, 0),
                color = ToolHandle.YAxisColor
            )

        if self.XAxis in self._enabled_axis:
            mb.addPyramid(
                width = 2,
                height = 4,
                depth = 2,
                center = Vector(20, 0, 0),
                color = ToolHandle.XAxisColor,
                axis = Vector.Unit_Z,
                angle = 90
            )

        if self.ZAxis in self._enabled_axis:
            mb.addPyramid(
                width = 2,
                height = 4,
                depth = 2,
                center = Vector(0, 0, 20),
                color = ToolHandle.ZAxisColor,
                axis = Vector.Unit_X,
                angle = -90
            )

        self.setSolidMesh(mb.getData())

        mb = MeshBuilder()

        if self.YAxis in self._enabled_axis:
            mb.addCube(
                width = 4,
                height = 20,
                depth = 4,
                center = Vector(0, 10, 0),
                color = ToolHandle.YAxisColor
            )

            mb.addPyramid(
                width = 4,
                height = 8,
                depth = 4,
                center = Vector(0, 20, 0),
                color = ToolHandle.YAxisColor
            )

        if self.XAxis in self._enabled_axis:
            mb.addCube(
                width = 20,
                height = 4,
                depth = 4,
                center = Vector(10, 0, 0),
                color = ToolHandle.XAxisColor
            )

            mb.addPyramid(
                width = 4,
                height = 8,
                depth = 4,
                center = Vector(20, 0, 0),
                color = ToolHandle.XAxisColor,
                axis = Vector.Unit_Z,
                angle = 90
            )

        if self.ZAxis in self._enabled_axis:
            mb.addCube(
                width = 4,
                height = 4,
                depth = 20,
                center = Vector(0, 0, 10),
                color = ToolHandle.ZAxisColor
            )

            mb.addPyramid(
                width = 4,
                height = 8,
                depth = 4,
                center = Vector(0, 0, 20),
                color = ToolHandle.ZAxisColor,
                axis = Vector.Unit_X,
                angle = -90
            )

        self.setSelectionMesh(mb.getData())
Exemple #20
0
    def rebuild(self):
        if self._width == 0 or self._height == 0 or self._depth == 0:
            return

        minW = -self._width / 2
        maxW = self._width / 2
        minH = 0.0
        maxH = self._height
        minD = -self._depth / 2
        maxD = self._depth / 2

        mb = MeshBuilder()

        mb.addLine(Vector(minW, minH, minD),
                   Vector(maxW, minH, minD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(minW, minH, minD),
                   Vector(minW, maxH, minD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, minD),
                   Vector(maxW, maxH, minD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, minD),
                   Vector(maxW, maxH, minD),
                   color=self.VolumeOutlineColor)

        mb.addLine(Vector(minW, minH, maxD),
                   Vector(maxW, minH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(minW, minH, maxD),
                   Vector(minW, maxH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, maxD),
                   Vector(maxW, maxH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, maxD),
                   Vector(maxW, maxH, maxD),
                   color=self.VolumeOutlineColor)

        mb.addLine(Vector(minW, minH, minD),
                   Vector(minW, minH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, minH, minD),
                   Vector(maxW, minH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(minW, maxH, minD),
                   Vector(minW, maxH, maxD),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(maxW, maxH, minD),
                   Vector(maxW, maxH, maxD),
                   color=self.VolumeOutlineColor)

        self.setMeshData(mb.getData())

        mb = MeshBuilder()
        mb.addQuad(Vector(minW, minH, minD), Vector(maxW, minH, minD),
                   Vector(maxW, minH, maxD), Vector(minW, minH, maxD))
        self._grid_mesh = mb.getData()
        for n in range(0, 6):
            v = self._grid_mesh.getVertex(n)
            self._grid_mesh.setVertexUVCoordinates(n, v[0], v[2])

        disallowed_area_size = 0
        if self._disallowed_areas:
            mb = MeshBuilder()
            for polygon in self._disallowed_areas:
                points = polygon.getPoints()
                mb.addQuad(Vector(points[0, 0], 0.1, points[0, 1]),
                           Vector(points[1, 0], 0.1, points[1, 1]),
                           Vector(points[2, 0], 0.1, points[2, 1]),
                           Vector(points[3, 0], 0.1, points[3, 1]),
                           color=Color(174, 174, 174, 255))
                # Find the largest disallowed area to exclude it from the maximum scale bounds
                size = abs(numpy.max(points[:, 1]) - numpy.min(points[:, 1]))
                disallowed_area_size = max(size, disallowed_area_size)

            self._disallowed_area_mesh = mb.getData()
        else:
            self._disallowed_area_mesh = None

        self._aabb = AxisAlignedBox(minimum=Vector(minW, minH - 1.0, minD),
                                    maximum=Vector(maxW, maxH, maxD))

        settings = Application.getInstance().getActiveMachine()

        skirt_size = 0.0
        if settings.getSettingValueByKey("adhesion_type") == "None":
            skirt_size = settings.getSettingValueByKey(
                "skirt_line_count") * settings.getSettingValueByKey(
                    "skirt_line_width") + settings.getSettingValueByKey(
                        "skirt_gap")
        elif settings.getSettingValueByKey("adhesion_type") == "Brim":
            skirt_size = settings.getSettingValueByKey(
                "brim_line_count") * settings.getSettingValueByKey(
                    "skirt_line_width")
        else:
            skirt_size = settings.getSettingValueByKey("skirt_line_width")

        skirt_size += settings.getSettingValueByKey("skirt_line_width")

        scale_to_max_bounds = AxisAlignedBox(
            minimum=Vector(minW + skirt_size, minH,
                           minD + skirt_size + disallowed_area_size),
            maximum=Vector(maxW - skirt_size, maxH,
                           maxD - skirt_size - disallowed_area_size))

        Application.getInstance().getController().getScene(
        )._maximum_bounds = scale_to_max_bounds
Exemple #21
0
    def rebuild(self):
        if self._width == 0 or self._height == 0 or self._depth == 0:
            return

        min_w = -self._width / 2
        max_w = self._width / 2
        min_h = 0.0
        max_h = self._height
        min_d = -self._depth / 2
        max_d = self._depth / 2

        mb = MeshBuilder()

        mb.addLine(Vector(min_w, min_h, min_d), Vector(max_w, min_h, min_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, min_h, min_d), Vector(min_w, max_h, min_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, max_h, min_d), Vector(max_w, max_h, min_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, min_h, min_d), Vector(max_w, max_h, min_d), color = self.VolumeOutlineColor)

        mb.addLine(Vector(min_w, min_h, max_d), Vector(max_w, min_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, min_h, max_d), Vector(min_w, max_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, max_h, max_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, min_h, max_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)

        mb.addLine(Vector(min_w, min_h, min_d), Vector(min_w, min_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, min_h, min_d), Vector(max_w, min_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, max_h, min_d), Vector(min_w, max_h, max_d), color = self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, max_h, min_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)

        self.setMeshData(mb.getData())

        mb = MeshBuilder()
        mb.addQuad(
            Vector(min_w, min_h - 0.2, min_d),
            Vector(max_w, min_h - 0.2, min_d),
            Vector(max_w, min_h - 0.2, max_d),
            Vector(min_w, min_h - 0.2, max_d)
        )
        self._grid_mesh = mb.getData()
        for n in range(0, 6):
            v = self._grid_mesh.getVertex(n)
            self._grid_mesh.setVertexUVCoordinates(n, v[0], v[2])

        disallowed_area_height = 0.1
        disallowed_area_size = 0
        if self._disallowed_areas:
            mb = MeshBuilder()
            color = Color(0.0, 0.0, 0.0, 0.15)
            for polygon in self._disallowed_areas:
                points = polygon.getPoints()
                first = Vector(self._clamp(points[0][0], min_w, max_w), disallowed_area_height, self._clamp(points[0][1], min_d, max_d))
                previous_point = Vector(self._clamp(points[0][0], min_w, max_w), disallowed_area_height, self._clamp(points[0][1], min_d, max_d))
                for point in points:
                    new_point = Vector(self._clamp(point[0], min_w, max_w), disallowed_area_height, self._clamp(point[1], min_d, max_d))
                    mb.addFace(first, previous_point, new_point, color = color)
                    previous_point = new_point
                # Find the largest disallowed area to exclude it from the maximum scale bounds.
                # This is a very nasty hack. This pretty much only works for UM machines. This disallowed area_size needs
                # A -lot- of rework at some point in the future: TODO
                if numpy.min(points[:, 1]) >= 0: # This filters out all areas that have points to the left of the centre. This is done to filter the skirt area.
                    size = abs(numpy.max(points[:, 1]) - numpy.min(points[:, 1]))
                else:
                    size = 0
                disallowed_area_size = max(size, disallowed_area_size)

            self._disallowed_area_mesh = mb.getData()
        else:
            self._disallowed_area_mesh = None

        self._aabb = AxisAlignedBox(minimum = Vector(min_w, min_h - 1.0, min_d), maximum = Vector(max_w, max_h, max_d))

        skirt_size = 0.0

        profile = Application.getInstance().getMachineManager().getWorkingProfile()
        if profile:
            skirt_size = self._getSkirtSize(profile)

        # As this works better for UM machines, we only add the dissallowed_area_size for the z direction.
        # This is probably wrong in all other cases. TODO!
        # The +1 and -1 is added as there is always a bit of extra room required to work properly.
        scale_to_max_bounds = AxisAlignedBox(
            minimum = Vector(min_w + skirt_size + 1, min_h, min_d + disallowed_area_size - skirt_size + 1),
            maximum = Vector(max_w - skirt_size - 1, max_h, max_d - disallowed_area_size + skirt_size - 1)
        )

        Application.getInstance().getController().getScene()._maximum_bounds = scale_to_max_bounds
    def rebuild(self):
        if self._width == 0 or self._height == 0 or self._depth == 0:
            return

        min_w = -self._width / 2
        max_w = self._width / 2
        min_h = 0.0
        max_h = self._height
        min_d = -self._depth / 2
        max_d = self._depth / 2

        mb = MeshBuilder()

        mb.addLine(Vector(min_w, min_h, min_d),
                   Vector(max_w, min_h, min_d),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, min_h, min_d),
                   Vector(min_w, max_h, min_d),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, max_h, min_d),
                   Vector(max_w, max_h, min_d),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, min_h, min_d),
                   Vector(max_w, max_h, min_d),
                   color=self.VolumeOutlineColor)

        mb.addLine(Vector(min_w, min_h, max_d),
                   Vector(max_w, min_h, max_d),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, min_h, max_d),
                   Vector(min_w, max_h, max_d),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, max_h, max_d),
                   Vector(max_w, max_h, max_d),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, min_h, max_d),
                   Vector(max_w, max_h, max_d),
                   color=self.VolumeOutlineColor)

        mb.addLine(Vector(min_w, min_h, min_d),
                   Vector(min_w, min_h, max_d),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, min_h, min_d),
                   Vector(max_w, min_h, max_d),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(min_w, max_h, min_d),
                   Vector(min_w, max_h, max_d),
                   color=self.VolumeOutlineColor)
        mb.addLine(Vector(max_w, max_h, min_d),
                   Vector(max_w, max_h, max_d),
                   color=self.VolumeOutlineColor)

        self.setMeshData(mb.getData())

        mb = MeshBuilder()
        mb.addQuad(Vector(min_w, min_h - 0.2, min_d),
                   Vector(max_w, min_h - 0.2, min_d),
                   Vector(max_w, min_h - 0.2, max_d),
                   Vector(min_w, min_h - 0.2, max_d))
        self._grid_mesh = mb.getData()
        for n in range(0, 6):
            v = self._grid_mesh.getVertex(n)
            self._grid_mesh.setVertexUVCoordinates(n, v[0], v[2])

        disallowed_area_height = 0.1
        disallowed_area_size = 0
        if self._disallowed_areas:
            mb = MeshBuilder()
            color = Color(0.0, 0.0, 0.0, 0.15)
            for polygon in self._disallowed_areas:
                points = polygon.getPoints()
                first = Vector(self._clamp(points[0][0], min_w, max_w),
                               disallowed_area_height,
                               self._clamp(points[0][1], min_d, max_d))
                previous_point = Vector(
                    self._clamp(points[0][0], min_w, max_w),
                    disallowed_area_height,
                    self._clamp(points[0][1], min_d, max_d))
                for point in points:
                    new_point = Vector(self._clamp(point[0], min_w, max_w),
                                       disallowed_area_height,
                                       self._clamp(point[1], min_d, max_d))
                    mb.addFace(first, previous_point, new_point, color=color)
                    previous_point = new_point
                # Find the largest disallowed area to exclude it from the maximum scale bounds.
                # This is a very nasty hack. This pretty much only works for UM machines. This disallowed area_size needs
                # A -lot- of rework at some point in the future: TODO
                if numpy.min(
                        points[:, 1]
                ) >= 0:  # This filters out all areas that have points to the left of the centre. This is done to filter the skirt area.
                    size = abs(
                        numpy.max(points[:, 1]) - numpy.min(points[:, 1]))
                else:
                    size = 0
                disallowed_area_size = max(size, disallowed_area_size)

            self._disallowed_area_mesh = mb.getData()
        else:
            self._disallowed_area_mesh = None

        self._aabb = AxisAlignedBox(minimum=Vector(min_w, min_h - 1.0, min_d),
                                    maximum=Vector(max_w, max_h, max_d))

        skirt_size = 0.0

        profile = Application.getInstance().getMachineManager(
        ).getWorkingProfile()
        if profile:
            skirt_size = self._getSkirtSize(profile)

        # As this works better for UM machines, we only add the dissallowed_area_size for the z direction.
        # This is probably wrong in all other cases. TODO!
        # The +1 and -1 is added as there is always a bit of extra room required to work properly.
        scale_to_max_bounds = AxisAlignedBox(
            minimum=Vector(min_w + skirt_size + 1, min_h,
                           min_d + disallowed_area_size - skirt_size + 1),
            maximum=Vector(max_w - skirt_size - 1, max_h,
                           max_d - disallowed_area_size + skirt_size - 1))

        Application.getInstance().getController().getScene(
        )._maximum_bounds = scale_to_max_bounds
    def _rebuild(self):
        mb = MeshBuilder()

        #SOLIDMESH -> LINES
        if self.YAxis in self._enabled_axis:
            mb.addCube(
                width = self._lineWidth,
                height = self._lineLength,
                depth = self._lineWidth,
                center = Vector(0, self._handlePosition/2, 0),
                color = ToolHandle.YAxisColor
            )
        if self.XAxis in self._enabled_axis:
            mb.addCube(
                width = self._lineLength,
                height = self._lineWidth,
                depth = self._lineWidth,
                center = Vector(self._handlePosition/2, 0, 0),
                color = ToolHandle.XAxisColor
            )

        if self.ZAxis in self._enabled_axis:
            mb.addCube(
                width = self._lineWidth,
                height = self._lineWidth,
                depth = self._lineLength,
                center = Vector(0, 0, self._handlePosition/2),
                color = ToolHandle.ZAxisColor
            )

        #SOLIDMESH -> HANDLES
        if self.YAxis in self._enabled_axis:
            mb.addPyramid(
                width = self._handleWidth,
                height = self._handleHeight,
                depth = self._handleWidth,
                center = Vector(0, self._handlePosition, 0),
                color = ToolHandle.YAxisColor
            )

        if self.XAxis in self._enabled_axis:
            mb.addPyramid(
                width = self._handleWidth,
                height = self._handleHeight,
                depth = self._handleWidth,
                center = Vector(self._handlePosition, 0, 0),
                color = ToolHandle.XAxisColor,
                axis = Vector.Unit_Z,
                angle = 90
            )

        if self.ZAxis in self._enabled_axis:
            mb.addPyramid(
                width = self._handleWidth,
                height = self._handleHeight,
                depth = self._handleWidth,
                center = Vector(0, 0, self._handlePosition),
                color = ToolHandle.ZAxisColor,
                axis = Vector.Unit_X,
                angle = -90
            )

        self.setSolidMesh(mb.getData())

        mb = MeshBuilder()
        #ACTIVEMESH -> LINES
        if self.YAxis in self._enabled_axis:
            mb.addCube(
                width = self._activeLineWidth,
                height = self._activeLineLength,
                depth = self._activeLineWidth,
                center = Vector(0, self._activeHandlePosition/2, 0),
                color = ToolHandle.YAxisColor
            )
        if self.XAxis in self._enabled_axis:
            mb.addCube(
                width = self._activeLineLength,
                height = self._activeLineWidth,
                depth = self._activeLineWidth,
                center = Vector(self._activeHandlePosition/2, 0, 0),
                color = ToolHandle.XAxisColor
            )

        if self.ZAxis in self._enabled_axis:
            mb.addCube(
                width = self._activeLineWidth,
                height = self._activeLineWidth,
                depth = self._activeLineLength,
                center = Vector(0, 0, self._activeHandlePosition/2),
                color = ToolHandle.ZAxisColor
            )

        #SELECTIONMESH -> HANDLES
        mb.addCube(
            width = self._activeHandleWidth,
            height = self._activeHandleWidth,
            depth = self._activeHandleWidth,
            center = Vector(0, 0, 0),
            color = ToolHandle.AllAxisColor
        )

        mb.addCube(
            width = self._activeHandleWidth,
            height = self._activeHandleWidth,
            depth = self._activeHandleWidth,
            center = Vector(0, self._activeHandlePosition, 0),
            color = ToolHandle.YAxisColor
        )

        mb.addCube(
            width = self._activeHandleWidth,
            height = self._activeHandleWidth,
            depth = self._activeHandleWidth,
            center = Vector(self._activeHandlePosition, 0, 0),
            color = ToolHandle.XAxisColor
        )

        mb.addCube(
            width = self._activeHandleWidth,
            height = self._activeHandleWidth,
            depth = self._activeHandleWidth,
            center = Vector(0, 0, self._activeHandlePosition),
            color = ToolHandle.ZAxisColor
        )
        self.setSelectionMesh(mb.getData())
Exemple #24
0
    def __init__(self, parent = None):
        super().__init__(parent)
        self._handle_width = 8
        self._handle_height = 14
        self._handle_position = 20

        mb = MeshBuilder()

        mb.addPyramid(
            width = self._handle_width,
            height = self._handle_height,
            depth = self._handle_width,
            center = Vector(0, self._handle_position, 0),
            color = ToolHandle.YAxisColor
        )

        mb.addPyramid(
            width = self._handle_width,
            height = self._handle_height,
            depth = self._handle_width,
            center = Vector(0, -self._handle_position, 0),
            color = ToolHandle.YAxisColor,
            axis = Vector.Unit_X,
            angle = 180
        )

        mb.addPyramid(
            width = self._handle_width,
            height = self._handle_height,
            depth = self._handle_width,
            center = Vector(self._handle_position, 0, 0),
            color = ToolHandle.XAxisColor,
            axis = Vector.Unit_Z,
            angle = 90
        )

        mb.addPyramid(
            width = self._handle_width,
            height = self._handle_height,
            depth = self._handle_width,
            center = Vector(-self._handle_position, 0, 0),
            color = ToolHandle.XAxisColor,
            axis = Vector.Unit_Z,
            angle = -90
        )

        mb.addPyramid(
            width = self._handle_width,
            height = self._handle_height,
            depth = self._handle_width,
            center = Vector(0, 0, -self._handle_position),
            color = ToolHandle.ZAxisColor,
            axis = Vector.Unit_X,
            angle = 90
        )

        mb.addPyramid(
            width = self._handle_width,
            height = self._handle_height,
            depth = self._handle_width,
            center = Vector(0, 0, self._handle_position),
            color = ToolHandle.ZAxisColor,
            axis = Vector.Unit_X,
            angle = -90
        )

        self.setSolidMesh(mb.getData())
        self.setSelectionMesh(mb.getData())
Exemple #25
0
    def __init__(self, parent = None):
        super().__init__(parent)

        self._lineWidth = 0.5
        self._lineLength= 40
        self._handlePosition = 40
        self._handleWidth = 4

        self._activeLineWidth = 0.8
        self._activeLineLength = 40
        self._activeHandlePosition = 40
        self._activeHandleWidth = 15

        #SOLIDMESH -> LINES
        mb = MeshBuilder()

        mb.addCube(
            width = self._lineWidth,
            height = self._lineLength,
            depth = self._lineWidth,
            center = Vector(0, self._handlePosition/2, 0),
            color = ToolHandle.YAxisColor
        )
        mb.addCube(
            width = self._lineLength,
            height = self._lineWidth,
            depth = self._lineWidth,
            center = Vector(self._handlePosition/2, 0, 0),
            color = ToolHandle.XAxisColor
        )

        mb.addCube(
            width = self._lineWidth,
            height = self._lineWidth,
            depth = self._lineLength,
            center = Vector(0, 0, self._handlePosition/2),
            color = ToolHandle.ZAxisColor
        )

        #SOLIDMESH -> HANDLES
        mb.addCube(
            width = self._handleWidth,
            height = self._handleWidth,
            depth = self._handleWidth,
            center = Vector(0, 0, 0),
            color = ToolHandle.AllAxisColor
        )

        mb.addCube(
            width = self._handleWidth,
            height = self._handleWidth,
            depth = self._handleWidth,
            center = Vector(0, self._handlePosition, 0),
            color = ToolHandle.YAxisColor
        )

        mb.addCube(
            width = self._handleWidth,
            height = self._handleWidth,
            depth = self._handleWidth,
            center = Vector(self._handlePosition, 0, 0),
            color = ToolHandle.XAxisColor
        )

        mb.addCube(
            width = self._handleWidth,
            height = self._handleWidth,
            depth = self._handleWidth,
            center = Vector(0, 0, self._handlePosition),
            color = ToolHandle.ZAxisColor
        )
        self.setSolidMesh(mb.getData())

        #SELECTIONMESH -> LINES
        mb = MeshBuilder()
        mb.addCube(
            width = self._activeLineWidth,
            height = self._activeLineLength,
            depth = self._activeLineWidth,
            center = Vector(0, self._activeHandlePosition/2, 0),
            color = ToolHandle.YAxisColor
        )

        mb.addCube(
            width = self._activeLineLength,
            height = self._activeLineWidth,
            depth = self._activeLineWidth,
            center = Vector(self._activeHandlePosition/2, 0, 0),
            color = ToolHandle.XAxisColor
        )

        mb.addCube(
            width = self._activeLineWidth,
            height = self._activeLineWidth,
            depth = self._activeLineLength,
            center = Vector(0, 0, self._activeHandlePosition/2),
            color = ToolHandle.ZAxisColor
        )

        #SELECTIONMESH -> HANDLES
        mb.addCube(
            width = self._activeHandleWidth,
            height = self._activeHandleWidth,
            depth = self._activeHandleWidth,
            center = Vector(0, 0, 0),
            color = ToolHandle.AllAxisColor
        )

        mb.addCube(
            width = self._activeHandleWidth,
            height = self._activeHandleWidth,
            depth = self._activeHandleWidth,
            center = Vector(0, self._activeHandlePosition, 0),
            color = ToolHandle.YAxisColor
        )

        mb.addCube(
            width = self._activeHandleWidth,
            height = self._activeHandleWidth,
            depth = self._activeHandleWidth,
            center = Vector(self._activeHandlePosition, 0, 0),
            color = ToolHandle.XAxisColor
        )

        mb.addCube(
            width = self._activeHandleWidth,
            height = self._activeHandleWidth,
            depth = self._activeHandleWidth,
            center = Vector(0, 0, self._activeHandlePosition),
            color = ToolHandle.ZAxisColor
        )

        self.setSelectionMesh(mb.getData())