Geometry¶
Core geometric entities for representing sliced models.
geometry
¶
Core geometric entities: Layer, Path, and PrintPoint.
Layer
dataclass
¶
Layer(paths=list(), is_brim=False, number_of_brim_offsets=None, is_raft=False, min_max_z_height=(None, None))
Bases: Data
A Layer stores a group of ordered paths generated when a geometry is sliced.
Layers are typically organized horizontally, but can also be organized vertically (see VerticalLayer). A Layer consists of one or multiple Paths.
Attributes:
| Name | Type | Description |
|---|---|---|
paths |
list[Path]
|
List of paths in this layer. |
is_brim |
bool
|
True if this layer is a brim layer. |
number_of_brim_offsets |
int | None
|
The number of brim offsets this layer has (None if no brim). |
is_raft |
bool
|
True if this layer is a raft layer. |
min_max_z_height |
tuple[float | None, float | None]
|
Tuple containing the min and max z height of the layer. |
total_number_of_points
property
¶
Returns the total number of points within the layer.
calculate_z_bounds
¶
Fills in the attribute self.min_max_z_height.
Source code in src/compas_slicer/geometry/layer.py
from_data
classmethod
¶
Construct a layer from its data representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The data dictionary. |
required |
Returns:
| Type | Description |
|---|---|
Layer
|
The constructed layer. |
Source code in src/compas_slicer/geometry/layer.py
to_data
¶
Returns a dictionary of structured data representing the layer.
Returns:
| Type | Description |
|---|---|
dict
|
The layer's data. |
VerticalLayer
dataclass
¶
VerticalLayer(paths=list(), is_brim=False, number_of_brim_offsets=None, is_raft=False, min_max_z_height=(None, None), id=0, head_centroid=None)
Bases: Layer
Vertical ordering layer that stores print paths sorted in vertical groups.
It is created with an empty list of paths that is filled in afterwards.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Identifier of vertical layer. |
head_centroid |
NDArray | None
|
Centroid of the last path's points. |
append_
¶
compute_head_centroid
¶
Find the centroid of all the points of the last path.
printout_details
¶
from_data
classmethod
¶
Construct a vertical layer from its data representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The data dictionary. |
required |
Returns:
| Type | Description |
|---|---|
VerticalLayer
|
The constructed vertical layer. |
Source code in src/compas_slicer/geometry/layer.py
to_data
¶
Returns a dictionary of structured data representing the vertical layer.
Returns:
| Type | Description |
|---|---|
dict
|
The vertical layer's data. |
Path
dataclass
¶
Bases: Data
A Path is a connected contour within a Layer.
A Path consists of a list of compas.geometry.Points.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
list[Point]
|
List of points defining the path. |
is_closed |
bool
|
True if the Path is a closed curve, False if the Path is open. If the path is closed, the first and the last point are identical. |
from_data
classmethod
¶
Construct a path from its data representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The data dictionary. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The constructed path. |
Source code in src/compas_slicer/geometry/path.py
to_data
¶
Returns a dictionary of structured data representing the path.
Returns:
| Type | Description |
|---|---|
dict
|
The path's data. |
PrintPoint
dataclass
¶
PrintPoint(pt, layer_height, mesh_normal, up_vector=(lambda: Vector(0, 0, 1))(), frame=None, extruder_toggle=None, velocity=None, wait_time=None, blend_radius=None, closest_support_pt=None, distance_to_support=None, is_feasible=True, attributes=dict())
Bases: Data
A PrintPoint consists of a compas.geometry.Point and printing attributes.
Attributes:
| Name | Type | Description |
|---|---|---|
pt |
Point
|
A compas Point consisting of x, y, z coordinates. |
layer_height |
float
|
The distance between the point on this layer and the previous layer. |
mesh_normal |
Vector
|
Normal of the mesh at this PrintPoint. |
up_vector |
Vector
|
Vector in up direction. |
frame |
Frame
|
Frame with x-axis pointing up, y-axis pointing towards the mesh normal. |
extruder_toggle |
bool | None
|
True if extruder should be on, False if off. |
velocity |
float | None
|
Velocity for printing (print speed), in mm/s. |
wait_time |
float | None
|
Time in seconds to wait at this PrintPoint. |
blend_radius |
float | None
|
Blend radius in mm. |
closest_support_pt |
Point | None
|
Closest support point. |
distance_to_support |
float | None
|
Distance to support. |
is_feasible |
bool
|
Whether this print point is feasible. |
attributes |
dict[str, Any]
|
Additional attributes transferred from the mesh. |
get_frame
¶
to_data
¶
Returns a dictionary of structured data representing the PrintPoint.
Returns:
| Type | Description |
|---|---|
dict
|
The PrintPoint's data. |
from_data
classmethod
¶
Construct a PrintPoint from its data representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The data dictionary. |
required |
Returns:
| Type | Description |
|---|---|
PrintPoint
|
The constructed PrintPoint. |