Code covered by the BSD License  

Highlights from
Converting a 3D logical array into an STL surface mesh

5.0

5.0 | 1 rating Rate this file 22 Downloads (last 30 days) File Size: 72.72 KB File ID: #27733
image thumbnail

Converting a 3D logical array into an STL surface mesh

by Adam A

 

25 May 2010 (Updated 24 Nov 2010)

Conversion of a voxelised object contained within a 3D logical array into an STL surface mesh.

| Watch this File

File Information
Description

Converting a 3D logical array into an STL surface mesh
======================================================
 
Adam H. Aitkenhead
adam.aitkenhead@physics.cr.man.ac.uk
The Christie NHS Foundation Trust
24th May 2010
 
 
USAGE
=====
 
>> CONVERT_voxels_to_stl(STLname,gridDATA,gridX,gridY,gridZ,'ascii')
converts the voxelised object contained within the 3D logical array <gridINPUT> into an STL surface mesh, which is saved to the ascii file <STLin>. The x,y,z axes for <gridINPUT> are defined by <gridX>, <gridY> and <gridZ>.
 
 
INPUT PARAMETERS
================
 
STLname - string - Filename of the STL file.
gridINPUT - 3D logical array of size (P,Q,R) - The voxelised object (1 => Inside the object, 0 => Outside the object)
gridX - A 1xP array - List of the X axis coordinates.
gridY - A 1xQ array - List of the Y axis coordinates.
gridZ - A 1xR array - List of the Z axis coordinates.
STLformat - string (optional) - STL file format: 'binary' or 'ascii'.
 
 
EXAMPLE
=======
 
For an example, run the following script:
>> CONVERT_voxels_to_stl_example
 
 
NOTES
=====
 
- This code does not apply any smoothing. The stl mesh will be exactly the same geometry as the original voxelised object.
 
 

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
17 Jan 2012 Johannes Korsawe

Really good and fast.
Sometimes there seem to be some artifacts (missing faces) in the resulting mesh. I have not already discovered where, but suspect a missing line somewhere.

Thanks for sharing!

20 Jan 2012 Adam A

Hi Johannes. If you're able to send an example of an array and the resulting mesh I will see if I can duplicate and fix any problems.

Please login to add a comment or rating.
Updates
27 May 2010

Improved memory usage.

29 Jun 2010

Improved speed.

30 Jun 2010

Major speed improvement

18 Aug 2010

Improved documentation

24 Nov 2010

Allow the STL to be written in either binary or ascii format.

Tag Activity for this File
Tag Applied By Date/Time
stl Adam A 25 May 2010 10:51:56
cad Adam A 25 May 2010 10:51:56
data export Adam A 25 May 2010 10:51:56
convert Adam A 25 May 2010 10:51:56
voxel Adam A 25 May 2010 10:51:56
mesh Adam A 25 May 2010 10:51:56
3d Adam A 14 Mar 2011 10:56:14

Contact us at files@mathworks.com