欢迎来到天天文库
浏览记录
ID:38783707
大小:16.10 KB
页数:6页
时间:2019-06-19
《将数据保存成stl等格式》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include"vtkRenderer.h"#include"vtkRenderWindow.h"#include"vtkRenderWindowInteractor.h"#include"vtkUnstructuredGrid.h"#include"vtkDataSetMapper.h"#include"vtkActor.h"#include"vtkCellType.h"#include"vtkProperty.h"#include"vtkInteractorStyleTrackballCamera.h"#include"vtkRenderer.h"#include"vtkRende
2、rWindow.h"#include"vtkRenderWindowInteractor.h"#include"vtkFloatArray.h"#include"vtkRectilinearGrid.h"#include"vtkRectilinearGridGeometryFilter.h"#include"vtkPolyDataMapper.h"#include"vtkActor.h"#include"vtkProperty.h"#include"vtkCamera.h"#include"vtkInteractorStyleTrackballCamera.h"#include"vtkR
3、enderWindowInteractor.h"#include"vtkSTLWriter.h"#include"vtkTriangleFilter.h"#include"vtkPolyData.h"#include"vtkCellArray.h"constintNface=612;constintNvertice=331;doublechar2num(char*s){ doubled=0; inti,t=0; doubleflag=1; intii=0; if(s[0]=='-') { flag=-1; ii=1; } for(i=ii;s[i]!=NULL;i++)
4、 { if(s[i]=='.') { t=10; } if(t==0) { d=d*10+(s[i]-'0'); } elseif(s[i]!='.') { d=d+(double)(s[i]-'0')/t; t*=10; } } returnd*flag;}intmain(){ ifstreamfin("D:\Users\liushuai\Desktop\mat\vertice.txt"); inti=0; doublex[Nface][3];charp[100]; while(!fin.eof()
5、)//读取数据到数组,file.eof()判断文件是否为空{ fin.getline(p,100); x[i/3][i-i/3*3]=char2num(p); //cout<
6、AddRenderer(renderer); vtkRenderWindowInteractor*iren=vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin); vtkPolyData*sphere=vtkPolyData::New(); vtkCellArray*polys=vtkCellArray::N
7、ew(); vtkPoints*points=vtkPoints::New(); for(i=0;iInsertPoint(i,x[i]); for(i=0;iInsertNextCell(3,pts[i]); } sphere->SetPoints(points);points->Delete(); sphere->SetPolys(polys
此文档下载收益归作者所有