Skip to content

Commit 4c16c21

Browse files
committed
add mesh quality measure
git-svn-id: http://svn.code.sf.net/p/iso2mesh/code/trunk/iso2mesh@279 786e58fb-9377-0410-9ff7-e4ac0ac0635c
1 parent c6e65e4 commit 4c16c21

8 files changed

+207
-62
lines changed

README.txt

+105-16
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ reference:
5454
(ISBI 2009), pp. 1142-1145, 2009
5555

5656

57-
== # List of functions ==
5857
=== # Streamlined mesh generation - shortcuts ===
5958

6059
==== function [node,elem,face]=v2m(img,isovalues,opt,maxvol,method) ====
@@ -85,20 +84,21 @@ reference:
8584
output:
8685
img: a volumetric binary image at position of ndgrid(xi,yi,zi)
8786

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)
9089
simplified version of surface mesh smoothing
9190
input:
9291
node: node coordinates of a surface mesh
9392
face: face element list of the surface mesh
9493
iter: smoothing iteration number
9594
alpha: scaler, smoothing parameter, v(k+1)=alpha*v(k)+(1-alpha)*mean(neighbors)
95+
method: same as in smoothsurf, default is 'laplacianhc'
9696
output:
9797
newnode: output, the smoothed node coordinates
9898
=== # Streamlined mesh generation ===
9999

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)
102102
convert a binary (or multi-valued) volume to tetrahedral mesh
103103
input:
104104
img: a volumetric binary image
@@ -123,6 +123,8 @@ reference:
123123
column is the region ID
124124
face: output, mesh surface element list of the tetrahedral mesh
125125
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
126128

127129
==== function [no,el,regions,holes]=vol2surf(img,ix,iy,iz,opt,dofix,method,isovalues) ====
128130
[no,el,regions,holes]=vol2surf(img,ix,iy,iz,opt,dofix,method,isovalues)
@@ -150,6 +152,8 @@ reference:
150152
opt(1,2,..).regions: user specified regions interior pt list
151153
opt(1,2,..).surf.{node,elem}: add additional surfaces
152154
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
153157
dofix: 1: perform mesh validation&repair, 0: skip repairing
154158
method: - if method is 'simplify', iso2mesh will first call
155159
binsurface to generate a voxel-based surface mesh and then
@@ -224,7 +228,7 @@ reference:
224228
opt: parameters for CGAL mesher, if opt is a structure, then
225229
opt.radbound: defines the maximum surface element size
226230
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
228232
center of the surface bounding circle and center of the
229233
element bounding sphere
230234
opt.reratio: maximum radius-edge ratio
@@ -242,7 +246,7 @@ reference:
242246

243247
==== function [node,elem,face]=cgals2m(v,f,opt,maxvol) ====
244248
[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)
246250
convert a binary (or multi-valued) volume to tetrahedral mesh
247251
http://www.cgal.org/Manual/3.5/doc_html/cgal_manual/Mesh_3/Chapter_main.html
248252
input:
@@ -251,7 +255,7 @@ reference:
251255
opt: parameters for CGAL mesher, if opt is a structure, then
252256
opt.radbound: defines the maximum surface element size
253257
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
255259
center of the surface bounding circle and center of the
256260
element bounding sphere
257261
opt.reratio: maximum radius-edge ratio
@@ -530,6 +534,65 @@ reference:
530534
output:
531535
seg: output, a single vector separated by NaN, each segment
532536
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.
533596
=== # Mesh processing and reparing ===
534597

535598
==== function [node,elem]=meshcheckrepair(node,elem,opt) ====
@@ -946,7 +1009,7 @@ reference:
9461009

9471010
==== function vol=smoothbinvol(vol,layer) ====
9481011
vol=smoothbinvol(vol,layer)
949-
convolve a 3x3 gaussian kernel to a binary image multiple times
1012+
perform a memory-limited 3D image smoothing
9501013
input:
9511014
vol: a 3D volumetric image to be smoothed
9521015
layer: number of iterations for the smoothing
@@ -1054,11 +1117,13 @@ reference:
10541117
'FaceColor','interp');
10551118

10561119
==== function plottetview(session,method) ====
1057-
runtetview(session,method)
1120+
plottetview(session,method)
10581121
wrapper for tetview to plot the generated mesh
10591122
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'
10621127
=== # Miscellaneous functions ===
10631128

10641129
==== function valnew=surfdiffuse(node,tri,val,ddt,iter,type1,opt) ====
@@ -1076,15 +1141,16 @@ reference:
10761141
valnew: nodal value vector after the smoothing
10771142

10781143
==== 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
10811146
input:
10821147
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
10831150
Amat: a 3x3 transformation matrix
10841151
Bvec: a 3x1 vector
10851152
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
10881154

10891155
==== function isoctave=isoctavemesh ====
10901156
isoctave=isoctavemesh
@@ -1102,6 +1168,29 @@ reference:
11021168
p: the value of the specified variable, if the variable does not
11031169
exist, return empty array
11041170

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+
11051194
==== function [a,b,c,d]=getplanefrom3pt(plane) ====
11061195
[a,b,c,d]=getplanefrom3pt(plane)
11071196
define a plane equation ax+by+cz+d=0 from three 3D points

TODO.txt

+9-8
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@
55
== high priority ==
66

77
* detect multi-value interfaces (i.e. voxels where more than 2 values meet) \
8-
and perturb the levelset surface mesh to avoid intersection [proposed on 02/11/09]
9-
10-
* if one levelset contains multiple disjointed surfaces, separate them, \
11-
and do sub-region labeling for each component [proposed on 02/11/09]
8+
and perturb the levelset surface mesh to avoid intersection [proposed on 2009/02/11]
129

1310
== low priority ==
1411

15-
* 2D image-based mesh generation support ? [proposed on 02/11/09]
12+
* 2D image-based mesh generation support ? [proposed on 2009/02/11]
1613

17-
* adaptive refining [proposed on 02/11/09]
14+
* adaptive refining [proposed on 2009/02/11]
1815

1916
* moving mesh
2017

@@ -28,10 +25,14 @@ and do sub-region labeling for each component [proposed on 02/11/09]
2825
files were opened but not closed and can not be deleted \
2926
- done, by FangQ 2009/05/04
3027

31-
* processing gray-scale images directly [proposed on 02/11/09] \
28+
* processing gray-scale images directly [proposed on 2009/02/11] \
3229
- done, by FangQ 2009/05/04
3330

3431
* setting RNG seeds when calling CGAL tools to ensure repeatibility \
35-
of the meshing [proposed 07/17/2010] \
32+
of the meshing [proposed 2010/07/17] \
3633
- done, by FangQ 2010/11/08
3734

35+
* if one levelset contains multiple disjointed surfaces, separate them, \
36+
and do sub-region labeling for each component [proposed on 2009/02/11]
37+
- done, by FangQ 2011/02/26
38+

doc/Advanced_Features.txt

+20-20
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@ Advanced Features in iso2mesh
55
Global variables
66

77
ISO2MESH_TEMP
8-
control the temporary file output directory
9-
10-
The default output directory is the system's temporary directory, i.e.
11-
the output of mwpath(''). However, if one does not have permission to
12-
write to this folder, or if this contains outputs from other users who
13-
shares the same output folder (for example, /tmp on Linux), one can
14-
avoid "write to file" error by setting his own output folder. To do
15-
this, he need to define
8+
controls the temporary file output directory
9+
10+
The default output directory is under the system's temporary directory,
11+
i.e. the output of mwpath(''). However, if one does not have permission
12+
to write to this folder, or if this contains outputs from other users
13+
who shares the same output folder (for example, /tmp/iso2mesh-username
14+
on Linux), one can avoid the permission error by setting his own output
15+
folder. To do this, he need to define
1616
ISO2MESH_TEMP='/folder/path/you/can/write';
1717

1818
in Matlab/Octave's "base workspace". The iso2mesh commands afterward
1919
will output the intermediate files under the specified temp directory.
2020

2121
ISO2MESH_SESSION
22-
control the output file name prefix
22+
controls the output file name prefix
2323

2424
If two users share a common output directory (for example /tmp for GNU
2525
Linux) on a single machine, some of the users may not able to write
2626
intermediate output files and encountered errors. If this happens, one
2727
can set "ISO2MESH_TEMP" to define a new output folder, alternatively,
2828
one can set ISO2MESH_SESSION to label all his output by a unique
2929
prefix. For example, if one define
30-
ISO2MESH_SESSION='john_';
30+
ISO2MESH_SESSION='foo_';
3131

32-
this will prepend 'john_' to all output file names, if this string is
32+
this will prepend 'foo_' to all output file names, if this string is
3333
unique, users can produce all their output files without conflict with
3434
other users.
3535

3636
ISO2MESH_BIN
37-
specify the folder where to look for the external binaries
37+
specifies the folder where to look for the external binaries
3838

3939
There are several external tools are essential for iso2mesh. These
4040
pre-compiled binaries are saved under iso2mesh/bin folder. In our
@@ -54,14 +54,14 @@ Global variables
5454
sets the seed for the random number generators in the CGAL
5555
modules
5656

57-
Iso2mesh versions later than 1.0.0-pre can make reproducible meshes
58-
across multiple runs. This was done by setting proper seeds for the
59-
random number generators called inside the CGAL executables. By
60-
default, iso2mesh will use 0x623F9A9E as the seed. If you prefer to set
61-
your own seed, please define a global variable named ISO2MESH_RANDSEED
62-
in the "base" workspace. The value of ISO2MESH_RANDSEED must be a
63-
positive integer. If iso2mesh detects the definition of
64-
ISO2MESH_RANDSEED, it will use it to seed the RNGs.
57+
Iso2mesh versions later than 1.0.0 can make reproducible meshes across
58+
multiple runs. This was done by setting proper seeds for the random
59+
number generators called inside the CGAL executables. By default,
60+
iso2mesh will use 0x623F9A9E as the seed. If you prefer to set your own
61+
seed, please define a global variable named ISO2MESH_RANDSEED in the
62+
"base" workspace. The value of ISO2MESH_RANDSEED must be a positive
63+
integer. If iso2mesh detects the definition of ISO2MESH_RANDSEED, it
64+
will use it to seed the RNGs.
6565

6666
Intermediate outputs
6767

doc/Get_Started.txt

+1-6
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@ Getting Started with iso2mesh
1818

1919
load mydata.mat
2020
[node,elem,face]=v2m(mydata,0.5,5,100);
21-
% or you can use the verbose form:
22-
% [node,elem,face]=vol2mesh(mydata>0.5,1:size(mydata,1),1:size(mydata,2),...
23-
1:size(mydata,3), 5, 100, 1,'cgalsurf');
2421
plotmesh(node,face)
25-
% be careful, the last column of face is a label, should not be used for plotti
26-
ng, same for elem
2722

2823
Needless to say, the first line loads the data to your current session.
29-
The second line calls an iso2mesh function, 'v2m', shortcut for
24+
The second line calls an iso2mesh function, 'v2m', the shortcut for
3025
vol2mesh, to construct a volumetric mesh from this data array. The
3126
first argument of v2m, "mydata", is the volumetric image you are about
3227
to mesh; the 2nd argument is the threshold value at which you define

doc/INSTALL.txt

+11-10
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ System Requirements
1717
The recommended system configuration for running this toolbox includes
1818
* a computer running GNU/Linux, Windows, Mac OS (either 32bit/64bit)
1919
* standard installation of Matlab (v7 or above) or Octave (3.0 or
20-
above) (for demo 3, you need to install image processing toolbox
21-
for maltab/octave)
20+
above) (for some demos, you need to install the image processing
21+
toolbox for maltab/octave)
2222
* 20M disk space for the toolbox and the examples
2323
* a folder where you have write permission
2424

@@ -54,17 +54,17 @@ For restricted users
5454
encounter is the "permission error" when saving the "pathtool" path
5555
list in order to add iso2mesh permanently. If this happens, you may
5656
work in a multi-user or network-based system. For Matlab users, you
57-
typically need to create file named [5]startup.m under your home
58-
directory (~/matlab/ for Linux/Unix), and put
57+
typically need to create file named [5]startup.m under the [6]Matlab
58+
startup directory (~/matlab/ for Linux/Unix), and put
5959
addpath('/path/to/iso2mesh/'); into this file. It will be automatically
60-
executed when Matlab starts. For Octave, this file is [6].octaverc.
60+
executed when Matlab starts. For Octave, this file is [7].octaverc.
6161

6262
When using this toolbox under an extensively restricted mode, one may
63-
encounter a "write to file" error, this may likely be caused by the
63+
encounter a "fail to write" error, this may likely be caused by the
6464
default output folder is not writable from your account. If you do have
6565
another folder which you have permission to write, you need to
66-
[7]define an variable ISO2MESH_TEMP in Matlab/Octave's "base workspace"
67-
and set the value as the writable folder path, then rerun your meshing
66+
[8]define an variable ISO2MESH_TEMP in Matlab/Octave's "base workspace"
67+
and set the value as the writable folder path, then rer-un your meshing
6868
commands.
6969

7070
References
@@ -74,5 +74,6 @@ References
7474
3. https://orbit.nmr.mgh.harvard.edu/plugins/scmcvs/cvsweb.php/?cvsroot=iso2mesh
7575
4. http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?Doc/AddPath
7676
5. http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f8-4994.html#brlkmbe-1
77-
6. http://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB#startup.m
78-
7. http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?Advanced
77+
6. http://www.mathworks.com/help/techdoc/matlab_env/f8-10506.html
78+
7. http://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB#startup.m
79+
8. http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?Advanced

0 commit comments

Comments
 (0)