Click here to Skip to main content
Click here to Skip to main content

StL Data File Viewer

By , 5 Mar 2003
 

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, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

About the Author

Sharjith
Engineer Tata Technologies Inc
United States United States
Member
Sharjith 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.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionVS 2010 build fails for me with missing iostream.h Pinmembercodegrunt2 Jun '12 - 17:37 
QuestionUnable to view the viewer after running the application Pinmembersidhu_ind23 May '12 - 21:47 
GeneralMy vote of 5 PinmemberVolynsky Alex23 May '12 - 3:42 
QuestionSlicing Pinmemberederson.nivel124 Apr '12 - 9:34 
QuestionSelection window on window 7 machine got distorted. Pinmembersingh96323 Apr '12 - 5:00 
Questionflash screen appear while resizing window Pinmembersingh96323 Apr '12 - 4:54 
QuestionRun-Time Check Failure #2 - Stack around the variable 'str' was corrupted. Pinmemberwaterharbin1 Mar '12 - 2:33 
GeneralSTL Viewer Pinmembercjellwood13 Feb '11 - 4:02 
GeneralError [modified] Pinmembersangar202023 Sep '10 - 18:21 
GeneralTell the path Pinmembersangar202023 Sep '10 - 0:54 
GeneralFatel error Pinmembersangar202022 Sep '10 - 23:48 
Questionfollowing message display in .net 2008? Pinmembersangar202022 Sep '10 - 18:12 
GeneralDuplicated points removal PinmemberM.Siyamalan3 May '10 - 18:56 
QuestionHow to calculate angle between triangles Pinmembernsivabalan202031 Mar '10 - 20:50 
GeneralUnable to open other stl file PinmemberMember 460375414 Feb '10 - 20:12 
GeneralStereolithography file (STL) edit Pinmembernsivabalan202030 Nov '09 - 19:25 
GeneralWat knowledge should i must have to handle this task PinmemberDevelopmentNoob21 Apr '09 - 17:58 
GeneralIs there component out there that can recognize the demension of stl and iges files PinmemberMember 14020139 Apr '09 - 5:56 
Questionhow to convert CL data file to G codes/machine language Pinmemberdixitava8 Feb '09 - 23:37 
QuestionHow can I contact you? Pinmemberjemmyell12 Dec '08 - 7:13 
General[Message Deleted] Pinmemberavajja17 Oct '08 - 19:02 
Questionthanks in advance Pinmembergaryzhg18 Jul '08 - 23:44 
QuestionGenport I/O initialitazion failure PinmemberVinod_code25 Sep '07 - 0:03 
Generaldimension of stl Pinmembersaisp22 Jul '07 - 21:42 
QuestionProblem Building Pinmemberdspantha29 Jan '07 - 15:54 
GeneralNOT ABLE TO DISPLAY OTHER STL Pinmembervickys24 Jan '07 - 12:42 
GeneralNOT ABLE TO DISPLAY OTHER STL files! Pinmembervickys24 Jan '07 - 12:42 
Questiontrouble building Pinmembermea3616 Jan '07 - 7:31 
QuestionI am very interested in the topological relation of triangles [modified] Pinmemberhyzhujc4 Dec '06 - 20:38 
GeneralNC & RP code Pinmemberharshalmsrsas19 Nov '06 - 23:14 
GeneralI want to use OpenGL with STL From Robotic 6 axis Pinmemberaluntum15 Feb '06 - 9:25 
QuestionI can't load other stl file Pinmemberqinhongxian19 Dec '05 - 6:24 
GeneralSlow and Selection should disabled out of the stl object Pinmemberlua8 Jun '05 - 1:03 
GeneralCould not complie a code PinmemberTejas_qp1 Mar '05 - 8:00 
QuestionHow to run 2 different(or same) OpenGL objects in one DialogBox? Pinmemberwerter15 Jun '04 - 21:53 
GeneralOT: Starting Point Pinsusslj993234 Aug '03 - 16:48 
GeneralCan't not #include <GL/glut.h> PinmemberICE_WIZARD24 Jul '03 - 7:25 
GeneralSTL viewer does not display Pinmemberreddnedk23 Jun '03 - 6:18 
Generalview Pinmembermcalves@coc.ufrj.br8 May '03 - 20:05 
QuestionHow does GL_SELECT mode work in MFC? Pinmemberkillerdoll18 Mar '03 - 5:33 
General0xC0000005: Access Violation. PinsussSorry I donnot know why I cannot fill in right con7 Mar '03 - 13:33 

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

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