Click here to Skip to main content
Licence 
First Posted 5 Mar 2003
Views 155,173
Downloads 3,235
Bookmarked 38 times

StL Data File Viewer

By Sharjith | 5 Mar 2003
A simple StereoLithography data file viewer.
1 vote, 3.0%
1

2
2 votes, 6.1%
3
3 votes, 9.1%
4
27 votes, 81.8%
5
4.92/5 - 34 votes
3 removed
μ 4.73, σa 1.49 [?]

Sample Image - StLViewer.jpg

Introduction

StereoLithography(StL) is something that is widely used in CAD/CAM, RapidPrototyping etc. The concept is that any surface or solid is exported to StL format by data exchange packages after they are modeled in commercial CAD packages. This data consists of triangulated facets that approximate the surface of the solid. No topological or geometric information is exported. The surface is subdivided into small triangles. The approximation uses chordal deflection for curved surfaces to smoothen the surface. More the smoothening required, more number of smaller triangles are generated by subdivision resulting in larger size of data file. Now, along with triangles, their facet normals are also generated. The data is written both in ASCII and binary formats. The data in ASCII is written like this:

facet normal  0.000000e+000 -1.000000e+000  0.000000e+000
   outer loop
     vertex -1.499999e+002 -1.000000e+002  0.000000e+000
     vertex -1.500000e+002 -1.000000e+002  0.000000e+000
     vertex -1.500000e+002 -1.000000e+002 -5.000000e+001
   endloop
 endfacet

The facet normal tells the three components of the facet normal followed by three vertices of one triangle, enclosed by the statements.

facet normal  0.000000e+000 -1.000000e+000  0.000000e+000

and

endfacet

Thus all the triangles are written one after the other. This data can be then used as input for generating Rapid Prototype models as well as for NC toolpath generation. The Normal data helps to compute tool offsets etc.

Here, for displaying the data in the OpenGL viewer, I have written the code for reading the data and displaying each triangle using glBegin(GL_TRIANGLES) and the normals for lighting. The viewer and geometry coding is same as my earlier project CadSurf. You can read as many StL (ASCII only) files into the viewer zoom, pan, rotate the views, select the objects, change attributes like color and material. The viewer provides object oriented context menus. I.e., when you click the right mouse button in the view with no active selection, you get a context menu for setting the viewer attributes, whereas with StL object selected, you get menu for the object attributes. Some sample StL data is also provided in the Data folder of the project.

Please let me know your comments. Thank you.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Sharjith

Engineer
Tata Technologies Inc
United States United States

Member
Sharjith's professional experience of 12 years is in manufacturing of sheet metal tools, dies and fixtures for the Automotive Industry in the domain of CAD/CAM (EUCLID, Catia, Tebis etc). He started learning C, C++ and OpenGL (for which he heavily depended and still depends on CodeProject) as a curiosity to know how CAD/CAM applications are developed and an ambition to develop one some day. Eventually, his programming skills and some useful implementations of applications that he did for TATA Motors (CNC simulator, G-Code convertors, Coordinate computation tools etc) gave him the opportunity to switch from manufacturing to software. Now since the past 2 years, he is working as a Software Engineer with TATA Technologies India, doing customization of Dassault Systemes' product CATIA, using CAA (Component Application Architecture). He is a Mechanical Engineer with strong passion for Automobiles, Aircrafts and Software development.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralSTL Viewer Pinmembercjellwood5:02 13 Feb '11  
GeneralRe: STL Viewer PinmemberSharjith6:54 13 Feb '11  
GeneralError [modified] Pinmembersangar202019:21 23 Sep '10  
GeneralRe: Error PinmemberSharjith8:28 24 Sep '10  
GeneralTell the path Pinmembersangar20201:54 23 Sep '10  
GeneralRe: Tell the path PinmemberSharjith5:42 23 Sep '10  
GeneralFatel error Pinmembersangar20200:48 23 Sep '10  
Questionfollowing message display in .net 2008? Pinmembersangar202019:12 22 Sep '10  
AnswerRe: following message display in .net 2008? PinmemberSharjith19:38 22 Sep '10  
GeneralDuplicated points removal PinmemberM.Siyamalan19:56 3 May '10  
GeneralRe: Duplicated points removal PinmemberSharjith20:40 3 May '10  
QuestionHow to calculate angle between triangles Pinmembernsivabalan202021:50 31 Mar '10  
AnswerRe: How to calculate angle between triangles PinmemberSharjith8:17 1 Apr '10  
GeneralUnable to open other stl file PinmemberMember 460375421:12 14 Feb '10  
GeneralStereolithography file (STL) edit Pinmembernsivabalan202020:25 30 Nov '09  
GeneralWat knowledge should i must have to handle this task PinmemberDevelopmentNoob18:58 21 Apr '09  
GeneralIs there component out there that can recognize the demension of stl and iges files PinmemberMember 14020136:56 9 Apr '09  
AnswerRe: Is there component out there that can recognize the demension of stl and iges files PinmemberSharjith8:21 9 Apr '09  
Questionhow to convert CL data file to G codes/machine language Pinmemberdixitava0:37 9 Feb '09  
AnswerRe: how to convert CL data file to G codes/machine language PinmemberSharjith3:29 9 Feb '09  
GeneralRe: how to convert CL data file to G codes/machine language Pinmemberdixitava20:06 9 Feb '09  
GeneralRe: how to convert CL data file to G codes/machine language Pinmemberdixitava19:07 11 Feb '09  
GeneralRe: for which controller Pinmemberdixitava19:09 11 Feb '09  
QuestionHow can I contact you? Pinmemberjemmyell8:13 12 Dec '08  
AnswerRe: How can I contact you? PinmemberSharjith5:47 15 Dec '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120209.1 | Last Updated 6 Mar 2003
Article Copyright 2003 by Sharjith
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid