@@ -54,7 +54,6 @@ reference:
54
54
(ISBI 2009), pp. 1142-1145, 2009
55
55
56
56
57
- == # List of functions ==
58
57
=== # Streamlined mesh generation - shortcuts ===
59
58
60
59
==== function [node,elem,face]=v2m(img,isovalues,opt,maxvol,method) ====
@@ -85,20 +84,21 @@ reference:
85
84
output:
86
85
img: a volumetric binary image at position of ndgrid(xi,yi,zi)
87
86
88
- ==== function newnode=sms(node,face,iter,alpha) ====
89
- newnode=sms(node,face,iter,useralpha)
87
+ ==== function newnode=sms(node,face,iter,alpha,method ) ====
88
+ newnode=sms(node,face,iter,useralpha,method )
90
89
simplified version of surface mesh smoothing
91
90
input:
92
91
node: node coordinates of a surface mesh
93
92
face: face element list of the surface mesh
94
93
iter: smoothing iteration number
95
94
alpha: scaler, smoothing parameter, v(k+1)=alpha*v(k)+(1-alpha)*mean(neighbors)
95
+ method: same as in smoothsurf, default is 'laplacianhc'
96
96
output:
97
97
newnode: output, the smoothed node coordinates
98
98
=== # Streamlined mesh generation ===
99
99
100
- ==== function [node,elem,face]=vol2mesh(img,ix,iy,iz,opt,maxvol,dofix,method,isovalues) ====
101
- [node,elem,face]=vol2mesh(img,ix,iy,iz,opt,maxvol,dofix,method,isovalues)
100
+ ==== function [node,elem,face,regions ]=vol2mesh(img,ix,iy,iz,opt,maxvol,dofix,method,isovalues) ====
101
+ [node,elem,face,regions ]=vol2mesh(img,ix,iy,iz,opt,maxvol,dofix,method,isovalues)
102
102
convert a binary (or multi-valued) volume to tetrahedral mesh
103
103
input:
104
104
img: a volumetric binary image
@@ -123,6 +123,8 @@ reference:
123
123
column is the region ID
124
124
face: output, mesh surface element list of the tetrahedral mesh
125
125
the last column denotes the boundary ID
126
+ region: optional output. if opt.autoregion is set to 1, region
127
+ saves the interior points for each closed surface component
126
128
127
129
==== function [no,el,regions,holes]=vol2surf(img,ix,iy,iz,opt,dofix,method,isovalues) ====
128
130
[no,el,regions,holes]=vol2surf(img,ix,iy,iz,opt,dofix,method,isovalues)
@@ -150,6 +152,8 @@ reference:
150
152
opt(1,2,..).regions: user specified regions interior pt list
151
153
opt(1,2,..).surf.{node,elem}: add additional surfaces
152
154
opt(1,2,..).{A,B}: linear transformation for each surface
155
+ opt.autoregion: if set to 1, vol2surf will try to determine
156
+ the interior points for each closed surface automatically
153
157
dofix: 1: perform mesh validation&repair, 0: skip repairing
154
158
method: - if method is 'simplify', iso2mesh will first call
155
159
binsurface to generate a voxel-based surface mesh and then
@@ -224,7 +228,7 @@ reference:
224
228
opt: parameters for CGAL mesher, if opt is a structure, then
225
229
opt.radbound: defines the maximum surface element size
226
230
opt.angbound: defines the miminum angle of a surface triangle
227
- opt.surfaceapprox : defines the maximum distance between the
231
+ opt.distbound : defines the maximum distance between the
228
232
center of the surface bounding circle and center of the
229
233
element bounding sphere
230
234
opt.reratio: maximum radius-edge ratio
@@ -242,7 +246,7 @@ reference:
242
246
243
247
==== function [node,elem,face]=cgals2m(v,f,opt,maxvol) ====
244
248
[node,elem,face]=cgals2m(v,f,opt,maxvol)
245
- wrapper for CGAL 3D mesher (CGAL 3.5)
249
+ wrapper for CGAL 3D mesher (CGAL 3.5 and newer )
246
250
convert a binary (or multi-valued) volume to tetrahedral mesh
247
251
http://www.cgal.org/Manual/3.5/doc_html/cgal_manual/Mesh_3/Chapter_main.html
248
252
input:
@@ -251,7 +255,7 @@ reference:
251
255
opt: parameters for CGAL mesher, if opt is a structure, then
252
256
opt.radbound: defines the maximum surface element size
253
257
opt.angbound: defines the miminum angle of a surface triangle
254
- opt.surfaceapprox : defines the maximum distance between the
258
+ opt.distbound : defines the maximum distance between the
255
259
center of the surface bounding circle and center of the
256
260
element bounding sphere
257
261
opt.reratio: maximum radius-edge ratio
@@ -530,6 +534,65 @@ reference:
530
534
output:
531
535
seg: output, a single vector separated by NaN, each segment
532
536
is a close-polygon on x/y/z plane
537
+
538
+ ==== function plane=surfplane(node,face) ====
539
+ plane=surfplane(node,face)
540
+ plane equation coefficients for each face in a surface
541
+ input:
542
+ node: a list of node coordinates (nn x 3)
543
+ face: a surface mesh triangle list (ne x 3)
544
+ output:
545
+ plane: a (ne x 4) array, in each row, it has [a b c d]
546
+ to denote the plane equation as "a*x+b*y+c*z+d=0"
547
+
548
+ ==== function [pt,p0,v0,t,idx]=surfinterior(node,face) ====
549
+ [pt,p0,v0,t,idx]=surfinterior(node,face)
550
+ identify a point that is enclosed by the (closed) surface
551
+ input:
552
+ node: a list of node coordinates (nn x 3)
553
+ face: a surface mesh triangle list (ne x 3)
554
+ output:
555
+ pt: the interior point coordinates [x y z]
556
+ p0: ray origin used to determine the interior point
557
+ v0: the vector used to determine the interior point
558
+ t : ray-tracing intersection distance (with signs) from p0. the
559
+ intersection coordinates can be expressed as p0+ts(i)*v0
560
+ idx: index to the face elements that intersect with the ray, order
561
+ match that of t
562
+
563
+ ==== function seeds=surfseeds(node,face) ====
564
+ seeds=surfseeds(node,face)
565
+ calculate a set of interior points with each enclosed by a closed
566
+ component of a surface
567
+ input:
568
+ node: a list of node coordinates (nn x 3)
569
+ face: a surface mesh triangle list (ne x 3)
570
+ output:
571
+ seeds: the interior points coordinates for each closed-surface
572
+ component
573
+
574
+ ==== function quality=meshquality(node,elem) ====
575
+ quality=meshquality(node,elem)
576
+ compute Joe-Liu mesh quality measure of a tetrahedral mesh
577
+ input:
578
+ node: node coordinates of the mesh (nn x 3)
579
+ elem: element table of a tetrahedral mesh (ne x 4)
580
+ output
581
+ edge: edge list; each row is an edge, specified by the starting and
582
+ ending node indices, the total edge number is
583
+ size(elem,1) x nchoosek(size(elem,2),2). All edges are ordered
584
+ by looping through each element first.
585
+
586
+ ==== function edges=meshedge(elem) ====
587
+ edges=meshedge(elem)
588
+ return all edges in a surface or volumetric mesh
589
+ input:
590
+ elem: element table of a mesh (support N-d space element)
591
+ output
592
+ edge: edge list; each row is an edge, specified by the starting and
593
+ ending node indices, the total edge number is
594
+ size(elem,1) x nchoosek(size(elem,2),2). All edges are ordered
595
+ by looping through each element first.
533
596
=== # Mesh processing and reparing ===
534
597
535
598
==== function [node,elem]=meshcheckrepair(node,elem,opt) ====
@@ -946,7 +1009,7 @@ reference:
946
1009
947
1010
==== function vol=smoothbinvol(vol,layer) ====
948
1011
vol=smoothbinvol(vol,layer)
949
- convolve a 3x3 gaussian kernel to a binary image multiple times
1012
+ perform a memory-limited 3D image smoothing
950
1013
input:
951
1014
vol: a 3D volumetric image to be smoothed
952
1015
layer: number of iterations for the smoothing
@@ -1054,11 +1117,13 @@ reference:
1054
1117
'FaceColor','interp');
1055
1118
1056
1119
==== function plottetview(session,method) ====
1057
- runtetview (session,method)
1120
+ plottetview (session,method)
1058
1121
wrapper for tetview to plot the generated mesh
1059
1122
input:
1060
- session: a string to identify the output files for plotting
1061
- method: method
1123
+ session: a string to identify the output files for plotting, '' for
1124
+ the default session
1125
+ method: method can be 'cgalsurf' (default), 'simplify', 'cgalpoly'
1126
+ 'cgalmesh' and 'remesh'
1062
1127
=== # Miscellaneous functions ===
1063
1128
1064
1129
==== function valnew=surfdiffuse(node,tri,val,ddt,iter,type1,opt) ====
@@ -1076,15 +1141,16 @@ reference:
1076
1141
valnew: nodal value vector after the smoothing
1077
1142
1078
1143
==== function [node,elem,face]=volmap2mesh(img,ix,iy,iz,elemnum,maxvol,thickness,Amat,Bvec) ====
1079
- [node,elem,face]=vol2mesh (img,ix,iy,iz,thickness,elemnum,maxvol,A,B)
1080
- convert a binary volume to tetrahedral mesh
1144
+ [node,elem,face]=volmap2mesh (img,ix,iy,iz,thickness,elemnum,maxvol,A,B)
1145
+ convert a binary volume to tetrahedral mesh followed by an Affine transform
1081
1146
input:
1082
1147
img, ix,iy,iz, elemnum and maxvol: see vol2mesh.m
1148
+ thickness: scale z-dimension of the mesh to specified thickness,
1149
+ if thickness==0, scaling is bypassed
1083
1150
Amat: a 3x3 transformation matrix
1084
1151
Bvec: a 3x1 vector
1085
1152
Amat and Bvec maps the image index space to real world coordnate system by
1086
- [x,y,z]_new=Amat*[x,y,z]_old+Bvec
1087
- thickness: scale z-dimension of the mesh to specified thickness, if thickness==0, scaling is bypassed
1153
+ [x,y,z]_new=Amat*[x,y,z]_old+Bvec
1088
1154
1089
1155
==== function isoctave=isoctavemesh ====
1090
1156
isoctave=isoctavemesh
@@ -1102,6 +1168,29 @@ reference:
1102
1168
p: the value of the specified variable, if the variable does not
1103
1169
exist, return empty array
1104
1170
1171
+ ==== function [t,u,v]=raytrace(p,v,node,face) ====
1172
+ [t,u,v]=raytrace(p,v,node,face)
1173
+ perform a Havel-styled ray tracing for a triangular surface
1174
+ input:
1175
+ p: starting point coordinate of the ray
1176
+ v: directional vector of the ray
1177
+ node: a list of node coordinates (nn x 3)
1178
+ face: a surface mesh triangle list (ne x 3)
1179
+ output:
1180
+ t: signed distance from p to the intersection point
1181
+ u: bary-centric coordinate 1 of the intersection point
1182
+ v: bary-centric coordinate 2 of the intersection point
1183
+ the final bary-centric triplet is [u,v,1-u-v]
1184
+ users can find the IDs of the elements intersecting with the ray by
1185
+ idx=find(u>=0 & v>=0 & u+v<=1.0);
1186
+ Reference:
1187
+ [1] J. Havel and A. Herout, "Yet faster ray-triangle intersection (using
1188
+ SSE4)," IEEE Trans. on Visualization and Computer Graphics,
1189
+ 16(3):434-438 (2010)
1190
+ [2] Q. Fang, "Comment on 'A study on tetrahedron-based inhomogeneous
1191
+ Monte-Carlo optical simulation'," Biomed. Opt. Express, (in
1192
+ press)
1193
+
1105
1194
==== function [a,b,c,d]=getplanefrom3pt(plane) ====
1106
1195
[a,b,c,d]=getplanefrom3pt(plane)
1107
1196
define a plane equation ax+by+cz+d=0 from three 3D points
0 commit comments