计算 volume of 3D .vtk points (triangle mesh, closed polydata)
2015-05-30 16:04
597 查看
问题描述:有一个.vtk点集,带triangle mesh,这些点构成一个闭合的三维物体表面。想计算这些点围成的这个closed object的内部体积。
解决思路:用vtkMassProperties就像这里对vtkMassProperties的提示:
Currently only triangles are processed. Use vtkTriangleFilter to convert any strips or polygons to triangles. 也就是说,目前该类只能用于triangle
mesh connectivity
closed surface
.
代码,polyDataVolume.cpp文件:
CMakeLists.txt文件:
编译:
ccmake ../
make
运行:
./polyDataVolume ../test.vtk
运行结果:
---- the volume of this vtk polydatais: 0.00339752
这个小实验的代码已打包,可点这里下载。
参考:
http://www.vtk.org/pipermail/vtkusers/2013-June/080004.html
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/EmbedPointsIntoVolume
http://markmail.org/message/6u6psqha5ckz2ec3
http://www.paraview.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataToImageData
http://permalink.gmane.org/gmane.comp.lib.vtk.user/67470
http://public.kitware.com/pipermail/vtkusers/2011-January/065437.html
http://vtk.1045678.n5.nabble.com/Polydata-volume-calculation-problem-td3347493.html
http://public.kitware.com/pipermail/vtkusers/2014-July/084469.html
http://www.paraview.org/Wiki/VTK/Examples/Cxx/Modelling/Delaunay3D
解决思路:用vtkMassProperties就像这里对vtkMassProperties的提示:
Currently only triangles are processed. Use vtkTriangleFilter to convert any strips or polygons to triangles. 也就是说,目前该类只能用于triangle
mesh connectivity
closed surface
.
代码,polyDataVolume.cpp文件:
#include <vtkPolyDataReader.h> #include "vtkPolyData.h" #include "vtkSmartPointer.h" #include <vtkMassProperties.h> int main( int argc, char* argv[] ){ // read in the .vtk file vtkSmartPointer<vtkPolyDataReader> reader = vtkSmartPointer<vtkPolyDataReader>::New(); reader->SetFileName(argv[1]); reader->Update(); vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New(); polyData = reader->GetOutput(); // evaluate the volume vtkMassProperties *mass = vtkMassProperties::New(); mass->SetInput(polyData); cout << "---- the volume of this vtk polydata is: " << mass->GetVolume() << endl; return 0; }
CMakeLists.txt文件:
cmake_minimum_required(VERSION 2.8) PROJECT(polyDataVolume) find_package(VTK REQUIRED) include(${VTK_USE_FILE}) add_executable(polyDataVolume MACOSX_BUNDLE polyDataVolume) if(VTK_LIBRARIES) target_link_libraries(polyDataVolume ${VTK_LIBRARIES}) else() target_link_libraries(polyDataVolume vtkHybrid vtkWidgets) endif()
编译:
ccmake ../
make
运行:
./polyDataVolume ../test.vtk
运行结果:
---- the volume of this vtk polydatais: 0.00339752
这个小实验的代码已打包,可点这里下载。
参考:
http://www.vtk.org/pipermail/vtkusers/2013-June/080004.html
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/EmbedPointsIntoVolume
http://markmail.org/message/6u6psqha5ckz2ec3
http://www.paraview.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataToImageData
http://permalink.gmane.org/gmane.comp.lib.vtk.user/67470
http://public.kitware.com/pipermail/vtkusers/2011-January/065437.html
http://vtk.1045678.n5.nabble.com/Polydata-volume-calculation-problem-td3347493.html
http://public.kitware.com/pipermail/vtkusers/2014-July/084469.html
http://www.paraview.org/Wiki/VTK/Examples/Cxx/Modelling/Delaunay3D
相关文章推荐
- Delphi常用快捷键
- POI--HSSFWorkbook类
- 通过Typesafe Activator创建akka java sample
- 线程通信机制:共享内存 VS 消息传递
- Eclipse去除js(JavaScript)验证错误
- 全国首发 | 腾讯Bugly携手极客学院,「Android Crash 跟踪方法」强势上线!
- 错误 'Cannot run program "/home/uv/IDE/adt/sdk/platform-tools/adb": error=2, No such file or directory
- Python学习之解析xml文件
- ubuntu 安装mysql及目录位置
- 黑马程序员——反射
- weak reference - 1
- MVC北京络捷斯特第三方物流系统技术解析(四)订单配送信息
- [注]微信公众号的运营推广总结方案(持续更新)
- 赠友【彩笔殷勤】
- Mysql基本sql指令
- 彻底掌握Quartus——基础篇
- Java代码 希尔排序
- PHP PDO 简单登陆操作
- JS验证代码时字母或者数字
- net start sshd出现发生系统错误 1069