Home > matGeom > meshes3d > ensureManifoldMesh.m

ensureManifoldMesh

PURPOSE ^

ENSUREMANIFOLDMESH Apply several simplification to obtain a manifold mesh.

SYNOPSIS ^

function varargout = ensureManifoldMesh(varargin)

DESCRIPTION ^

ENSUREMANIFOLDMESH Apply several simplification to obtain a manifold mesh.

   Try to transform an input mesh into a manifold mesh.

   Not all cases of "non-manifoldity" are checked, so please use with
   care.

   [V2, F2] = ensureManifoldMesh(V, F);
   [V2, F2] = ensureManifoldMesh(MESH);
   MESH2 = ensureManifoldMesh(...);

   Example
   ensureManifoldMesh

   See also
    meshes3d, isManifoldMesh

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = ensureManifoldMesh(varargin)
0002 %ENSUREMANIFOLDMESH Apply several simplification to obtain a manifold mesh.
0003 %
0004 %   Try to transform an input mesh into a manifold mesh.
0005 %
0006 %   Not all cases of "non-manifoldity" are checked, so please use with
0007 %   care.
0008 %
0009 %   [V2, F2] = ensureManifoldMesh(V, F);
0010 %   [V2, F2] = ensureManifoldMesh(MESH);
0011 %   MESH2 = ensureManifoldMesh(...);
0012 %
0013 %   Example
0014 %   ensureManifoldMesh
0015 %
0016 %   See also
0017 %    meshes3d, isManifoldMesh
0018  
0019 % ------
0020 % Author: David Legland
0021 % e-mail: david.legland@inra.fr
0022 % Created: 2019-02-01,    using Matlab 9.5.0.944444 (R2018b)
0023 % Copyright 2019 INRA - Cepia Software Platform.
0024 
0025 
0026 %% Parse input arguments
0027 
0028 [vertices, faces] = parseMeshData(varargin{:});
0029 verbose = true;
0030 
0031 
0032 %% Pre-processing
0033 
0034 % remove duplicate faces if any
0035 if verbose
0036     disp('remove duplicate faces');
0037 end
0038 faces = removeDuplicateFaces(faces);
0039 
0040 
0041 %% Iterative processing of multiple edges
0042 % Reduces all edges connected to more than two faces, by collapsing second
0043 % vertex onto the first one.
0044 
0045 % iter = 0;
0046 % while ~isManifoldMesh(vertices, faces) && iter < 10
0047 %     iter = iter + 1;
0048     if verbose
0049         disp('collapse edges with many faces');
0050     end
0051     
0052     [vertices, faces] = collapseEdgesWithManyFaces(vertices, faces);
0053 % end
0054 
0055 
0056 
0057 %% Format output
0058 
0059 varargout = formatMeshOutput(nargout, vertices, faces);
0060

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019