国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

vtk在Java2中的使用

2019-11-18 13:19:18
字體:
來源:轉載
供稿:網友

  VTK(Visualization ToolKit)是一個開放源碼、自由獲取的軟件系統,全世界的數以千計的研究人員和開發人員用它來進行3D計算機圖形,圖像處理,可視化。VTK包含一個c++類庫,眾多的翻譯接口層,包括Tcl/Tk,java,Python。
  
  Visualization Toolkit 是一個用于可視化應用程序構造與運行的支撐環境,它是在三維函數庫OpenGL 的基礎上采用面向對象的設計方法發展起來的,它將我們在可視化開發過程中會經常碰到的細節屏蔽起來,并將一些常用的算法封裝起來。比如Visualization Toolkit 將我們在表面重建中比較常見的Marching Cubes 算法封裝起來,以類的形式給我們以支持,這樣我們在對三維規則點陣數據進行表面重建時就不必再重復編寫MarchingCubes 算法的代碼,而直接使用Visualization Toolkit 中已經提供的vtkMarchingCubes 類
  
  Visualization Toolkit 是給從事可視化應用程序開發工作的研究人員提供直接的技術支持的一個強大的可視化開發工具,它以用戶使用的方便性和靈活性為主要原則,具有如下的特點:
  
  1) 具有強大的三維圖形功能。Visualization Toolkit 既支持基于體素Voxel-basedrendering 的體繪制Volume Rendering又保留了傳統的面繪制,從而在極大的改善可視化效果的同時又可以充分利用現有的圖形庫和圖形硬件
  
  2) Visualization Toolkit 的體系結構使其具有非常好的流streaming 和高速緩存caching 的能力,在處理大量的數據時不必考慮內存資源的限制
  
  3) Visualization Toolkit 能夠更好的支持基于網絡的工具比如Java 和VRML 隨著Web 和Internet 技術的發展Visualization Toolkit 有著很好的發展前景
  
  4) 能夠支持多種著色如OpenGL 等
  
  5) Visualization Toolkit 具有設備無關性使其代碼具有良好的可移植性
  
  6) Visualization Toolkit 中定義了許多宏,這些宏極大的簡化了編程工作并且加強了一致的對象行為
  
  7) Visualization Toolkit 具有更豐富的數據類型,支持對多種數據類型進行處理
  
  8) 既可以工作于Windows 操作系統又可以工作于Unix 操作系統極大的方便了用戶
  
  下面介紹一下VTK在JDK1.4.1_02下的使用方法,
  
  1) 從vtk的網站(http://www.vtk.org/)上下載最新的軟件包,版本是4.2。然后把它安裝到C:/vtk42/目錄下
  
  2) 從Sun官方下載鏈接,版本1.4.1_02,然后安裝到C:/j2sdk1.4.1_02上
  
  3) 設置環境變量,系統->高級->環境變量->path,設置為C:/j2sdk1.4.1_02/bin;C:/PRogramFiles/Java/j2re1.4.1_02/bin;C:/j2sdk1.4.1_02/jre/bin;C:/vtk42/bin
  
  4) 拷貝C:/vtk42/bin/*java.dll到系統目錄
  
  5) 編譯,運行,為了方便起見,拷貝C:/vtk42/Examples/Tutorial/Step1/Java目錄下的Cone.java到d盤,當前目錄為d盤
  
  D:/>javac -classpath c:/vtk42/bin/vtk.jar Cone.java
  
  D:/>java -classpath .;c:/vtk42/bin/vtk.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 );
  
     }
  
    }
  }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泽普县| 南康市| 卢龙县| 长葛市| 县级市| 松潘县| 阿坝县| 永春县| 隆德县| 乌恰县| 大姚县| 同江市| 桐柏县| 华池县| 永靖县| 元谋县| 江西省| 乐陵市| 宣城市| 本溪市| 靖边县| 荔波县| 香格里拉县| 桂东县| 正定县| 西充县| 介休市| 灵川县| 鄂托克旗| 柞水县| 乌苏市| 北宁市| 昌平区| 富蕴县| 日喀则市| 班戈县| 沽源县| 五莲县| 彰化市| 喀喇沁旗| 新泰市|