Slicing CAD Models into 3D Printing Toolpaths
Transforming a continuous 3D Computer-Aided Design (CAD) model into machine-executable additive manufacturing instructions requires a multi-step computational process known as slicing. This article explains how digital solid geometry is converted into polygonal meshes, mathematically intersected into two-dimensional planar cross-sections, and translated into vectorized toolpaths such as G-code for 3D printers.
1. Mesh Tessellation
Native CAD models rely on Boundary Representation (B-Rep) utilizing non-uniform rational B-splines (NURBS) to represent perfectly smooth mathematical curves and surfaces. Because calculating direct intersections on complex mathematical equations is computationally intensive, slicing software first converts the B-Rep model into a tessellated triangular mesh format, typically STL, OBJ, or 3MF. This mesh approximates the surface using flat triangles defined by three vertices and a surface normal vector.
2. Planar Slicing and Intersection
Once the mesh is oriented within the digital build volume, the slicing engine establishes a series of parallel cutting planes along the vertical build axis (\(Z\)-axis). The distance between these planes corresponds to the specified layer height.
For each plane, the slicer executes line-plane intersection algorithms:
- It evaluates every triangle in the mesh to determine if the horizontal slicing plane intersects its edges.
- Where an intersection occurs, it calculates the Cartesian coordinates of the entry and exit points.
- The algorithm connects these intersection line segments sequentially to form continuous, closed two-dimensional loops (polygons) representing the boundary of the part at that specific \(Z\)-height.
3. Feature Identification and Region Segmentation
The resulting 2D cross-sections are mathematically categorized into distinct functional regions:
- Perimeters (Shells): The outermost and innermost boundaries of the solid.
- Infill Areas: The enclosed internal space within the boundaries.
- Top and Bottom Solid Skins: Layers determined by comparing the current layer's cross-section with adjacent layers above and below to identify areas exposed to the exterior.
- Overhangs and Supports: Algorithms evaluate the angle of the polygons relative to the prior layer; areas exceeding a self-supporting threshold (typically \(45^\circ\)) trigger the generation of temporary sacrificial support structures beneath them.
4. Toolpath Vectorization and Offsetting
With the regions classified, the software computes the actual physical motion paths of the tool (an extruder nozzle, laser spot, or print head):
- Tool Compensation (Offsetting): The tool has a finite width (bead width or laser beam diameter). The path algorithms offset the outermost polygon inward by half the tool diameter to ensure the exterior boundary of the final physical part aligns accurately with the CAD dimensions.
- Infill Generation: The open internal areas are filled using algorithmic patterns (such as rectilinear, honeycomb, or gyroid). These are calculated by casting parallel lines across the polygon interior and trimming them at the internal boundary offsets.
5. G-Code Generation
The final step translates these geometric vectors into standardized machine control commands, commonly G-code. This includes linear interpolation commands (\(G1\)) detailing precise \(X\), \(Y\), and \(Z\) coordinates, along with process-specific variables including feed rate, volumetric material extrusion, laser power, travel speeds, and temperature parameters.