Validate and Optimize Meshes

Contents
[ ]

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.isManifold() method checks this, the result is not cached so each call recalculates it:

var aspose = aspose || {};

aspose.threed = require("aspose.3d");

// Check if a mesh is manifold
var box = new aspose.threed.Box(1, 1, 1).toMesh();
console.log("The box mesh is manifold: " + box.isManifold());

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:

var aspose = aspose || {};

aspose.threed = require("aspose.3d");

// Eliminate duplicated control points to reduce memory usage
var optimized = box.optimize(true);
console.log("The optimized mesh is manifold: " + optimized.isManifold());

// Fine-tune the tolerances used when comparing control points
var fineTuned = box.optimize(true, 1e-8, 1e-9, 1e-8);
console.log("Control points: " + fineTuned.getControlPoints().size());

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.