1.vtkå¨Java2ä¸ç使ç¨
vtkå¨Java2ä¸ç使ç¨
ããVTK(Visualization ToolKit)æ¯ä¸ä¸ªå¼æ¾æºç èªç±è·åçè½¯ä»¶ç³»ç» å ¨ä¸ççæ°ä»¥å计çç 究人ååå¼å人åç¨å®æ¥è¿è¡ D计ç®æºå¾å½¢ å¾åå¤ç å¯è§å VTKå å«ä¸ä¸ªc++ç±»åº ä¼å¤çç¿»è¯æ¥å£å± å æ¬Tcl/Tk Java Python ããããVisualization Toolkit æ¯ä¸ä¸ªç¨äºå¯è§ååºç¨ç¨åºæé ä¸è¿è¡çæ¯æç¯å¢ å®æ¯å¨ä¸ç»´å½æ°åºOpenGL çåºç¡ä¸éç¨é¢å对象ç设计æ¹æ³åå±èµ·æ¥ç å®å°æ们å¨å¯è§åå¼åè¿ç¨ä¸ä¼ç»å¸¸éå°çç»èå±è½èµ·æ¥ 并å°ä¸äºå¸¸ç¨çç®æ³å°è£ èµ·æ¥ æ¯å¦Visualization Toolkit å°æ们å¨è¡¨é¢é建ä¸æ¯è¾å¸¸è§çMarching Cubes ç®æ³å°è£ èµ·æ¥ ä»¥ç±»çå½¢å¼ç»æ们以æ¯æ è¿æ ·æ们å¨å¯¹ä¸ç»´è§åç¹éµæ°æ®è¿è¡è¡¨é¢é建æ¶å°±ä¸å¿ åéå¤ç¼åMarchingCubes ç®æ³ç代ç èç´æ¥ä½¿ç¨Visualization Toolkit ä¸å·²ç»æä¾çvtkMarchingCubes ç±»ããããVisualization Toolkit æ¯ç»ä»äºå¯è§ååºç¨ç¨åºå¼åå·¥ä½çç 究人åæä¾ç´æ¥çææ¯æ¯æçä¸ä¸ªå¼ºå¤§çå¯è§åå¼åå·¥å · å®ä»¥ç¨æ·ä½¿ç¨çæ¹ä¾¿æ§åçµæ´»æ§ä¸ºä¸»è¦åå å ·æå¦ä¸çç¹ç¹ ãããã ) å ·æ强大çä¸ç»´å¾å½¢åè½ Visualization Toolkit æ¢æ¯æåºäºä½ç´ Voxel basedrendering çä½ç»å¶Volume Renderingåä¿çäºä¼ ç»çé¢ç»å¶ ä»èå¨æ大çæ¹åå¯è§åææçåæ¶åå¯ä»¥å åå©ç¨ç°æçå¾å½¢åºåå¾å½¢ç¡¬ä»¶ãããã ) Visualization Toolkit çä½ç³»ç»æä½¿å ¶å ·æé常好çæµstreaming åé«éç¼åcaching çè½å å¨å¤ç大éçæ°æ®æ¶ä¸å¿ èèå åèµæºçéå¶ãããã ) Visualization Toolkit è½å¤æ´å¥½çæ¯æåºäºç½ç»çå·¥å ·æ¯å¦Java åVRML éçWeb åInternet ææ¯çåå±Visualization Toolkit æçå¾å¥½çåå±åæ¯ãããã ) è½å¤æ¯æå¤ç§çè²å¦OpenGL çãããã ) Visualization Toolkit å ·æ设å¤æ å ³æ§ä½¿å ¶ä»£ç å ·æè¯å¥½çå¯ç§»æ¤æ§ãããã ) Visualization Toolkit ä¸å®ä¹äºè®¸å¤å® è¿äºå®æ大çç®åäºç¼ç¨å·¥ä½å¹¶ä¸å 强äºä¸è´ç对象è¡ä¸ºãããã ) Visualization Toolkit å ·ææ´ä¸°å¯çæ°æ®ç±»å æ¯æ对å¤ç§æ°æ®ç±»åè¿è¡å¤çãããã ) æ¢å¯ä»¥å·¥ä½äºWindows æä½ç³»ç»åå¯ä»¥å·¥ä½äºUnix æä½ç³»ç»æ大çæ¹ä¾¿äºç¨æ·ããããä¸é¢ä»ç»ä¸ä¸VTKå¨JDK _ ä¸ç使ç¨æ¹æ³ ãããã ) ä»vtkçç½ç«()ä¸ä¸è½½ææ°ç软件å çæ¬æ¯ ç¶åæå®å®è£ å°C:\vtk \ç®å½ä¸ãããã ) ä»Sunå®æ¹ä¸è½½é¾æ¥ çæ¬ _ ç¶åå®è£ å°C:\j sdk _ ä¸ãããã ) 设置ç¯å¢åé ç³»ç» >é«çº§ >ç¯å¢åé >path 设置为C:\j sdk _ \bin;C:\ProgramFiles\Java\j re _ \bin;C:\j sdk _ \jre\bin;C:\vtk \binãããã ) æ·è´C:\vtk \bin\*java dllå°ç³»ç»ç®å½ãããã ) ç¼è¯ è¿è¡ 为äºæ¹ä¾¿èµ·è§ æ·è´C:\vtk \Examples\Tutorial\Step \Javaç®å½ä¸çCone javaå°dç å½åç®å½ä¸ºdçããããD:\>javac classpath c:\vtk \bin\vtk jar Cone javaããããD:\>java classpath ;c:\vtk \bin\vtk jar Coneããããæºç å¦ä¸ ãããã//ãããã// This 码下equals方法的源码example creates a polygonal model of a cone and then renders it toãããã// the screen It will rotate the cone 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( );ããããããcone SetRadius( );ããããããcone SetResolution( );ãããããã // ãããããã// In this example we terminate the pipeline with a mapper process object ãããããã// (Intermediate filters such as vtkShrinkPolyData could be inserted inãããããã// beeen 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 ren = new vtkRenderer();ããããããren AddActor( coneActor );ããããããren SetBackground( );ãããããã//ãããããã// 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 pixels by ãããããã//ããããããvtkRenderWindow renWin = new vtkRenderWindow();ããããããrenWin AddRenderer( ren );ããããããrenWin SetSize( );ãããããã//ãããããã// now we loop over degreeees and render the cone each timeãããããã//ããããããint i;ããããããfor (i = ; i < ; ++i)ããããããã{ ããããããã// render the imageãããããããrenWin Render();ããããããã// rotate the active camera by one degreeãããããããren GetActiveCamera() Azimuth( );ããããããã}ãããããã} ãã} lishixinzhi/Article/program/Java/JSP//