| [834] | 1 | ----- How to visualize Geant4 simulation -----
|
|---|
| 2 | ----- with VRML-network drivers and g4vrmlview -----
|
|---|
| 3 |
|
|---|
| 4 | November 04, 1999
|
|---|
| 5 |
|
|---|
| 6 | Satoshi Tanaka and Yasuhide Sawada
|
|---|
| 7 | Fukui University, Japan
|
|---|
| 8 | tanaka@i1nws1.fuis.fukui-u.ac.jp
|
|---|
| 9 |
|
|---|
| 10 | ------------------------
|
|---|
| 11 | Section 1: Introduction
|
|---|
| 12 | ------------------------
|
|---|
| 13 |
|
|---|
| 14 | This is a document to explain how to perform Geant4
|
|---|
| 15 | "remote" visualization with VRML. You can visualize Geant4
|
|---|
| 16 | simulation on your WWW browser.
|
|---|
| 17 | You have to prepare the following softwares beforehand:
|
|---|
| 18 |
|
|---|
| 19 | (1) Geant4
|
|---|
| 20 | (2) g4vrmlview, a small java software included in the Geant4 package
|
|---|
| 21 |
|
|---|
| 22 | geant4/source/visualization/VRML/g4vrmlview/
|
|---|
| 23 |
|
|---|
| 24 | Or you can also obtain it from our ftp site:
|
|---|
| 25 |
|
|---|
| 26 | ftp://i1nws2.fuis.fukui-u.ac.jp/pub/graphics
|
|---|
| 27 | /fukui_graphics_system/g4vrmlview_VERSION.tar.gz
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | (3) VRML browser, e.g., vrweb, VRMLview, etc
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | -----------------------------------------------
|
|---|
| 34 | Section 2: What is the Geant4 VRML-network drivers?
|
|---|
| 35 | -----------------------------------------------
|
|---|
| 36 |
|
|---|
| 37 | Geant4 VRML-network drivers are included in visualization category of
|
|---|
| 38 | the Geant4 package:
|
|---|
| 39 |
|
|---|
| 40 | geant4/source/visualization/VRML/
|
|---|
| 41 |
|
|---|
| 42 | The VRML-network drivers work as follows:
|
|---|
| 43 |
|
|---|
| 44 | (1) Convert 3D data of Geant4 simulation into VRML 1.0/2.0 codes.
|
|---|
| 45 | (2) Send the generated VRML codes to another process of "g4vrmlview",
|
|---|
| 46 | running at either local or remote host.
|
|---|
| 47 |
|
|---|
| 48 | (Note: For local visualization, use the VRML-file drivers,
|
|---|
| 49 | which can be invoked with the following commands:
|
|---|
| 50 |
|
|---|
| 51 | .....
|
|---|
| 52 |
|
|---|
| 53 | Idle> /vis/sceneHandler/create VRML1FILE
|
|---|
| 54 |
|
|---|
| 55 | for VRML 1.0 and
|
|---|
| 56 |
|
|---|
| 57 | Idle> /vis/sceneHandler/create VRML2FILE
|
|---|
| 58 |
|
|---|
| 59 | for VRML 2.0.
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 | ------------------------------------------------------------------------
|
|---|
| 63 | Section 3: Environmental variables to customize the VRML-network drivers
|
|---|
| 64 | ------------------------------------------------------------------------
|
|---|
| 65 |
|
|---|
| 66 | You can customize the VRML-network drivers by setting environmental
|
|---|
| 67 | variables at Geant4 host, i.e., the host where Geant4 runs:
|
|---|
| 68 |
|
|---|
| 69 | Geant4_host % setenv G4VRML_PORT port_number
|
|---|
| 70 | Geant4_host % setenv G4VRML_HOST_NAME host_name
|
|---|
| 71 |
|
|---|
| 72 | The default port number is 40801, and the default host name
|
|---|
| 73 | is "localhost". You need not define the environmental
|
|---|
| 74 | variables if you use the default values.
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | ---------------------------------
|
|---|
| 78 | Section 4: What is g4vrmlview?
|
|---|
| 79 | ---------------------------------
|
|---|
| 80 |
|
|---|
| 81 | g4vrmlview is a software written in java.
|
|---|
| 82 | It works as follows:
|
|---|
| 83 |
|
|---|
| 84 | (1) Receive VRML codes from a VRML-network driver of Geant4
|
|---|
| 85 | via local or wide-area network.
|
|---|
| 86 | (2) Save the received VRML codes to a local file named "g4.wrl" etc.
|
|---|
| 87 | (3) Invoke a VRML viewer, which is specified at the command line,
|
|---|
| 88 | automatically.
|
|---|
| 89 |
|
|---|
| 90 | --------------------------------------
|
|---|
| 91 | Section 5: How to install g4vrmlview
|
|---|
| 92 | --------------------------------------
|
|---|
| 93 |
|
|---|
| 94 | You need JDK1.1 to install g4vrmlview.
|
|---|
| 95 | The installation can be done by doing the following steps:
|
|---|
| 96 |
|
|---|
| 97 | (1) % cd g4vrmlview
|
|---|
| 98 | (2) Edit Makefile and set a proper directory name to variable
|
|---|
| 99 | "INSTALL_DIR". The default setting is:
|
|---|
| 100 |
|
|---|
| 101 | INSTALL_DIR = "/usr/local/javaclass"
|
|---|
| 102 |
|
|---|
| 103 | Later, java classes (g4vrmlview.class etc) are installed
|
|---|
| 104 | to the directory specified by the variable INSTALL_DIR.
|
|---|
| 105 |
|
|---|
| 106 | (3) Set the environmental variable "CLASSPATH" in .cshrc etc.
|
|---|
| 107 | (This step can be skipped in some platforms.)
|
|---|
| 108 | For example, if JDK1.1.1 is installed in the directory
|
|---|
| 109 | "/usr/local/dev/jdk1.1.1" and you want to install g4vrmlview
|
|---|
| 110 | into "/usr/local/javaclass", then the variable CLASSPATH
|
|---|
| 111 | should be defined as:
|
|---|
| 112 |
|
|---|
| 113 | # java in Unix (.cshrc)
|
|---|
| 114 | setenv CLASSPATH .:/usr/local/dev/jdk1.1.1/lib/classes.zip:\
|
|---|
| 115 | /usr/local/javaclass
|
|---|
| 116 |
|
|---|
| 117 | Similarly, in Windows NT/95, if JDK.1.1 is installed in
|
|---|
| 118 | the directory "C:\jdk1.1.1" and you want to install g4vrmlview
|
|---|
| 119 | into C:\dev\javaclass, you should add the following lines to
|
|---|
| 120 | AUTOEXEC.BAT:
|
|---|
| 121 |
|
|---|
| 122 | # java in Windows NT/95 (autoexec.bat)
|
|---|
| 123 | SET CLASSPATH = .;C:\jdk1.1.1\lib\classes.zip;C:\dev\javaclass
|
|---|
| 124 |
|
|---|
| 125 | (4) % make clean
|
|---|
| 126 | (5) % make
|
|---|
| 127 |
|
|---|
| 128 | (6) Test created java classes using g4mini.
|
|---|
| 129 | You can do it using two separate windows,
|
|---|
| 130 | instead of using two separate hosts.
|
|---|
| 131 | Here we assume that we use windows named "window_1"
|
|---|
| 132 | and "window_2", and use the VRML browser "vrweb".
|
|---|
| 133 |
|
|---|
| 134 | window_1 % java g4vrmlview vrweb
|
|---|
| 135 | Waiting for requests at port 40801 ...
|
|---|
| 136 |
|
|---|
| 137 | window_2 % java g4vrmlview vrweb
|
|---|
| 138 | % java g4mini
|
|---|
| 139 | Usage: java g4mini src_file server_hostname
|
|---|
| 140 |
|
|---|
| 141 | window_2 % java g4mini sample.wrl localhost
|
|---|
| 142 |
|
|---|
| 143 | The test is successful if you see pictures on the VRML browser.
|
|---|
| 144 |
|
|---|
| 145 | Now you can use g4vrmlview if the class path of java is,
|
|---|
| 146 | explicitly or implicitly set to the current directory.
|
|---|
| 147 | Go on to the next step if you want to install g4vrmlview into
|
|---|
| 148 | a public place.
|
|---|
| 149 |
|
|---|
| 150 | Here you have to become root if you do not have permission
|
|---|
| 151 | to INSTALL_DIR. If the directory INSTALL_DIR does not exist,
|
|---|
| 152 | it will be created automatically.
|
|---|
| 153 |
|
|---|
| 154 | (5) % make install
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 | --------------------------------------
|
|---|
| 158 | Section 6: How to use g4vrmlview
|
|---|
| 159 | --------------------------------------
|
|---|
| 160 |
|
|---|
| 161 | (1) Invoke g4vrmlview at the host where g4vrmlview runs,
|
|---|
| 162 | say, "VRML_host". For example,
|
|---|
| 163 |
|
|---|
| 164 | VRML_host% java g4vrmlview VRML_browser_name
|
|---|
| 165 |
|
|---|
| 166 | where the last argument is a name of your favorite VRML browser.
|
|---|
| 167 |
|
|---|
| 168 | (2) Invoke Geant4 at the host, where Geant4 runs, say, Geant4_host.
|
|---|
| 169 | For example,
|
|---|
| 170 |
|
|---|
| 171 | Geant4_host% exampleN03
|
|---|
| 172 |
|
|---|
| 173 | .....
|
|---|
| 174 |
|
|---|
| 175 | Idel> /vis/sceneHandler/create VRML1
|
|---|
| 176 |
|
|---|
| 177 | for VRML 1.0 and
|
|---|
| 178 |
|
|---|
| 179 | Idel> /vis/sceneHandler/create VRML2
|
|---|
| 180 |
|
|---|
| 181 | for VRML 2.0.
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 | ---------------------------------------
|
|---|
| 185 | Section 7: More notes on g4vrmlview
|
|---|
| 186 | ---------------------------------------
|
|---|
| 187 |
|
|---|
| 188 | (1) Format of invoking g4vrmlview:
|
|---|
| 189 |
|
|---|
| 190 | % java g4vrmlview VRML_browser_name [port_number]
|
|---|
| 191 |
|
|---|
| 192 | VRML_browser_name:
|
|---|
| 193 | "netscape", "vrweb", etc,
|
|---|
| 194 | or "NONE" to suppress invoking VRML browser
|
|---|
| 195 |
|
|---|
| 196 | port_number:
|
|---|
| 197 | The default port number is 40801.
|
|---|
| 198 | If you have set the environmental variable
|
|---|
| 199 | "G4VRML_PORT" at Geant4 host,
|
|---|
| 200 | you have to give the same port number.
|
|---|
| 201 | For example,
|
|---|
| 202 |
|
|---|
| 203 | Geant4_host % setenv G4VRML_PORT 40802
|
|---|
| 204 | VRML_host % java g4vrmlview netscape 40802
|
|---|
| 205 |
|
|---|
| 206 | (2) Auto increment of port number:
|
|---|
| 207 | If the port number 40801 is already in use, it is
|
|---|
| 208 | automatically incremented one by one up to 40810.
|
|---|
| 209 |
|
|---|
| 210 | (3) Multiple thread:
|
|---|
| 211 | g4vrmlview is a multi-thread software.
|
|---|
| 212 | It can accept data from plural Geant4 at the same time.
|
|---|
| 213 |
|
|---|
| 214 | (4) Saving VRML codes to files:
|
|---|
| 215 | VRML codes sent from Geant4 is saved to a file named
|
|---|
| 216 | "g4.wrl". If g4.wrl already exists, the file name is
|
|---|
| 217 | incremented to g4_2.wrl. Similarly the file name is
|
|---|
| 218 | incremented to g4_3.wrl, g4_4.wrl, etc.
|
|---|
| 219 | The files are created in the directory where you invoked g4vrmlview.
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 | ===== End of document =====
|
|---|