Click here to Skip to main content
6,295,667 members and growing! (15,509 online)
Email Password   helpLost your password?
Multimedia » OpenGL » General     Advanced

StL Data File Viewer

By Sharjith

A simple StereoLithography data file viewer.
VC6Win2K, MFC, OpenGL, Dev
Posted:5 Mar 2003
Views:110,650
Bookmarked:26 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
27 votes for this article.
Popularity: 6.64 Rating: 4.64 out of 5
1 vote, 3.8%
1

2
2 votes, 7.7%
3
2 votes, 7.7%
4
21 votes, 80.8%
5

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


Member
My professional experience of 12 years is in manufacturing of sheet metal tools, dies and fixtures in the domain of CAD/CAM (EUCLID, Catia, Tebis etc).
Now working as a Software Engineer with TATA Technologies India, doing Catia customization using CAA.
Occupation: Engineer
Company: Tata Technologies Ltd
Location: India India

Other popular OpenGL articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 48 (Total in Forum: 48) (Refresh)FirstPrevNext
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  
Generalhow to convert CL data file to G codes/machine language Pinmemberdixitava0:37 9 Feb '09  
GeneralRe: 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  
GeneralHow can I contact you? Pinmemberjemmyell8:13 12 Dec '08  
GeneralRe: How can I contact you? PinmemberSharjith5:47 15 Dec '08  
General[Message Deleted] Pinmemberavajja20:02 17 Oct '08  
GeneralRe: How to View STL file in BINARY format PinmemberSharjith7:34 23 Oct '08  
Questionthanks in advance Pinmembergaryzhg0:44 19 Jul '08  
QuestionGenport I/O initialitazion failure PinmemberVinod_code1:03 25 Sep '07  
Generaldimension of stl Pinmembersaisp22:42 22 Jul '07  
QuestionRe: dimension of stl PinmemberSharjith7:51 23 Jul '07  
AnswerRe: dimension of stl [modified]-pls i need ur help Pinmembersaisp18:28 24 Jul '07  
QuestionProblem Building Pinmemberdspantha16:54 29 Jan '07  
GeneralNOT ABLE TO DISPLAY OTHER STL Pinmembervickys13:42 24 Jan '07  
GeneralNOT ABLE TO DISPLAY OTHER STL files! Pinmembervickys13:42 24 Jan '07  
AnswerRe: NOT ABLE TO DISPLAY OTHER STL files! Pinmembertulip.sun23:45 7 Feb '07  
Questiontrouble building Pinmembermea368:31 16 Jan '07  
QuestionI am very interested in the topological relation of triangles [modified] Pinmemberhyzhujc21:38 4 Dec '06  
AnswerRe: I am very interested in the topological relation of triangles PinmemberSharjith5:15 18 Dec '06  
GeneralNC & RP code Pinmemberharshalmsrsas0:14 20 Nov '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 5 Mar 2003
Editor: Smitha Vijayan
Copyright 2003 by Sharjith
Everything else Copyright © CodeProject, 1999-2009
Web11 | Advertise on the Code Project