/** * Topology Auto-Fix System * * Comprehensive mesh validation and repair system * * Automatically detects and fixes: * - Duplicate vertices * - Degenerate faces (zero area, invalid vertex count) * - Orphaned edges and vertices * - Non-manifold geometry * - Broken triangulation * - Invalid vertex references * - Holes in mesh */ import { Mesh } from '../geometry/mesh'; import { MeshFace } from '../geometry/mesh_face'; import { MeshEdge } from './mesh_util'; /** * Auto-fix result */ export interface AutoFixResult { /** * Number of duplicate vertices removed */ removedDuplicateVertices: number; /** * Number of degenerate faces removed */ removedDegenerateFaces: number; /** * Number of orphaned vertices removed */ removedOrphanedVertices: number; /** * Number of orphaned edges removed */ removedOrphanedEdges: number; /** * Number of faces re-triangulated */ retriangulatedFaces: number; /** * Number of non-manifold edges fixed */ fixedNonManifoldEdges: number; /** * Number of bow-tie vertices fixed */ fixedBowTieVertices: number; /** * Number of invalid vertex references fixed */ fixedInvalidReferences: number; /** * Whether mesh is now valid */ isValid: boolean; } /** * Remove duplicate vertices (same position) */ export declare function removeDuplicateVertices(mesh: Mesh, tolerance?: number): { removed: number; merged: Record; }; /** * Check if face is degenerate */ export declare function isDegenerateFace(face: MeshFace, mesh: Mesh, areaThreshold?: number): boolean; /** * Remove degenerate faces */ export declare function removeDegenerateFaces(mesh: Mesh, areaThreshold?: number): string[]; /** * Check if vertex is orphaned (not used by any face) */ export declare function isOrphanedVertex(mesh: Mesh, vertexKey: string): boolean; /** * Remove orphaned vertices */ export declare function removeOrphanedVertices(mesh: Mesh): string[]; /** * Check if edge is orphaned (no faces use it) */ export declare function isOrphanedEdge(mesh: Mesh, edge: MeshEdge): boolean; /** * Remove orphaned edges * * Note: Edges are derived from faces, so this actually * removes faces that create invalid edges. */ export declare function removeOrphanedEdges(mesh: Mesh): number; /** * Fix invalid vertex references in faces */ export declare function fixInvalidVertexReferences(mesh: Mesh): number; /** * Check if edge is non-manifold (shared by more than 2 faces) */ export declare function isNonManifoldEdge(mesh: Mesh, edge: MeshEdge): boolean; /** * Fix non-manifold edges * * Strategy: Split the edge by duplicating vertices */ export declare function fixNonManifoldEdges(mesh: Mesh): number; /** * Check if vertex is a bow-tie vertex (faces wrap around in figure-8 pattern) * * A bow-tie vertex occurs when faces connected to a vertex form a non-manifold * pattern where the vertex neighborhood cannot be consistently oriented. */ export declare function isBowTieVertex(mesh: Mesh, vertexKey: string): boolean; /** * Fix bow-tie vertices by splitting them * * Strategy: Split vertex into multiple vertices, one for each * consistent group of faces. */ export declare function fixBowTieVertices(mesh: Mesh): number; /** * Re-triangulate invalid faces */ export declare function retriangulateInvalidFaces(mesh: Mesh): number; /** * Validate mesh integrity */ export declare function validateMesh(mesh: Mesh): { isValid: boolean; errors: string[]; warnings: string[]; }; /** * Complete auto-fix routine * * Runs all fix operations in the correct order. */ export declare function autoFixMesh(mesh: Mesh, options?: { removeDuplicates?: boolean; removeDegenerate?: boolean; removeOrphaned?: boolean; fixNonManifold?: boolean; retriangulate?: boolean; recalculateNormals?: boolean; duplicateTolerance?: number; areaThreshold?: number; }): AutoFixResult; /** * Quick fix - minimal repairs */ export declare function quickFixMesh(mesh: Mesh): AutoFixResult; /** * Deep fix - comprehensive repairs */ export declare function deepFixMesh(mesh: Mesh): AutoFixResult; /** * Clean mesh selection after topology changes */ export declare function cleanMeshSelection(mesh: Mesh, selection: { vertices?: string[]; edges?: MeshEdge[]; faces?: string[]; }): { vertices: string[]; edges: MeshEdge[]; faces: string[]; }; /** * Check if mesh needs auto-fix */ export declare function needsAutoFix(mesh: Mesh): boolean; //# sourceMappingURL=topology_autofix.d.ts.map