This library contains a class SubdivisionSmoothing that provides methods for performing subdivision and smoothing operations on 3D meshes. The class includes methods for Simple Subdivsion, Laplacian Smoothing, and a custom Subdivision Method that takes into account vertex position and edge sharpness. It also includes some helpful methods for making a subdivision or smoothing method yourself.
To use this library, you need to have Python installed.
- Create and navigate to your project directory.
- Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install the package using pip:
For normal installation:
For development installation:
pip install subdivision-smoothing
pip install subdivision-smoothing[dev]
- For development, clone the
subdivision_smoothing\debugdir from the repository. You can use thedebug.pyscript to visualize the intermediate steps of the algorithms.
Here's a basic example of how to use the SubdivisionSmoothing class:
from subdivision_smoothing import SubdivisionSmoothing
import trimesh
# Load a mesh
mesh = trimesh.load_mesh('path_to_your_mesh.obj')
# Use a sudivision method on the mesh
subdivided_mesh = SubdivisionSmoothing.simple_subdivide(mesh, iterations=2)
# Save or visualize the subdivided mesh
subdivided_mesh.export('subdivided_mesh.obj')The following are known issues with the most recent version of the package
edge_erosion_subdivisionis only stable for 1 iteration for some meshes. The cause is how the meshing library handles degenerate faces, so I am working a solution that doesn't create any degenerate facessimple_smoothraises an error when processing certain meshes. The cause is unknown.