Pre-processing¶
Mesh preparation utilities before slicing.
pre_processing
¶
Pre-processing utilities for mesh preparation before slicing.
GradientEvaluation
¶
Evaluation of the gradient of the scalar function of the mesh. The scalar function should be stored as a vertex attribute on every vertex, with key='scalar_field'
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
:class: 'compas.datastructures.Mesh'
|
|
DATA_PATH |
str, path to the data folder
|
|
Source code in src/compas_slicer/pre_processing/gradient_evaluation.py
compute_gradient
¶
Computes the gradient on the faces and the vertices.
Source code in src/compas_slicer/pre_processing/gradient_evaluation.py
compute_gradient_norm
¶
Computes the norm of the gradient.
Source code in src/compas_slicer/pre_processing/gradient_evaluation.py
find_critical_points
¶
Finds minima, maxima and saddle points of the scalar function on the mesh.
Source code in src/compas_slicer/pre_processing/gradient_evaluation.py
InterpolationSlicingPreprocessor
¶
Handles pre-processing for interpolation slicing.
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
Mesh
|
Input mesh. |
config |
InterpolationConfig
|
Interpolation configuration. |
DATA_PATH |
str | Path
|
Path to the data folder. |
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
create_compound_targets
¶
Create target_LOW and target_HIGH and compute geodesic distances.
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
targets_laplacian_smoothing
¶
Smooth geodesic distances of targets. Saves again the distances to json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterations
|
int
|
|
required |
strength
|
float
|
|
required |
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
create_gradient_evaluation
¶
create_gradient_evaluation(target_1, target_2=None, save_output=True, norm_filename='gradient_norm.json', g_filename='gradient.json')
Creates a compas_slicer.pre_processing.GradientEvaluation that is stored in self.g_evaluation Also, computes the gradient and gradient_norm and saves them to Json .
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
find_critical_points
¶
Computes and saves to json the critical points of the df on the mesh (minima, maxima, saddles)
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
region_split
¶
region_split(cut_mesh=True, separate_neighborhoods=True, topological_sorting=True, save_split_meshes=True)
Splits the mesh on the saddle points. This process can take a long time. It consists of four parts: 1) Create cuts on the mesh so that they intersect the saddle points and follow the get_distance function iso-contour 2) Separate mesh neighborhoods from cuts 3) Topological sorting of split meshes to determine their connectivity and sequence. 4) Finally resulting meshes are saved to json.
The intermediary outputs are saved to json, so if you don'weight want to be recomputing the entire thing every time, you can turn the respective processes to false.
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
cleanup_mesh_attributes_based_on_selected_order
¶
Based on the selected order of split meshes, it rearranges their attributes, so that they can then be used with an interpolation slicer that requires data['boundary'] to be filled for every vertex. The vertices that originated from cuts have data['cut']=cut_index. This is replaced by data['boundary'] = 1 or 2 depending on connectivity of mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selected_order
|
list[int]
|
The indices of ordered split meshes. |
required |
graph
|
MeshDirectedGraph
|
|
required |
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
move_mesh_to_point
¶
Moves (translates) a mesh to a target point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
A compas mesh. |
required |
target_point
|
Point
|
The point to move the mesh to. |
required |
Source code in src/compas_slicer/pre_processing/positioning.py
get_mid_pt_base
¶
Gets the middle point of the base (bottom) of the mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
A compas mesh. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
mesh_mid_pt |
:class:`compas.geometry.Point`
|
Middle point of the base of the mesh. |
Source code in src/compas_slicer/pre_processing/positioning.py
remesh_mesh
¶
Remesh a triangle mesh to achieve uniform edge lengths.
Uses CGAL's isotropic remeshing to improve mesh quality for slicing. This can help with curved slicing and geodesic computations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
A compas mesh (must be triangulated). |
required |
target_edge_length
|
float
|
Target edge length for the remeshed output. |
required |
number_of_iterations
|
int
|
Number of remeshing iterations (default: 10). |
10
|
do_project
|
bool
|
Reproject vertices onto original surface (default: True). |
True
|
Returns:
| Type | Description |
|---|---|
Mesh
|
Remeshed compas mesh. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If compas_cgal is not available. |
Examples:
>>> from compas.datastructures import Mesh
>>> from compas_slicer.pre_processing import remesh_mesh
>>> mesh = Mesh.from_stl('model.stl')
>>> remeshed = remesh_mesh(mesh, target_edge_length=2.0)
Source code in src/compas_slicer/pre_processing/positioning.py
gradient_evaluation
¶
GradientEvaluation
¶
Evaluation of the gradient of the scalar function of the mesh. The scalar function should be stored as a vertex attribute on every vertex, with key='scalar_field'
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
:class: 'compas.datastructures.Mesh'
|
|
DATA_PATH |
str, path to the data folder
|
|
Source code in src/compas_slicer/pre_processing/gradient_evaluation.py
compute_gradient
¶
Computes the gradient on the faces and the vertices.
Source code in src/compas_slicer/pre_processing/gradient_evaluation.py
compute_gradient_norm
¶
Computes the norm of the gradient.
Source code in src/compas_slicer/pre_processing/gradient_evaluation.py
find_critical_points
¶
Finds minima, maxima and saddle points of the scalar function on the mesh.
Source code in src/compas_slicer/pre_processing/gradient_evaluation.py
count_sign_changes
¶
Returns the number of sign changes in a list of values.
Source code in src/compas_slicer/pre_processing/gradient_evaluation.py
interpolation_slicing_preprocessor
¶
InterpolationSlicingPreprocessor
¶
Handles pre-processing for interpolation slicing.
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
Mesh
|
Input mesh. |
config |
InterpolationConfig
|
Interpolation configuration. |
DATA_PATH |
str | Path
|
Path to the data folder. |
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
create_compound_targets
¶
Create target_LOW and target_HIGH and compute geodesic distances.
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
targets_laplacian_smoothing
¶
Smooth geodesic distances of targets. Saves again the distances to json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterations
|
int
|
|
required |
strength
|
float
|
|
required |
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
create_gradient_evaluation
¶
create_gradient_evaluation(target_1, target_2=None, save_output=True, norm_filename='gradient_norm.json', g_filename='gradient.json')
Creates a compas_slicer.pre_processing.GradientEvaluation that is stored in self.g_evaluation Also, computes the gradient and gradient_norm and saves them to Json .
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
find_critical_points
¶
Computes and saves to json the critical points of the df on the mesh (minima, maxima, saddles)
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
region_split
¶
region_split(cut_mesh=True, separate_neighborhoods=True, topological_sorting=True, save_split_meshes=True)
Splits the mesh on the saddle points. This process can take a long time. It consists of four parts: 1) Create cuts on the mesh so that they intersect the saddle points and follow the get_distance function iso-contour 2) Separate mesh neighborhoods from cuts 3) Topological sorting of split meshes to determine their connectivity and sequence. 4) Finally resulting meshes are saved to json.
The intermediary outputs are saved to json, so if you don'weight want to be recomputing the entire thing every time, you can turn the respective processes to false.
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
cleanup_mesh_attributes_based_on_selected_order
¶
Based on the selected order of split meshes, it rearranges their attributes, so that they can then be used with an interpolation slicer that requires data['boundary'] to be filled for every vertex. The vertices that originated from cuts have data['cut']=cut_index. This is replaced by data['boundary'] = 1 or 2 depending on connectivity of mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selected_order
|
list[int]
|
The indices of ordered split meshes. |
required |
graph
|
MeshDirectedGraph
|
|
required |
Source code in src/compas_slicer/pre_processing/interpolation_slicing_preprocessor.py
positioning
¶
move_mesh_to_point
¶
Moves (translates) a mesh to a target point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
A compas mesh. |
required |
target_point
|
Point
|
The point to move the mesh to. |
required |
Source code in src/compas_slicer/pre_processing/positioning.py
get_mid_pt_base
¶
Gets the middle point of the base (bottom) of the mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
A compas mesh. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
mesh_mid_pt |
:class:`compas.geometry.Point`
|
Middle point of the base of the mesh. |
Source code in src/compas_slicer/pre_processing/positioning.py
remesh_mesh
¶
Remesh a triangle mesh to achieve uniform edge lengths.
Uses CGAL's isotropic remeshing to improve mesh quality for slicing. This can help with curved slicing and geodesic computations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
A compas mesh (must be triangulated). |
required |
target_edge_length
|
float
|
Target edge length for the remeshed output. |
required |
number_of_iterations
|
int
|
Number of remeshing iterations (default: 10). |
10
|
do_project
|
bool
|
Reproject vertices onto original surface (default: True). |
True
|
Returns:
| Type | Description |
|---|---|
Mesh
|
Remeshed compas mesh. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If compas_cgal is not available. |
Examples:
>>> from compas.datastructures import Mesh
>>> from compas_slicer.pre_processing import remesh_mesh
>>> mesh = Mesh.from_stl('model.stl')
>>> remeshed = remesh_mesh(mesh, target_edge_length=2.0)
Source code in src/compas_slicer/pre_processing/positioning.py
preprocessing_utils
¶
CompoundTarget
¶
CompoundTarget(mesh, v_attr, value, DATA_PATH, union_method='min', union_params=None, geodesics_method='heat_cgal', anisotropic_scaling=False)
Represents a desired user-provided target. It acts as a key-frame that controls the print paths orientations. After the curved slicing , the print paths will be aligned to the compound target close to its area. The vertices that belong to the target are marked with their vertex attributes; they have data['v_attr'] = value.
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
:class:`compas.datastructures.Mesh`
|
|
v_attr |
str
|
The key of the attribute dict to be checked. |
value |
int
|
The value of the attribute dict with key=v_attr. If in a vertex data[v_attr]==value then the vertex is part of this target. |
DATA_PATH |
str
|
|
has_blend_union |
bool
|
|
blend_radius |
float
|
|
geodesics_method |
str
|
'heat_cgal' CGAL heat geodesic distances (recommended) 'heat' custom heat geodesic distances |
anisotropic_scaling |
bool
|
This is not yet implemented |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
has_uneven_weights
property
¶
Returns True if the target has uneven_weights calculated, False otherwise.
find_targets_connected_components
¶
Clusters all the vertices that belong to the target into neighborhoods using a graph. Each target can have an arbitrary number of neighborhoods/clusters. Fills in the attributes: self.all_target_vkeys, self.clustered_vkeys, self.number_of_boundaries
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
compute_geodesic_distances
¶
Computes the geodesic distances from each of the target's neighborhoods to all the mesh vertices. Fills in the distances attributes.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
update_distances_lists
¶
Fills in the distances attributes.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
compute_uneven_boundaries_weight_max
¶
If the target has multiple neighborhoods/clusters of vertices, then it computes their maximum distance from the other_target. Based on that it calculates their weight_max for the interpolation process
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_boundaries_rel_dist_from_other_target
¶
Returns a list, one relative distance value per connected boundary neighborhood. That is the average of the distances of the vertices of that boundary neighborhood from the other_target.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_avg_distances_from_other_target
¶
Returns the minimum and maximum distance of the vertices of this target from the other_target
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_all_clusters_distances_dict
¶
Returns dict. keys: index of connected target neighborhood, value: list, distances (one per vertex).
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_max_dist
¶
Returns the maximum distance that the target has on a mesh vertex.
get_all_distances
¶
Return distances for all vertices as 1D array, applying union method.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_all_distances_array
¶
Return raw distances as (n_boundaries, n_vertices) array.
get_all_distances_for_vkey
¶
Returns distances from each cluster separately for vertex i. Smooth union doesn't play here any role.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_distance
¶
Return get_distance for vertex with vkey i.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
laplacian_smoothing
¶
Smooth the distances on the mesh, using iterative laplacian smoothing.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
save_distances
¶
Save distances to json. Saves one list with distance values (one per vertex).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
|
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
assign_new_mesh
¶
When the base mesh changes, a new mesh needs to be assigned.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
GeodesicsCache
¶
Cache for geodesic distances to avoid redundant computations.
Note: This class is kept for backwards compatibility but now uses CGAL. The CGAL solver has its own internal caching via _cgal_solver_cache.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
clear
¶
get_distances
¶
Get geodesic distances from sources, using cache when possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
The mesh to compute distances on. |
required |
sources
|
list[int]
|
Source vertex indices. |
required |
method
|
str
|
Geodesic method (ignored, always uses CGAL heat method). |
'heat'
|
Returns:
| Type | Description |
|---|---|
NDArray
|
Minimum distance from any source to each vertex. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
MeshSplitter
¶
Curved slicing pre-processing step.
Takes one continuous mesh with various saddle points and splits it up at every saddle point following the direction of the iso-contour that intersects that saddle point, so that the resulting mesh has no remaining saddle points.
The result is a series of split meshes whose vertex attributes have been updated with boundary attributes at the newly created cuts, (i.e. they all have vertex 'boundary' attributes 1,2 on their lower and upper boundaries)
For each newly created mesh, a separate slicer needs to be created. Like that, we will always have one slicer per mesh with the correct attributes already assigned. However, it can still happen that a slicer that takes a split mesh outputs more than one vertical_layers_print_data (vertical layers).
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
:class: 'compas.datastructures.Mesh'
|
|
target_LOW |
:class: 'compas_slicer.pre_processing.CompoundTarget'
|
|
target_HIGH |
:class: 'compas_slicer.pre_processing.CompoundTarget'
|
|
DATA_PATH |
str, the path to the data folder
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
run
¶
Runs the mesh splitting process. This consists of the following parts.
(1) Find the iso-contours that intersect the saddle points. Iteratively find the weights (from 0 to 1) that output a distance field whose iso-contour is intersecting each saddle point. Here two iterations are carried out (one rough and one exact search).
For each saddle point and its respective weight and iso-contour: (2) Find the zero-crossing points of the iso-contour and merge points that are close to the saddle to ensure connection. (3) Cleanup iso-contour. Only keep neighborhoods that are intersecting the saddle point. Discard all other. (4) Create the cut on the mesh. (5) Weld the resulting mesh, and restore all the vertex attributes. Note that the mesh remains in one piece, although the cuts have been created. (6) Update compound tardets with the new mesh.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
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 | |
update_targets
¶
Update targets with the new mesh that was created during the split process. Note: This only works if the target vertices have not been touched. If all has gone well, targets can only have minima and maxima, so they should remain intact after the split
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
split_intersected_faces
¶
Create cuts on intersected faces
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zero_contours
|
|
required | |
cut_index
|
|
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
identify_positions_to_split
¶
Find the weights that create iso-contours that intersect the saddle points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
saddles
|
|
required |
Returns:
| Type | Description |
|---|---|
list, float, the weights from 0 to 1. One for each saddle point.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
find_weight_intersecting_vkey
¶
Find the weights that intersect the vertex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vkey
|
|
required | |
threshold
|
|
required | |
resolution
|
|
required |
Returns:
| Type | Description |
|---|---|
float, the weights from 0 to 1.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
assign_interpolation_distance_to_mesh_vertices
¶
Fills in the 'get_distance' attribute of every vertex of the mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
weight
|
float
|
The weighting of the distances from the lower and the upper target, from 0 to 1. |
required |
target_LOW
|
CompoundTarget
|
The lower compound target. |
required |
target_HIGH
|
CompoundTarget | None
|
The upper compound target. |
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/assign_vertex_distance.py
assign_interpolation_distance_to_mesh_vertex
¶
Fills in the 'get_distance' attribute for a single vertex with vkey.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vkey
|
int
|
The vertex key. |
required |
weight
|
float
|
The weighting of the distances from the lower and the upper target, from 0 to 1. |
required |
target_LOW
|
CompoundTarget
|
The lower compound target. |
required |
target_HIGH
|
CompoundTarget | None
|
The upper compound target. |
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/assign_vertex_distance.py
blend_union_list
¶
Returns a smooth union of all the elements in the list, with blend radius blend_radius.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
stairs_union_list
¶
Returns a stairs union of all the elements in the list, with blend radius r and number of peaks n-1.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_heat_geodesic_distances
¶
Calculate geodesic distances using CGAL heat method.
Uses compas_cgal's HeatGeodesicSolver which provides CGAL's Heat_method_3 implementation with intrinsic Delaunay triangulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
A compas mesh (must be triangulated). |
required |
vertices_start
|
list[int]
|
Source vertex indices. |
required |
Returns:
| Type | Description |
|---|---|
NDArray
|
Minimum distance from any source to each vertex. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
get_custom_HEAT_geodesic_distances
¶
Calculate geodesic distances using the custom heat method.
This is a pure Python implementation of the heat method (Crane et al., 2013). For production use, prefer CGAL's implementation via get_heat_geodesic_distances() which uses intrinsic Delaunay triangulation for better accuracy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
A compas mesh (must be triangulated). |
required |
vi_sources
|
list[int]
|
Source vertex indices. |
required |
OUTPUT_PATH
|
str
|
Path to save intermediate results. |
required |
v_equalize
|
list[int] | None
|
Vertices to equalize (for saddle point handling). |
None
|
Returns:
| Type | Description |
|---|---|
NDArray
|
Geodesic distance from sources to each vertex. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
get_vertex_gradient_from_face_gradient
¶
Finds vertex gradient given an already calculated per face gradient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
face_gradient
|
NDArray[floating]
|
|
required |
Returns:
| Type | Description |
|---|---|
np.array (dimensions : #V x 3) one gradient vector per vertex.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
get_edge_gradient_from_vertex_gradient
¶
Finds edge gradient given an already calculated per vertex gradient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
vertex_gradient
|
NDArray[floating]
|
|
required |
Returns:
| Type | Description |
|---|---|
np.array (dimensions : #E x 3) one gradient vector per edge.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
get_face_gradient_from_scalar_field
¶
Finds face gradient from scalar field u. Scalar field u is given per vertex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
u
|
NDArray[floating]
|
|
required |
Returns:
| Type | Description |
|---|---|
np.array (dimensions : #F x 3) one gradient vector per face.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
get_per_vertex_divergence
¶
Computes the divergence of the gradient X for the mesh, using cotangent weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
X
|
NDArray[floating]
|
|
required |
cotans
|
NDArray[floating]
|
|
required |
Returns:
| Type | Description |
|---|---|
np.array (dimensions : #V x 1) one float (divergence value) per vertex.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
normalize_gradient
¶
Returns normalized gradient X.
get_scalar_field_from_gradient
¶
Find scalar field u that best explains gradient X. Laplacian(u) = Divergence(X). This defines a scalar field up to translation, then we subtract the min to make sure it starts from 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
X
|
NDArray[floating]
|
|
required |
C
|
csr_matrix
|
sparse matrix (dimensions: #V x #V), cotmatrix, each row i corresponding to v(i, :) |
required |
cotans
|
NDArray[floating]
|
|
required |
Returns:
| Type | Description |
|---|---|
np.array (dimensions : #V x 1) one scalar value per vertex.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
create_mesh_boundary_attributes
¶
Creates a default vertex attribute data['boundary']=0. Then it gives the value 1 to the vertices that belong to the lower boundary, and the value 2 to the vertices that belong to the higher boundary.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
get_existing_cut_indices
¶
Returns:
| Type | Description |
|---|---|
list, int.
|
The cut indices (data['cut']>0) that exist on the mesh vertices. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
get_existing_boundary_indices
¶
Returns:
| Type | Description |
|---|---|
list, int.
|
The boundary indices (data['boundary']>0) that exist on the mesh vertices. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
get_vertices_that_belong_to_cuts
¶
Returns:
| Type | Description |
|---|---|
dict, key: int, the index of each cut
|
value: dict, the points that belong to this cut (point_list_to_dict format) |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
save_vertex_attributes
¶
Saves the boundary and cut attributes that are on the mesh on a dictionary.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
restore_mesh_attributes
¶
Restores the cut and boundary attributes on the mesh vertices from the dictionary of the previously saved attributes
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
replace_mesh_vertex_attribute
¶
Replaces one vertex attribute with a new one. For all the vertices where data[old_attr]=old_val, then the old_val is replaced with 0, and data[new_attr]=new_val.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
assign_vertex_distance
¶
assign_interpolation_distance_to_mesh_vertices
¶
Fills in the 'get_distance' attribute of every vertex of the mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
weight
|
float
|
The weighting of the distances from the lower and the upper target, from 0 to 1. |
required |
target_LOW
|
CompoundTarget
|
The lower compound target. |
required |
target_HIGH
|
CompoundTarget | None
|
The upper compound target. |
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/assign_vertex_distance.py
assign_interpolation_distance_to_mesh_vertex
¶
Fills in the 'get_distance' attribute for a single vertex with vkey.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vkey
|
int
|
The vertex key. |
required |
weight
|
float
|
The weighting of the distances from the lower and the upper target, from 0 to 1. |
required |
target_LOW
|
CompoundTarget
|
The lower compound target. |
required |
target_HIGH
|
CompoundTarget | None
|
The upper compound target. |
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/assign_vertex_distance.py
get_weighted_distance
¶
Computes the weighted get_distance for a single vertex with vkey.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vkey
|
int
|
The vertex key. |
required |
weight
|
float
|
The weighting of the distances from the lower and the upper target, from 0 to 1. |
required |
target_LOW
|
CompoundTarget
|
The lower compound target. |
required |
target_HIGH
|
CompoundTarget
|
The upper compound target. |
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/assign_vertex_distance.py
compound_target
¶
CompoundTarget
¶
CompoundTarget(mesh, v_attr, value, DATA_PATH, union_method='min', union_params=None, geodesics_method='heat_cgal', anisotropic_scaling=False)
Represents a desired user-provided target. It acts as a key-frame that controls the print paths orientations. After the curved slicing , the print paths will be aligned to the compound target close to its area. The vertices that belong to the target are marked with their vertex attributes; they have data['v_attr'] = value.
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
:class:`compas.datastructures.Mesh`
|
|
v_attr |
str
|
The key of the attribute dict to be checked. |
value |
int
|
The value of the attribute dict with key=v_attr. If in a vertex data[v_attr]==value then the vertex is part of this target. |
DATA_PATH |
str
|
|
has_blend_union |
bool
|
|
blend_radius |
float
|
|
geodesics_method |
str
|
'heat_cgal' CGAL heat geodesic distances (recommended) 'heat' custom heat geodesic distances |
anisotropic_scaling |
bool
|
This is not yet implemented |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
has_uneven_weights
property
¶
Returns True if the target has uneven_weights calculated, False otherwise.
find_targets_connected_components
¶
Clusters all the vertices that belong to the target into neighborhoods using a graph. Each target can have an arbitrary number of neighborhoods/clusters. Fills in the attributes: self.all_target_vkeys, self.clustered_vkeys, self.number_of_boundaries
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
compute_geodesic_distances
¶
Computes the geodesic distances from each of the target's neighborhoods to all the mesh vertices. Fills in the distances attributes.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
update_distances_lists
¶
Fills in the distances attributes.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
compute_uneven_boundaries_weight_max
¶
If the target has multiple neighborhoods/clusters of vertices, then it computes their maximum distance from the other_target. Based on that it calculates their weight_max for the interpolation process
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_boundaries_rel_dist_from_other_target
¶
Returns a list, one relative distance value per connected boundary neighborhood. That is the average of the distances of the vertices of that boundary neighborhood from the other_target.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_avg_distances_from_other_target
¶
Returns the minimum and maximum distance of the vertices of this target from the other_target
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_all_clusters_distances_dict
¶
Returns dict. keys: index of connected target neighborhood, value: list, distances (one per vertex).
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_max_dist
¶
Returns the maximum distance that the target has on a mesh vertex.
get_all_distances
¶
Return distances for all vertices as 1D array, applying union method.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_all_distances_array
¶
Return raw distances as (n_boundaries, n_vertices) array.
get_all_distances_for_vkey
¶
Returns distances from each cluster separately for vertex i. Smooth union doesn't play here any role.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
get_distance
¶
Return get_distance for vertex with vkey i.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
laplacian_smoothing
¶
Smooth the distances on the mesh, using iterative laplacian smoothing.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
save_distances
¶
Save distances to json. Saves one list with distance values (one per vertex).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
|
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
assign_new_mesh
¶
When the base mesh changes, a new mesh needs to be assigned.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
blend_union_list
¶
Returns a smooth union of all the elements in the list, with blend radius blend_radius.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
stairs_union_list
¶
Returns a stairs union of all the elements in the list, with blend radius r and number of peaks n-1.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
blend_union
¶
Returns a smooth union of the two elements da, db with blend radius blend_radius.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
chamfer_union
¶
Returns a chamfer union of the two elements da, db with radius r.
stairs_union
¶
Returns a stairs union of the two elements da, db with radius r.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/compound_target.py
geodesics
¶
GeodesicsCache
¶
Cache for geodesic distances to avoid redundant computations.
Note: This class is kept for backwards compatibility but now uses CGAL. The CGAL solver has its own internal caching via _cgal_solver_cache.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
clear
¶
get_distances
¶
Get geodesic distances from sources, using cache when possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
The mesh to compute distances on. |
required |
sources
|
list[int]
|
Source vertex indices. |
required |
method
|
str
|
Geodesic method (ignored, always uses CGAL heat method). |
'heat'
|
Returns:
| Type | Description |
|---|---|
NDArray
|
Minimum distance from any source to each vertex. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
GeodesicsSolver
¶
Computes custom geodesic distances. Starts from implementation of the method presented in the paper 'Geodesics in Heat' (Crane, 2013)
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
:class: compas.datastructures.Mesh
|
|
OUTPUT_PATH |
str
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
diffuse_heat
¶
Heat diffusion using iterative backward Euler.
This is a custom Python implementation of the heat method. For production use, prefer CGAL's heat method (geodesics_method='heat_cgal') which uses intrinsic Delaunay triangulation for better accuracy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vi_sources
|
list[int]
|
The vertex indices of the heat sources. |
required |
v_equalize
|
list[int] | None
|
Vertex indices whose values should be equalized (for handling saddle points). |
None
|
Returns:
| Type | Description |
|---|---|
NDArray
|
Heat distribution u, with sources at 0 and increasing away from them. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
get_geodesic_distances
¶
Finds geodesic distances from heat distribution u. I
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
NDArray[floating]
|
|
required |
vi_sources
|
list[int]
|
|
required |
v_equalize
|
list[int] | None
|
|
None
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
get_heat_geodesic_distances
¶
Calculate geodesic distances using CGAL heat method.
Uses compas_cgal's HeatGeodesicSolver which provides CGAL's Heat_method_3 implementation with intrinsic Delaunay triangulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
A compas mesh (must be triangulated). |
required |
vertices_start
|
list[int]
|
Source vertex indices. |
required |
Returns:
| Type | Description |
|---|---|
NDArray
|
Minimum distance from any source to each vertex. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
get_custom_HEAT_geodesic_distances
¶
Calculate geodesic distances using the custom heat method.
This is a pure Python implementation of the heat method (Crane et al., 2013). For production use, prefer CGAL's implementation via get_heat_geodesic_distances() which uses intrinsic Delaunay triangulation for better accuracy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
A compas mesh (must be triangulated). |
required |
vi_sources
|
list[int]
|
Source vertex indices. |
required |
OUTPUT_PATH
|
str
|
Path to save intermediate results. |
required |
v_equalize
|
list[int] | None
|
Vertices to equalize (for saddle point handling). |
None
|
Returns:
| Type | Description |
|---|---|
NDArray
|
Geodesic distance from sources to each vertex. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/geodesics.py
gradient
¶
get_vertex_gradient_from_face_gradient
¶
Finds vertex gradient given an already calculated per face gradient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
face_gradient
|
NDArray[floating]
|
|
required |
Returns:
| Type | Description |
|---|---|
np.array (dimensions : #V x 3) one gradient vector per vertex.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
get_edge_gradient_from_vertex_gradient
¶
Finds edge gradient given an already calculated per vertex gradient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
vertex_gradient
|
NDArray[floating]
|
|
required |
Returns:
| Type | Description |
|---|---|
np.array (dimensions : #E x 3) one gradient vector per edge.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
get_face_gradient_from_scalar_field
¶
Finds face gradient from scalar field u. Scalar field u is given per vertex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
u
|
NDArray[floating]
|
|
required |
Returns:
| Type | Description |
|---|---|
np.array (dimensions : #F x 3) one gradient vector per face.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
get_face_edge_vectors
¶
Returns the edge vectors of the face with fkey.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
get_per_vertex_divergence
¶
Computes the divergence of the gradient X for the mesh, using cotangent weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
X
|
NDArray[floating]
|
|
required |
cotans
|
NDArray[floating]
|
|
required |
Returns:
| Type | Description |
|---|---|
np.array (dimensions : #V x 1) one float (divergence value) per vertex.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
normalize_gradient
¶
Returns normalized gradient X.
get_scalar_field_from_gradient
¶
Find scalar field u that best explains gradient X. Laplacian(u) = Divergence(X). This defines a scalar field up to translation, then we subtract the min to make sure it starts from 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
|
required |
X
|
NDArray[floating]
|
|
required |
C
|
csr_matrix
|
sparse matrix (dimensions: #V x #V), cotmatrix, each row i corresponding to v(i, :) |
required |
cotans
|
NDArray[floating]
|
|
required |
Returns:
| Type | Description |
|---|---|
np.array (dimensions : #V x 1) one scalar value per vertex.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/gradient.py
mesh_attributes_handling
¶
create_mesh_boundary_attributes
¶
Creates a default vertex attribute data['boundary']=0. Then it gives the value 1 to the vertices that belong to the lower boundary, and the value 2 to the vertices that belong to the higher boundary.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
get_existing_cut_indices
¶
Returns:
| Type | Description |
|---|---|
list, int.
|
The cut indices (data['cut']>0) that exist on the mesh vertices. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
get_existing_boundary_indices
¶
Returns:
| Type | Description |
|---|---|
list, int.
|
The boundary indices (data['boundary']>0) that exist on the mesh vertices. |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
get_vertices_that_belong_to_cuts
¶
Returns:
| Type | Description |
|---|---|
dict, key: int, the index of each cut
|
value: dict, the points that belong to this cut (point_list_to_dict format) |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
save_vertex_attributes
¶
Saves the boundary and cut attributes that are on the mesh on a dictionary.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
restore_mesh_attributes
¶
Restores the cut and boundary attributes on the mesh vertices from the dictionary of the previously saved attributes
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
replace_mesh_vertex_attribute
¶
Replaces one vertex attribute with a new one. For all the vertices where data[old_attr]=old_val, then the old_val is replaced with 0, and data[new_attr]=new_val.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/mesh_attributes_handling.py
region_split
¶
MeshSplitter
¶
Curved slicing pre-processing step.
Takes one continuous mesh with various saddle points and splits it up at every saddle point following the direction of the iso-contour that intersects that saddle point, so that the resulting mesh has no remaining saddle points.
The result is a series of split meshes whose vertex attributes have been updated with boundary attributes at the newly created cuts, (i.e. they all have vertex 'boundary' attributes 1,2 on their lower and upper boundaries)
For each newly created mesh, a separate slicer needs to be created. Like that, we will always have one slicer per mesh with the correct attributes already assigned. However, it can still happen that a slicer that takes a split mesh outputs more than one vertical_layers_print_data (vertical layers).
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
:class: 'compas.datastructures.Mesh'
|
|
target_LOW |
:class: 'compas_slicer.pre_processing.CompoundTarget'
|
|
target_HIGH |
:class: 'compas_slicer.pre_processing.CompoundTarget'
|
|
DATA_PATH |
str, the path to the data folder
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
run
¶
Runs the mesh splitting process. This consists of the following parts.
(1) Find the iso-contours that intersect the saddle points. Iteratively find the weights (from 0 to 1) that output a distance field whose iso-contour is intersecting each saddle point. Here two iterations are carried out (one rough and one exact search).
For each saddle point and its respective weight and iso-contour: (2) Find the zero-crossing points of the iso-contour and merge points that are close to the saddle to ensure connection. (3) Cleanup iso-contour. Only keep neighborhoods that are intersecting the saddle point. Discard all other. (4) Create the cut on the mesh. (5) Weld the resulting mesh, and restore all the vertex attributes. Note that the mesh remains in one piece, although the cuts have been created. (6) Update compound tardets with the new mesh.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
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 | |
update_targets
¶
Update targets with the new mesh that was created during the split process. Note: This only works if the target vertices have not been touched. If all has gone well, targets can only have minima and maxima, so they should remain intact after the split
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
split_intersected_faces
¶
Create cuts on intersected faces
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zero_contours
|
|
required | |
cut_index
|
|
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
identify_positions_to_split
¶
Find the weights that create iso-contours that intersect the saddle points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
saddles
|
|
required |
Returns:
| Type | Description |
|---|---|
list, float, the weights from 0 to 1. One for each saddle point.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
find_weight_intersecting_vkey
¶
Find the weights that intersect the vertex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vkey
|
|
required | |
threshold
|
|
required | |
resolution
|
|
required |
Returns:
| Type | Description |
|---|---|
float, the weights from 0 to 1.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
get_weights_list
¶
Returns a numpy array with n numbers from start to end.
separate_disconnected_components
¶
Given a mesh with cuts that have already been created, it separates the disconnected components by cutting along marked edges. Then it welds them and restores their attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
|
required | |
attr
|
|
required | |
values
|
|
required | |
OUTPUT_PATH
|
|
required |
Returns:
| Type | Description |
|---|---|
list, :class: 'compas.datastructures.Mesh' The resulting split meshes.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
smoothen_cut
¶
smoothen_cut(zero_contours, mesh, saddle_vkeys, iterations, strength, distance_threshold=20.0 * 20.0)
Iterative smoothing of the cut around the saddle point.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
merge_clusters_saddle_point
¶
Merge the points that are on edges that have the saddle point as one of their edges to the saddle point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zero_contours
|
ScalarFieldContours
|
Contours object. |
required |
saddle_vkeys
|
list[int]
|
Vertex keys of the current saddle points (currently only single saddle point supported). |
required |
Returns:
| Type | Description |
|---|---|
list, int. The index neighborhoods that are related to the saddle points.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
cleanup_unrelated_isocontour_neighborhoods
¶
Remove the neighborhoods of the zero-crossing contour when they are not related to the saddle points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zero_contours
|
|
required | |
keys_of_clusters_to_keep
|
|
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
weld_mesh
¶
Welds mesh and check that the result is valid.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/region_split.py
topological_sorting
¶
DirectedGraph
¶
Base class for topological sorting of prints that consist of several parts that lie on each other. For example the graph A->B->C would represent a print that consists of three parts; A, B, C where A lies on the build platform, B lies on A, and C lies on B. This graph cannot have cycles; cycles would represent an unfeasible print.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
find_roots
abstractmethod
¶
Roots are vertical_layers_print_data that lie on the build platform. Like that they can be print first.
find_ends
abstractmethod
¶
Ends are vertical_layers_print_data that belong to exclusively one segment. Like that they can be print last.
create_graph_nodes
abstractmethod
¶
get_children_of_node
abstractmethod
¶
Find all the vertical_layers_print_data that lie on the current root segment.
create_directed_graph_edges
¶
Create the connectivity of the directed graph using breadth-first search graph traversal.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
check_that_all_nodes_found_their_connectivity
¶
Assert that there is no island, i.e. no node or groups of nodes that are not connected to the base.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
sort_queue_with_end_targets_last
¶
Sorts the queue so that the vertical_layers_print_data that have an end target are always at the end.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
get_adjacency_list
¶
Returns adjacency list. Nested list where adj_list[i] is a list of all the neighbors of the ith component
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
get_in_degree
¶
Returns in_degree list. Nested list where adj_list[i] is a list of all the edges pointing to the node.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
get_all_topological_orders
¶
Finds all topological orders from source to sink.
Returns:
| Type | Description |
|---|---|
list of lists of integers. Each list represents the indices of one topological order.
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
get_orders
¶
Finds all topological orders from source to sink. Sorting algorithm taken from https://www.techiedelight.com/find-all-possible-topological-orderings-of-dag/
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
get_parents_of_node
¶
Returns the parents of node with i = node_index.
MeshDirectedGraph
¶
Bases: DirectedGraph
The MeshDirectedGraph is used for topological sorting of multiple meshes that have been generated as a result of region split over the saddle points of the mesh scalar function
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
find_roots
¶
Roots are vertical_layers_print_data that lie on the build platform. Like that they can be print first.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
find_ends
¶
Ends are vertical_layers_print_data that belong to exclusively one segment. Like that they can be print last.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
create_graph_nodes
¶
Add each of the split meshes to the graph as nodes. Cuts and boundaries are stored as attributes.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
get_children_of_node
¶
Find all the nodes that lie on the current root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
int
|
|
required |
Returns:
| Type | Description |
|---|---|
2 lists [child1, child2, ...], [[common cuts 1], [common cuts 2] ...]
|
|
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
SegmentsDirectedGraph
¶
Bases: DirectedGraph
The SegmentsDirectedGraph is used for topological sorting of multiple vertical_layers_print_data in one mesh
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
find_roots
¶
Roots are vertical_layers_print_data that lie on the build platform. Like that they can be print first.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
find_ends
¶
Ends are vertical_layers_print_data that belong to exclusively one segment. Like that they can be print last.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
create_graph_nodes
¶
Add each segment to to the graph as a node.
get_children_of_node
¶
Find all the nodes that lie on the current root.
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
are_neighboring_point_clouds
¶
Returns True if 3 or more points of the point clouds are closer than the threshold. False otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pts1
|
list[Point]
|
|
required |
pts2
|
list[Point]
|
|
required |
threshold
|
float
|
|
required |
Source code in src/compas_slicer/pre_processing/preprocessing_utils/topological_sorting.py
is_true_mesh_adjacency
¶
Returns True if the two meshes share 3 or more vertices. False otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
all_meshes
|
list[Mesh]
|
|
required |
key1
|
int
|
|
required |
key2
|
int
|
|
required |