[WPF VTK]三维图形开发基础(四)

0.条条大路

前面介绍的使用WPF自己撰写算法实现点数据的三角划分以图实现轮廓的三维重构。

但简单的算法以及不加其他处理效果不佳,对于点数据的三角划分在查阅了一些论文后发现有:

基于图的最短路径、Delaunay、角点匹配后的等比例三角划分、插值、平滑等操作。

恰好师姐的老公便是研究三维重建这块,这就叫好运道吧,缠着赖着请刘石坚师兄做了一番指导,

并查看了他说做的实验的一些结果like this:

OMG相对于我自己实现的效果一个是天蓬一个是高老庄老猪!

更要命的是这个效果仅仅需要调用一些函数即可!

于是,性喜偷懒的我立马调转草头转入VTK阵营。

1.Force Of OpenSource

下面是VTK官网的简介:

http://www.vtk.org/Wiki/VTK

The Visualization ToolKit (VTK) is an open source, freely available software system for 3D computer graphics,image processing, and visualization used by thousands of researchers and developers around the world. VTK consists of a C++ class library, and several interpreted interface layers including Tcl/Tk, Java, and Python. Professional support and products for VTK are provided by Kitware, Inc. (www.kitware.com) VTK supports a wide variety of visualization algorithms including scalar, vector, tensor, texture, and volumetric methods; and advanced modeling techniques such as implicit modelling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay triangulation. In addition, dozens of imaging algorithms have been directly integrated to allow the user to mix 2D imaging / 3D graphics algorithms and data.

这里是一个VTK相关论坛

http://www.vislab.cn/bbs/forumdisplay.php?fid=19

感谢OpenSource参与人,你们让世界更和谐;感谢互联网让这么多好用的库得以发展壮大。

VTK下载安装请参考:(64bit WIN7 & VS2012)

http://blog.csdn.net/shenlan282/article/details/8262232

(注:本人并没按博主所说做第二步

2. 用 vc++2010打开 D:\VTK\VTKbin\Utilities\MaterialLibrary目录下的 MaterialLibrary.sln 文件,右键点击All_Build选择重新生成。

也成功了,说明这步是可以跳过的吧,或者影响不是全局的)

VTK的安装需要预先CMAKE然后再编译因此还是有一些步骤需要处理,上面文章介绍很好,感谢博主。

本人由于是64bit WIN8 & VS2012安装起来又有一些不同。这里做简单介绍:

vtk_data_root,浏到例子数据所在位置,如“d:\vtk\vtkdata”

这里是用于将实例程序的数据路径指定到下载的vtkdata文件夹,如果没有在cmake时候选择这一个那么很多实例就

不会出效果,奈何呢,因为程序参数里面没有指定路径呀,因此如果你需要编译实验测试例子的话还请记得加上这个!

然后就是出现This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended.

的错误,对于WIN8来说需要将几个页面的define修改成(注意,整个VTKsolution有很5个文件需要修改!所以别指望修改了一个编译就可通过哦)

关于为什么修改成类似0x0602请参考MSDN

http://msdn.microsoft.com/zh-cn/library/windows/desktop/aa383745(v=vs.85).aspx

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER        // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0602    // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT    // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0602    // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif            

#if _MSC_VER >= 1300
#ifndef _WIN32_WINDOWS    // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#endif

#ifndef _WIN32_IE      // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400  // Change this to the appropriate value to target IE 5.0 or later.

#endif

在对build_all成功后可以运行coneX这几个实例看看效果,但是通常实例会一闪而过,因为程序并没做等待用户控制才结束的情况!

里面实例很多很多,相信大家把他们啃完就会画龙懂描蛇鸟~~

顺便说一下,VTK的.NET版本,由于当时找了好几个都是网友做的,都停留在很老的版本里,所以这里附上我找到最好的版本:

而这也是维护VTK的kitware说维护的版本因此更新快,质量好,目前是到5.8.0,不过郁闷的是.NET下只能支持到VS2008 by Now。

所以我的2012就费了... 

VTK.NET之ACTIVIZ.NET

http://www.vtk.org/Wiki/VTK/CSharp/ActiViz.NET

Activiz.NET例子

http://www.vtk.org/Wiki/VTK/Examples/CSharp

在安装好后剩下的就是生成轮廓,并实现三维模型的任意平面切割了。

原文地址:https://www.cnblogs.com/dawnWind/p/3D_04.html