读取STL模型
读取二进制格式的STL模型文件
std::ifstream fin;
fin.open(stlFilePath, std::ios::in | std::ios::binary);
bool isBinary=true;//判断stl是否是二进制流文件
fin.seekg(0, std::ios::end);
std::streamoff stlFileSize=fin.tellg();//文件大小
char buf[4];
fin.seekg(80, std::ios::beg);
fin.read(buf, 4);
int triNum=*(int*)(buf);//三角面个数
if ((80+4+triNum*50)!=stlFileSize)
{
isBinary=false;
}
//一个STL里面的facet占50个字节
float normal[3];//三角面法向量3*sizeof(float)=12字节
float v1[3]; //第一个顶点3*sizeof(float)=12字节
float v2[3]; //第二个顶点3*sizeof(float)=12字节
float v3[3]; //第三个顶点3*sizeof(float)=12字节
short attribute;//2字节,属性信息(暂未使用)
for (int meshId=0; meshId<triNum; meshId++)
{
fin.read((char*)normal, 12);
fin.read((char*)v1, 12);
fin.read((char*)v2, 12);
fin.read((char*)v3, 12);
fin.read((char*)&attribute, sizeof(short));
}
读取STL模型的更多相关文章
- VTK中获取STL模型点的坐标以及对其进行变换
VTK是一个基于面向对象的开源三维绘图软件包,和其它的的三维绘图引擎如OSG.OGRE不同之处在于,VTK可视化对象主要是各种数据,更加注重对数据分析处理后的可视化,可视化的内容是人们无法直接感受到的 ...
- c# winform用sharpGL(OpenGl)解析读取3D模型obj
原文作者:aircraft 原文链接:https://www.cnblogs.com/DOMLX/p/11783026.html 自己写了个简单的类读取解析obj模型,使用导入类,然后new个对象,在 ...
- VS+OpenGl 显示三维STL模型 代码
今天调出了用VS环境结合OpenGL glut工具包进行显示STL模型的模块,进行了渲染.效果: 如下,后期会进行进一步优化,先贴上: #ifndef DATA_H #define DATA_H st ...
- Three.js基础:导入STL模型文件
stlloadertest.html: <!DOCTYPE html> <html lang="en"> <head> <title> ...
- 保存及读取keras模型参数
转自:http://blog.csdn.net/u010159842/article/details/54407745,感谢分享~ 你可以使用model.save(filepath)将Keras模型和 ...
- Java3D读取3DMax模型并实现鼠标拖拽、旋转、滚轮缩放等功能
/**-------------------------------------------------代码区--------------------------------------------- ...
- 第九章 用多线程来读取epoll模型下的client数据
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include &l ...
- R 读取回归模型的信息
参考博客: http://blog.sina.com.cn/s/blog_8f5b2a2e0101fmiq.html https://blog.csdn.net/huangyouyu523/artic ...
- c++ opencv3.4 保存和读取PCA模型
cv::PCA pca(samples, cv::Mat(), cv::PCA::DATA_AS_ROW,); FileStorage fs("pca.xml",FileStora ...
随机推荐
- hdu 3068 最长回文子串 马拉车模板
前几天用后缀数组写过一次这题,毫无疑问很感人的TLE了-_-|| 今天偶然发现了马拉车模板,O(N)时间就搞定 reference:http://acm.uestc.edu.cn/bbs/read.p ...
- CodeForces 559C Gerald and Giant Chess
C. Gerald and Giant Chess time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Linux Rootkit Learning
目录 . 学习Rootkit需要了解的基础知识 . 挂钩(HOOKING) . 直接内核对象操作 . LSM框架(Linux Security Module)于LKM安全 . rootkit检测技术及 ...
- configure new linux
vim http://www.cnblogs.com/wswang/p/5088078.html zsh sh -c "$(curl -fsSL https://raw.github. ...
- MySQL 存储过程传参之in, out, inout 参数用法
存储过程传参:存储过程的括号里,可以声明参数. 语法是 create procedure p([in/out/inout] 参数名 参数类型 ..) in :给参数传入值,定义的参数就得到了值 ou ...
- CSS------添加注释框
my.html <div><a href="#" class="tip">你好<span><k>哈哈哈哈< ...
- web.xml文件中的web-app元素 部署
[转载]web.xml文件中的web-app元素 (2012-05-24 13:35:57) 转载▼ 标签: 转载 分类: java 挺全 的 呵呵呵 转了 原文地址:web.xml文件中的web-a ...
- shell编程报错 [: missing `]'
NGINX_RATES=50 NGINX_BURST=3000 NGINX_PATH=/opt/srv/nginx/conf/nginx.conf BEE_PATH=/opt/srv/nginx/co ...
- 压缩 javascript 和 css
www.iwangzheng.com 目前我们项目中的 CSS/JS 文件比较多, 由于RAILS 3.0 没有提供asset pipeline功能,所以这样会制约我们的访问速度. 例如: 目前,我 ...
- [Educational Codeforces Round 16]B. Optimal Point on a Line
[Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...