- 浏览: 837890 次
- 性别:
- 来自: 南京
文章分类
最新评论
-
loveseed1989:
您好,我用您的方法运行Cone.java,会给我报java.l ...
vtk学习笔记 --- 编译vtk库和java库 -
60love5:
60love5 写道首先谢谢你的解析,但你这个验证可见性的小程 ...
多线程中共享对象的可见性 -
60love5:
首先谢谢你的解析,但你这个验证可见性的小程序是存在问题的,你的 ...
多线程中共享对象的可见性 -
Gamehu520:
...
java 中的Unsafe -
shanpao1234560:
这个list不是静态的第一种情况下也会有线程安全的问题么,求指 ...
一个看似线程安全的示例
环境:
操作系统:windows xp
编译环境:visual studio 2008 + jdk 1.6
这里选择的vtk版本为:vtk 5.8.0 ,下载地址:
安装文件:http://www.vtk.org/files/release/5.8/vtk-5.8.0-win32-x86.exe
源码:http://www.vtk.org/files/release/5.8/vtk-5.8.0.zip
还需要另外一个项目配置工具:cmake 2.8.6 ,下载地址:http://www.cmake.org/files/v2.8/cmake-2.8.6-win32-x86.exe
注意事项:操作系统最好选择32位的,之前因为本机操作系统为win7 64位,便尝试着编译了一次,结果失败。也可以在xp虚拟机里面编译。只不过速度稍微慢点。
1、安装vtk 和 cmake,上面选择的是可安装的vtk版本,这样我们直接将其安装在某个目录,如E:\VTK-5.8.0,为了编码出错,安装目录最好不要包含空格。然后在该目录下新建源码目录,vtk,以及用于后续编译的工作目录build,然后将上面的vtk源码解压到vtk目录。 接着安装cmake,这个没有限制,默认即可 。
2、配置项目,打开cmake工具,截图如下:
在上面的source code地址选择vtk源码目录,在下面的build 地址选择build目录,然后点击下面的Configure按钮,
在接下来的窗口,会让你选择编译工具, 选择机器上安装的vs2008 即可。完成以后,cmake开始配置项目,这个过程
可能会需要几分钟时间,如果配置一切正确,那最后会显示Confiure done,否则提示出错。同时在Configure过程结束以后,
在中间的窗口中会显示很多配置项,有的后面会显示复选框,有的后面已经有值了。如果出错,一般都是因为某些配置不正确,
在这里需要选中BUILD SHARED LIBS和VTK_WRAP_JAVA这两个复选框。如果你希望用mfc来开发界面,还需要选择一项GUISUPPORT,重新配置以后,需要再次点击Configure,这个时候,cmake会检查,如果选择了GUISUPPORT,那么后面还需要选择一项VTK_USER_MFC,然后再次Configure,知道没错了,最后点击Generate来生成vs项目。生成的项目在build目录。
3,编译vtk c++库以及java库,找到build目录下的VTK.sln文件,这个是对应的vs工程主文件,打开即可打开整个工程,里面包含的项目很多,大概100多个。然后选择重新生成解决方案,剩下的时间就是等待编译完成,这个过程看个人机器配置,估计需要30分钟以上。如果一切ok的话,那么在build目录下会生成一个bin目录,里面会包含一个Debug或者Release目录,这个取决于你编译的是什么版本,在这个目录里面会包含生成的库文件,以及对应的jar包。我们只需要里面的dll文件和jar包。
4,编译测试demo。这个可以直接使用源码里面example目录中的例子来测试,在example目录中有个tutorial目录,里面包含几个项目,找到Step1项目,把java目录中的java文件复制出来即可。
// // This example creates a polygonal model of a cone, and then renders it to // the screen. It will rotate the cone 360 degrees and then exit. The basic // setup of source -> mapper -> actor -> renderer -> renderwindow is // typical of most VTK programs. // // We import the vtk wrapped classes first. import vtk.*; // Then we define our class. public class Cone { // In the static contructor we load in the native code. // The libraries must be in your path to work. static { System.loadLibrary("vtkCommonJava"); System.loadLibrary("vtkFilteringJava"); System.loadLibrary("vtkIOJava"); System.loadLibrary("vtkImagingJava"); System.loadLibrary("vtkGraphicsJava"); System.loadLibrary("vtkRenderingJava"); } // now the main program public static void main (String []args) { // // Next we create an instance of vtkConeSource and set some of its // properties. The instance of vtkConeSource "cone" is part of a // visualization pipeline (it is a source process object); it produces data // (output type is vtkPolyData) which other filters may process. // vtkConeSource cone = new vtkConeSource(); cone.SetHeight( 3.0 ); cone.SetRadius( 1.0 ); cone.SetResolution( 10 ); // // In this example we terminate the pipeline with a mapper process object. // (Intermediate filters such as vtkShrinkPolyData could be inserted in // between the source and the mapper.) We create an instance of // vtkPolyDataMapper to map the polygonal data into graphics primitives. We // connect the output of the cone souece to the input of this mapper. // vtkPolyDataMapper coneMapper = new vtkPolyDataMapper(); coneMapper.SetInputConnection( cone.GetOutputPort() ); // // Create an actor to represent the cone. The actor orchestrates rendering // of the mapper's graphics primitives. An actor also refers to properties // via a vtkProperty instance, and includes an internal transformation // matrix. We set this actor's mapper to be coneMapper which we created // above. // vtkActor coneActor = new vtkActor(); coneActor.SetMapper( coneMapper ); // // Create the Renderer and assign actors to it. A renderer is like a // viewport. It is part or all of a window on the screen and it is // responsible for drawing the actors it has. We also set the background // color here // vtkRenderer ren1 = new vtkRenderer(); ren1.AddActor( coneActor ); ren1.SetBackground( 0.1, 0.2, 0.4 ); // // Finally we create the render window which will show up on the screen // We put our renderer into the render window using AddRenderer. We also // set the size to be 300 pixels by 300 // vtkRenderWindow renWin = new vtkRenderWindow(); renWin.AddRenderer( ren1 ); renWin.SetSize( 300, 300 ); // // now we loop over 360 degreeees and render the cone each time // int i; for (i = 0; i < 360; ++i) { // render the image renWin.Render(); // rotate the active camera by one degree ren1.GetActiveCamera().Azimuth( 1 ); } } }
注意,需要将vtk.jar文件加入eclipse的build path,同时把上面拷贝出来的dll文件拷贝到java 安装目录下的bin目录下,即和java.exe文件在同一目录。接下来就是执行程序测试结果了,如果不出问题,那么可以得到以下效果:
至此,编译的java库已经能够正常工作了,后面可以在此基础上开发vtk程序了。
评论
发表评论
-
基于Oracle Streams + Oracle AQ 捕获变更,发布变更(二)
2014-11-21 22:23 3164要求:使用Oracle Streams捕获某个用户下部 ... -
基于Oracle Streams + Oracle AQ 捕获变更,发布变更(一)
2014-11-20 22:23 2715要求:使用Oracle Streams捕获某个用户下部分表 ... -
如何去掉在浏览器中打开java applet时的警告对话框
2013-08-24 12:10 6948好久没更新博客了! 最近,由于项目要求,需要将sw ... -
Android 内存泄露笔记
2013-03-05 23:10 01、大部分内存泄露都是错误的持有了Activity或者Con ... -
java 虚拟机总结 【思维导图】
2012-12-22 20:11 2054java虚拟机总结思维导图: 参考《深入理解jav ... -
Java虚拟机字节码执行引擎 【思维导图】
2012-12-22 19:51 1592java虚拟机字节码执行引擎思维导图总结: 参考《深入理 ... -
java 垃圾回收相关总结 【思维导图】
2012-12-21 19:03 3235java垃圾回收相关总结: 参考《深入理解java ... -
java并发中的延迟初始化
2012-12-12 19:17 4639在《java并发编程实战 ... -
java同步容器与并发容器
2012-12-09 18:07 4298何为同步容器:可以简 ... -
一个看似线程安全的示例
2012-12-09 14:56 4970在《java并发编程实战》第四章4.4.1节给出了一个程序示 ... -
多线程中的long和double
2012-12-08 19:26 4124在看一些代码的时候,会发现在定义long型和double型的 ... -
多线程中共享对象的可见性
2012-12-08 18:52 5058在阅读《java并发编程实战》的第三章的时候,看到书中的一个 ... -
一个快速、轻量级 Collection 库 Trove
2012-12-07 09:35 3693Trove一个快速、轻量级针对java原子类型(byte,i ... -
java 中的Unsafe
2012-12-05 22:25 32671在阅读AtomicInteger的源码时,看到了这个类:su ... -
在ubuntu10上编译Thrift0.8.0
2012-08-01 15:34 2103下载thrift0.8.0 ,地址: http:// ... -
生活小工具--记账小助手1.0发布
2012-05-31 15:08 1646因为自己平时喜欢记账,把每日的消费情况都记录下来,所以希望找 ... -
话费速查升级版v1.3发布
2012-05-04 12:47 1376前段时间开发了一个话费速查的小应用,最近一直保持每周更新一个 ... -
编译zeromq的java绑定:jzmq
2012-05-03 22:47 134901、 下载zeromq源码:http://www.ze ... -
Android软件包静默安装小应用 - 附源码
2012-04-21 20:50 12343老早之前,写了一个android软件包静默安装的应用,放在工 ... -
最方便的联通话费,余额查询软件来了! --- 联通话费速查v1.2
2012-04-12 18:01 3953软件介绍: 联通话费速查是一款针对联通 ...
相关推荐
NULL 博文链接:https://aswang.iteye.com/blog/1250669
VTK-8.2.0-cp38-cp38-win_amd64
VTK-8.1.0是安装mayavi-4.5.0+vtk81-cp36-cp36m-win_amd64.whl的基础模块,为后期numpy模块中图像的显示做铺垫。
VTK-9.0.3-cp310-cp310-win_amd64
VTK consists of a C++ class library and several interpreted interface layers including Tcl/Tk, Java, and Python. Kitware, whose team created and continues to extend the toolkit, offers professional ...
vtk7.1.1和opencv3.4.1-viz库文件(已编译好并测试完成,可以直接用)。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。...
VTK-5.0.1-control-1.1.zip 开发三维软件必备
VTK-7.1.1-cp36-cp36m-win32
怎样使用VTK----------------------------------------------------------------------------------8 附加资源-----------------------------------------------------------------------------------------8 第2章 ...
资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:vtk-8.1.0-cp36-cp36m-win_amd64.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
VTK-9.0.1-cp36-cp36m-win_amd64
VTK安装全部文件,从官方网站下载的最新版本5.2
VTK是一个开放的、面向对象的软件系统,主要功能是计算机图形学、可视化和图像处理。尽管它庞大和复杂,但它是为易学易用设计的,一旦你学会了基本的面向对象的设计和实现方法。
VTK的最新版本,有兴趣可以下载玩玩~~
VTK-Designer-User-Manual
从事医疗软件、CAE软件等开发的小伙伴可以用作参考。文件来自互联网,鄙人在阅读的过程中增加了完整书签目录。
python库,解压后可用。 资源全名:vtk-9.0.3-cp39-cp39-macosx_11_0_arm64.whl
vtk-user-'s-guide-中文版.doc vtk-user-'s-guide-中文版.doc vtk-user-'s-guide-中文版.doc
python库,解压后可用。 资源全名:vtk-9.1.0rc4-cp39-cp39-win_amd64.whl
vtk.jar对应的dll vtk版本5.10.1 jar包已发