Code covered by the BSD License  

Highlights from
Write STL C++ Mex function

5.0 | 1 rating Rate this file 9 Downloads (last 30 days) File Size: 30.1 KB File ID: #41597 Version: 1.1
image thumbnail

Write STL C++ Mex function


Arso (view profile)


02 May 2013 (Updated )

c++ mex function for writing ASCII stl file from nodes and triangles list

| Watch this File

File Information

Matlab functions for writing and reading textual files are lacking in speed. Here is c++ implementation for simple writing ASCII stl files from Matlab with reasonable speed for data up to 250k nodes and triangles.

For writing 100k(17MB on HDD) it takes 2-3 seconds and for huge stl like 10 millions nodes/triangles(over 1GB stl file) it takes approximately one minute on my machine(1.5GM RAM, 1.5 GHz).

  %nodes[NumberOfNodes x 3]
  %trianles[NumberOfTringles x 3]

nodes = [1 2 3; 4 5 6; 7 8 9];
triangles = [1 2 3];
filaname = 'one triangle.stl';

I have been reported that sharing mex files is not allowed. If You are not sure how to compile c++ to mex go to folder with writeSTL.cpp and just type "mex writeSTL.cpp", then call function.

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
23 May 2013 Arso

Arso (view profile)

Thanks to you Ben:)
I will check it(i don't promise anything), for sure it is possible.

Comment only
23 May 2013 Ben

Ben (view profile)

Really fast! Thanks for sharing.

Is it possible to make a version that saves binary STL file? In that case, the file size should be significantly reduced for large mesh.

03 May 2013 1.1

fixed title...

Contact us