Post-processing¶
Path modification utilities after slicing.
post_processing
¶
Post-processing utilities for modifying sliced paths.
offset_polygon
¶
Offset a polygon, using CGAL if available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list[Point]
|
Points of the polygon. |
required |
offset
|
float
|
Offset distance (positive = outward). |
required |
z
|
float
|
Z coordinate for result points. |
required |
Returns:
| Type | Description |
|---|---|
list[Point]
|
Offset polygon points. |
Source code in src/compas_slicer/post_processing/generate_brim.py
offset_polygon_with_holes
¶
Offset a polygon with holes using CGAL straight skeleton.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outer
|
list[Point]
|
Points of the outer boundary (CCW orientation). |
required |
holes
|
list[list[Point]]
|
List of hole polygons (CW orientation). |
required |
offset
|
float
|
Offset distance (positive = outward, negative = inward). |
required |
z
|
float
|
Z coordinate for result points. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[list[Point], list[list[Point]]]]
|
List of (outer_boundary, holes) tuples for resulting polygons. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If CGAL is not available. |
Source code in src/compas_slicer/post_processing/generate_brim.py
generate_medial_axis_infill
¶
Generate medial axis infill paths for all layers.
Uses CGAL's straight skeleton to compute the medial axis of each closed contour, then converts skeleton edges to infill paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
Slicer with layers containing boundary paths. |
required |
min_length
|
float
|
Minimum skeleton edge length to include. Shorter edges are skipped. |
5.0
|
include_bisectors
|
bool
|
If True, include bisector edges (skeleton to boundary connections). If False, only include inner_bisector edges (skeleton internal edges). |
True
|
Source code in src/compas_slicer/post_processing/infill/medial_axis_infill.py
generate_brim
¶
offset_polygon
¶
Offset a polygon, using CGAL if available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list[Point]
|
Points of the polygon. |
required |
offset
|
float
|
Offset distance (positive = outward). |
required |
z
|
float
|
Z coordinate for result points. |
required |
Returns:
| Type | Description |
|---|---|
list[Point]
|
Offset polygon points. |
Source code in src/compas_slicer/post_processing/generate_brim.py
offset_polygon_with_holes
¶
Offset a polygon with holes using CGAL straight skeleton.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outer
|
list[Point]
|
Points of the outer boundary (CCW orientation). |
required |
holes
|
list[list[Point]]
|
List of hole polygons (CW orientation). |
required |
offset
|
float
|
Offset distance (positive = outward, negative = inward). |
required |
z
|
float
|
Z coordinate for result points. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[list[Point], list[list[Point]]]]
|
List of (outer_boundary, holes) tuples for resulting polygons. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If CGAL is not available. |
Source code in src/compas_slicer/post_processing/generate_brim.py
generate_brim
¶
Creates a brim around the bottom contours of the print.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
An instance of the compas_slicer.slicers.PlanarSlicer class |
required |
layer_width
|
float
|
A number representing the distance between brim contours (typically the width of a layer) |
required |
number_of_brim_offsets
|
int
|
Number of brim paths to add. |
required |
Source code in src/compas_slicer/post_processing/generate_brim.py
generate_raft
¶
generate_raft
¶
generate_raft(slicer, raft_offset=10, distance_between_paths=10, direction='xy_diagonal', raft_layers=1, raft_layer_height=None)
Creates a raft.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
An instance of one of the compas_slicer.slicers.BaseSlicer classes. |
required | |
raft_offset
|
Distance (in mm) that the raft should be offsetted from the first layer. Defaults to 10mm |
10
|
|
distance_between_paths
|
Distance (in mm) between the printed lines of the raft. Defaults to 10mm |
10
|
|
direction
|
x_axis: Create a raft aligned with the x_axis y_axis: Create a raft aligned with the y_axis xy_diagonal: Create a raft int the diagonal direction in the xy_plane |
'xy_diagonal'
|
|
raft_layers
|
Number of raft layers to add. Defaults to 1 |
1
|
|
raft_layer_height
|
Layer height of the raft layers. Defaults to same value as used in the slicer. |
None
|
Source code in src/compas_slicer/post_processing/generate_raft.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
infill
¶
Infill generation for sliced paths.
generate_medial_axis_infill
¶
Generate medial axis infill paths for all layers.
Uses CGAL's straight skeleton to compute the medial axis of each closed contour, then converts skeleton edges to infill paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
Slicer with layers containing boundary paths. |
required |
min_length
|
float
|
Minimum skeleton edge length to include. Shorter edges are skipped. |
5.0
|
include_bisectors
|
bool
|
If True, include bisector edges (skeleton to boundary connections). If False, only include inner_bisector edges (skeleton internal edges). |
True
|
Source code in src/compas_slicer/post_processing/infill/medial_axis_infill.py
medial_axis_infill
¶
Medial axis based infill generation using CGAL straight skeleton.
generate_medial_axis_infill
¶
Generate medial axis infill paths for all layers.
Uses CGAL's straight skeleton to compute the medial axis of each closed contour, then converts skeleton edges to infill paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
Slicer with layers containing boundary paths. |
required |
min_length
|
float
|
Minimum skeleton edge length to include. Shorter edges are skipped. |
5.0
|
include_bisectors
|
bool
|
If True, include bisector edges (skeleton to boundary connections). If False, only include inner_bisector edges (skeleton internal edges). |
True
|
Source code in src/compas_slicer/post_processing/infill/medial_axis_infill.py
reorder_vertical_layers
¶
reorder_vertical_layers
¶
Re-orders the vertical layers in a specific way
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
An instance of one of the compas_slicer.slicers classes. |
required |
align_with
|
AlignWith | Point
|
x_axis = reorders the vertical layers starting from the positive x-axis y_axis = reorders the vertical layers starting from the positive y-axis Point(x,y,z) = reorders the vertical layers starting from a given Point |
required |
Source code in src/compas_slicer/post_processing/reorder_vertical_layers.py
seams_align
¶
seams_align
¶
Aligns the seams (start- and endpoint) of a print.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
An instance of one of the compas_slicer.slicers classes. |
required |
align_with
|
AlignWith | Point
|
Direction to orient the seams in. next_path = orients the seam to the next path origin = orients the seam to the origin (0,0,0) x_axis = orients the seam to the x_axis y_axis = orients the seam to the y_axis Point(x,y,z) = orients the seam according to the given point |
'next_path'
|
Source code in src/compas_slicer/post_processing/seams_align.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
seams_smooth
¶
seams_smooth
¶
Smooths the seams (transition between layers) by removing points within a certain distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
An instance of one of the compas_slicer.slicers classes. |
required |
smooth_distance
|
float
|
Distance (in mm) to perform smoothing |
required |
Source code in src/compas_slicer/post_processing/seams_smooth.py
simplify_paths_rdp
¶
simplify_paths_rdp
¶
Simplify paths using the Ramer-Douglas-Peucker algorithm.
Uses CGAL native implementation if available (10-20x faster), otherwise falls back to Python rdp library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
An instance of one of the compas_slicer.slicers classes. |
required |
threshold
|
float
|
Controls the degree of polyline simplification. Low threshold removes few points, high threshold removes many points. |
required |
Source code in src/compas_slicer/post_processing/simplify_paths_rdp.py
sort_into_vertical_layers
¶
sort_into_vertical_layers
¶
Sorts the paths from horizontal layers into Vertical Layers.
Vertical Layers are layers at different heights that are grouped together by proximity of their center points. Can be useful for reducing travel time in a robotic printing process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
An instance of one of the compas_slicer.slicers classes. |
required |
dist_threshold
|
float
|
The maximum get_distance that the centroids of two successive paths can have to belong in the same VerticalLayer Recommended value, slightly bigger than the layer height |
25.0
|
max_paths_per_layer
|
int | None
|
Maximum number of layers that a vertical layer can consist of. If None, then the vertical layer has an unlimited number of layers. |
None
|
Source code in src/compas_slicer/post_processing/sort_into_vertical_layers.py
sort_paths_minimum_travel_time
¶
sort_paths_minimum_travel_time
¶
Sorts the paths within a horizontal layer to reduce total travel time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
An instance of one of the compas_slicer.slicers classes. |
required |
Source code in src/compas_slicer/post_processing/sort_paths_minimum_travel_time.py
adjust_seam_to_closest_pos
¶
Aligns the seam (start- and endpoint) of a contour so that it is closest to a given point. for open paths, check if the end point closest to the reference point is the start point
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref_point
|
Point
|
The reference point |
required |
path
|
Path
|
The contour to be adjusted. |
required |
Source code in src/compas_slicer/post_processing/sort_paths_minimum_travel_time.py
closest_path
¶
Finds the closest path to a reference point in a list of paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref_point
|
Point
|
|
required |
somepaths
|
list[Path]
|
|
required |
Source code in src/compas_slicer/post_processing/sort_paths_minimum_travel_time.py
spiralize_contours
¶
spiralize_contours
¶
Spiralizes contours. Only works for Planar Slicer. Can only be used for geometries consisting out of a single closed contour (i.e. vases).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
PlanarSlicer
|
An instance of the compas_slicer.slicers.PlanarSlicer class. |
required |
Source code in src/compas_slicer/post_processing/spiralize_contours.py
unify_paths_orientation
¶
unify_paths_orientation
¶
Unifies the orientation of paths that are closed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
BaseSlicer
|
An instance of one of the compas_slicer.slicers classes. |
required |
Source code in src/compas_slicer/post_processing/unify_paths_orientation.py
match_paths_orientations
¶
Check if new curve has same direction as prev curve, otherwise reverse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pts
|
list[Point]
|
|
required |
reference_points
|
list[Point]
|
|
required |
is_closed
|
bool, Determines if the path is closed or open
|
|
required |
Source code in src/compas_slicer/post_processing/unify_paths_orientation.py
zig_zag_open_paths
¶
zig_zag_open_paths
¶
Reverses half of the open paths of the slicer, so that they can be printed in a zig zag motion.