C + + STL Self-study summary, for reference only

Source: Internet
Author: User

The content of this article, for bloggers in the online to see the summary of the integration of information

Introduction of STL Format

The. stl file is a file format used in a computer graphics application system to represent a closed polygon or body that represents a triangular mesh. The abbreviation for stereo lithography, developed by 3D Systems in 1987, uses triangular discrete approximation to represent three-dimensional models and has become a widely used document format and interface standard in rapid prototyping technology in recent years.

An STL file coordinate must be positive, no proportional information, and the unit is arbitrary.

Second, STL file format

STL files are available in ASCII plaintext format and binary format.

The STL structure in ASCII format is as follows:

1Solid Filename.stl//file path and file name2Facet normal x Y x//the outer normal vector of triangular slices3Vertex x y Z//first vertex4Vertex x y Z//a second vertex5Vertex x y Z//a third vertex6 End Loop7 Endfacet8  .9  .Ten  . OneEndsolid

An example of a fragment running a generated STL file for me

A triangular piece contains the outer normal vector of the triangle and three vertices arranged by the right-hand spiral rule.

Because the ASCII format can be very large, there is a binary format

The STL structure in binary format is as follows:

1UINT8//File Header2UINT32//number of triangular slices3 foreachTriangle4real32[3]//normal vector5real32[3]//Vertex One6real32[3]//Vertex two7real32[3]//Vertex three8UINT16//file attribute Statistics9End

Iii.. stl file export and display tools

Here I use VTK to write. stl files, and then use MeshLab to open files for display

The export code is as follows:

1 //VTK2 ......3#include"VtkSTLWriter.h"4 5 intMainintargcChar*argv[])6{//ARGC indicates the number of arguments passed into the main function, Argv0 represents the name of the program, and contains the full path where the Cheng is located7 8             .......9Vtkstlwriter *writer = Vtkstlwriter::new ();//Stereo lithography files only contain triangles. If polygons with more than 3 vertices is present, only the first 3 vertices is written.TenWriter->setinputconnection (skinstripper->Getoutputport ()); OneWriter->setfilename ("D:/dataout/poly2procs.stl"); AWriter->Update (); -Writer->Write (); -          theSystem"Pause"); -  -         return 0; -}

C + + STL Self-study summary, for reference only

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.