Initializing 3D Canvas...

Planar Slicing & Layering

4 min read1 page

Planar Mesh Slicing (Contour Generation): Slicing is the fundamental gateway of 3D printing (FDM, SLA, SLS). An arbitrary triangular mesh model is intersected by horizontal cutting planes at height $z = k \cdot \Delta z$. Each triangle intersecting the plane produces an isolated line segment. Graph chaining stitches segments end-to-end into closed, winding-oriented perimeter polygons.

Slicing Contour Pipeline:

1. Triangle Intersection: Edge interpolation where vertex signs $(z_i - z_0)$ differ across the slicing plane. 2. Segment Chaining: Hash-map indexing connects endpoints sharing spatial coordinates into ordered polygons. 3. Winding Classification: Outer perimeters wind counter-clockwise (CCW); interior holes wind clockwise (CW).
python
1def intersect_triangle_plane(v0, v1, v2, z_slice):
2 """
3 Computes intersection segment between a 3D triangle and a horizontal slicing plane Z = z_slice.
4 Returns None if triangle does not cross plane, or a 2-point line segment [P1, P2].
5 """
6 vertices = [v0, v1, v2]
7 dists = [v[2] - z_slice for v in vertices]
8
9 # Check if all vertices lie on one side
10 if (dists[0] > 0 and dists[1] > 0 and dists[2] > 0) or \
11 (dists[0] < 0 and dists[1] < 0 and dists[2] < 0):
12 return None
13
14 pts = []
15 edges = [(0, 1), (1, 2), (2, 0)]
16 for i, j in edges:
17 d_i, d_j = dists[i], dists[j]
18 # Edge crosses slicing plane
19 if (d_i > 0 and d_j < 0) or (d_i < 0 and d_j > 0):
20 t = abs(d_i) / (abs(d_i) + abs(d_j))
21 p_interp = vertices[i] + t * (vertices[j] - vertices[i])
22 pts.append(p_interp)
23
24 return pts if len(pts) == 2 else None
Slicing Plane Z
0.20
2 min read1 page

Adaptive Layer Slicing (Cusp Height Optimization): Constant layer thickness forces a harsh trade-off between print time and surface fidelity. Adaptive slicing calculates the layer height dynamically: steep vertical walls slice at maximum speed with thick layers, while gently sloping domes automatically thin down to sub-millimeter slices to suppress stair-stepping artifacts below the threshold of human perception.

Cusp Geometry Invariant:

1. Cusp Height Metric: The maximum geometric deviation between the stepped slice edge and the continuous curved boundary. 2. Slope Inversion: Layer height scales inversely with surface normal horizontal tilt $\cos \theta$. 3. Print Acceleration: Reduces total build time by 40-60% without compromising surface roughness standards.
python
1import math
2
3def compute_adaptive_layer_height(surface_normal, target_cusp=0.02, min_h=0.05, max_h=0.30):
4 """
5 Computes adaptive slicing thickness based on surface inclination angle theta.
6 Cusp error delta = layer_height * cos(theta).
7 Therefore layer_height = target_cusp / cos(theta), clamped to [min_h, max_h].
8 """
9 # Normal dot product with vertical Z axis
10 nz = abs(surface_normal[2])
11 cos_theta = math.sqrt(max(0.0, 1.0 - nz * nz)) # inclination relative to vertical
12
13 if cos_theta < 1e-4:
14 return min_h # Flat horizontal surfaces require finest resolution
15
16 adaptive_h = target_cusp / cos_theta
17 return max(min_h, min(max_h, adaptive_h))
Target Cusp Height (mm)
0.03