stl文件格式
http://wenku.baidu.com/view/a3ab7a26ee06eff9aef8077b.html
[每个三角形面片的定义包括三角形各个定点的三维坐标及三角形面片的法矢量[三角形的法线。它是一个向量,是三角形平面上的一条垂线]]
科学技术法[e+n][E(代表指数)表示将前面的数字乘以 10 的 n 次幂。]:10进制123456789 = 1.23e+7
stl格式
STL文件的最大特点也是其主要问题是,它是由一系列的三角形面片无序排列组合在一起的,没有反映三角形面片之间的拓扑关系
STL文件规则
(1)共顶点规则
每一个三角面片必须与其相邻的每一个面片共两个顶点 ,即一个三角面片的顶点不能落在相邻的任何三角面片的边上;
(2)取向规则
单个面片法向量符合右手法则且其法向量必须指向实体外面;
(3)充满规则
小三角面片必须布满三维模型的所有表面,不得有任何遗漏;
(4)取值规则
每个顶点的坐标值必须为非负 ,即 STL 文件的实体应该在坐标系的第一象限.
文件格式的结构
目前的STL文件格式包括二进制文件(BINARY)和文本文件(ASCII)两种
ASCII STL An ASCII STL file begins with the line:solid name where name is an optional string (though if name is omitted there must still be a space after solid). The file continueswith any number of triangles, each represented as follows:
solid filename stl //自定义文件头
facet normal x y z //三角面片法向量的3个坐标
outer loop
vertex v1x v1y v1z //三角面片第一个顶点坐标
vertex v2x v2y v2z //三角面片第二个顶点坐标
vertex v3x v3y v3z //三角面片第三个顶点坐标
endloop
endfacet //完成一个三角面片定义
where each n or v is a floating point number in sign-mantissa 'e'-sign-exponent format, e.g., "-2.648000e-002". Thefile concludes with:endsolid name The structure of the format suggests that other possibilities exist (e.g., facets with more than one 'loop', or loops with more than three vertices) but in practice, all facets are simple triangles. White space (spaces, tabs, newlines) may be used anywhere in the file except within numbers or words. The spaces between 'facet' and 'normal' and between 'outer' and 'loop' are required
Binary STL
Because ASCII STL files can become very large, a binary version of STL exists. A binary STL file has an 80character header (which is generally ignored – but which should never begin with 'solid' because that will lead mostsoftware to assume that this is an ASCII STL file). Following the header is a 4 byte unsigned integer indicating the number of triangular facets in the file. Following that is data describing each triangle in turn. The file simply endsafter the last triangle.
Each triangle is described by twelve 32-bit-floating point numbers: three for the normal and then three for the X/Y/Z coordinate of each vertex – just as with the ASCII version of STL. After the twelve floats there is a two byteunsigned 'short' integer that is the 'attribute byte count' – in the standard format, this should be zero because mostsoftware does not understand anything else.
Floating point numbers are represented as IEEE floating point numbers and are assumed to be little endian, althoughthis is not stated in documentation.
UINT8[80] – Header //which is generally ignored – but which should never begin with 'solid' because that will lead most software to assume that this is an ASCII STL file
UINT32 – Number of triangles //indicating thenumber of triangular facets in the file.
foreach triangle
REAL32[3] – Normal vector
REAL32[3] – Vertex 1
REAL32[3] – Vertex 2
REAL32[3] – Vertex 3
UINT16 – Attribute byte count
end
Color in binary STL
There are at least two variations on the binary STL format for adding color information:
•The VisCAM and SolidView software packages use the two 'attribute byte count' bytes at the end of every triangle to store a 15 bit RGB color:
•bit 0 to 4 are the intensity level for blue (0 to 31)
•bits 5 to 9 are the intensity level for green (0 to 31)
•bits 10 to 14 are the intensity level for red (0 to 31)
•bit 15 is 1 if the color is valid
•bit 15 is 0 if the color is not valid (as with normal STL files)
•The Materialise Magics software does things a little differently. It uses the 80 byte header at the top of the file to represent the overall color of the entire part. If color is used, then somewhere in the header should be the ASCII string "COLOR=" followed by four bytes representing red, green, blue and alpha channel (transparency) in the range 0–255.
This is the color of the entire object unless overridden at each facet. Magics also recognizes a material description; a more detailed surface characteristic. Just after "COLOR=RGBA" specification should be another ASCII string ",MATERIAL=" followed by three colors (3 × 4 bytes):
first is a color of diffuse reflection,
second is a color of specular highlight,
and third is an ambient light.
Material settings are preferred over color.The per-facet color is represented in the two 'attribute byte count' bytes as follows:
•bit 0 to 4 are the intensity level for red (0 to 31)
•bits 5 to 9 are the intensity level for green (0 to 31)
•bits 10 to 14 are the intensity level for blue (0 to 31)
•bit 15 is 0 if this facet has its own unique color
•bit 15 is 1 if the per-object color is to be used
The red/green/blue ordering within those two bytes is reversed in these two approaches
– so while these formatscould easily have been compatible the reversal of the order of the colors means that they are not
– and worse still, ageneric STL file reader cannot automatically distinguish between them. There is also no way to have facets beselectively transparent because there is no per-facet alpha value
– although in the context of current rapid prototyping machinery, this is not important.
最后粘贴上,在github上找到的stl文件解析类:
https://github.com/Ultimaker/ruby-admesh/blob/master/ext/admesh/admesh/src/stlinit.c
stl文件格式的更多相关文章
- stl文件格式解析代码--java版
代码是参考three.js中的stlLoader.js写的. 需要注意的地方,java中byte取值-128~127 package test_stl.test_entry; import java. ...
- Open Cascade Data Exchange STL
Open Cascade Data Exchange STL eryar@163.com 摘要Abstract:介绍了三维数据交换格式STL的组成,以及Open Cascade中对STL的读写.并将O ...
- C++ STL自学总结,仅供参考
本文内容,为博主在网上看到资料总结整合而来 一.stl格式简介 .stl文件是在计算机图形应用系统,来表示封闭的面或者体,用来表示三角形网格的一种文件格式.为STereo Lithography的缩写 ...
- 从STL文件到网格拓扑
原文链接 STL文件是什么 STL文件是网格文件的一种格式,分为二进制和文本两种类型.具体来讲,它定义了一群三角面片,比如下面是一个文本的STL示例: solid geometryplusplus f ...
- Delaunay Triangulation in OpenCascade
Delaunay Triangulation in OpenCascade eryar@163.com 摘要:本文简要介绍了Delaunay三角剖分的基础理论,并使用OpenCascade的三角剖分算 ...
- 免费开源3D模型设计软件汇总
免费开源3D模型设计软件汇总 3D 打印需要先通过计算机辅助设计(CAD)进行建模,再将建好的3D模型“分割”成逐层的截面,从而指导3D打印机进行逐层打印.因此用于3D打印的3D模 型大都储存或输出成 ...
- 使用WebGL实现一个Viewer来显示STL文件
关键字:WebGL,STL,ThreeJS,Chrome,Viewer,Python3.4, HTML5,Canvas. OS:Windows 10. 本文介绍如何使用ThreeJS来实现一个WebG ...
- Assimp场景模型输出Collada,STL,3DPDF
本文介绍开源库模型的几种输出格式:DAE,STL,3DPDF. Assimp是C++写的,AssimpNet是C#重构其中主要数据结构,并开通Assimp中重要方法的调用接口,为不熟悉C++的码农带来 ...
- Three.js 3D打印数据模型文件(.STL)载入中
3DPrint是现在和未来10年度科技产品的主流之中.广泛的. 对于电子商务类3D打印网站.一个主要功能就是商品3D呈现的方式,那是,3D数据可视化技术. HTML5(WebGL)它可以用于构建3D查 ...
随机推荐
- 【Alpha版本】冲刺总结随笔
项目预期计划 确定代码规范与编码原则. 根据原型设计,界面设计,搭建应用大致框架,完善控件,背景等的界面设计. 根据体系结构设计,完善界面跳转逻辑,确定功能模块,实现1.0版本功能. 重点完善需求说明 ...
- Asp.Net Core--简单的授权
翻译如下: 在MVC中授权通过控制AuthorizeAttribute属性及其各种参数.在最简单的应用AuthorizeAttribute属性控制器或行动限制访问控制器或操作任何身份验证的用户. 例如 ...
- TouchSlide1.1,手机上的幻灯片
TouchSlide 是纯javascript打造的触屏滑动特效插件 http://pan.baidu.com/s/1bpoWNin 官网:http://www.superslide2.com/Tou ...
- 耿丹CS16-2班第一次作业汇总
第一次作业统计完成. 注:1.作业顺序:取最早交作业的前3名,依次拿5,2,1分,前提是作业质量较高,否则轮至下一名同学得分,其余同学得0分:2.作业情况:满10分,空一题扣2分,心得写得好的有额外加 ...
- MySQL 5.7 学习:功能性能的提升
背景: 继上次介绍 初识 MySQL 5.6 新功能.参数完之后,刚好MySQL 5.7又GA了,在官方测试里看到,MySQL5.7在功能.性能.可用性.安全和监控上又提升了很高.现在看看和MySQL ...
- 一个漂亮的上传按钮input[type=file]
;;} <div class="input-group xj-file xj-panel-top"> <span class="input-group- ...
- C#调用webservice简单实例
如何利用IIS创建webservice不多做阐述,直接讲C#代码中如何调用已创建好的webservice. 首先在VS2010中新建一个工程项目,然后右键点击工程名选择添加服务引用. 在URL一栏中输 ...
- C# 获取时间差状态
/// <summary> /// 根据时间获取时间状态 /// </summary> /// <param name="dt"></pa ...
- 懵逼的闭包--for循环(转)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 如何用C#+WinRAR 实现压缩 分类:
前提:必须安装 WinRAR 1. 工具类 using System; using System.Diagnostics; using System.IO; using Microsoft.Win32 ...