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查 ...
随机推荐
- 【重装系统】线上Linux服务器(2TB)分区参考方案
如果是线上服务器,假设它是 2TB 的 SATA 硬盘.8GB 内存,建议按如下方式进行分区: / 20480M(20G)(主分区) /boot 128M swap 10240M /data 2016 ...
- 02OC的类和对象
这章重点介绍OC的类以及对象,由于C语言是面向过程语言,而OC只是对于C语言多了一些面向对象的特性,所以OC相对于其他面向对象语言,例如C#.Java等没有那么多的语法特性,所以差别还是比较大的. 一 ...
- C#获取命令行输出内容的方法
获取命令行输出内容的方式有传统和异步两种方式. 传统方式: public static void RunExe(string exePath, string arguments, out string ...
- python file
>>> help(open) Help on built-in function open in module __builtin__: open(...) open(name[, ...
- 如何更高效地定制你的bootstrap
bootstrap已经作为前端开发必不可少的框架之一,应用bootstrap使得我们对布局.样式的设定变得非常简单.但bootstrap提供的默认样式往往不能满足我们的需求,从而定制化bootstra ...
- jQuery UI Datepicker
http://www.runoob.com/try/try.php?filename=jqueryui-example-datepicker-dropdown-month-year <!doct ...
- Other Linker Flags到底是什么
一.问题描述 在项目开发中用到百度地图,有时候在工程中会报“方法找不到”的错误(unrecognized selector sent to instance). 二.问题分析 首先,要说明一下Othe ...
- 再谈通过http访问SSAS
问题: 在有些场景下,数据中心会分为不同的服务器场:数据库场和应用程序场.服务器场间有严格的防火墙控制,其中数据库场只能建立从应用程序场的防火墙穿越,也就是说不允许任何客户端直接连接到防火墙. 这种策 ...
- android 得到缩略图
转载至 http://blog.csdn.net/dxh040431104/article/details/6667448 怎样获取图片的大小?思路很简单:首先我们把这个图片转成Bitmap,然后再利 ...
- 【CentOS】虚拟机网络配置与远程登录
////////////////////////////////////11月16日更新////////////////////////////////////////////////////// 一 ...