文章詳情頁(yè)
vtk在Java2中的使用
瀏覽:81日期:2024-06-20 15:37:11
內(nèi)容: 來(lái)自:CSDN 作者:ithinkuml VTK(Visualization ToolKit)是一個(gè)開(kāi)放源碼、自由獲取的軟件系統(tǒng),全世界的數(shù)以千計(jì)的研究人員和開(kāi)發(fā)人員用它來(lái)進(jìn)行3D計(jì)算機(jī)圖形,圖像處理,可視化。VTK包含一個(gè)c++類庫(kù),眾多的翻譯接口層,包括Tcl/Tk,Java,Python。 Visualization Toolkit 是一個(gè)用于可視化應(yīng)用程序構(gòu)造與運(yùn)行的支撐環(huán)境,它是在三維函數(shù)庫(kù)OpenGL 的基礎(chǔ)上采用面向?qū)ο蟮脑O(shè)計(jì)方法發(fā)展起來(lái)的,它將我們?cè)诳梢暬_(kāi)發(fā)過(guò)程中會(huì)經(jīng)常遇到的細(xì)節(jié)屏蔽起來(lái),并將一些常用的算法封裝起來(lái)。比如Visualization Toolkit 將我們?cè)诒砻嬷亟ㄖ斜容^常見(jiàn)的Marching Cubes 算法封裝起來(lái),以類的形式給我們以支持,這樣我們?cè)趯?duì)三維規(guī)則點(diǎn)陣數(shù)據(jù)進(jìn)行表面重建時(shí)就不必再重復(fù)編寫(xiě)MarchingCubes 算法的代碼,而直接使用Visualization Toolkit 中已經(jīng)提供的vtkMarchingCubes 類 Visualization Toolkit 是給從事可視化應(yīng)用程序開(kāi)發(fā)工作的研究人員提供直接的技術(shù)支持的一個(gè)強(qiáng)大的可視化開(kāi)發(fā)工具,它以用戶使用的方便性和靈活性為主要原則,具有如下的特點(diǎn):1) 具有強(qiáng)大的三維圖形功能。Visualization Toolkit 既支持基于體素Voxel-basedrendering 的體繪制Volume Rendering又保留了傳統(tǒng)的面繪制,從而在極大的改善可視化效果的同時(shí)又可以充分利用現(xiàn)有的圖形庫(kù)和圖形硬件2) Visualization Toolkit 的體系結(jié)構(gòu)使其具有非常好的流streaming 和高速緩存caching 的能力,在處理大量的數(shù)據(jù)時(shí)不必考慮內(nèi)存資源的限制3) Visualization Toolkit 能夠更好的支持基于網(wǎng)絡(luò)的工具比如Java 和VRML 隨著Web 和Internet 技術(shù)的發(fā)展Visualization Toolkit 有著很好的發(fā)展前景4) 能夠支持多種著色如OpenGL 等5) Visualization Toolkit 具有設(shè)備無(wú)關(guān)性使其代碼具有良好的可移植性6) Visualization Toolkit 中定義了許多宏,這些宏極大的簡(jiǎn)化了編程工作并且加強(qiáng)了一致的對(duì)象行為7) Visualization Toolkit 具有更豐富的數(shù)據(jù)類型,支持對(duì)多種數(shù)據(jù)類型進(jìn)行處理8) 既可以工作于Windows 操作系統(tǒng)又可以工作于Unix 操作系統(tǒng)極大的方便了用戶 下面介紹一下VTK在JDK1.4.1_02下的使用方法,1) 從vtk的網(wǎng)站(http://www.vtk.org/)上下載最新的軟件包,版本是4.2。然后把它安裝到C:vtk42目錄下2) 從Sun官方下載鏈接,版本1.4.1_02,然后安裝到C:j2sdk1.4.1_02上3) 設(shè)置環(huán)境變量,系統(tǒng)->高級(jí)->環(huán)境變量->path,設(shè)置為C:j2sdk1.4.1_02bin;C:ProgramFilesJavaj2re1.4.1_02bin;C:j2sdk1.4.1_02jrebin;C:vtk42bin4) 拷貝C:vtk42bin*java.dll到系統(tǒng)目錄5) 編譯,運(yùn)行,為了方便起見(jiàn),拷貝C:vtk42ExamplesTutorialStep1Java目錄下的Cone.java到d盤(pán),當(dāng)前目錄為d盤(pán) D:>javac -classpath c:vtk42binvtk.jar Cone.javaD:>java -classpath .;c:vtk42binvtk.jar Cone源碼如下://// 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.SetInput( cone.GetOutput() ); // // 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 ); } } } Java, java, J2SE, j2se, J2EE, j2ee, J2ME, j2me, ejb, ejb3, JBOSS, jboss, spring, hibernate, jdo, struts, webwork, ajax, AJAX, mysql, MySQL, Oracle, Weblogic, Websphere, scjp, scjd
標(biāo)簽:
Java
相關(guān)文章:
1. Vue為什么要謹(jǐn)慎使用$attrs與$listeners2. 使用EF Code First搭建簡(jiǎn)易ASP.NET MVC網(wǎng)站并允許數(shù)據(jù)庫(kù)遷移3. JavaScript中html畫(huà)布的使用與頁(yè)面存儲(chǔ)技術(shù)詳解4. 如何使用iostat查看linux硬盤(pán)IO性能5. 如何在vue中使用pdfjs預(yù)覽pdf文件6. JavaWeb Servlet中url-pattern的使用7. 如何使用Python的Pandas庫(kù)繪制折線圖8. java使用FFmpeg合成視頻和音頻并獲取視頻中的音頻等操作(實(shí)例代碼詳解)9. Spring-基于Spring使用自定義注解及Aspect實(shí)現(xiàn)數(shù)據(jù)庫(kù)切換操作10. python使用pymongo與MongoDB基本交互操作示例
排行榜
