vtk点云数据的显示[转]
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkPoints.h"
#include "vtkPolyVertex.h"
#include "vtkUnstructuredGrid.h"
#include "vtkDataSetMapper.h" int main(int argc, char* argv[])
{
FILE *fp = NULL;
if (argc==)
{
if ((fp=fopen("venus.asc","r"))== NULL)
{
printf("Error in open file mbr.asc\n");
return ;
}
}
else
{
if ((fp=fopen(argv[],"r"))== NULL)
{
printf("Error in open file %s\n", argv[]);
return ;
}
} vtkRenderer *ren=vtkRenderer::New();
double arr[]; vtkPoints * points = vtkPoints::New();
int n=;
while(!feof(fp))//首先读取点云数据到点表points同时指定点对应的id:
{
int ret=fscanf(fp,"%lf %lf %lf",&arr[],&arr[],&arr[]);
if(ret!=)
break;
points->InsertPoint(n,arr[],arr[],arr[]);
n++;
}
printf("%d\n", n);
fclose(fp); vtkPolyVertex * polyvertex = vtkPolyVertex::New();
polyvertex->GetPointIds()->SetNumberOfIds(n);
int i=;
for(i=;i<n;i++)//建立拓扑关系
{
polyvertex->GetPointIds()->SetId(i,i);
} vtkUnstructuredGrid * grid=vtkUnstructuredGrid::New();
grid->SetPoints(points);
grid->InsertNextCell(polyvertex->GetCellType(),
polyvertex->GetPointIds()); vtkDataSetMapper *map1 = vtkDataSetMapper::New();
map1->SetInput(grid); vtkActor *actor1 = vtkActor::New();
actor1->SetMapper(map1);
actor1->GetProperty()->SetColor(0.194,0.562, 0.75); ren->AddActor(actor1);
ren->SetBackground(, , ); vtkRenderWindow* win=vtkRenderWindow::New();
win->AddRenderer(ren);
win->SetSize(,);
win->BordersOn();
//win->FullScreenOn();
//win->HideCursor(); vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(win);
vtkInteractorStyleTrackballCamera *style =
vtkInteractorStyleTrackballCamera::New();
iren->SetInteractorStyle(style); iren->Start();
ren->Delete();
win->Delete();
iren->Delete(); return ;
}
编译命令为
gcc -o 可执行文件名 源文件名 -I 头文件目录 需要的库文件 -Wno-dprecated: gcc -o cloud cloud.cxx -I /usr/include/vtk-5.0 /usr/lib/libvtkRendering.so -Wno-deprecated 运行: ./cloud venus.asc //数据文件 转为:http://www.cnblogs.com/lilun/archive/2013/06/10/3131240.html
vtk点云数据的显示[转]的更多相关文章
- 在Ubuntu Server上使用vtk处理体数据,直接得到渲染结果图片避免显示窗口
概述 需要调用vtk对体数据进行渲染处理,处理结果直接存为图片而不通过窗口显示. 直接使用vtkRenderWindow加上vtkWindowToImageFilter类写入,在调用渲染的过程中会出现 ...
- 百度——LBS.云 v2.0——创建自己的地理云数据
随着云技术和地理信息(GIS)技术的发展,今年终于进入了.地理分享的新纪元.百度提供了LBS的云存储.真是个不错的功能.下面让我们来看看如何使用吧. 1.注册百度开发者账号(此处略去88个字) 2.创 ...
- 向PCD文件写入点云数据
博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=83 本小节我们学习如何向PCD文件写入点云数据. 代码 章例2文件夹中,打开 ...
- 激光雷达lidar与点云数据
激光雷达lidar与点云数据 DEM是分布和显示数字地形的首个广泛使用的机制. 点云是在空间中随机放置的3D点的集合.传感器发出能量脉冲并乘以其返回行程(TWTT,双向行程时间).知道了传感器的位置以 ...
- EXTJS中grid的数据特殊显示,不同窗口的数据传递
//EXTJS中grid的数据特殊显示renderer : function(value, metaData, record, rowIndex, colIndex, store, view) { v ...
- SDN与NFV技术在云数据中心的规模应用探讨
Neo 2016-1-29 | 发表评论 编者按:以云数据中心为切入点,首先对SDN领域中的叠加网络.SDN控制器.VxLAN 3种重要技术特点进行了研究,接下来对NFV领域中的通用服务器性能.服务链 ...
- input中空格后的数据不显示
bug,input中空格后的数据不显示 昨天在修bug,有一个bug是用户修改的个人信息的地址栏,输入有空格的话,空格后面的内容存不上,而且没有报错,奇怪了,只好跟踪下. 页面上的输入框就是个 ...
- easyui datagrid 没数据时显示滚动条的解决方法
今天解决了一个bug,因为datagrid有多列,可是当没有数据的时候,后面的列无法通过滚动条拉动来显示,比较麻烦,而需求要求没有数据也要拉动滚动条查看后面有什么列,一开始在网上找了一些资料,发现都不 ...
- ENVI软件操作之【数据的显示操作】
数据的显示操作主要包括以下的一些简单窗口操作 1.文件列表管理 1)可用的波段列表Available Bands List,使用于存取ENVI图像文件和显示图像文件的主要控制对话框.无论何时何地打开一 ...
随机推荐
- CentOS 安装BitTorrent Sync详细步骤
官网:https://www.getsync.com 这个软件安装完后通过网页浏览器设置共享目录并生成同步Secret,异地的客户端可以通过这个同步Secret访问共的目录,其中有读写和只读两种同步方 ...
- Microsoft Visual Studio 2010中文版编译SQLlite3.7.0版
作为一名教师,没有具体项目的开发,却喜欢尝鲜,不经意间开始追星了. 换了Win7,安装了Microsoft Visual Studio 2010中文版,7月22日SQLite发布了3.7.0版.当然想 ...
- JAVA多线程二
Thread.Join() join()函数表示等待当前线程结束,然后返回. public final synchronized void join(long millis) throws Inter ...
- nslookup返回信息说明
先看一个示例: 如上图,我们把输出结果分成三部分,下面分别来描述: 第一部分: 这里是我们本机的DNS服务器信息. 客户机先到主DNS Server进行连接查询,结果发现异常,连接失败,于是出 ...
- 浅谈AndroidManifest.xml与R.java及各个目录的作用
在开发Android项目中,AndroidManifest.xml与R.java是自动生成的.但是对于测试来说,非常重要.经过师父的点拨,我对AndroidManifest.xml与R.java有了更 ...
- 求职基础复习之冒泡排序c++版
代码中在第一层循环中增加一个bool值,是为了防止在排序完成后还继续无谓的比较,最多会有(n-1)*(n-2)/2次循环. #include<iostream> using namespa ...
- Http状态码的种类及含义
1xx 临时响应:2xx 成功:3xx 重定向: 4xx 请求错误: 5xx 服务器错误: http://www.hostspaces.net/wenzhang-detail.php?id=198 常 ...
- Spring Batch的事务-Part 1:基础
原文 https://blog.codecentric.de/en/2012/03/transactions-in-spring-batch-part-1-the-basics/ This is th ...
- CSStickyHeaderFlowLayout collectionView headerView 悬浮
github:https://github.com/levyleo/CSStickyHeaderFlowLayout iOS 10 使用时会出现崩溃:https://github.com/CSStic ...
- Xcode集成Google Test
Xcode集成Google Test 1.下载源代码https://github.com/google/googletest 2.进入下载文件目录下googletest/make中运行make gte ...