mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-11 16:57:51 -06:00
Changed the point data type sent from the backend from int64 to float.
Added extruder information to LayerPolygon
This commit is contained in:
parent
d31516bbb1
commit
3d413df215
3 changed files with 27 additions and 13 deletions
|
@ -17,11 +17,12 @@ class LayerPolygon:
|
|||
|
||||
__jump_map = numpy.logical_or( numpy.arange(10) == NoneType, numpy.arange(10) >= MoveCombingType )
|
||||
|
||||
def __init__(self, mesh, line_types, data, line_widths):
|
||||
def __init__(self, mesh, extruder, line_types, data, line_widths):
|
||||
self._mesh = mesh
|
||||
self._extruder = extruder
|
||||
self._types = line_types
|
||||
self._data = data
|
||||
self._line_widths = line_widths / 1000
|
||||
self._line_widths = line_widths
|
||||
|
||||
self._vertex_begin = 0
|
||||
self._vertex_end = 0
|
||||
|
@ -113,6 +114,10 @@ class LayerPolygon:
|
|||
def lineMeshElementCount(self):
|
||||
return (self._index_end - self._index_begin)
|
||||
|
||||
@property
|
||||
def extruder(self):
|
||||
return self._extruder
|
||||
|
||||
@property
|
||||
def types(self):
|
||||
return self._types
|
||||
|
|
|
@ -77,9 +77,9 @@ message PathSegment {
|
|||
Point3D = 1;
|
||||
}
|
||||
PointType point_type = 2;
|
||||
bytes points = 3; // The points defining the line segments, bytes of int64[2/3]? array of length N+1
|
||||
bytes points = 3; // The points defining the line segments, bytes of float[2/3] array of length N+1
|
||||
bytes line_type = 4; // Type of line segment as an unsigned char array of length 1 or N, where N is the number of line segments in this path
|
||||
bytes line_width = 5; // The widths of the line segments as bytes of a float? array of length 1 or N
|
||||
bytes line_width = 5; // The widths of the line segments as bytes of a float array of length 1 or N
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -94,26 +94,35 @@ class ProcessSlicedLayersJob(Job):
|
|||
for p in range(layer.repeatedMessageCount("path_segment")):
|
||||
polygon = layer.getRepeatedMessage("path_segment", p)
|
||||
|
||||
extruder = polygon.extruder
|
||||
|
||||
line_types = numpy.fromstring(polygon.line_type, dtype="u1") # Convert bytearray to numpy array
|
||||
line_types = line_types.reshape((-1,1))
|
||||
|
||||
points = numpy.fromstring(polygon.points, dtype="i8") # Convert bytearray to numpy array
|
||||
points = numpy.fromstring(polygon.points, dtype="f4") # Convert bytearray to numpy array
|
||||
if polygon.point_type == 0: # Point2D
|
||||
points = points.reshape((-1,2)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly.
|
||||
else: # Point3D
|
||||
points = points.reshape((-1,3))
|
||||
|
||||
line_widths = numpy.fromstring(polygon.line_width, dtype="i4") # Convert bytearray to numpy array
|
||||
line_widths = numpy.fromstring(polygon.line_width, dtype="f4") # Convert bytearray to numpy array
|
||||
line_widths = line_widths.reshape((-1,1)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly.
|
||||
|
||||
# Create a new 3D-array, copy the 2D points over and insert the right height.
|
||||
# This uses manual array creation + copy rather than numpy.insert since this is
|
||||
# faster.
|
||||
new_points = numpy.empty((len(points), 3), numpy.float32)
|
||||
if polygon.point_type == 0: # Point2D
|
||||
new_points[:,0] = points[:,0]
|
||||
new_points[:,1] = layer.height
|
||||
new_points[:,1] = layer.height/1000 # layer height value is in backend representation
|
||||
new_points[:,2] = -points[:,1]
|
||||
else: # Point3D
|
||||
new_points[:,0] = points[:,0]
|
||||
new_points[:,1] = points[:,2]
|
||||
new_points[:,2] = -points[:,1]
|
||||
|
||||
new_points /= 1000
|
||||
|
||||
this_poly = LayerPolygon.LayerPolygon(layer_data, line_types, new_points, line_widths)
|
||||
this_poly = LayerPolygon.LayerPolygon(layer_data, extruder, line_types, new_points, line_widths)
|
||||
this_poly.buildCache()
|
||||
|
||||
this_layer.polygons.append(this_poly)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue