Mercurial > octave-nkf
comparison scripts/plot/draw/private/__marching_cube__.m @ 19867:9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Try to trim long lines to < 80 chars.
Use '##' for single line comments.
Use '(...)' around tests for if/elseif/switch/while.
Abut cell indexing operator '{' next to variable.
Abut array indexing operator '(' next to variable.
Use space between negation operator '!' and following expression.
Use two newlines between endfunction and start of %!test or %!demo code.
Remove unnecessary parens grouping between short-circuit operators.
Remove stray extra spaces (typos) between variables and assignment operators.
Remove stray extra spaces from ends of lines.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 23 Feb 2015 14:54:39 -0800 |
parents | 00e31f316a3a |
children |
comparison
equal
deleted
inserted
replaced
19866:a1acca0c2216 | 19867:9fc020886ae9 |
---|---|
96 | 96 |
97 if ((nargin != 5 && nargin != 6) || (nargout != 2 && nargout != 3)) | 97 if ((nargin != 5 && nargin != 6) || (nargout != 2 && nargout != 3)) |
98 print_usage (); | 98 print_usage (); |
99 endif | 99 endif |
100 | 100 |
101 if (!isnumeric (xx) || !isnumeric (yy) || !isnumeric (zz) || !isnumeric (c) || ... | 101 if (! isnumeric (xx) || ! isnumeric (yy) || ! isnumeric (zz) |
102 ndims (xx) != 3 || ndims (yy) != 3 || ndims (zz) != 3 || ndims (c) != 3) | 102 || ! isnumeric (c) || ndims (xx) != 3 || ndims (yy) != 3 |
103 || ndims (zz) != 3 || ndims (c) != 3) | |
103 error ("__marching_cube__: XX, YY, ZZ, C must be matrices of dim 3"); | 104 error ("__marching_cube__: XX, YY, ZZ, C must be matrices of dim 3"); |
104 endif | 105 endif |
105 | 106 |
106 if (!size_equal (xx, yy, zz, c)) | 107 if (! size_equal (xx, yy, zz, c)) |
107 error ("__marching_cube__: XX, YY, ZZ, C must be of equal size"); | 108 error ("__marching_cube__: XX, YY, ZZ, C must be of equal size"); |
108 endif | 109 endif |
109 | 110 |
110 if (any (size (xx) < [2 2 2])) | 111 if (any (size (xx) < [2 2 2])) |
111 error ("__marching_cube__: grid size must be at least 2x2x2"); | 112 error ("__marching_cube__: grid size must be at least 2x2x2"); |
112 endif | 113 endif |
113 | 114 |
114 if (!isscalar (iso)) | 115 if (! isscalar (iso)) |
115 error ("__marching_cube__: ISO must be scalar value"); | 116 error ("__marching_cube__: ISO must be scalar value"); |
116 endif | 117 endif |
117 | 118 |
118 if (nargin == 6) | 119 if (nargin == 6) |
119 if ( !isnumeric (colors) || ndims (colors) != 3 || size (colors) != size (c) ) | 120 if ( ! isnumeric (colors) || ndims (colors) != 3 || size (colors) != size (c) ) |
120 error ( "COLORS must be a matrix of dim 3 and of same size as C" ); | 121 error ( "COLORS must be a matrix of dim 3 and of same size as C" ); |
121 endif | 122 endif |
122 calc_cols = true; | 123 calc_cols = true; |
123 lindex = 5; | 124 lindex = 5; |
124 endif | 125 endif |
144 idx = c(vertex_idx{ii, :}) > iso; | 145 idx = c(vertex_idx{ii, :}) > iso; |
145 cc(idx) = bitset (cc(idx), ii); | 146 cc(idx) = bitset (cc(idx), ii); |
146 endfor | 147 endfor |
147 | 148 |
148 cedge = edge_table(cc+1); # assign the info about intersected edges | 149 cedge = edge_table(cc+1); # assign the info about intersected edges |
149 id = find (cedge); # select only voxels which are intersected | 150 id = find (cedge); # select only voxels which are intersected |
150 if (isempty (id)) | 151 if (isempty (id)) |
151 T = p = col = []; | 152 T = p = col = []; |
152 return; | 153 return; |
153 endif | 154 endif |
154 | 155 |
182 T = []; | 183 T = []; |
183 tri = tri_table(cc(id)+1, :); | 184 tri = tri_table(cc(id)+1, :); |
184 for jj=1:3:15 | 185 for jj=1:3:15 |
185 id_ = find (tri(:, jj)>0); | 186 id_ = find (tri(:, jj)>0); |
186 p = [id_, lindex*ones(rows (id_), 1),tri(id_, jj:jj+2)]; | 187 p = [id_, lindex*ones(rows (id_), 1),tri(id_, jj:jj+2)]; |
187 if (!isempty (p)) | 188 if (! isempty (p)) |
188 p1 = sub2ind (size (pp), p(:,1), p(:,2), p(:,3)); | 189 p1 = sub2ind (size (pp), p(:,1), p(:,2), p(:,3)); |
189 p2 = sub2ind (size (pp), p(:,1), p(:,2), p(:,4)); | 190 p2 = sub2ind (size (pp), p(:,1), p(:,2), p(:,4)); |
190 p3 = sub2ind (size (pp), p(:,1), p(:,2), p(:,5)); | 191 p3 = sub2ind (size (pp), p(:,1), p(:,2), p(:,5)); |
191 T = [T; pp(p1), pp(p2), pp(p3)]; | 192 T = [T; pp(p1), pp(p2), pp(p3)]; |
192 endif | 193 endif |