Below is a demonstration of the features of the meshView function


clear; close all; clc;




This function visualizes volumetric mesh data (e.g. tetrahedral or hexahedral elements). The visualization uses the anim8 function to generate a slider controlled cut view of the mesh. The input is a mesh structure and an option structure. The default option structure (if optionStruct is left empty/incomplete) is:

defaultOptionStruct.hFig=[]; %Figure handle (if empty a new figure is
defaultOptionStruct.numSLiceSteps=25; %Number of slice steps
defaultOptionStruct.cMap=[]; %Colormap used (if empty it is based of
number of element material types
defaultOptionStruct.faceAlpha1=0.2; %Alpha level for boundary surface
defaultOptionStruct.faceAlpha2=1; %Alpha level for mesh elements
defaultOptionStruct.lightWeightPlot=1; %Option to only plot element
outer boundaries to create a more lightweigth plot

The output consists of a figure handle and a graphics handle. If tetgen is used the meshStruct can be the tetgen output structure.


Plot settings


Creating an example mesh

Surface mesh

switch testCase
    case 1
        [F,V,~]=geoSphere(2,1); % Building a geodesic dome surface model
    case 2
        [F,V]=stanford_bunny('g'); %Bunny

Using runTetGen to mesh the geometry

inputStruct.holePoints=[]; %holes
inputStruct.faceBoundaryMarker=ones(size(F,1),1); %Face boundary markers
inputStruct.regionPoints=getInnerPoint(F,V); %region interior point
inputStruct.regionA=tetVolMeanEst(F,V); %Volume attribute
inputStruct.minRegionMarker=2; %Minimum region marker

% Mesh model using tetrahedral elements using tetGen
[meshOutput]=runTetGen(inputStruct); %Run tetGen
--- TETGEN Tetrahedral meshing --- 03-Jun-2019 17:31:09
--- Writing SMESH file --- 03-Jun-2019 17:31:09
----> Adding node field
----> Adding facet field
----> Adding holes specification
----> Adding region specification
--- Done --- 03-Jun-2019 17:31:09
--- Running TetGen to mesh input boundary--- 03-Jun-2019 17:31:09
Opening /mnt/data/MATLAB/GIBBON/data/temp/temp.smesh.
Delaunizing vertices...
Delaunay seconds:  0.008471
Creating surface mesh ...
Surface mesh seconds:  0.002337
Recovering boundaries...
Boundary recovery seconds:  0.003294
Removing exterior tetrahedra ...
Spreading region attributes.
Exterior tets removal seconds:  0.001877
Recovering Delaunayness...
Delaunay recovery seconds:  0.001851
Refining mesh...
Refinement seconds:  0.078542
Optimizing mesh...
Optimization seconds:  0.006142

Writing /mnt/data/MATLAB/GIBBON/data/temp/temp.1.node.
Writing /mnt/data/MATLAB/GIBBON/data/temp/temp.1.ele.
Writing /mnt/data/MATLAB/GIBBON/data/temp/temp.1.face.
Writing /mnt/data/MATLAB/GIBBON/data/temp/temp.1.edge.

Output seconds:  0.068305
Total running seconds:  0.170984


  Input points: 1520
  Input facets: 3036
  Input segments: 4554
  Input holes: 0
  Input regions: 1

  Mesh points: 5861
  Mesh tetrahedra: 32563
  Mesh faces: 66644
  Mesh faces on exterior boundary: 3036
  Mesh faces on input facets: 3036
  Mesh edges on input segments: 4554
  Steiner points inside domain: 4341

--- Done --- 03-Jun-2019 17:31:10
--- Importing TetGen files --- 03-Jun-2019 17:31:10
--- Done --- 03-Jun-2019 17:31:10

Visualizing mesh using meshView, see also anim8



Kevin Mattheus Moerman, [email protected]

GIBBON footer text


GIBBON: The Geometry and Image-based Bioengineering add-On. A toolbox for image segmentation, image-based modeling, meshing, and finite element analysis.

Copyright (C) 2019 Kevin Mattheus Moerman

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see