2D triangle mesh remeshing toolkit (greedy + patch drivers, pocket fill, visualization).
Project description
SOFIA - Scalable Operators for Field-driven Iso/Ani Adaptation
A Modern 2D Triangular Mesh Modification Library
Features • Installation • Quick Start • Documentation • Examples • Roadmap
What is SOFIA?
SOFIA is a pure Python library for 2D triangular mesh modification and remeshing. It provides robust, high-quality local operations to edit, refine, and optimize meshes while maintaining mesh conformity and quality.
Perfect for:
- Computational scientists working with 2D simulations
- Computer graphics professionals needing mesh processing
- Numerical analysis requiring adaptive mesh refinement
- Researchers in mesh generation and optimization
Features
Core Operations
- Edge Split - Midpoint and Delaunay-based splitting
- Edge Collapse - Quality-preserving mesh coarsening
- Edge Flip - Improve triangle quality through flipping
- Vertex Insertion/Removal - Add or remove mesh vertices
- Pocket Filling - Fill holes in meshes intelligently
- Boundary Operations - Safe manipulation of mesh boundaries
Quality & Robustness
- Quality Metrics - Min angle, area, shape measures
- Conformity Checks - Ensure valid mesh topology
- Amortized Validation - Fast incremental checking
- Strict Mode - Optional rigorous validation
- Area Preservation - Maintain geometric properties
Workflows
- Greedy Remeshing - Iterative quality improvement
- Patch-based Processing - Batch operations on mesh regions
- Visualization - Built-in plotting with Matplotlib
- Extensive Testing - 50+ unit tests for reliability
Installation
Using pip (Recommended)
pip install sofia-mesh
From Source
git clone https://github.com/youssef-mesri/sofia.git
cd sofia
pip install -e .
Requirements
- Python 3.8 or higher
- NumPy ≥ 1.20
- SciPy ≥ 1.7
- Matplotlib ≥ 3.3
Quick Start
Basic Example - Improve Mesh Quality
import numpy as np
from sofia import PatchBasedMeshEditor
# Create a simple mesh
points = np.array([
[0.0, 0.0], [1.0, 0.0], [0.5, 0.8],
[0.0, 1.0], [1.0, 1.0]
])
triangles = np.array([
[0, 1, 2], [0, 2, 3], [1, 4, 2], [3, 2, 4]
])
# Initialize editor
editor = PatchBasedMeshEditor(points, triangles)
# Split an edge to refine the mesh
success = editor.split_edge(edge_id=0, method='midpoint')
print(f"Edge split: {success}")
# Get the updated mesh
new_points = editor.pts
new_triangles = editor.tris
# Check mesh quality
min_angle = editor.mesh_min_angle()
print(f"Minimum angle: {min_angle:.2f}°")
Remeshing Example
from sofia.core.remesh_driver import greedy_remesh
# Iteratively improve mesh quality
improved_editor = greedy_remesh(
editor,
target_min_angle=25.0, # Target minimum angle in degrees
max_iterations=100
)
print(f"Final quality: {improved_editor.mesh_min_angle():.2f}°")
Documentation
- API Reference - Complete API documentation
- Examples - Practical usage examples
- Contributing - How to contribute
- Publication Strategy - Development roadmap
Examples
Check out the examples/ directory for more:
basic_remeshing.py- Simple mesh refinementquality_improvement.py- Iterative quality optimizationboundary_operations.py- Boundary manipulation
Roadmap
Current (v1.0) - Python Implementation
- Pure Python implementation
- All core features working
- Suitable for meshes up to ~10K triangles
- Easy installation, no compilation needed
Next (v2.0) - High-Performance C++ Backend
- 20-50x performance improvement 🚀
- Transparent integration (same API)
- Suitable for meshes up to 1M+ triangles
- Optional: falls back to Python if C++ unavailable
- Status: In development (private branch)
Future (v3.0+)
- GPU acceleration
- 3D tetrahedral mesh support
- Parallel batch processing
- Advanced anisotropic remeshing
Citation
If you use SOFIA in your research, please cite:
@software{sofia2025,
author = {Mesri, Youssef},
title = {SOFIA: Scalable Operators for Field-driven Iso/Ani Adaptation},
year = {2025},
url = {https://github.com/youssef-mesri/sofia},
version = {1.0.0}
}
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Found a bug? Open an issue
- Have an idea? Start a discussion
- Want to contribute? Submit a pull request
License
SOFIA is released under the MIT License.
Acknowledgments
- Inspired by classical mesh modification algorithms
- Built with modern Python best practices
- Developed for research in computational geometry
Contact
Author: Youssef Mesri
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: youssef.mesri@minesparis.psl.eu
- ORCID: 0000-0002-5136-5435
Made with love for the computational geometry community
Star us on GitHub if you find SOFIA useful!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sofia_mesh-0.1.0.tar.gz.
File metadata
- Download URL: sofia_mesh-0.1.0.tar.gz
- Upload date:
- Size: 218.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd062a08ad6fb5a1b0bf8e51e8103e3806b5d31d884114515e37d20981c90ea5
|
|
| MD5 |
d435da0a9fd18fc4e2f062625918300b
|
|
| BLAKE2b-256 |
87123d5bbc239bb87a387d22f08078d2781f0e45074f5e762272cb8604c0e065
|
File details
Details for the file sofia_mesh-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sofia_mesh-0.1.0-py3-none-any.whl
- Upload date:
- Size: 258.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2163e9bf5a37639b3a4fc0d9c512dc9c670cb529ab00e11f00884e33252365d
|
|
| MD5 |
db0e24cbdb91d0dcebc576d81566ff48
|
|
| BLAKE2b-256 |
1a5acb51058d7ed7d55bd73c5cd940e5f074cc67e39d2a1463d377245dbdd446
|