# STL Slicer

At Re: Software we had a client who needed custom STL slicing software, a STL slicer takes an STL model and slices it into bitmaps which are then used by a 3D printer to print the model. I was the sole programmer at this project and my work allowed me to place this on my portfolio.

## How it works

An STL model exists out a lot of triangles and vertices the slicer uses these triangles and vertices to get vertical slices of the model. The slicer sorts the triangles from lowest to highest on the Y-axis. Once the triangles are sorted, the slicer will start slicing the model and exporting these slices to BMP’s.

The slicer moves an imaginary line from the Y 0 coordinate and moves it up all the way till the highest point of the STL model. The slicer looks for triangles intersecting with this imaginary line for every time the slicer moves this imaginary line up on the Y coordinate. For every triangle that intersects with this imaginary line, the slicer will calculate the coordinates of this intersection and will project a line between these two intersection coordinates in the BMP for the current slice (The line is an edge on the real model.).

Once we’ve looked through all the intersecting triangles for this Y coordinate we process the BMP for this current slice. This processing ensures that the hollow parts of the model are filled with black pixels in the BMP.

Once the processing is completed, the slicer will write the BMP for this slice to the hard drive.

I’ve optimized the speed of the program by removing triangles from the list the slicer needs to look through. I remove the triangles that are below the imaginary line of the slicer. So once the slicer gets closer to the end, the fewer triangles it needs to look through which speeds up the program in an enormous way.

The slicer also contains the functionality to convert a slice BMP into two BMP’s where the black parts of the BMP are changed with a black/white checkerboard pattern.

## Additional info

GitHub: | |

Developed in: | 2020 |

Technologies used: | STL, BMP, C++ |

Team size: | 1 |