Slicers¶
Mesh slicing algorithms.
slicers
¶
Mesh slicing algorithms.
BaseSlicer
¶
Base class for slicers that holds all information for the slice process.
Do not use this class directly. Instead use PlanarSlicer or InterpolationSlicer. This class is meant to be extended for implementing various slicers.
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
Mesh
|
Input mesh, must be triangular (no quads or n-gons allowed). |
layer_height |
float | None
|
Height between layers. |
layers |
list[Layer]
|
List of layers generated by slicing. |
Source code in src/compas_slicer/slicers/base_slicer.py
slice_model
¶
Slices the model and applies standard post-processing.
generate_paths
abstractmethod
¶
post_processing
¶
Applies standard post-processing: seams_align and unify_paths.
Source code in src/compas_slicer/slicers/base_slicer.py
close_paths
¶
For closed paths, ensures first and last point are identical.
Source code in src/compas_slicer/slicers/base_slicer.py
remove_invalid_paths_and_layers
¶
Removes invalid layers and paths from the slicer.
Source code in src/compas_slicer/slicers/base_slicer.py
find_vertical_layers_with_first_path_on_base
¶
Find vertical layers whose first path is on the base.
Returns:
| Type | Description |
|---|---|
tuple[list[Path], list[int]]
|
Paths on base and their vertical layer indices. |
Source code in src/compas_slicer/slicers/base_slicer.py
printout_info
¶
Prints out slicing information.
Source code in src/compas_slicer/slicers/base_slicer.py
from_data
classmethod
¶
Construct a slicer from its data representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The data dictionary. |
required |
Returns:
| Type | Description |
|---|---|
BaseSlicer
|
The constructed slicer. |
Source code in src/compas_slicer/slicers/base_slicer.py
to_json
¶
to_data
¶
Returns a dictionary of structured data representing the slicer.
Returns:
| Type | Description |
|---|---|
dict
|
The slicer's data. |
Source code in src/compas_slicer/slicers/base_slicer.py
PlanarSlicer
¶
Bases: BaseSlicer
Generates planar contours on a mesh that are parallel to the xy plane.
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
Mesh
|
Input mesh, must be triangular (no quads or n-gons allowed). |
layer_height |
float
|
Distance between layers (slices) in mm. |
slice_height_range |
tuple[float, float] | None
|
Optional tuple (z_start, z_end) to slice only part of the model. Values are relative to mesh minimum height. |
Source code in src/compas_slicer/slicers/planar_slicer.py
generate_paths
¶
Generate the planar slicing paths.
Source code in src/compas_slicer/slicers/planar_slicer.py
InterpolationSlicer
¶
Bases: BaseSlicer
Generates non-planar contours that interpolate user-defined boundaries.
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
Mesh
|
Input mesh, must be triangular (no quads or n-gons allowed). Topology matters; irregular tessellation can lead to undesired results. Recommend: re-topologize, triangulate, and weld mesh in advance. |
preprocessor |
InterpolationSlicingPreprocessor | None
|
Preprocessor containing compound targets. |
config |
InterpolationConfig
|
Interpolation configuration. |
n_multiplier |
float
|
Multiplier for number of isocurves. |
Source code in src/compas_slicer/slicers/interpolation_slicer.py
generate_paths
¶
Generate curved paths.
Source code in src/compas_slicer/slicers/interpolation_slicer.py
ScalarFieldSlicer
¶
Bases: BaseSlicer
Generates the isocontours of a scalar field defined on mesh vertices.
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
Mesh
|
Input mesh, must be triangular (no quads or n-gons allowed). Topology matters; irregular tessellation can lead to undesired results. Recommend: re-topologize, triangulate, and weld mesh in advance. |
scalar_field |
list[float]
|
One float per vertex representing the scalar field. |
no_of_isocurves |
int
|
Number of isocontours to generate. |
config |
InterpolationConfig
|
Configuration parameters. |
Source code in src/compas_slicer/slicers/scalar_field_slicer.py
generate_paths
¶
Generate isocontours.
Source code in src/compas_slicer/slicers/scalar_field_slicer.py
UVSlicer
¶
Bases: BaseSlicer
Generates contours on the mesh corresponding to straight lines on the UV plane.
Uses a UV map (from 3D space to plane) defined on mesh vertices.
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
Mesh
|
Input mesh, must be triangular (no quads or n-gons allowed). Topology matters; irregular tessellation can lead to undesired results. Recommend: re-topologize, triangulate, and weld mesh in advance. |
vkey_to_uv |
dict[int, tuple[float, float]]
|
Mapping from vertex key to UV coordinates. UV should be in [0,1]. |
no_of_isocurves |
int
|
Number of levels to generate. |
config |
InterpolationConfig
|
Configuration parameters. |
Source code in src/compas_slicer/slicers/uv_slicer.py
generate_paths
¶
Generate isocontours.