File: removedupnodes.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 (30 lines) | stat: -rw-r--r-- 810 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
function [newnode, newelem] = removedupnodes(node, elem, tol)
%
% [newnode,newelem]=removedupnodes(node,elem)
%
% removing the duplicated nodes from a mesh
%
% author: Qianqian Fang <q.fang at neu.edu>
%
% input:
%   elem: integer array with dimensions of NE x 4, each row contains
%         the indices of all the nodes for each tetrahedron
%   node: node coordinates, 3 columns for x, y and z respectively
%
% output:
%   newnode: nodes without duplicates
%   newelem: elements with only the unique nodes
%
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

if (nargin >= 3 && tol ~= 0)
    node = round(node / tol) * tol;
end
[newnode, I, J] = unique(node, 'rows');
if (iscell(elem))
    newelem = cellfun(@(x) J(x)', elem, 'UniformOutput', false);
else
    newelem = J(elem);
end