Validate and Optimize Meshes
Contents
[
Hide
]
Check If a Mesh Is Manifold
A mesh is manifold when every edge is shared by exactly two polygons — the mesh forms a closed, watertight surface. Several operations like boolean operations require manifold meshes as their operands. The Mesh.is_manifold() method checks this, the result is not cached so each call recalculates it:
from aspose.threed.entities import Box
# Check if a mesh is manifold
box = Box(1.0, 1.0, 1.0).to_mesh()
print("The box mesh is manifold:", box.is_manifold())Optimize the Mesh’s Memory Usage
Real-world models exported from CAD or DCC tools often contain duplicated control points — identical vertex positions stored multiple times. The Mesh.optimize() method eliminates duplicated control points to reduce the mesh’s memory usage:
# Eliminate duplicated control points to reduce memory usage
optimized = box.optimize(True)
print("The optimized mesh is manifold:", optimized.is_manifold())
# Fine-tune the tolerances used when comparing control points
fine_tuned = box.optimize(True, 1e-8, 1e-9, 1e-8)
print("Control points:", len(fine_tuned.control_points))The overload with four parameters lets you specify the tolerances used when comparing control points, normals and UV coordinates — vertices closer together than the tolerance are considered identical and merged.