Skip to content

Commit 0d31813

Browse files
committed
[format] complete reformat of code using miss_hit
1 parent 0dd6ce2 commit 0d31813

File tree

206 files changed

+7890
-7758
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+7890
-7758
lines changed

.miss_hit

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
project_root
2+
3+
suppress_rule: "redundant_brackets"
4+
suppress_rule: "line_length"
5+
suppress_rule: "file_length"
6+
suppress_rule: "copyright_notice"
7+
suppress_rule: "naming_functions"
8+
suppress_rule: "naming_parameters"
9+
suppress_rule: "naming_scripts"
10+
suppress_rule: "unicode"
11+
indent_function_file_body: false

advancefront.m

+22-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [elist,nextfront]=advancefront(edges,loop,elen)
1+
function [elist, nextfront] = advancefront(edges, loop, elen)
22
%
33
% [elist,nextfront]=advancefront(edges,loop,elen)
44
%
@@ -21,32 +21,34 @@
2121
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
2222
%
2323

24-
elist=[];
25-
nextfront=[];
24+
elist = [];
25+
nextfront = [];
2626

27-
if(nargin<3) elen=3; end
27+
if (nargin < 3)
28+
elen = 3;
29+
end
2830

29-
[hasedge, loc]=ismember(loop,edges,'rows');
31+
[hasedge, loc] = ismember(loop, edges, 'rows');
3032

31-
if(~all(hasedge))
32-
error('loop edge is not defined in the mesh');
33+
if (~all(hasedge))
34+
error('loop edge is not defined in the mesh');
3335
end
3436

35-
nodenum=size(edges,1)/elen;
37+
nodenum = size(edges, 1) / elen;
3638

37-
elist=unique(mod(loc-1,nodenum))+1;
38-
nextfront=edges(elist,:);
39-
for i=1:elen-1
40-
nextfront=[nextfront;edges(elist+nodenum*i,:)];
39+
elist = unique(mod(loc - 1, nodenum)) + 1;
40+
nextfront = edges(elist, :);
41+
for i = 1:elen - 1
42+
nextfront = [nextfront; edges(elist + nodenum * i, :)];
4143
end
42-
nextfront=setdiff(nextfront,loop,'rows');
44+
nextfront = setdiff(nextfront, loop, 'rows');
4345

4446
% remove reversed edge pairs
45-
[flag,loc]=ismember(nextfront,nextfront(:,[2 1]),'rows');
46-
id=find(flag);
47-
if(~isempty(id))
48-
delmark=flag;
49-
delmark(loc(find(loc>0)))=1;
50-
nextfront(find(delmark),:)=[];
47+
[flag, loc] = ismember(nextfront, nextfront(:, [2 1]), 'rows');
48+
id = find(flag);
49+
if (~isempty(id))
50+
delmark = flag;
51+
delmark(loc(find(loc > 0))) = 1;
52+
nextfront(find(delmark), :) = [];
5153
end
52-
nextfront=nextfront(:,[2 1]); % reverse this loop, as it is reversed to the input loop
54+
nextfront = nextfront(:, [2 1]); % reverse this loop, as it is reversed to the input loop

affinemap.m

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [A,b]=affinemap(pfrom,pto)
1+
function [A, b] = affinemap(pfrom, pto)
22
% [A,b]=affinemap(pfrom,pto)
33
%
44
% calculate an affine transform (A matrix and b vector) to map n
@@ -7,7 +7,7 @@
77
% author: Qianqian Fang <q.fang at neu.edu>
88
% date: 12/12/2008
99
%
10-
% parameters:
10+
% parameters:
1111
% pfrom: nx3 matrix, each row is a 3d point in original space
1212
% pto: nx3 matrix, each row is a 3d point in the mapped space
1313
%
@@ -21,20 +21,20 @@
2121
%
2222
% this function is part of "metch" toobox, see COPYING for license
2323

24-
bsubmat=eye(3);
25-
ptnum=size(pfrom,1);
26-
if(size(pto,1)~=ptnum)
27-
error('two inputs should have the same size');
24+
bsubmat = eye(3);
25+
ptnum = size(pfrom, 1);
26+
if (size(pto, 1) ~= ptnum)
27+
error('two inputs should have the same size');
2828
end
29-
amat=zeros(ptnum*3,9);
30-
for i=1:ptnum
31-
amat(i*3-2:i*3,:)=kron(bsubmat,pfrom(i,:));
29+
amat = zeros(ptnum * 3, 9);
30+
for i = 1:ptnum
31+
amat(i * 3 - 2:i * 3, :) = kron(bsubmat, pfrom(i, :));
3232
end
33-
amat=[amat,repmat(bsubmat,ptnum,1)];
33+
amat = [amat, repmat(bsubmat, ptnum, 1)];
3434

35-
bvec=pto';
36-
bvec=bvec(:);
35+
bvec = pto';
36+
bvec = bvec(:);
3737

38-
x=amat\bvec;
39-
A=reshape(x(1:9),3,3)';
40-
b=x(end-2:end);
38+
x = amat \ bvec;
39+
A = reshape(x(1:9), 3, 3)';
40+
b = x(end - 2:end);

aos2soa.m

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function st=aos2soa(starray)
1+
function st = aos2soa(starray)
22
%
33
% st=aos2soa(starray)
44
%
@@ -23,18 +23,17 @@
2323
% License: GPLv3 or Apache 2.0, see https://github.com/NeuroJSON/jsnirf for details
2424
%
2525

26-
27-
if(nargin<1 || ~isstruct(starray))
26+
if (nargin < 1 || ~isstruct(starray))
2827
error('you must give an array of struct');
2928
end
3029

31-
if(numel(starray)==1)
32-
st=starray;
33-
return;
30+
if (numel(starray) == 1)
31+
st = starray;
32+
return
3433
end
3534

36-
st=struct;
37-
fn=fieldnames(starray);
38-
for i=1:length(fn)
39-
st.(fn{i})=[starray(:).(fn{i})];
40-
end
35+
st = struct;
36+
fn = fieldnames(starray);
37+
for i = 1:length(fn)
38+
st.(fn{i}) = [starray(:).(fn{i})];
39+
end

barydualmesh.m

+21-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [newnode,newelem]=barydualmesh(node,elem,flag)
1+
function [newnode, newelem] = barydualmesh(node, elem, flag)
22
%
33
% [newnode,newelem]=barydualmesh(node,elem)
44
%
@@ -24,36 +24,28 @@
2424
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
2525
%
2626

27-
[enodes,eidx]=highordertet(node,elem); % compute edge-centers
27+
[enodes, eidx] = highordertet(node, elem); % compute edge-centers
2828

29-
if(size(elem,2)==3)
30-
fnodes=meshcentroid(node,elem); % compute face-centers
31-
fidx=1:
32-
newnode=[enodes;fnodes];
33-
newidx=[eidx, fidx+size(enodes,1), (1:size(elem,1))'+(size(enodes,1)+size(fnodes,1))];
34-
return;
35-
end
36-
37-
[fnodes,fidx]=elemfacecenter(node,elem); % compute face-centers
38-
c0=meshcentroid(node,elem(:,1:min(size(elem,2),4))); % compute elem-centers
29+
[fnodes, fidx] = elemfacecenter(node, elem); % compute face-centers
30+
c0 = meshcentroid(node, elem(:, 1:min(size(elem, 2), 4))); % compute elem-centers
3931

4032
% concatenated new nodes and their indices
41-
newnode=[enodes;fnodes;c0];
42-
newidx=[eidx, fidx+size(enodes,1), (1:size(elem,1))'+(size(enodes,1)+size(fnodes,1))];
33+
newnode = [enodes; fnodes; c0];
34+
newidx = [eidx, fidx + size(enodes, 1), (1:size(elem, 1))' + (size(enodes, 1) + size(fnodes, 1))];
4335

44-
newelem=[
45-
1 8 11 7
46-
2 7 11 9
47-
3 9 11 8
48-
4 7 11 10
49-
5 8 11 10
50-
6 9 11 10
51-
];
52-
newelem=newelem';
53-
newelem=newidx(:,newelem(:));
54-
newelem=reshape(newelem,[size(elem,1) 4 6]);
55-
newelem=permute(newelem,[1 3 2]);
56-
newelem=reshape(newelem,[size(elem,1)*6 4]);
57-
if(nargin>2 && ischar(flag) && strcmp(flag,'cell'))
58-
newelem=num2cell(newelem,2);
36+
newelem = [
37+
1 8 11 7
38+
2 7 11 9
39+
3 9 11 8
40+
4 7 11 10
41+
5 8 11 10
42+
6 9 11 10
43+
];
44+
newelem = newelem';
45+
newelem = newidx(:, newelem(:));
46+
newelem = reshape(newelem, [size(elem, 1) 4 6]);
47+
newelem = permute(newelem, [1 3 2]);
48+
newelem = reshape(newelem, [size(elem, 1) * 6 4]);
49+
if (nargin > 2 && ischar(flag) && strcmp(flag, 'cell'))
50+
newelem = num2cell(newelem, 2);
5951
end

bbxflatsegment.m

+59-47
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,99 @@
1-
function seg=bbxflatsegment(node,loop)
1+
function seg = bbxflatsegment(node, loop)
22
%
33
% seg=bbxflatsegment(node,loop)
44
%
5-
% decompose edge loops into flat segments along the x/y/z
5+
% decompose edge loops into flat segments along the x/y/z
66
% planes of the bounding box
77
%
88
% author: Qianqian Fang, <q.fang at neu.edu>
99
% date: 2008/04/08
1010
%
11-
% input:
11+
% input:
1212
% node: x,y,z coordinates of each node of the mesh
1313
% loop: input, a single vector separated by NaN, each segment
14-
% is a close-polygon consisted by node IDs
14+
% is a close-polygon consisted by node IDs
1515
% output:
1616
% seg: output, a single vector separated by NaN, each segment
17-
% is a close-polygon on x/y/z plane
17+
% is a close-polygon on x/y/z plane
1818
%
1919
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
2020
%
2121

22-
pos=node(loop,:);
22+
pos = node(loop, :);
2323

2424
% get the bounding box
25-
mi=min(pos);
26-
ma=max(pos);
25+
mi = min(pos);
26+
ma = max(pos);
2727

2828
% extract nodes on the bounding box
29-
idx0=find(abs(pos(:,1)-mi(1))<1e-6)';
30-
idx1=find(abs(pos(:,1)-ma(1))<1e-6)';
29+
idx0 = find(abs(pos(:, 1) - mi(1)) < 1e-6)';
30+
idx1 = find(abs(pos(:, 1) - ma(1)) < 1e-6)';
3131

32-
idy0=find(abs(pos(:,2)-mi(2))<1e-6)';
33-
idy1=find(abs(pos(:,2)-ma(2))<1e-6)';
32+
idy0 = find(abs(pos(:, 2) - mi(2)) < 1e-6)';
33+
idy1 = find(abs(pos(:, 2) - ma(2)) < 1e-6)';
3434

35-
idz0=find(abs(pos(:,3)-mi(3))<1e-6)';
36-
idz1=find(abs(pos(:,3)-ma(3))<1e-6)';
35+
idz0 = find(abs(pos(:, 3) - mi(3)) < 1e-6)';
36+
idz1 = find(abs(pos(:, 3) - ma(3)) < 1e-6)';
3737

3838
% need to be more than 3 points to make a flat polygon
3939

40-
if(length(idx0)<=3) idx0=[]; end
41-
if(length(idx1)<=3) idx1=[]; end
42-
if(length(idy0)<=3) idy0=[]; end
43-
if(length(idy1)<=3) idy1=[]; end
44-
if(length(idz0)<=3) idz0=[]; end
45-
if(length(idz1)<=3) idz1=[]; end
40+
if (length(idx0) <= 3)
41+
idx0 = [];
42+
end
43+
if (length(idx1) <= 3)
44+
idx1 = [];
45+
end
46+
if (length(idy0) <= 3)
47+
idy0 = [];
48+
end
49+
if (length(idy1) <= 3)
50+
idy1 = [];
51+
end
52+
if (length(idz0) <= 3)
53+
idz0 = [];
54+
end
55+
if (length(idz1) <= 3)
56+
idz1 = [];
57+
end
4658

47-
nn=length(loop);
59+
nn = length(loop);
4860

4961
% if the original is a flat polygon, return
5062

51-
if(unique(length(idx0))==nn || unique(length(idx1))==nn ...
52-
|unique(length(idy0))==nn || unique(length(idy1))==nn ...
53-
|unique(length(idz0))==nn || unique(length(idz1))==nn)
54-
seg=loop(:)';
55-
return;
63+
if (unique(length(idx0)) == nn || unique(length(idx1)) == nn || ...
64+
unique(length(idy0)) == nn || unique(length(idy1)) == nn || ...
65+
unique(length(idz0)) == nn || unique(length(idz1)) == nn)
66+
seg = loop(:)';
67+
return
5668
end
5769

5870
% otherwise, find the combination that split the loop
5971

60-
if(length(unique([idx0 idy0 idz0]))==nn)
61-
seg= [loop(idx0),nan,loop(idy0),nan,loop(idz0)];
62-
elseif(length(unique([idx0 idy1 idz0]))==nn)
63-
seg= [loop(idx0),nan,loop(idy1),nan,loop(idz0)];
64-
elseif(length(unique([idx0 idy0 idz1]))==nn)
65-
seg= [loop(idx0),nan,loop(idy0),nan,loop(idz1)];
66-
elseif(length(unique([idx0 idy1 idz1]))==nn)
67-
seg= [loop(idx0),nan,loop(idy1),nan,loop(idz1)];
68-
elseif(length(unique([idx1 idy0 idz0]))==nn)
69-
seg= [loop(idx1),nan,loop(idy0),nan,loop(idz0)];
70-
elseif(length(unique([idx1 idy1 idz0]))==nn)
71-
seg= [loop(idx1),nan,loop(idy1),nan,loop(idz0)];
72-
elseif(length(unique([idx1 idy0 idz1]))==nn)
73-
seg= [loop(idx1),nan,loop(idy0),nan,loop(idz1)];
74-
elseif(length(unique([idx1 idy1 idz1]))==nn)
75-
seg= [loop(idx1),nan,loop(idy1),nan,loop(idz1)];
72+
if (length(unique([idx0 idy0 idz0])) == nn)
73+
seg = [loop(idx0), nan, loop(idy0), nan, loop(idz0)];
74+
elseif (length(unique([idx0 idy1 idz0])) == nn)
75+
seg = [loop(idx0), nan, loop(idy1), nan, loop(idz0)];
76+
elseif (length(unique([idx0 idy0 idz1])) == nn)
77+
seg = [loop(idx0), nan, loop(idy0), nan, loop(idz1)];
78+
elseif (length(unique([idx0 idy1 idz1])) == nn)
79+
seg = [loop(idx0), nan, loop(idy1), nan, loop(idz1)];
80+
elseif (length(unique([idx1 idy0 idz0])) == nn)
81+
seg = [loop(idx1), nan, loop(idy0), nan, loop(idz0)];
82+
elseif (length(unique([idx1 idy1 idz0])) == nn)
83+
seg = [loop(idx1), nan, loop(idy1), nan, loop(idz0)];
84+
elseif (length(unique([idx1 idy0 idz1])) == nn)
85+
seg = [loop(idx1), nan, loop(idy0), nan, loop(idz1)];
86+
elseif (length(unique([idx1 idy1 idz1])) == nn)
87+
seg = [loop(idx1), nan, loop(idy1), nan, loop(idz1)];
7688
else
77-
seg=[];
89+
seg = [];
7890
end
7991

8092
% remove pattern [ ... nan nan ...] in the result
8193

82-
if(length(seg) && any(isnan(seg)))
83-
id=regexp(sprintf('%d',isnan(seg)),'11');
84-
if(length(id))
85-
seg(id+1)=[];
94+
if (length(seg) && any(isnan(seg)))
95+
id = regexp(sprintf('%d', isnan(seg)), '11');
96+
if (length(id))
97+
seg(id + 1) = [];
8698
end
8799
end

0 commit comments

Comments
 (0)