Overview
SVG (Scalable Vector Graphics) is an XML-based vector image format. Mslicer’s SVG output represents each layer as a collection of polygons showing the exact slice geometry.Key Features
- Format: XML-based SVG
- Content: Vector polygons (not rasterized)
- Scalability: Resolution-independent
- Size: Variable (depends on model complexity)
- Use Case: Visualization and debugging
- Compression: None (plain text XML)
Output Structure
Mslicer arranges layers in a grid layout within a single SVG file:Grid Layout
Fromslicer/src/slicer/slice_vector.rs:109-120:
- Grid size = ⌈√(layer_count)⌉ × ⌈√(layer_count)⌉
- Each cell = platform width × platform height
- Layers fill left-to-right, top-to-bottom
Example Layout (9 layers)
Geometry Representation
Polygon Elements
Each layer’s solid regions are represented as SVG polygons:Layer Boundaries
Each layer cell has a bounding rectangle:Slicing Process
Vector Slicing
Fromslicer/src/slicer/slice_vector.rs:29-60:
Segment Joining
The slicer generates line segments from mesh intersections, then joins them into closed polygons:- Mesh Intersection: Find where each triangle intersects the slice plane
- Segment Collection: Gather all intersection segments
- Polygon Assembly: Join segments into closed polygons (from
slice_vector.rs:66-98)
Use Cases
1. Slice Verification
Visually inspect slice geometry:- Verify correct slicing orientation
- Check for missing/extra geometry
- Identify thin walls or small features
- Spot mesh errors
2. Quality Inspection
Analyze slice quality:- Measure feature sizes
- Check wall thickness consistency
- Verify support placement
- Identify problematic layers
3. Documentation
Create technical documentation:- Export to PDF for reports
- Include in presentations
- Share slice previews
- Generate instruction manuals
4. Debugging
Troubleshoot slicing issues:- Inspect mesh topology problems
- Verify coordinate transformations
- Check layer height calculations
- Identify floating geometry
5. Post-Processing
Manipulate slice data:- Import into CAD software
- Edit polygons manually
- Generate toolpaths
- Create custom visualizations
Viewing SVG Files
Web Browsers
All modern browsers support SVG:Vector Editors
- Inkscape: Full-featured vector editor
- Adobe Illustrator: Professional vector editing
- Affinity Designer: Vector design software
Image Viewers
- GIMP: Can import and rasterize SVG
- Preview (macOS): Native SVG support
- Eye of GNOME (Linux): SVG viewer
Advantages
Resolution Independent
Zoom infinitely without pixelation:- Inspect fine details
- Measure exact dimensions
- Verify sub-pixel features
Editable
Modify geometry in vector editors:- Adjust polygon vertices
- Add annotations
- Overlay measurements
- Combine multiple slices
Small File Size (Simple Models)
For models with simple geometry:- Much smaller than raster formats
- Quick to load and render
- Easy to share
Human-Readable
XML format is text-based:- Version control friendly
- Diffable
- Parseable with standard tools
Limitations
Not for Printing
SVG output cannot be used directly on printers:- No rasterization
- No exposure settings
- No preview images
- Missing printer-specific metadata
Large File Size (Complex Models)
For highly detailed models:- Many polygons = large XML
- Can be slow to render
- May exceed memory limits in viewers
No Anti-Aliasing
Vector output shows exact geometry:- No grayscale values
- No anti-aliasing data
- Binary (solid/empty) representation
Performance
Vector slicing is fast but uses more memory:- Slicing: Comparable to raster slicing
- Segment Joining: O(n²) algorithm (can be slow for complex layers)
- Serialization: Fast (just write XML)
Very complex models with many small features may take longer to process due to the segment joining algorithm.
Implementation Details
Fromslicer/src/slicer/slice_vector.rs:
Segment Storage
SVG Generation
The SVG document is created using thesvg crate:
SlicedFile Trait
SVG implements theSlicedFile trait with limitations:
Command Line Usage
Example Output
A simple cube sliced into 10 layers would generate an SVG showing:- 10 cells in a 4×3 grid (⌈√10⌉ = 4)
- Each cell contains a square polygon
- Gray borders around each cell
- Black outlines for the cube cross-sections
See Also
- Chitu CTB Format - Binary raster format for printing
- Elegoo GOO Format - Binary raster format for printing
- NanoDLP Format - PNG-based raster format for printing
- Format Overview - Compare all formats