mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
T466: Added test line
This commit is contained in:
parent
ac6ad5ec6c
commit
b9514527dd
2 changed files with 71 additions and 12 deletions
|
@ -7,6 +7,15 @@ from UM.Mesh.MeshBuilder import MeshBuilder
|
||||||
import os
|
import os
|
||||||
from UM.Scene.SceneNode import SceneNode
|
from UM.Scene.SceneNode import SceneNode
|
||||||
from UM.Math.Vector import Vector
|
from UM.Math.Vector import Vector
|
||||||
|
from UM.Math.AxisAlignedBox import AxisAlignedBox
|
||||||
|
from UM.Application import Application
|
||||||
|
|
||||||
|
from cura import LayerDataBuilder
|
||||||
|
from cura import LayerDataDecorator
|
||||||
|
from cura import LayerPolygon
|
||||||
|
|
||||||
|
import numpy
|
||||||
|
|
||||||
|
|
||||||
from UM.Job import Job
|
from UM.Job import Job
|
||||||
|
|
||||||
|
@ -22,19 +31,63 @@ class GCODEReader(MeshReader):
|
||||||
if extension.lower() in self._supported_extensions:
|
if extension.lower() in self._supported_extensions:
|
||||||
scene_node = SceneNode()
|
scene_node = SceneNode()
|
||||||
|
|
||||||
mesh_builder = MeshBuilder()
|
# mesh_builder = MeshBuilder()
|
||||||
mesh_builder.setFileName(file_name)
|
# mesh_builder.setFileName(file_name)
|
||||||
|
#
|
||||||
|
# mesh_builder.addCube(
|
||||||
|
# width=5,
|
||||||
|
# height=5,
|
||||||
|
# depth=5,
|
||||||
|
# center=Vector(0, 2.5, 0)
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# scene_node.setMeshData(mesh_builder.build())
|
||||||
|
|
||||||
mesh_builder.addCube(
|
def getBoundingBox():
|
||||||
width=5,
|
return AxisAlignedBox(minimum=Vector(0, 0, 0), maximum=Vector(10, 10, 10))
|
||||||
height=5,
|
|
||||||
depth=5,
|
|
||||||
center=Vector(0, 2.5, 0)
|
|
||||||
)
|
|
||||||
|
|
||||||
scene_node.setMeshData(mesh_builder.build())
|
scene_node.getBoundingBox = getBoundingBox
|
||||||
|
scene_node.gcode = True
|
||||||
|
|
||||||
scene_node.setEnabled(False)
|
layer_data = LayerDataBuilder.LayerDataBuilder()
|
||||||
scene_node.setSelectable(False)
|
layer_count = 1
|
||||||
|
for id in range(layer_count):
|
||||||
|
layer_data.addLayer(id)
|
||||||
|
this_layer = layer_data.getLayer(id)
|
||||||
|
layer_data.setLayerHeight(id, 1)
|
||||||
|
layer_data.setLayerThickness(id, 1)
|
||||||
|
|
||||||
|
extruder = 1
|
||||||
|
line_types = numpy.empty((1, 1), numpy.int32)
|
||||||
|
line_types[0, 0] = 6
|
||||||
|
line_widths = numpy.empty((1, 1), numpy.int32)
|
||||||
|
line_widths[0, 0] = 1
|
||||||
|
points = numpy.empty((2, 3), numpy.float32)
|
||||||
|
points[0, 0] = 0
|
||||||
|
points[0, 1] = 0
|
||||||
|
points[0, 2] = 0
|
||||||
|
points[1, 0] = 10
|
||||||
|
points[1, 1] = 10
|
||||||
|
points[1, 2] = 10
|
||||||
|
|
||||||
|
this_poly = LayerPolygon.LayerPolygon(layer_data, extruder, line_types, points, line_widths)
|
||||||
|
this_poly.buildCache()
|
||||||
|
|
||||||
|
this_layer.polygons.append(this_poly)
|
||||||
|
|
||||||
|
layer_mesh = layer_data.build()
|
||||||
|
decorator = LayerDataDecorator.LayerDataDecorator()
|
||||||
|
decorator.setLayerData(layer_mesh)
|
||||||
|
scene_node.addDecorator(decorator)
|
||||||
|
|
||||||
|
scene_node_parent = Application.getInstance().getBuildVolume()
|
||||||
|
scene_node.setParent(scene_node_parent)
|
||||||
|
|
||||||
|
view = Application.getInstance().getController().getActiveView()
|
||||||
|
if view.getPluginId() == "LayerView":
|
||||||
|
view.resetLayerData()
|
||||||
|
|
||||||
|
#scene_node.setEnabled(False)
|
||||||
|
#scene_node.setSelectable(False)
|
||||||
|
|
||||||
return scene_node
|
return scene_node
|
||||||
|
|
|
@ -45,10 +45,16 @@ class LayerPass(RenderPass):
|
||||||
tool_handle_batch = RenderBatch(self._tool_handle_shader, type = RenderBatch.RenderType.Overlay)
|
tool_handle_batch = RenderBatch(self._tool_handle_shader, type = RenderBatch.RenderType.Overlay)
|
||||||
|
|
||||||
for node in DepthFirstIterator(self._scene.getRoot()):
|
for node in DepthFirstIterator(self._scene.getRoot()):
|
||||||
|
flag = False
|
||||||
|
try:
|
||||||
|
flag = node.gcode
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
if isinstance(node, ToolHandle):
|
if isinstance(node, ToolHandle):
|
||||||
tool_handle_batch.addItem(node.getWorldTransformation(), mesh = node.getSolidMesh())
|
tool_handle_batch.addItem(node.getWorldTransformation(), mesh = node.getSolidMesh())
|
||||||
|
|
||||||
elif isinstance(node, SceneNode) and node.getMeshData() and node.isVisible():
|
elif isinstance(node, SceneNode) and (node.getMeshData() or flag) and node.isVisible():
|
||||||
layer_data = node.callDecoration("getLayerData")
|
layer_data = node.callDecoration("getLayerData")
|
||||||
if not layer_data:
|
if not layer_data:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue