MESHFACEPOLYGONS Returns the set of polygons that constitutes a mesh. POLYGONS = meshFacePolygons(V, F) POLYGONS = meshFacePolygons(MESH) Example [v f] = createCubeOctahedron; polygons = meshFacePolygons(v, f); areas = polygonArea3d(polygons); sum(areas) ans = 18.9282 See also meshes3d, meshFace, polygonArea3d
0001 function polys = meshFacePolygons(varargin) 0002 %MESHFACEPOLYGONS Returns the set of polygons that constitutes a mesh. 0003 % 0004 % POLYGONS = meshFacePolygons(V, F) 0005 % POLYGONS = meshFacePolygons(MESH) 0006 % 0007 % Example 0008 % [v f] = createCubeOctahedron; 0009 % polygons = meshFacePolygons(v, f); 0010 % areas = polygonArea3d(polygons); 0011 % sum(areas) 0012 % ans = 0013 % 18.9282 0014 % 0015 % See also 0016 % meshes3d, meshFace, polygonArea3d 0017 0018 % ------ 0019 % Author: David Legland 0020 % e-mail: david.legland@grignon.inra.fr 0021 % Created: 2013-08-20, using Matlab 7.9.0.529 (R2009b) 0022 % Copyright 2013 INRA - Cepia Software Platform. 0023 0024 % extract vertices and faces 0025 [v, f] = parseMeshData(varargin{:}); 0026 0027 % number of faces 0028 if iscell(f) 0029 nFaces = length(f); 0030 else 0031 nFaces = size(f, 1); 0032 end 0033 0034 % allocate cell array for result 0035 polys = cell(nFaces, 1); 0036 0037 % compute polygon corresponding to each face 0038 if iscell(f) 0039 for i = 1:nFaces 0040 polys{i} = v(f{i}, :); 0041 end 0042 else 0043 for i = 1:nFaces 0044 polys{i} = v(f(i,:), :); 0045 end 0046 end