VS2005+VTK读入点云文件
使用VTK读入点云文件的基础代码:
头文件:
也许不是全部都用到,为了接下来得工程还是全部都包含进去了
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSphereSource.h"
#include "vtkShrinkFilter.h"
#include "vtkElevationFilter.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkCullerCollection.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkPolyVertex.h"
#include "vtkUnstructuredGrid.h"
#include <iostream>
#include "vtkPolyDataMapper.h"
#include "vtkScanPointReader.h"
#include "vtkProperty.h"
main部分:
//读取点云数据
void main()
{
FILE *fp = NULL;
fp = fopen( "C:\\test.sp", "r");
if ( fp == NULL)
{
printf("Error in open file test.sp\n");
getchar();
exit(-1);
}else
printf("open scan point success\n"); vtkRenderer *ren = vtkRenderer::New();
double arr[3] = {0}; vtkPoints *points = vtkPoints::New(); int n = 0;
while(!feof(fp))//首先读取点云数据到点表points同时指定点对应的id:
{
int ret=fscanf(fp,"%lf %lf %lf",&arr[0],&arr[1],&arr[2]);
if(ret!=3)
break;
points->InsertPoint(n,arr[0],arr[1],arr[2]);
n++;
}
printf("%d\n", n);
fclose(fp); vtkPolyVertex *polyvertex = vtkPolyVertex::New();
polyvertex->GetPointIds()->SetNumberOfIds(n); int i = 0; for( i = 0;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(1,0, 0); ren->AddActor(actor1);
ren->SetBackground(1, 1, 1); vtkRenderWindow* win=vtkRenderWindow::New();
win->AddRenderer(ren);
win->SetSize(400,400);
win->BordersOn();
//On则运行起来将会是全屏显示
//win->FullScreenOn();
//win->HideCursor(); vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(win);
vtkInteractorStyleTrackballCamera *style = vtkInteractorStyleTrackballCamera::New();
iren->SetInteractorStyle(style); iren->Initialize();
iren->Start();
ren->Delete();
win->Delete();
iren->Delete(); }
运行结果:
本文使用的是 vs2005+vtk5.10.1
使用的是vs里面的控制台程序编写。
这样读入点云的方式是最原始的方式。
VS2005+VTK读入点云文件的更多相关文章
- PCL学习(一)从PLY文件读入点云数据
#include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/point_types.h> #inclu ...
- 在c++MFC下用PCL显示操作点云文件 MFC对话框显示操作PCL点云
原文作者:aircraft 原文地址:https://www.cnblogs.com/DOMLX/p/13115873.html 第一步 下载PCL库 我的版本是1.8.1的 你都要MFC下跑PCL ...
- 在windows下使用cmd命令全速下载百度云文件
在windows下使用cmd命令全速下载百度云文件 需要的工具BaiduPCS-GO(链接:https://pan.baidu.com/s/19Sn8gmNi_GZHJwUPu79DPg 密码:gqi ...
- 阿里云文件存储(NAS)助力业务系统承载双十一尖峰流量
2018天猫双11全球狂欢节,全天成交额再次刷新纪录达到2135亿元,其中总成交额在开场后仅仅用了2分05秒即突破100亿元,峰值的交易量达到惊人的高度,背后离不开阿里云大数据计算和存储能力的支撑.在 ...
- 为数据计算提供强力引擎,阿里云文件存储HDFS v1.0公测发布
在2019年3月的北京云栖峰会上,阿里云正式推出全球首个云原生HDFS存储服务—文件存储HDFS,为数据分析业务在云上提供可线性扩展的吞吐能力和免运维的快速弹性伸缩能力,降低用户TCO.阿里云文件存储 ...
- 基于 Octotree 的[码云]文件树插件
之前一直在用github上面的Octotree,现在在用gitee(主要是github的访问速度太慢了). 现在主要转到了gitee上面了,那么有没有基于 Octotree 的[码云]文件树插 ...
- 干货 | 玩转云文件存储——利用CFS实现web应用的共享访问
京东云文件服务(Cloud File Service,以下简称:CFS)是一种高可靠.可扩展.可共享访问的全托管分布式文件系统.它可在不中断应用服务的情况下,根据您对文件系统的使用,按需扩展或缩减,并 ...
- VTK 简单点云数据显示绘制
基于vtkPolyData,绘制时除了输入点坐标,还需要通过setVerts指定点绘制信息. simplePoints.txt的内容为简单的 xyz,如: 20 20 20 20 20 30 20 2 ...
- Send竞争对手:百度云一小时,QQ超大附件最多支持2G,邮件附件20M到50M不等(附国外所有storage列表)——痛点是,最大传输2G,最大容量只有3G(和微云不是一回事),转存到微云文件不能超过1G
QQ邮箱最大可发送50M普通附件(群邮件则限制在2M).此外也可以使用超大附件功能,支持将1G的文件发往任意邮箱.QQ邮箱根据你的QQ邮箱容量的不同制定相应的接受附件限制,包括附件在内,2G用户所发送 ...
随机推荐
- 求一个n!中尾数有多少个零
题目描述: 输入一个正整数n,求n!(即阶乘)末尾有多少个0? 比如: n = 10; n! = 3628800,所以答案为2 输入描述: 输入为一行,n(1 ≤ n ≤ 1000) 输出描述: 输出 ...
- 4_5.springboot2.x之Web开发RestfulCRUD操作
1).RestfulCRUD:CRUD满足Rest风格 URI: /资源名称/资源标识 HTTP请求方式区分对资源CRUD操作 普通CRUD(uri来区分操作) RestfulCRUD 查询 getE ...
- pip的使用方法简介
pip是Python包管理工具,它提供了对Python包的查找.下载.安装.卸载的功能 目前如果你在 python.org 下载最新版本的安装包,则是已经自带了该工具. 以下是pip常用命令 显示版本 ...
- JQ实现全选、全不选
代码: <table class="table myTable table-hover"> <thead> <tr> <th> &l ...
- python语句结构(控制语句与pass语句)
python语句结构(控制语句和pass语句) break-跳出循环:语句可以跳出for和while语句的循环体.如果你从for和while循环中终止,任何对应循环的else语块均终止 continu ...
- Android开发 处理拍照完成后的照片角度
private void initImageAngle(){ Bitmap imageBitmap = BitmapFactory.decodeFile(FilePathSession.getFace ...
- BZOJ 3668: [Noi2014]起床困难综合症
Time Limit: 10 Sec Memory Limit: 512 MB Submit: 2693 Solved: 1563 [Submit][Status][Discuss] Descript ...
- Audio 标签的使用和自己封装一个强大的React音乐播放器
原文地址:https://www.dodoblog.cn/blog?id=5be84d5c70b2b617f27a4610 这篇文章主要介绍一下博客里的这个音乐播放器是怎么写的 为了更好的表达高深的东 ...
- DotNetBar2设置窗体为office风格
帮同事写个桌面工具,刚学着用DotNetBar2.后面面分享学习过程.下面是给窗体设置成office风格的方法.(1)拷贝DotNetBar2的dll文件,添加引用. (2)在需要用office风格的 ...
- 简单科普下hosts文件原理与制作
简单科普下hosts文件原理与制作 hosts文件是一个用于储存计算机网络中各节点信息的计算机文件.这个文件负责将主机名映射到相应的IP地址.hosts文件通常用于补充或取代网络中DNS的功能.和DN ...