使用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读入点云文件的更多相关文章

  1. PCL学习(一)从PLY文件读入点云数据

    #include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/point_types.h> #inclu ...

  2. 在c++MFC下用PCL显示操作点云文件 MFC对话框显示操作PCL点云

    原文作者:aircraft 原文地址:https://www.cnblogs.com/DOMLX/p/13115873.html 第一步 下载PCL库  我的版本是1.8.1的 你都要MFC下跑PCL ...

  3. 在windows下使用cmd命令全速下载百度云文件

    在windows下使用cmd命令全速下载百度云文件 需要的工具BaiduPCS-GO(链接:https://pan.baidu.com/s/19Sn8gmNi_GZHJwUPu79DPg 密码:gqi ...

  4. 阿里云文件存储(NAS)助力业务系统承载双十一尖峰流量

    2018天猫双11全球狂欢节,全天成交额再次刷新纪录达到2135亿元,其中总成交额在开场后仅仅用了2分05秒即突破100亿元,峰值的交易量达到惊人的高度,背后离不开阿里云大数据计算和存储能力的支撑.在 ...

  5. 为数据计算提供强力引擎,阿里云文件存储HDFS v1.0公测发布

    在2019年3月的北京云栖峰会上,阿里云正式推出全球首个云原生HDFS存储服务—文件存储HDFS,为数据分析业务在云上提供可线性扩展的吞吐能力和免运维的快速弹性伸缩能力,降低用户TCO.阿里云文件存储 ...

  6. 基于 Octotree 的[码云]文件树插件

      之前一直在用github上面的Octotree,现在在用gitee(主要是github的访问速度太慢了).   现在主要转到了gitee上面了,那么有没有基于 Octotree 的[码云]文件树插 ...

  7. 干货 | 玩转云文件存储——利用CFS实现web应用的共享访问

    京东云文件服务(Cloud File Service,以下简称:CFS)是一种高可靠.可扩展.可共享访问的全托管分布式文件系统.它可在不中断应用服务的情况下,根据您对文件系统的使用,按需扩展或缩减,并 ...

  8. VTK 简单点云数据显示绘制

    基于vtkPolyData,绘制时除了输入点坐标,还需要通过setVerts指定点绘制信息. simplePoints.txt的内容为简单的 xyz,如: 20 20 20 20 20 30 20 2 ...

  9. Send竞争对手:百度云一小时,QQ超大附件最多支持2G,邮件附件20M到50M不等(附国外所有storage列表)——痛点是,最大传输2G,最大容量只有3G(和微云不是一回事),转存到微云文件不能超过1G

    QQ邮箱最大可发送50M普通附件(群邮件则限制在2M).此外也可以使用超大附件功能,支持将1G的文件发往任意邮箱.QQ邮箱根据你的QQ邮箱容量的不同制定相应的接受附件限制,包括附件在内,2G用户所发送 ...

随机推荐

  1. CCPC 2019 网络赛 HDU huntian oy (杜教筛)

    1005 huntian oy (HDU 6706) 题意: 令,有T次询问,求 f(n, a, b). 其中 T = 10^4,1 <= n,a,b <= 1e9,保证每次 a,b互质. ...

  2. git push到多个不同的远程仓库

    1.若现在本地有一个已经和github远程仓库关联好的本地仓库,平时都会将本地仓库push到github上. 2.有一天突然发现"码云"这个远程仓库网站,咦!这个还可以创建priv ...

  3. 通过key_len分析联合索引的使用

    The key_len column indicates the length of the key that MySQL decided to use. The length is NULL if ...

  4. TortoiseGit可能遇到Permission denied (publickey).

    1.检测是不是没设置公钥和私钥 2.公钥有没有添加到git账户里面去 3.检测如下图路径正确不正确

  5. SpringMVC参数绑定(未完待续)

    1. Strut2与SpringMVC接收请求参数的区别 Struts2通过action类的成员变量接收SpringMVC通过controller方法的形参接收 2. SpringMVC参数绑定流程 ...

  6. 深入理解Java虚拟机(自动内存管理机制)

    文章首发于公众号:BaronTalk 书籍真的是常读常新,古人说「书读百遍其义自见」还是很有道理的.周志明老师的这本<深入理解 Java 虚拟机>我细读了不下三遍,每一次阅读都有新的收获, ...

  7. mac下安装Python的工具包pip

    1. 在终端下输入 sudo easy_install pip  password:输入电脑密码 Finished processing dependencies for pip 表示安装完成 boe ...

  8. Python(四)基础篇之「文件对象&错误处理」

    [笔记]Python(四)基础篇之「文件对象&错误处理」 2016-12-08 ZOE    编程之魅  Python Notes: ★ 如果你是第一次阅读,推荐先浏览:[重要公告]文章更新. ...

  9. OpenCASCADE 平面求交

    OpenCASCADE 平面求交 eryar@163.com OpenCASCADE提供了类IntAna_QuadQuadGeo用来计算两个二次曲面quadric(球面.圆柱面.圆锥面及平面,平面是二 ...

  10. java多线程编程建议

    多线程编程建议 1,将应用设计成支持多线程并发,可提高性能 2,编写多线程程序,首先保证它是正确的,其次再考虑性能 3,同步处理的开销大于非同步处理,如果可能,尽量使用非同步处理 4,避免多个共享变量 ...