CLIP Slicer is a model-preparation tool for 3D printing, with an emphasis on slice inspection and support generation. It grew out of my experience with models that developed printing artifacts because of defects in STL geometry or insufficient support.
CLIP Slicer accepts 3D models in
STL format, reads and exports
slices in Common Layer Interface (CLI) format,
and saves complete document layouts as compressed .clipslicer workspaces.
A workspace preserves groups, visibility, selections, and model transformation
matrices. Model files may either remain linked or be embedded to make the
workspace self-contained.
Before export, the Section tool can inspect
the contours produced at the configured layer thickness and first-layer offset.
Z-axis sections correspond to the layers produced by normal slicing; X- and
Y-axis sections are inspection views and are not exported as layers.
Support generation consists of three main tools:
- Detect visualizes areas with insufficient support.
- Optimize searches for a model orientation that minimizes the total area of unsupported surfaces.
- Generate produces support structures that connect unsupported surfaces to the build platform.
The core application code is structured as a reusable C++17 library that can be integrated into other projects. A small command-line slicer is also provided for batch processing.
The following screenshots show the model view and generated supports:
The model shown is the traditional Bust of Sappho from Thingiverse (thing 14565).
The command-line target depends only on a C++17 compiler and CMake. The GUI target additionally requires development packages for wxWidgets 3.2 (including wxWebView), OpenGL, GLU, and libepoxy. On Linux, wxWebView uses the system WebKitGTK backend.
Build the command-line slicer only:
cmake -S . -B build-cli \
-DCMAKE_BUILD_TYPE=Release \
-DSTL_SLICER_BUILD_GUI=OFF
cmake --build build-cliBuild the GUI and command-line targets together:
cmake -S . -B build-gui \
-DCMAKE_BUILD_TYPE=Release \
-DSTL_SLICER_BUILD_GUI=ON
cmake --build build-guiRun the test suite:
ctest --test-dir build-cli --output-on-failure
ctest --test-dir build-gui --output-on-failureRun the binaries:
./build-cli/stl-slicer
./build-gui/stl-slicer
./build-gui/clip-slicer
./build-gui/clip-slicer model.stl
./build-gui/clip-slicer --help-topicsIf wxWidgets with wxWebView, OpenGL, GLU, or libepoxy development packages are not installed, keep
-DSTL_SLICER_BUILD_GUI=OFF.
If the host uses ccache with an unavailable cache directory, prefix these commands with
CCACHE_DISABLE=1.
An RPM spec is provided in packaging/rpm/clip-slicer.spec. On Fedora, install
its build dependencies with:
sudo dnf install rpm-build rpmdevtools cmake gcc-c++ ninja-build \
polyclipping2-devel wxGTK-devel wxGTK-webview gtk3-devel \
libepoxy-devel mesa-libGLU-develTo build from a versioned checkout, create the source archive expected by the
spec and run rpmbuild:
rpmdev-setuptree
git archive --format=tar.gz --prefix=clip-slicer-0.2.2/ \
--output="$HOME/rpmbuild/SOURCES/v0.2.2.tar.gz" HEAD
rpmbuild -ba packaging/rpm/clip-slicer.specThe build produces clip-slicer-libs, containing the shared slicing library,
and clip-slicer, containing both the GUI and command-line applications.
Windows cross-compilation requires locally installed MSVC and Windows SDK headers and libraries. For the GUI build described here, mstorsjo/msvc-wine was installed first and used to download and configure those Microsoft components for Clang/LLD's MSVC-compatible mode. Installing the Microsoft toolchain requires accepting the applicable Microsoft license.
The msvc-wine setup scripts are licensed under the permissive ISC license,
but that license does not cover the downloaded MSVC or Windows SDK files. The
installed Microsoft toolchain is not redistributable and must not be added to
this repository or binary packages. The resulting application binaries may be
distributed subject to the applicable Microsoft runtime redistribution terms
and the other licenses documented by this project.
build_windows.sh expects msvc-wine/msvcenv-native.sh under the user's home
directory and, by default, an installed toolchain under my_msvc/ there. After
installing those prerequisites, run:
./build_windows.shThis builds the command-line slicer into build-windows/ with the Windows toolchain from
cmake/toolchains/windows-clang-msvc.cmake. The wrapper defaults to
STL_SLICER_BUILD_GUI=OFF and STL_SLICER_BUILD_TESTS=OFF, which avoids depending on
Windows-targeted wxWidgets during initial cross-compilation. After Windows wxWidgets is
installed, enable the GUI build with:
STL_SLICER_BUILD_GUI=ON ./build_windows.shThe CLIP Slicer user manual is written in LaTeX and can be built with:
make -C docs pdf
make -C docs htmlThe generated manuals are stored at docs/build/main.pdf and
docs/build/main.html. The HTML target requires Pandoc and produces one
self-contained file with an embedded stylesheet and offline MathML. The GUI
loads a generated copy of this file directly from its executable. After
changing the manual, refresh that embedded copy with:
make -C docs embeddedPandoc preserves the TikZ figure captions but not the drawings; the diagrams currently remain available in the PDF manual only.
To enable compile-time CPU-specific vectorization, set the compiler architecture target:
cmake -S . -B build-native -DCMAKE_BUILD_TYPE=Release -DSTL_SLICER_ARCH=native
cmake --build build-nativeThe target is intentionally opt-in so normal release binaries remain portable. A named GCC target
such as core-avx-i can be used instead of native when building for another machine. GCC
vectorization decisions and source-interleaved assembly can be inspected with:
c++ -std=c++17 -O3 -march=native -fopt-info-vec-all=vectorization.txt \
-S -g -fverbose-asm -Iinclude src/slicer.cpp -o slicer.s./build-cli/stl-slicer model.stl layers.cli 0.1
./build-cli/stl-slicer --ascii --tolerance 0.00001 model.stl layers.cli 0.1
./build-cli/stl-slicer --healing-threshold 0.01 model.stl layers.cli 0.1The layer thickness defaults to 0.1 mm. Binary CLI output using PolyLine Long commands is the
default; --ascii is useful for inspection. STL coordinates are treated as millimeters because
STL itself does not store units. When writing CLI geometry, layer Z coordinates are translated so
the lowest generated layer is positioned at half the layer thickness above the build platform.
X and Y coordinates are translated by their minimum emitted values. The resulting CLI model has
its bounding-box origin at (0, 0, 0), while the reusable slice objects retain their original
model-space coordinates. CLI DIMENSION metadata describes this translated geometry and the full
layer-stack height.
After exact segment connection, the slicer heals endpoints of paths that remain open when their
gap is no more than the contour healing threshold. The threshold defaults to 0.01 model units.
Use --healing-threshold to adjust the maximum crack width accepted when a model intentionally
contains closely separated features. The --tolerance option independently controls endpoint
matching during initial segment connection and also defaults to 0.01 model units.
The writer includes the custom header directive $$USERDATA/CLIPSlicer,0,. This compatibility
instruction tells the target third-party reader to join open contours automatically and determine
filled and empty regions from the winding rule. It is emitted for both ASCII and binary CLI files.
The library API is divided into reusable data and processing components:
TriangleMesh,Triangle,Vec2,Vec3, andBounds3store model geometry.BinaryStlReadervalidates and reads little-endian binary STL streams or files.Slicerproduces reusableSliceData,SliceLayer, andSlicePathobjects.FlatFacetDetectorfinds ranked outer planar facets and merges disconnected coplanar fragments within its configured plane tolerance;alignFacetToBuildPlatformproduces a non-destructive placement transform.CliWriterwrites binary or ASCII CLI streams or files.CliReaderreads binary CLI layer files.SceneModel,MeshSceneModel, andSliceSceneModelprovide shared transformed/renderable model abstractions for applications.
- Left drag rotates the camera around the models.
- Holding X, Y, or Z while left-dragging rotates selected models around the corresponding absolute build axis and their common geometric center. Horizontal drag controls the rotation angle.
- Middle drag translates the camera parallel to the screen; right drag moves it along the screen normal.
- Mouse wheel zooms the camera view. Ctrl+left drag duplicates wheel zoom, and Ctrl+right drag duplicates middle drag.
- Holding Shift with a mouse operation targets selected models instead of the camera. Shift+middle drag translates them in the absolute X-Y build plane, and Shift+right drag translates them along the absolute Z axis, independently of camera orientation. Shift+left drag rotates them and Shift+wheel scales them around their common geometric center.
- Section mode supports planes normal to the X, Y, or Z axis. Alt+wheel moves the translucent section plane and updates a filled, double-sided cross-section on a separate display plane outside the selected models. The optional best-view mode faces and fits that plane to the viewport. Optional Above or Below clipping hides the corresponding side of selected model geometry while leaving the section display intact. Z section positions snap to the global build-layer sequence defined by the configured first-layer offset and layer thickness; X and Y sections use the corresponding selected-bounds minimum as their origin. Alt+Shift+left drag provides the same section-position control without a wheel. A horizontal scrollbar above the view and a slice-index spin box to its right provide direct positioning. With the scrollbar focused, Up/Down move one slice and Page Up/Page Down move ten slices. Cross-section previews update continuously while the scrollbar thumb is dragged. Model visibility does not hide the build platform, section plane, projection plane, or projected contours.
File > Open... accepts multiple STL or CLI files and creates one new document containing
them, while File > Open into document... adds all selected files to the active
document. Slice export merges every selected sliced model and stably orders their layers by
Z, including layers from different models at the same height.
The viewport draws global X/Y/Z axes in both directions. Cross-tick spacing follows viewport scale in power-of-ten steps with a 2x density adjustment. A fixed-size orientation vane in the lower-left uses blue for X, red for Y, and bright green for Z.
Model transforms are matrix-based and do not modify source coordinates. Slicing applies the stored transforms to a temporary triangle mesh. Render normals are blended across non-crease edges. Sliced models use GLU winding-rule tessellation for concave top and bottom caps, including holes. Side and cap geometry are cached in static OpenGL vertex buffers and rebuilt only when model geometry changes.
Closed contours are classified by containment depth. External contours are emitted
counter-clockwise (dir = 1), internal contours clockwise (dir = 0), and unconnected paths as
open (dir = 2). Coplanar horizontal triangles are ignored using a consistent half-open plane
intersection rule.
The slicer assumes a clean, watertight triangle mesh for closed output. Endpoint tolerance can bridge small numeric discrepancies, but this version does not repair holes, self-intersections, overlapping shells, or non-manifold geometry.
Sliced-model rendering includes vertical walls and tessellated top and bottom caps, including concave contours and holes. Contour editing and comprehensive mesh-repair tools remain planned geometry/editor work.
Except for this disclosure, the brief introduction, and the screenshots, the code, documentation, and artwork in this project were created entirely through vibe coding with OpenAI's ChatGPT 5.6 model. The project is part of my learning experience with AI agents and production-oriented software development.
The source code is available under the PolyForm Noncommercial License 1.0.0; commercial use requires separate explicit permission. Original documentation and original artwork are available under CC0 1.0. The example screenshots are excluded from CC0 because they incorporate a CC BY-SA 4.0 model and are distributed under CC BY-SA 4.0. See LICENSE.md for the precise scope, third-party attribution, license texts, and commercial-contact details.

