0001 function varargout = createStellatedMesh(vertices, faces, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 nVertices = size(vertices, 1);
0022 nFaces = size(faces, 1);
0023
0024
0025 coeffs = ones(nFaces, 1);
0026 if ~isempty(varargin)
0027 var1 = varargin{1};
0028 if isnumeric(var1) && isscalar(var1)
0029 coeffs = coeffs * var1;
0030 elseif isnumeric(var1) && length(var1) == nFaces
0031 coeffs = var1(:);
0032 else
0033 error('Coefficients must be either a scalar or a nFaces-by-1 array');
0034 end
0035 end
0036
0037
0038 fc = meshFaceCentroids(vertices, faces);
0039 fn = meshFaceNormals(vertices, faces);
0040
0041
0042 nv = fc + bsxfun(@times, fn, coeffs);
0043
0044
0045 v2 = [vertices ; nv];
0046 f2 = zeros(nFaces * 3, 3);
0047 indF = 0;
0048
0049
0050 for iFace = 1:nFaces
0051
0052 face = meshFace(faces, iFace);
0053
0054
0055
0056 for ivf = 1:length(face)
0057 ind1 = face(ivf);
0058 ind2 = face(mod(ivf, length(face)) + 1);
0059
0060 indF = indF + 1;
0061 f2(indF, :) = [ind1 ind2 iFace+nVertices];
0062 end
0063 end
0064
0065
0066 varargout = formatMeshOutput(nargout, v2, f2);