File: meshface.m

package info (click to toggle)
octave-iso2mesh 1.9.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 11,982; ansic: 10,158; sh: 365; makefile: 59
file content (33 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function faces = meshface(elem, varargin)
%
% faces=meshface(elem,opt)
%
% return all faces in a surface or volumetric mesh
%
% author: Qianqian Fang, <q.fang at neu.edu>
% date: 2011/02/26
%
% input:
%    elem:  element table of a mesh (support N-d space element)
%    opt: optional input, giving the additional options. If opt
%         is a struct, it can have the following field:
%       opt.nodeorder: if 1, assuming the elem node indices is in CCW
%                      orientation; 0 use nchoosek() output to order faces
%         you can replace opt by a series of ('param', value) pairs.
%
% output:
%    face:  face list; each row is an face, specified by the starting and
%           ending node indices, the total face number is
%           size(elem,1) x nchoosek(size(elem,2),2). All faces are ordered
%           by looping through each element first.
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

dim = size(elem);
faceid = nchoosek(1:dim(2), 3);
len = size(faceid, 1);
faces = zeros(dim(1) * len, 3);
for i = 0:len - 1
    faces((i * dim(1) + 1):((i + 1) * dim(1)), :) = [elem(:, faceid(i + 1, 1)) elem(:, faceid(i + 1, 2)) elem(:, faceid(i + 1, 3))];
end