Fast Quadratic Mesh Simplification

0.1.13 · active · verified Thu Apr 16

fast-simplification is a Python wrapper around the high-performance Fast-Quadric-Mesh-Simplification C++ library. It provides efficient algorithms for reducing the polygon count of 3D meshes while striving to preserve their overall shape. The library is currently at version 0.1.13, actively maintained by the PyVista project, with a history of regular minor releases addressing compatibility and adding features.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to simplify a mesh using NumPy arrays for points and faces. The `simplify` function returns the new points and faces of the decimated mesh.

import numpy as np
import fast_simplification

# Example mesh data (a simple tetrahedron)
points = np.array([
    [0.0, 0.0, 0.0],
    [1.0, 0.0, 0.0],
    [0.0, 1.0, 0.0],
    [0.0, 0.0, 1.0]
], dtype=np.float64)

# Faces: connectivity of points, typically flattened for PyVista/VTK style
# Each face is defined by its number of vertices (e.g., 3 for a triangle) followed by vertex indices.
faces = np.array([
    3, 0, 1, 2,
    3, 0, 1, 3,
    3, 0, 2, 3,
    3, 1, 2, 3
], dtype=np.int64)

# Perform simplification, e.g., reduce to 50% of original faces
reduction_factor = 0.5
points_simplified, faces_simplified = fast_simplification.simplify(
    points,
    faces,
    reduction_factor
)

print(f"Original points: {len(points)}, Original faces: {len(faces) // 4}") # //4 because each face is 3 indices + 1 count
print(f"Simplified points: {len(points_simplified)}, Simplified faces: {len(faces_simplified) // 4}")

view raw JSON →