Overview
Mslicer supports loading 3D mesh files in STL and OBJ formats. These are the standard mesh formats used in 3D printing workflows.Format Detection
The mesh format is automatically detected based on the file extension:.stl- Stereolithography format.obj- Wavefront OBJ format
Mesh Structure
All loaded meshes are converted to Mslicer’s internal representation:STL Format
Overview
STL (Stereolithography) is the most common format for 3D printing. It represents surfaces as a collection of triangular facets.Binary STL
Mslicer automatically detects and parses binary STL files: File Structure:ASCII STL
ASCII STL files are also supported: Format:STL Features
- Automatic format detection - Binary vs ASCII determined by file size
- Vertex deduplication - Shared vertices are merged to save memory
- Normal vectors ignored - Normals are recalculated during slicing
- Progress tracking - Reports loading progress for large files
STL Loading Example
OBJ Format
Overview
Wavefront OBJ is a text-based format commonly used in 3D modeling software. Mslicer supports a subset of the OBJ specification focused on triangle meshes.Supported OBJ Elements
Vertex position (x, y, z coordinates)
Face definition (triangle with vertex indices)Supports multiple formats:Note: Only vertex indices are used; texture and normal indices are ignored.
f 1 2 3- Vertex indices onlyf 1/1/1 2/2/2 3/3/3- Vertex/texture/normal indices
OBJ Features
- 1-indexed vertices - OBJ uses 1-based indexing; automatically converted to 0-based
- Line-by-line parsing - Efficient streaming parser
- Flexible face format - Handles vertex-only and vertex/texture/normal formats
- Comments ignored - Lines starting with
#are skipped
Unsupported OBJ Features
Mslicer does not support:- Texture coordinates (
vt) - Vertex normals (
vn) - Materials (
mtllib,usemtl) - Groups (
g) and objects (o) - Smooth shading (
s) - Quads or polygons with more than 3 vertices
OBJ Loading Example
Vertex Deduplication
Both STL and OBJ parsers implement vertex deduplication:f32::to_bits) to ensure exact matches. This:
- Reduces memory usage
- Improves slicing performance
- Maintains mesh topology
Progress Tracking
Both formats support progress reporting during loading:- STL Binary: Progress based on triangle count
- STL ASCII: Progress based on bytes read
- OBJ: Progress based on bytes read
Error Handling
Common errors when loading meshes:- Invalid vertex data: Malformed coordinates or non-numeric values
- Invalid face data: References to non-existent vertices
- File not found: Input path does not exist
- Permission denied: Insufficient permissions to read file
Best Practices
For STL Files
- Use binary STL for larger models (more compact, faster to parse)
- Ensure models are watertight (closed surface)
- Export with consistent units (millimeters recommended)
For OBJ Files
- Triangulate meshes before export
- Use vertex-only format when possible (no textures/normals)
- Verify 1-indexed vertex references
- Remove unused vertices and materials
Performance Comparison
| Format | Parse Speed | File Size | Memory Usage |
|---|---|---|---|
| STL Binary | Fast | Compact | Low |
| STL ASCII | Medium | Large | Low |
| OBJ | Medium | Large | Low |
Example: Multi-Model Loading
Load multiple meshes with different formats:See Also
- Slicer Command - Using the CLI with mesh files
- CLI Options - Model transformation options
- Project Files - Saving and loading projects