4.0

4.0 | 3 ratings Rate this file 75 downloads (last 30 days) File Size: 9.53 KB File ID: #16215

Triangular Mesh Refinement

by Dirk-Jan Kroon

 

03 Sep 2007 (Updated 16 Feb 2010)

Code covered by the BSD License  

This function will refine a triangular mesh with 4-split spline interpolation

Download Now | Watch this File

File Information
Description

This function "refinepatch" can refine any triangular mesh surface ( patch) with 4-split spline interpolation, see screenshot.

Literature:
The spline interpolation of the face edges is done by the Opposite Edge Method, described in: "Construction of Smooth Curves and Surfaces from Polyhedral Models" by Leon A. Shirman

How it works:
The tangents (normals) and velocity on the edge points of all edges are calculated. Which are later used for b-spline interpolation when splitting the edges.
A tangent on an 3D line or edge is under defined and can rotate along the line, thus an (virtual) opposite vertex is used to fix the tangent and make it more like a surface normal.
B-spline interpolate a half way vertices between all existing vertices using the velocity and tangent from the edge points. After splitting a new face list is constructed with 4 times as many faces.

Implementation:
Some Matlab files are also available as MEX files to allow quick refinement of large meshes.

Please Leave a comment, if you find a bug, like the code or know improvements.
 

MATLAB release MATLAB 7.9 (2009b)
Zip File Content  
Other Files edge_tangents.m,
edge_tangents_double.c,
edge_tangents_double.m,
license.txt,
make_halfway_vertices.m,
makenewfacelist.m,
refinepatch.m,
vertex_neighbours.m,
vertex_neighbours_double.c,
vertex_neighbours_double.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
17 Oct 2007 hazem wannous

Hello;
To compile your code, i need to the function 'val_even' which is undefined.
can you send me this function.
thanks

18 Oct 2007 Dirk-Jan Kroon

Oops, i forgot that little function val_even:

function bin=val_even(val)
bin=mod(val,2)==0

16 Nov 2007 Duane Hanselman

This code produces pretty pictures, but is poorly documented and poorly written. It needs improvement--thus the reason for a 2=Needs Improvement ranking.

Can the input variables be defined differently?
%[V,F] = Refine_Mesh(V,F)
% The variable V is a list of vertices xyz coordinates
% The variable F is a list of faces described by indices of the vertices.

How do these correspond to MATLAB triangulation function arguments?, e.g., from TRIMESH
%TRIMESH(TRI,X,Y,Z,C) displays the triangles defined in the M-by-3 face matrix TRI as a mesh. A row of TRI contains indexes into the X,Y, and Z vertex vectors to define a single triangular face.

Your code was written using R2007a, but you still use obsolete structure functions getfield and setfield. Why? For example, Eb=getfield(Et,['F' num2str(Pneig(j)) 'T' num2str(i)]);
Perhaps it would be better to not use structures at all? That is, avoid
Et=struct(); % Edge tangents
Vt=struct(); % Edge velocity
The use of structures seems to make the code very cumbersome.

The H1 line is not informative and it would be good to describe the general algorithm in the text file so folks do not have to find the journal article to get the general idea of what is being done.

There is no use of vectorization, but clearly much of this code could be vectorized.

In MATLAB new lines are free, so there is no need to cram multiple MATLAB statements on a single line. Doing so makes it difficult to follow the code and may impede the JIT accelerator.

I am willing to change my rating if the code is revised.

28 Apr 2008 ivan scardanzan

it refines patches as claimed !
and given that
a)matlab does not have a better alternative tool
b) the functionality is important
it deserves a good rating

24 Apr 2009 Edward Bender

This is an excellent file that does exactly what it says it does. It worked the first time. I don't know why someone else gave it a bad rating - I think it's perfect as is.

Please login to add a comment or rating.
Updates
18 Oct 2007

Matlab code used an unknown function val_even , to determine even or odd value..

16 Feb 2010

Know also c-code files are available, and mesh no longer have to be closed.

16 Feb 2010

Fixed NaN bug in case of all neighbor vertices
Fixed Crash bug in case of vertex not present in face-list.

Tag Activity for this File
Tag Applied By Date/Time
approximation Dirk-Jan Kroon 22 Oct 2008 09:25:30
interpolation Dirk-Jan Kroon 22 Oct 2008 09:25:30
triangular Dirk-Jan Kroon 22 Oct 2008 09:25:30
mesh Dirk-Jan Kroon 22 Oct 2008 09:25:30
refinement Dirk-Jan Kroon 22 Oct 2008 09:25:30
spline Dirk-Jan Kroon 22 Oct 2008 09:25:31
4split Dirk-Jan Kroon 22 Oct 2008 09:25:31
mesh Yosi 13 Nov 2008 11:14:23
refinement Yosi 13 Nov 2008 11:14:39
triangular Martin Huber 16 Jul 2009 13:46:12
refinement Farheen 26 Nov 2009 01:55:27
faces Dirk-Jan Kroon 16 Feb 2010 12:12:24
3d Dirk-Jan Kroon 16 Feb 2010 12:12:24
patch Dirk-Jan Kroon 16 Feb 2010 12:12:24
edges Dirk-Jan Kroon 16 Feb 2010 12:12:24
vertices Dirk-Jan Kroon 16 Feb 2010 12:12:24
surface Dirk-Jan Kroon 16 Feb 2010 12:12:24
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com