Be the first to rate this file! 40 downloads (last 30 days) File Size: 1.8 KB File ID: #22602

Export triangulation to Paraview

by David Gingras

 

06 Jan 2009 (Updated 05 May 2009)

Code covered by BSD License  

Function to export an unrestricted 2D triangulation to a VTK file which can be open with Paraview.

Download Now | Watch this File

File Information
Description

Trying to visualize a huge triangulation with trisurf or triplot is often very slow and frustrating. Solution : use Paraview, a very powerful and free 3D data viewer. But it could be complicated to generate the input file specially with binary format. The function proposed takes a 2.5D unrestricted triangulation and generates the ASCII VTK file for Paraview.

function exportTriangulation2VTK(file,XYZ,tri,dir)
Input :
          "dir" is the path of the directory where the file is saved (string). (Optional)
           "file" is the name without extension of the file (string).
           "XYZ" is the coordinate of the vertex of the triangulation (nx3 matrix).
          "tri" is the list of triangles which contain indexes of XYZ (mx3 matrix).

Simple example :
[X,Y,Z]=peaks(25);
X=reshape(X,[],1);
Y=reshape(Y,[],1);
Z=0.4*reshape(Z,[],1);
tri = delaunay(X,Y);
exportTriangulation2VTK('sampleExampleTri',[X Y Z],tri)

Note : If the triangulation doesn't have Z component (a plane), put the third column of XYZ with all zeros. Paraview only deals with 3D object.

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
05 May 2009

updated the description

Tag Activity for this File
Tag Applied By Date/Time
2d Cristina McIntire 07 Jan 2009 15:30:50
3d Cristina McIntire 07 Jan 2009 16:04:01
visualization David Gingras 07 Jan 2009 16:04:12
data export David Gingras 07 Jan 2009 16:04:12
paraview David Gingras 07 Jan 2009 16:04:12
vtk David Gingras 07 Jan 2009 16:04:12
triangulation David Gingras 07 Jan 2009 16:04:12
2d Francesco Boselli 02 Feb 2009 09:26:48
 

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