Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 14:46:44 +01:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
+9
View File
@@ -19,6 +19,15 @@ committal in the CVS repository !
History file for visualization/VRML sub-category
------------------------------------------------
26 August 2021 Ben Morgan (VRML-V10-07-03)
- Remove obsolete VRML1 and network VRML2 drivers
25 August 2021 John Allison (VRML-V10-07-02)
- VRML*FILE drivers:
o Introduce environment variables G4VRMLFILE_HEADER and G4VRMLFILE_FILE_NAME
to allow the user to change the defaults. Also improve messaging to
inform the user of this possibility.
07 June 2021 John Allison (VRML-V10-07-01)
- Fix hidden function warning.
@@ -1,20 +0,0 @@
INSTALL_DIR = "/usr/local/javaclass"
JAVAC = javac
g4vrmlview.class: g4vrmlview.java
$(JAVAC) g4vrmlview.java
$(JAVAC) g4mini.java
install:
@if [ ! -d $(INSTALL_DIR) ] ; then mkdir $(INSTALL_DIR) ;fi
cp g4vrmlview.class $(INSTALL_DIR)
cp g4vrmlviewThread.class $(INSTALL_DIR)
clean:
rm -f *.class
rm -f \#* *~ *.bak
wrlclean:
rm -f g4.wrl g4_*.wrl
-222
View File
@@ -1,222 +0,0 @@
----- How to visualize Geant4 simulation -----
----- with VRML-network drivers and g4vrmlview -----
November 04, 1999
Satoshi Tanaka and Yasuhide Sawada
Fukui University, Japan
tanaka@i1nws1.fuis.fukui-u.ac.jp
------------------------
Section 1: Introduction
------------------------
This is a document to explain how to perform Geant4
"remote" visualization with VRML. You can visualize Geant4
simulation on your WWW browser.
You have to prepare the following softwares beforehand:
(1) Geant4
(2) g4vrmlview, a small java software included in the Geant4 package
geant4/source/visualization/VRML/g4vrmlview/
Or you can also obtain it from our ftp site:
ftp://i1nws2.fuis.fukui-u.ac.jp/pub/graphics
/fukui_graphics_system/g4vrmlview_VERSION.tar.gz
(3) VRML browser, e.g., vrweb, VRMLview, etc
-----------------------------------------------
Section 2: What is the Geant4 VRML-network drivers?
-----------------------------------------------
Geant4 VRML-network drivers are included in visualization category of
the Geant4 package:
geant4/source/visualization/VRML/
The VRML-network drivers work as follows:
(1) Convert 3D data of Geant4 simulation into VRML 1.0/2.0 codes.
(2) Send the generated VRML codes to another process of "g4vrmlview",
running at either local or remote host.
(Note: For local visualization, use the VRML-file drivers,
which can be invoked with the following commands:
.....
Idle> /vis/sceneHandler/create VRML1FILE
for VRML 1.0 and
Idle> /vis/sceneHandler/create VRML2FILE
for VRML 2.0.
------------------------------------------------------------------------
Section 3: Environmental variables to customize the VRML-network drivers
------------------------------------------------------------------------
You can customize the VRML-network drivers by setting environmental
variables at Geant4 host, i.e., the host where Geant4 runs:
Geant4_host % setenv G4VRML_PORT port_number
Geant4_host % setenv G4VRML_HOST_NAME host_name
The default port number is 40801, and the default host name
is "localhost". You need not define the environmental
variables if you use the default values.
---------------------------------
Section 4: What is g4vrmlview?
---------------------------------
g4vrmlview is a software written in java.
It works as follows:
(1) Receive VRML codes from a VRML-network driver of Geant4
via local or wide-area network.
(2) Save the received VRML codes to a local file named "g4.wrl" etc.
(3) Invoke a VRML viewer, which is specified at the command line,
automatically.
--------------------------------------
Section 5: How to install g4vrmlview
--------------------------------------
You need JDK1.1 to install g4vrmlview.
The installation can be done by doing the following steps:
(1) % cd g4vrmlview
(2) Edit Makefile and set a proper directory name to variable
"INSTALL_DIR". The default setting is:
INSTALL_DIR = "/usr/local/javaclass"
Later, java classes (g4vrmlview.class etc) are installed
to the directory specified by the variable INSTALL_DIR.
(3) Set the environmental variable "CLASSPATH" in .cshrc etc.
(This step can be skipped in some platforms.)
For example, if JDK1.1.1 is installed in the directory
"/usr/local/dev/jdk1.1.1" and you want to install g4vrmlview
into "/usr/local/javaclass", then the variable CLASSPATH
should be defined as:
# java in Unix (.cshrc)
setenv CLASSPATH .:/usr/local/dev/jdk1.1.1/lib/classes.zip:\
/usr/local/javaclass
Similarly, in Windows NT/95, if JDK.1.1 is installed in
the directory "C:\jdk1.1.1" and you want to install g4vrmlview
into C:\dev\javaclass, you should add the following lines to
AUTOEXEC.BAT:
# java in Windows NT/95 (autoexec.bat)
SET CLASSPATH = .;C:\jdk1.1.1\lib\classes.zip;C:\dev\javaclass
(4) % make clean
(5) % make
(6) Test created java classes using g4mini.
You can do it using two separate windows,
instead of using two separate hosts.
Here we assume that we use windows named "window_1"
and "window_2", and use the VRML browser "vrweb".
window_1 % java g4vrmlview vrweb
Waiting for requests at port 40801 ...
window_2 % java g4vrmlview vrweb
% java g4mini
Usage: java g4mini src_file server_hostname
window_2 % java g4mini sample.wrl localhost
The test is successful if you see pictures on the VRML browser.
Now you can use g4vrmlview if the class path of java is,
explicitly or implicitly set to the current directory.
Go on to the next step if you want to install g4vrmlview into
a public place.
Here you have to become root if you do not have permission
to INSTALL_DIR. If the directory INSTALL_DIR does not exist,
it will be created automatically.
(5) % make install
--------------------------------------
Section 6: How to use g4vrmlview
--------------------------------------
(1) Invoke g4vrmlview at the host where g4vrmlview runs,
say, "VRML_host". For example,
VRML_host% java g4vrmlview VRML_browser_name
where the last argument is a name of your favorite VRML browser.
(2) Invoke Geant4 at the host, where Geant4 runs, say, Geant4_host.
For example,
Geant4_host% exampleN03
.....
Idel> /vis/sceneHandler/create VRML1
for VRML 1.0 and
Idel> /vis/sceneHandler/create VRML2
for VRML 2.0.
---------------------------------------
Section 7: More notes on g4vrmlview
---------------------------------------
(1) Format of invoking g4vrmlview:
% java g4vrmlview VRML_browser_name [port_number]
VRML_browser_name:
"netscape", "vrweb", etc,
or "NONE" to suppress invoking VRML browser
port_number:
The default port number is 40801.
If you have set the environmental variable
"G4VRML_PORT" at Geant4 host,
you have to give the same port number.
For example,
Geant4_host % setenv G4VRML_PORT 40802
VRML_host % java g4vrmlview netscape 40802
(2) Auto increment of port number:
If the port number 40801 is already in use, it is
automatically incremented one by one up to 40810.
(3) Multiple thread:
g4vrmlview is a multi-thread software.
It can accept data from plural Geant4 at the same time.
(4) Saving VRML codes to files:
VRML codes sent from Geant4 is saved to a file named
"g4.wrl". If g4.wrl already exists, the file name is
incremented to g4_2.wrl. Similarly the file name is
incremented to g4_3.wrl, g4_4.wrl, etc.
The files are created in the directory where you invoked g4vrmlview.
===== End of document =====
@@ -1,81 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
import java.io.*;
import java.net.*;
public class g4mini
{
public static void main( String[] args )
{
try{
// port number
final int DEFALUT_PORT_NO = 40801 ;
int portNo = DEFALUT_PORT_NO ;
// argument checking
if( args.length != 2 )
{
System.out.println( "Usage: java g4mini src_file server_hostname");
return ;
}
String src = args[0];
String server = args[1];
// open connection
Socket socket = new Socket( server, portNo ) ;
// get input stream from file
BufferedReader br
= new BufferedReader ( new FileReader ( src ) ) ;
// get output stream to socket
BufferedWriter bw
= new BufferedWriter ( new OutputStreamWriter ( socket.getOutputStream() ) ) ;
// file ==> socket
String line ;
while ( (line = br.readLine()) != null )
{
bw.write( line );
bw.newLine() ;
bw.flush () ;
}
// close streams
br.close();
bw.close();
socket.close() ;
}
catch( Exception e )
{
System.out.println( e.toString() );
}
} // main
}
@@ -1,245 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
import java.io.*;
import java.net.*;
//------------------//
// class g4vrmlview //
// ( main() ) //
//------------------//
public class g4vrmlview
{
public static void main( String[] args )
{
try{
// CONST
final String VERSION = "1.00" ;
final String DATE = "August 19, 1997";
final int PORT_NO = 40801 ;
final String OUTPUT_FILE_HEAD = "g4" ;
final String OUTPUT_FILE_EXT = "wrl" ;
final int MAX_TRIAL = 10 ;
// local
int portNo = PORT_NO ;
// argument checking
if( args.length != 1 && args.length != 2 )
{
System.out.println( "-------------------------------");
System.out.println( " G4VRMLView version " + VERSION );
System.out.println( " " + DATE );
System.out.println( "-------------------------------");
System.out.println( "Usage: java g4vrmlview browser_name [port_number]");
System.out.println( " Browser_name: netscape, vrweb, etc, or NONE");
return ;
}
// VRML browser
String browser = new String ( args[0] ) ;
// port number
if( args.length == 2 )
{
portNo = Integer.parseInt( args[1] );
}
// make a server socket
ServerSocket ss = null ;
for ( int i = 0 ; i < MAX_TRIAL ; i++ )
{
try
{
ss = new ServerSocket( portNo );
System.out.println( "Waiting for requests at port " +portNo + " ...");
break ;
}
catch ( Exception e )
{
portNo++ ;
if( i >= MAX_TRIAL )
{
System.out.println( "Sockets are not available.");
return ;
}
}
} // for
// open connection and invoke thread
int nSpawn = 0 ;
while( true )
{
Socket socket = ss.accept(); nSpawn++ ;
System.out.println( "Connection accepted by thread " + nSpawn );
( new g4vrmlviewThread( socket, OUTPUT_FILE_HEAD, OUTPUT_FILE_EXT , browser )).start() ;
} // while
}
catch ( Exception e )
{
System.out.println( e.toString() );
}
} // main()
} // g4vrmlview
//------------------------//
// class g4vrmlviewThread //
//------------------------//
class g4vrmlviewThread extends Thread
{
private final String NONE = "NONE" ; // no browser
private Socket m_socket ;
private String m_outputFile ;
private String m_browser ;
// constuctor
public g4vrmlviewThread( Socket socket ,
String outputFileHead ,
String outputFileExt ,
String browser )
{
m_socket = socket ;
SetOutputFileName ( outputFileHead , outputFileExt );
m_browser = new String ( browser );
}
private void SetOutputFileName( String outputFileHead,
String outputFileExt )
{
// temporary file name
String outputFile_tmp
= new String ( outputFileHead +
"." +
outputFileExt ) ;
// for modification of temporary filename
int n = 1 ;
// make a non-existing filename
while ( true )
{
File file = new File ( outputFile_tmp );
if ( !file.exists() )
{
break ;
} else {
outputFile_tmp
= new String ( outputFileHead +
"_" +
(n++) +
"." +
outputFileExt );
}
} // while
// set decided filename to data field
m_outputFile = new String ( outputFile_tmp );
} // g4vrmlviewThread::setOutputFileName()
// run ()
public void run ()
{
try{
// get input stream from socket
BufferedReader br
= new BufferedReader ( new InputStreamReader ( m_socket.getInputStream() ) ) ;
// get output stream to file
BufferedWriter bw
= new BufferedWriter ( new FileWriter ( m_outputFile ) ) ;
// socket ==> file
String line ;
while ( (line = br.readLine()) != null )
{
bw.write( line );
bw.newLine() ;
bw.flush () ;
}
System.out.println( "VRML data is saved to file " +m_outputFile );
// close streams and socket
br.close();
bw.close();
m_socket.close() ;
// invoke browser
if( !m_browser.equals(NONE) )
{
try
{
File file = new File ( m_outputFile );
// visualize created VRML file with browser
if ( file.exists() )
{
String outputFileAbs = new String ( file.getAbsolutePath() ) ;
String[] command = { m_browser, outputFileAbs };
System.out.println( "Command: " + command[0] + " " + command[1] );
Process exec_process = null ;
Runtime runtime = Runtime.getRuntime();
exec_process = runtime.exec( command );
exec_process.waitFor() ;
} else {
System.out.println( "Error: Failed to open file" + m_outputFile );
}
}
catch ( Exception e )
{
System.out.println( e.toString() );
}
}
else
{
System.out.println( "No browser was invoked" );
}
}
catch( Exception e )
{
System.out.println( e.toString() );
}
} // run()
} // g4vrmlviewThread
@@ -1,700 +0,0 @@
#VRML V1.0 ascii
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
}
DEF box_WBox_10 Separator {
Material {
diffuseColor 1 1 1
}
Cube {
width 12000
height 24000
depth 20000
}
}
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 0 1
}
DEF box_WSBox_11 Separator {
Material {
diffuseColor 1 0 0
}
Cube {
width 3200
height 1300
depth 3200
}
}
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 0 1
}
DEF box_WSWBox_12 Separator {
Material {
diffuseColor 0 1 0
}
Cube {
width 3180
height 1280
depth 3180
}
}
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 400 0 1
}
DEF box_WSSBox_13 Separator {
Material {
diffuseColor 0 0 1
}
Cube {
width 3180
height 2
depth 3180
}
}
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 460 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 520 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 580 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 640 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 700 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 760 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 820 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 880 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 940 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1060 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1120 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1180 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1240 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1300 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1360 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1420 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1480 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1540 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1600 0 1
}
USE box_WSSBox_13
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 -1220 1
}
DEF tubs_CUTubsR_14 Separator {
ShapeHints {
vertexOrdering COUNTERCLOCKWISE
shapeType SOLID
faceType CONVEX
}
Material {
diffuseColor 1 1 1
}
Coordinate3 {
point [
1512.5 1512.5 305,
1069.5 1852.43 305,
553.614 2066.12 305,
1.30972e-13 2139 305,
1512.5 1512.5 -305,
1069.5 1852.43 -305,
553.614 2066.12 -305,
1.30972e-13 2139 -305,
1234.86 1234.86 305,
873.18 1512.39 305,
451.991 1686.85 305,
1.0693e-13 1746.36 305,
1234.86 1234.86 -305,
873.18 1512.39 -305,
451.991 1686.85 -305,
1.0693e-13 1746.36 -305,
]
}
IndexedFaceSet {
coordIndex [
0, 4, 5, 1, -1,
1, 5, 6, 2, -1,
2, 6, 7, 3, -1,
12, 8, 9, 13, -1,
13, 9, 10, 14, -1,
14, 10, 11, 15, -1,
8, 0, 1, 9, -1,
9, 1, 2, 10, -1,
10, 2, 3, 11, -1,
4, 12, 13, 5, -1,
5, 13, 14, 6, -1,
6, 14, 15, 7, -1,
0, 8, 12, 4, -1,
7, 15, 11, 3, -1,
]
}
}
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 -1220 1
}
DEF tubs_CRTubsR_15 Separator {
ShapeHints {
vertexOrdering COUNTERCLOCKWISE
shapeType SOLID
faceType CONVEX
}
Material {
diffuseColor 1 1 1
}
Coordinate3 {
point [
1505.43 1505.43 305,
1064.5 1843.77 305,
551.026 2056.46 305,
1.30359e-13 2129 305,
1505.43 1505.43 -305,
1064.5 1843.77 -305,
551.026 2056.46 -305,
1.30359e-13 2129 -305,
1234.86 1234.86 305,
873.18 1512.39 305,
451.991 1686.85 305,
1.0693e-13 1746.36 305,
1234.86 1234.86 -305,
873.18 1512.39 -305,
451.991 1686.85 -305,
1.0693e-13 1746.36 -305,
]
}
IndexedFaceSet {
coordIndex [
0, 4, 5, 1, -1,
1, 5, 6, 2, -1,
2, 6, 7, 3, -1,
12, 8, 9, 13, -1,
13, 9, 10, 14, -1,
14, 10, 11, 15, -1,
8, 0, 1, 9, -1,
9, 1, 2, 10, -1,
10, 2, 3, 11, -1,
4, 12, 13, 5, -1,
5, 13, 14, 6, -1,
6, 14, 15, 7, -1,
0, 8, 12, 4, -1,
7, 15, 11, 3, -1,
]
}
}
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 -1220 1
}
DEF tubs_CUTubsL_16 Separator {
ShapeHints {
vertexOrdering COUNTERCLOCKWISE
shapeType SOLID
faceType CONVEX
}
Material {
diffuseColor 1 1 1
}
Coordinate3 {
point [
1.30972e-13 2139 305,
-553.614 2066.12 305,
-1069.5 1852.43 305,
-1512.5 1512.5 305,
1.30972e-13 2139 -305,
-553.614 2066.12 -305,
-1069.5 1852.43 -305,
-1512.5 1512.5 -305,
1.0693e-13 1746.36 305,
-451.991 1686.85 305,
-873.18 1512.39 305,
-1234.86 1234.86 305,
1.0693e-13 1746.36 -305,
-451.991 1686.85 -305,
-873.18 1512.39 -305,
-1234.86 1234.86 -305,
]
}
IndexedFaceSet {
coordIndex [
0, 4, 5, 1, -1,
1, 5, 6, 2, -1,
2, 6, 7, 3, -1,
12, 8, 9, 13, -1,
13, 9, 10, 14, -1,
14, 10, 11, 15, -1,
8, 0, 1, 9, -1,
9, 1, 2, 10, -1,
10, 2, 3, 11, -1,
4, 12, 13, 5, -1,
5, 13, 14, 6, -1,
6, 14, 15, 7, -1,
0, 8, 12, 4, -1,
7, 15, 11, 3, -1,
]
}
}
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 -1220 1
}
DEF tubs_CRTubsL_17 Separator {
ShapeHints {
vertexOrdering COUNTERCLOCKWISE
shapeType SOLID
faceType CONVEX
}
Material {
diffuseColor 1 1 1
}
Coordinate3 {
point [
1.30359e-13 2129 305,
-551.026 2056.46 305,
-1064.5 1843.77 305,
-1505.43 1505.43 305,
1.30359e-13 2129 -305,
-551.026 2056.46 -305,
-1064.5 1843.77 -305,
-1505.43 1505.43 -305,
1.0693e-13 1746.36 305,
-451.991 1686.85 305,
-873.18 1512.39 305,
-1234.86 1234.86 305,
1.0693e-13 1746.36 -305,
-451.991 1686.85 -305,
-873.18 1512.39 -305,
-1234.86 1234.86 -305,
]
}
IndexedFaceSet {
coordIndex [
0, 4, 5, 1, -1,
1, 5, 6, 2, -1,
2, 6, 7, 3, -1,
12, 8, 9, 13, -1,
13, 9, 10, 14, -1,
14, 10, 11, 15, -1,
8, 0, 1, 9, -1,
9, 1, 2, 10, -1,
10, 2, 3, 11, -1,
4, 12, 13, 5, -1,
5, 13, 14, 6, -1,
6, 14, 15, 7, -1,
0, 8, 12, 4, -1,
7, 15, 11, 3, -1,
]
}
}
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 -610 1
}
USE tubs_CUTubsR_14
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 -610 1
}
USE tubs_CRTubsR_15
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 -610 1
}
USE tubs_CUTubsL_16
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 -610 1
}
USE tubs_CRTubsL_17
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 0 1
}
USE tubs_CUTubsR_14
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 0 1
}
USE tubs_CRTubsR_15
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 0 1
}
USE tubs_CUTubsL_16
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 0 1
}
USE tubs_CRTubsL_17
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 610 1
}
USE tubs_CUTubsR_14
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 610 1
}
USE tubs_CRTubsR_15
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 610 1
}
USE tubs_CUTubsL_16
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 610 1
}
USE tubs_CRTubsL_17
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 1220 1
}
USE tubs_CUTubsR_14
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 1220 1
}
USE tubs_CRTubsR_15
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 1220 1
}
USE tubs_CUTubsL_16
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 1000 1220 1
}
USE tubs_CRTubsL_17
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 4100 0 1
}
DEF box_muCh_18 Separator {
Material {
diffuseColor 1 1 1
}
Cube {
width 8000
height 200
depth 8000
}
}
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 4250 0 1
}
DEF box_muFe_19 Separator {
Material {
diffuseColor 1 1 1
}
Cube {
width 8000
height 100
depth 8000
}
}
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 4400 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 4550 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 4700 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 4850 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 5000 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 5150 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 5300 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 5450 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 5550 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 5700 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 5850 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 5950 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 6100 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 6250 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 6350 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 6500 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 6650 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 6750 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 6900 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 7050 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 7150 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 7300 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 7450 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 7550 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 7700 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 7850 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 7950 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 8100 0 1
}
USE box_muCh_18
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 8250 0 1
}
USE box_muFe_19
}
Separator {
MatrixTransform {
matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 8350 0 1
}
USE box_muFe_19
}
#End of file.
@@ -1,62 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// FRClient.h
// FukuiRenderer Client
// Yasuhide Sawada & Satoshi Tanaka
#ifndef WIN32
#ifdef G4VIS_BUILD_VRML_DRIVER
#ifndef FR_CLIENT_H
#define FR_CLIENT_H
#define FRSendLength 256
class FRClient {
public:
FRClient();
virtual ~FRClient();
int create();
int connect(const char *hostname, int port);
int send(const char *sendbuf);
int receive(char *recvbuf);
int close();
protected:
int fd;
int port;
};
#endif //FR_CLIENT_H
#endif //G4VIS_BUILD_VRML_DRIVER
#endif //WIN32
@@ -1,71 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4FRClient.hh
// Yasuhide Sawada and Satoshi Tanaka
#ifndef WIN32
#ifdef G4VIS_BUILD_VRML_DRIVER
#ifndef G4_FR_CLIENT_HH
#define G4_FR_CLIENT_HH
#include "globals.hh"
class FRClient;
class G4FRClient {
// G4FRClient can SEND only!
public:
G4FRClient();
virtual ~G4FRClient();
G4bool connect(const char *hostname, G4int port);
void close();
G4int getPort() const;
G4bool isConnected() const { return connected; }
G4bool is_open () const { return connected; }
G4FRClient& operator << (G4int);
G4FRClient& operator << (G4double);
G4FRClient& operator << (const char *);
G4FRClient& operator << (G4FRClient& (*)(G4FRClient&));
private:
FRClient *fFRClient;
G4bool connected;
G4int fPort;
};
//manipulator
//G4FRClient& endl(G4FRClient&);
#endif //G4_FR_CLIENT_HH
#endif //G4VIS_BUILD_VRML_DRIVER
#endif //WIN32
@@ -1,68 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1.hh
// Yasuhide Sawada and Satoshi Tanaka
#ifndef WIN32
#if defined (G4VIS_BUILD_VRML_DRIVER) || defined (G4VIS_USE_VRML)
#ifndef G4VRML1_HH
#define G4VRML1_HH
#include "G4VGraphicsSystem.hh"
#include "FRClient.h"
class G4VSceneHandler;
//#define FR_VRML_DEFAULT_PORT 40801
//#define FR_VRML_PORT_ENV "FR_VRML_PORT"
//#define FR_VRML_HOST_NAME_ENV "FR_VRML_HOST_NAME"
#include "G4VRMLNetConfig.hh"
class G4VRML1: public G4VGraphicsSystem {
public:
G4VRML1();
virtual ~G4VRML1();
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer(G4VSceneHandler&, const G4String& name = "");
public:
const G4String& getHostName() { return fHostName; }
G4int getPort() { return fPort; }
private:
G4String fHostName;
G4int fPort;
};
#endif //G4VRML1_HH
#endif //G4VIS_BUILD_VRML_DRIVER
#endif //WIN32
@@ -1,47 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1File.hh
// Satoshi Tanaka & Yasuhide Sawada
#ifndef G4VRML1FILE_HH
#define G4VRML1FILE_HH
#include "G4VGraphicsSystem.hh"
class G4VSceneHandler;
class G4VRML1File: public G4VGraphicsSystem {
public:
G4VRML1File();
virtual ~G4VRML1File();
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer(G4VSceneHandler&, const G4String& name = "");
};
#endif //G4VRML1File_HH
@@ -1,121 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1FileSceneHandler.hh
// Satoshi Tanaka & Yasuhide Sawada
#ifndef G4VRML1FILE_SCENE_HANDLER_HH
#define G4VRML1FILE_SCENE_HANDLER_HH
#include <fstream>
#include "globals.hh"
#include "G4LogicalVolume.hh"
#include "G4VSceneHandler.hh"
class G4VRML1File;
class G4VisAttributes;
class G4VRML1FileSceneHandler: public G4VSceneHandler {
friend class G4VRML1FileViewer;
// methods (public)
public:
G4VRML1FileSceneHandler(G4VRML1File& system, const G4String& name = "");
virtual ~G4VRML1FileSceneHandler();
using G4VSceneHandler::AddSolid;
void AddSolid(const G4Box&);
void AddSolid(const G4Cons&);
void AddSolid(const G4Tubs&);
void AddSolid(const G4Trd&);
void AddSolid(const G4Trap&);
void AddSolid(const G4Sphere&);
void AddSolid(const G4Para&);
void AddSolid(const G4Torus&);
void AddSolid(const G4VSolid&);
using G4VSceneHandler::AddCompound;
void BeginPrimitives(const G4Transform3D& objectTransformation);
void EndPrimitives();
using G4VSceneHandler::AddPrimitive;
void AddPrimitive(const G4Polyline&);
void AddPrimitive(const G4Polyhedron&);
void AddPrimitive(const G4Text&);
void AddPrimitive(const G4Circle&);
void AddPrimitive(const G4Square&);
void ClearTransientStore(); // Used for triggering detector re-drawing.
void BeginModeling();
void EndModeling();
void VRMLBeginModeling();
void VRMLEndModeling();
void connectPort();
void closePort();
// methods (private)
private:
void SendMaterialNode( const G4VisAttributes* pAV ); // NEW NEW NEW
void SendMaterialNode();
void SendMatrixTransformNode(const G4Transform3D &);
void SendCubeNode(G4double, G4double, G4double);
void SendCylinderNode(G4double, G4double);
void SendSphereNode(G4double);
void SendMarkerColor ( const G4VMarker& mark ) ;
void SendMarkerWorldPosition ( const G4VMarker& mark ) ;
G4double GetMarkerHalfSize ( const G4VMarker& mark ) ;
G4bool isConnected () { return fFlagDestOpen ; }
// data
private:
char fVRMLFileDestDir[256] ;
char fVRMLFileName[256] ;
G4String fCurrentDEF;
G4VRML1File& fSystem; // Graphics system for this scene.
std::ofstream fDest ;
G4bool fFlagDestOpen ;
G4int fMaxFileNum ;
static G4int fSceneIdCount;
};
#endif //G4VRML1FILE_SCENE_HANDLER_HH
@@ -1,54 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1FileViewer.hh
// Satoshi Tanaka and Yasuhide Sawada
#ifndef G4VRML1FILE_VIEWER_HH
#define G4VRML1FILE_VIEWER_HH
#include "G4VViewer.hh"
#include "globals.hh"
class G4VRML1FileSceneHandler;
class G4VRML1FileViewer: public G4VViewer {
public:
G4VRML1FileViewer(G4VRML1FileSceneHandler& scene, const G4String& name = "");
virtual ~G4VRML1FileViewer();
void ClearView();
void DrawView();
void ShowView();
void FinishView();
private:
void SetView();
private:
G4VRML1FileSceneHandler& fSceneHandler; // Reference to Graphics Scene for this view.
};
#endif //G4VRML1File_VIEW_HH
@@ -1,118 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1SceneHandler.hh
// Yasuhide Sawada & Satoshi Tanaka
#ifndef WIN32
#ifdef G4VIS_BUILD_VRML_DRIVER
#ifndef G4VRML1_SCENE_HANDLER_HH
#define G4VRML1_SCENE_HANDLER_HH
#include "globals.hh"
#include "G4LogicalVolume.hh"
#include "G4VSceneHandler.hh"
#include "G4FRClient.hh"
class G4VRML1;
class G4VisAttributes;
class G4VRML1SceneHandler: public G4VSceneHandler {
enum { MAX_CONNECTION_TRIAL = 10 } ;
// methods (public)
public:
G4VRML1SceneHandler(G4VRML1& system, const G4String& name = "");
virtual ~G4VRML1SceneHandler();
using G4VSceneHandler::AddSolid;
void AddSolid(const G4Box&);
void AddSolid(const G4Cons&);
void AddSolid(const G4Tubs&);
void AddSolid(const G4Trd&);
void AddSolid(const G4Trap&);
void AddSolid(const G4Sphere&);
void AddSolid(const G4Para&);
void AddSolid(const G4Torus&);
void AddSolid(const G4VSolid&);
using G4VSceneHandler::AddCompound;
void BeginPrimitives(const G4Transform3D& objectTransformation);
void EndPrimitives();
using G4VSceneHandler::AddPrimitive;
void AddPrimitive(const G4Polyline&);
void AddPrimitive(const G4Polyhedron&);
void AddPrimitive(const G4Text&);
void AddPrimitive(const G4Circle&);
void AddPrimitive(const G4Square&);
void ClearTransientStore(); // Used for triggering detector re-drawing.
void BeginModeling();
void EndModeling();
void VRMLBeginModeling();
void VRMLEndModeling();
void connectPort(int max_trial = MAX_CONNECTION_TRIAL );
void closePort();
// methods (private)
private:
void SendMaterialNode( const G4VisAttributes* pAV );
void SendMaterialNode();
void SendMatrixTransformNode(const G4Transform3D &);
void SendCubeNode(G4double, G4double, G4double);
void SendCylinderNode(G4double, G4double);
void SendSphereNode(G4double);
void SendMarkerColor ( const G4VMarker& mark ) ;
void SendMarkerWorldPosition ( const G4VMarker& mark ) ;
G4double GetMarkerHalfSize ( const G4VMarker& mark ) ;
// data
private:
G4String fCurrentDEF;
G4VRML1& fSystem; // Graphics system for this scene.
G4FRClient fDest ;
static G4int fSceneIdCount;
};
#endif //G4VRML1_SCENE_HH
#endif //G4VIS_BUILD_VRML_DRIVER
#endif //WIN32
@@ -1,60 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1Viewer.hh
// Satoshi Tanaka & Yasuhide Sawada
#ifndef WIN32
#ifdef G4VIS_BUILD_VRML_DRIVER
#ifndef G4VRML1_VIEWER_HH
#define G4VRML1_VIEWER_HH
#include "G4VViewer.hh"
#include "globals.hh"
class G4VRML1SceneHandler;
class G4VRML1Viewer: public G4VViewer {
public:
G4VRML1Viewer(G4VRML1SceneHandler& scene, const G4String& name = "");
virtual ~G4VRML1Viewer();
void ClearView();
void DrawView();
void ShowView();
void FinishView();
private:
void SetView();
private:
G4VRML1SceneHandler& fSceneHandler; // Reference to Graphics Scene for this view.
};
#endif //G4VRML1_VIEW_HH
#endif //G4VIS_BUILD_VRML_DRIVER
#endif //WIN32
@@ -1,67 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML2.hh
// Satoshi Tanaka and Yasuhide Sawada
#ifndef WIN32
#if defined (G4VIS_BUILD_VRML_DRIVER) || defined (G4VIS_USE_VRML)
#ifndef G4VRML2_HH
#define G4VRML2_HH
#include "G4VGraphicsSystem.hh"
#include "FRClient.h"
class G4VSceneHandler;
#include "G4VRMLNetConfig.hh"
//#define FR_VRML_DEFAULT_PORT 40801
//#define FR_VRML_PORT_ENV "FR_VRML_PORT"
//#define FR_VRML_HOST_NAME_ENV "FR_VRML_HOST_NAME"
class G4VRML2: public G4VGraphicsSystem {
public:
G4VRML2();
virtual ~G4VRML2();
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer(G4VSceneHandler&, const G4String& name = "");
public:
const G4String& getHostName() { return fHostName; }
G4int getPort() { return fPort; }
private:
G4String fHostName;
G4int fPort;
};
#endif //G4VRML2_HH
#endif //G4VIS_BUILD_VRML_DRIVER
#endif //WIN32
@@ -35,13 +35,13 @@
class G4VSceneHandler;
class G4VRML2File: public G4VGraphicsSystem {
public:
G4VRML2File();
virtual ~G4VRML2File();
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer(G4VSceneHandler&, const G4String& name = "");
class G4VRML2File : public G4VGraphicsSystem
{
public:
G4VRML2File();
virtual ~G4VRML2File();
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer(G4VSceneHandler&, const G4String& name = "");
};
#endif //G4VRML2FILE_HH
#endif // G4VRML2FILE_HH
@@ -37,94 +37,89 @@
#include "G4LogicalVolume.hh"
#include "G4VSceneHandler.hh"
class G4VRML2File;
class G4VisAttributes;
class G4VRML2FileSceneHandler: public G4VSceneHandler {
class G4VRML2FileSceneHandler : public G4VSceneHandler
{
friend class G4VRML2FileViewer;
// methods (public)
public:
G4VRML2FileSceneHandler(G4VRML2File& system, const G4String& name = "");
virtual ~G4VRML2FileSceneHandler();
// methods (public)
public:
G4VRML2FileSceneHandler(G4VRML2File& system, const G4String& name = "");
virtual ~G4VRML2FileSceneHandler();
using G4VSceneHandler::AddSolid;
void AddSolid(const G4Box&);
void AddSolid(const G4Cons&);
void AddSolid(const G4Tubs&);
void AddSolid(const G4Trd&);
void AddSolid(const G4Trap&);
void AddSolid(const G4Sphere&);
void AddSolid(const G4Para&);
void AddSolid(const G4Torus&);
void AddSolid(const G4VSolid&);
using G4VSceneHandler::AddSolid;
void AddSolid(const G4Box&);
void AddSolid(const G4Cons&);
void AddSolid(const G4Tubs&);
void AddSolid(const G4Trd&);
void AddSolid(const G4Trap&);
void AddSolid(const G4Sphere&);
void AddSolid(const G4Para&);
void AddSolid(const G4Torus&);
void AddSolid(const G4VSolid&);
using G4VSceneHandler::AddCompound;
using G4VSceneHandler::AddCompound;
void BeginPrimitives(const G4Transform3D& objectTransformation);
void EndPrimitives();
void BeginPrimitives(const G4Transform3D& objectTransformation);
void EndPrimitives();
using G4VSceneHandler::AddPrimitive;
void AddPrimitive(const G4Polyline&);
void AddPrimitive(const G4Polyhedron&);
void AddPrimitive(const G4Text&);
void AddPrimitive(const G4Circle&);
void AddPrimitive(const G4Square&);
using G4VSceneHandler::AddPrimitive;
void AddPrimitive(const G4Polyline&);
void AddPrimitive(const G4Polyhedron&);
void AddPrimitive(const G4Text&);
void AddPrimitive(const G4Circle&);
void AddPrimitive(const G4Square&);
void ClearTransientStore(); // Used for triggering detector re-drawing.
void ClearTransientStore(); // Used for triggering detector re-drawing.
void BeginModeling();
void EndModeling();
void BeginModeling();
void EndModeling();
void VRMLBeginModeling();
void VRMLEndModeling();
void VRMLBeginModeling();
void VRMLEndModeling();
void connectPort();
void closePort();
void connectPort();
void closePort();
// methods (private)
private:
// methods (private)
private:
void SendMaterialNode(const G4VisAttributes* pAV);
void SendMaterialNode();
void SendMaterialNode ( const G4VisAttributes* pAV );
void SendMaterialNode ();
void SendLineColor(const G4VisAttributes* pAV);
void SendMarkerColor(const G4VMarker& mark);
void SendMarkerWorldPosition(const G4VMarker& mark);
void SendLineColor ( const G4VisAttributes* pAV );
void SendMarkerColor ( const G4VMarker& mark ) ;
void SendMarkerWorldPosition ( const G4VMarker& mark ) ;
G4double GetMarkerHalfSize(const G4VMarker& mark);
void GetMarkerWorldPosition(const G4VMarker& mark, double* pX, double* pY,
double* pZ);
G4double GetMarkerHalfSize ( const G4VMarker& mark ) ;
void GetMarkerWorldPosition ( const G4VMarker& mark ,
double* pX ,
double* pY ,
double* pZ ) ;
G4bool isConnected() { return fFlagDestOpen; }
G4bool isConnected () { return fFlagDestOpen ; }
G4bool IsPVPickable() { return fPVPickable; }
void SetPVPickability(G4bool on_off) { fPVPickable = on_off; }
G4double SetPVTransparency();
G4double GetPVTransparency() { return fPVTransparency; }
G4bool IsPVPickable () { return fPVPickable ;}
void SetPVPickability ( G4bool on_off ) { fPVPickable = on_off ;}
G4double SetPVTransparency () ;
G4double GetPVTransparency () { return fPVTransparency ; }
// data
private:
char fVRMLFileDestDir[256];
char fVRMLFileName[256];
// data
private:
char fVRMLFileDestDir[256] ;
char fVRMLFileName[256] ;
G4VRML2File& fSystem; // Graphics system for this scene.
G4bool fFlagDestOpen;
G4VRML2File& fSystem; // Graphics system for this scene.
G4bool fFlagDestOpen ;
G4int fMaxFileNum;
G4int fMaxFileNum ;
G4bool fPVPickable;
G4double fPVTransparency;
G4bool fPVPickable ;
G4double fPVTransparency ;
static G4int fSceneIdCount;
public:
std::ofstream fDest ;
static G4int fSceneIdCount;
public:
std::ofstream fDest;
};
#endif //G4VRML2FILE_SCENE_HANDLER_HH
#endif // G4VRML2FILE_SCENE_HANDLER_HH
@@ -37,25 +37,27 @@
class G4VRML2FileSceneHandler;
class G4VRML2FileViewer: public G4VViewer {
public:
G4VRML2FileViewer(G4VRML2FileSceneHandler& scene, const G4String& name = "");
virtual ~G4VRML2FileViewer();
void ClearView();
void DrawView();
void ShowView();
void FinishView();
private:
void SetView(); // Do nothing. SendViewParameters will do its job.
void SendViewParameters () ;
class G4VRML2FileViewer : public G4VViewer
{
public:
G4VRML2FileViewer(G4VRML2FileSceneHandler& scene, const G4String& name = "");
virtual ~G4VRML2FileViewer();
void ClearView();
void DrawView();
void ShowView();
void FinishView();
private:
G4VRML2FileSceneHandler& fSceneHandler; // Reference to Graphics Scene for this view.
std::ofstream& fDest ;
private:
void SetView(); // Do nothing. SendViewParameters will do its job.
void SendViewParameters();
G4double fViewHalfAngle ;
G4double fsin_VHA ;
private:
G4VRML2FileSceneHandler&
fSceneHandler; // Reference to Graphics Scene for this view.
std::ofstream& fDest;
G4double fViewHalfAngle;
G4double fsin_VHA;
};
#endif //G4VRML2FILE_VIEWER_HH
#endif // G4VRML2FILE_VIEWER_HH
@@ -1,127 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML2SceneHandler.hh
// Satoshi Tanaka & Yasuhide Sawada
#ifndef WIN32
#ifdef G4VIS_BUILD_VRML_DRIVER
#ifndef G4VRML2_SCENE_HANDLER_HH
#define G4VRML2_SCENE_HANDLER_HH
#include "globals.hh"
#include "G4LogicalVolume.hh"
#include "G4VSceneHandler.hh"
#include "G4FRClient.hh"
class G4VRML2;
class G4VisAttributes;
class G4VRML2SceneHandler: public G4VSceneHandler {
enum { MAX_CONNECTION_TRIAL = 10 } ;
// methods (public)
public:
G4VRML2SceneHandler(G4VRML2& system, const G4String& name = "");
virtual ~G4VRML2SceneHandler();
using G4VSceneHandler::AddSolid;
void AddSolid(const G4Box&);
void AddSolid(const G4Cons&);
void AddSolid(const G4Tubs&);
void AddSolid(const G4Trd&);
void AddSolid(const G4Trap&);
void AddSolid(const G4Sphere&);
void AddSolid(const G4Para&);
void AddSolid(const G4Torus&);
void AddSolid(const G4VSolid&);
using G4VSceneHandler::AddCompound;
void BeginPrimitives(const G4Transform3D& objectTransformation);
void EndPrimitives();
using G4VSceneHandler::AddPrimitive;
void AddPrimitive(const G4Polyline&);
void AddPrimitive(const G4Polyhedron&);
void AddPrimitive(const G4Text&);
void AddPrimitive(const G4Circle&);
void AddPrimitive(const G4Square&);
void ClearTransientStore(); // Used for triggering detector re-drawing.
void BeginModeling();
void EndModeling();
void VRMLBeginModeling();
void VRMLEndModeling();
void connectPort(int max_trial = MAX_CONNECTION_TRIAL );
void closePort();
// methods (private)
private:
void SendMaterialNode ( const G4VisAttributes* pAV );
void SendMaterialNode ();
void SendLineColor ( const G4VisAttributes* pAV );
void SendMarkerColor ( const G4VMarker& mark ) ;
void SendMarkerWorldPosition ( const G4VMarker& mark ) ;
G4double GetMarkerHalfSize ( const G4VMarker& mark ) ;
void GetMarkerWorldPosition ( const G4VMarker& mark ,
double* pX ,
double* pY ,
double* pZ ) ;
G4bool IsPVPickable () { return fPVPickable ;}
void SetPVPickability ( G4bool on_off ) { fPVPickable = on_off ;}
G4double SetPVTransparency () ;
G4double GetPVTransparency () { return fPVTransparency ; }
// data
private:
G4VRML2& fSystem; // Graphics system for this scene.
G4bool fPVPickable ;
G4double fPVTransparency ;
static G4int fSceneIdCount;
public:
G4FRClient fDest ;
};
#endif //G4VRML2_SCENE_HH
#endif //G4VIS_BUILD_VRML_DRIVER
#endif //WIN32
@@ -1,67 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML2Viewer.hh
// Satoshi Tanaka & Yasuhide Sawada
#ifndef WIN32
#ifdef G4VIS_BUILD_VRML_DRIVER
#ifndef G4VRML2_VIEWER_HH
#define G4VRML2_VIEWER_HH
#include "G4VViewer.hh"
#include "globals.hh"
#include "G4FRClient.hh"
class G4VRML2SceneHandler;
class G4VRML2Viewer: public G4VViewer {
public:
G4VRML2Viewer(G4VRML2SceneHandler& scene, const G4String& name = "");
virtual ~G4VRML2Viewer();
void ClearView();
void DrawView();
void ShowView();
void FinishView();
private:
void SetView(); // Do nothing. SendViewParameters will do its job.
void SendViewParameters () ;
private:
G4VRML2SceneHandler& fSceneHandler; // Reference to Graphics Scene for this view.
G4FRClient& fDest ;
G4double fViewHalfAngle ;
G4double fsin_VHA ;
};
#endif //G4VRML2_VIEW_HH
#endif //G4VIS_BUILD_VRML_DRIVER
#endif //WIN32
@@ -1,44 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRMLNetConfig.hh
// Satoshi Tanaka
#ifndef WIN32
#ifdef G4VIS_BUILD_VRML_DRIVER
#ifndef G4VRML_NET_CONFIG_HH
#define G4VRML_NET_CONFIG_HH
const int FR_VRML_DEFAULT_PORT = 40801 ;
const char FR_VRML_PORT_ENV [] = "G4VRML_PORT" ;
const char FR_VRML_HOST_NAME_ENV[] = "G4VRML_HOST_NAME" ;
#endif // G4VRML_NET_CONFIG_HH
#endif // G4VIS_BUILD_VRML_DRIVER
#endif //WIN32
+7 -49
View File
@@ -1,58 +1,16 @@
# - G4VRML module build definition
# Module has optional sources
# List those always built
set(G4VIS_VRML_MODULE_HEADERS
G4VRML1File.hh
G4VRML1FileSceneHandler.hh
G4VRML1FileViewer.hh
G4VRML2File.hh
G4VRML2FileSceneHandler.hh
G4VRML2FileViewer.hh)
set(G4VIS_VRML_MODULE_SOURCES
G4VRML1File.cc
G4VRML1FileSceneHandler.cc
G4VRML1FileViewer.cc
G4VRML1SceneHandlerFunc.icc
G4VRML2File.cc
G4VRML2FileSceneHandler.cc
G4VRML2FileViewer.cc
G4VRML2SceneHandlerFunc.icc)
# VRML Network drivers only if user selected
if(GEANT4_USE_NETWORKVRML)
list(APPEND G4VIS_VRML_MODULE_HEADERS
FRClient.h
G4FRClient.hh
G4VRML1.hh
G4VRML1SceneHandler.hh
G4VRML1Viewer.hh
G4VRML2.hh
G4VRML2SceneHandler.hh
G4VRML2Viewer.hh
G4VRMLNetConfig.hh)
list(APPEND G4VIS_VRML_MODULE_SOURCES
FRClient.cc
G4FRClient.cc
G4VRML1.cc
G4VRML1SceneHandler.cc
G4VRML1Viewer.cc
G4VRML2.cc
G4VRML2SceneHandler.cc
G4VRML2Viewer.cc)
# Add extra needed defs here
add_definitions(-DG4VIS_BUILD_VRML_DRIVER)
endif()
# Define the Geant4 Module.
geant4_add_module(G4VRML
PUBLIC_HEADERS
${G4VIS_VRML_MODULE_HEADERS}
G4VRML2File.hh
G4VRML2FileSceneHandler.hh
G4VRML2FileViewer.hh
SOURCES
${G4VIS_VRML_MODULE_SOURCES})
G4VRML2File.cc
G4VRML2FileSceneHandler.cc
G4VRML2FileViewer.cc
G4VRML2SceneHandlerFunc.icc)
geant4_module_link_libraries(G4VRML
PUBLIC
-158
View File
@@ -1,158 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// FRClient.cc
// FukuiRenderer Client
// Yasuhide Sawada & Satoshi Tanaka
//=================//
#ifndef WIN32
//=================//
//=================//
#ifdef G4VIS_BUILD_VRML_DRIVER
//=================//
#include "G4ios.hh"
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include "G4VisManager.hh"
#include "FRClient.h"
FRClient::FRClient()
{
fd = -1;
create();
}
FRClient::~FRClient()
{
close();
}
int FRClient::create()
{
/* stream socket */
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
fputs("error: socket.\n", stderr);
return fd;
}
int FRClient::connect(const char *hostname, int port_)
{
// local variables
struct sockaddr_in sa;
struct hostent *hp;
// set port ( sa.sin_family, sa.sin_port )
port = port_; // Store port number to data member
memset( (char *)&sa, '\0', sizeof(sa)) ;
sa.sin_family = AF_INET;
sa.sin_port = htons(port);
// set server host ( sa.sin_addr )
if (hostname == NULL) {
hostname = "localhost";
// reset arg
}
hp = gethostbyname(hostname) ;
if ( !hp ) {
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "ERROR: gethostbyname() failed" << G4endl;
return -1;
}
memcpy( (char * )&sa.sin_addr, (char * )hp->h_addr, hp->h_length );
// make connection to server
if (::connect(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
fputs("error: connect\n", stderr);
return -1;
}
// return file descripter (data member)
return fd;
}
int FRClient::send(const char *sendbuf)
{
int len = strlen(sendbuf);
if (::send(fd, sendbuf, len, 0) < 0) {
fputs("error: Send()\n", stderr);
len = -1;
}
return len;
}
int FRClient::receive(char *recvbuf)
{
int len;
memset(recvbuf, '\0', FRSendLength + 1);
len = ::recv(fd, recvbuf, FRSendLength, 0);
if(len < 0) {
fputs("error: Receive()\n", stderr);
len = -1;
}
return len;
}
int FRClient::close()
{
/*
shutdown :argument '2' means shutdown both send and receive.
*/
if (::shutdown(fd, 2) < 0) {
fputs("error: shutdown\n", stderr);
return -1;
}
::close(fd);
return 0;
}
#endif //G4VIS_BUILD_VRML_DRIVER
#endif // WIN32
-123
View File
@@ -1,123 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4FRClient.cc
// Yasuhide Sawada & Satoshi Tanaka
//=================//
#ifndef WIN32
//=================//
//=================//
#ifdef G4VIS_BUILD_VRML_DRIVER
//=================//
#include <stdio.h>
#include "G4FRClient.hh"
#include "FRClient.h"
G4FRClient::G4FRClient()
{
fFRClient = NULL;
fPort = -1;
connected = false;
}
G4FRClient::~G4FRClient()
{
if (connected)
this->close();
}
G4bool G4FRClient::connect(const char *hostname, G4int port)
{
if (connected)
return false;
delete fFRClient;
fFRClient = new FRClient();
fPort = port;
connected = (fFRClient->connect(hostname, port) < 0) ? false : true ;
return connected;
}
void G4FRClient::close()
{
delete fFRClient;
fFRClient = NULL;
connected = false;
}
G4int G4FRClient::getPort() const
{
return fPort;
}
G4FRClient& G4FRClient::operator << (G4int val)
{
char buf[64];
sprintf(buf, "%d", val);
fFRClient->send(buf);
return *this;
}
G4FRClient& G4FRClient::operator << (G4double val)
{
char buf[64];
sprintf(buf, "%g", val);
fFRClient->send(buf);
return *this;
}
G4FRClient& G4FRClient::operator << (const char *pval)
{
fFRClient->send(pval);
return *this;
}
G4FRClient& G4FRClient::operator << (G4FRClient& (*func)(G4FRClient&))
{
return func(*this);
}
////////////////////////////////////////
////manipulator
//G4FRClient& endl(G4FRClient& c)
//{
// return c << "\n";
//}
///////////////////////////////////////
#endif //G4VIS_BUILD_VRML_DRIVER
#endif //WIN32
-94
View File
@@ -1,94 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1.cc
// Yasuhide Sawada & Satoshi Tanaka
#ifndef WIN32
//=================//
#ifdef G4VIS_BUILD_VRML_DRIVER
//=================//
#include <stdio.h> // sscanf
#include <stdlib.h> // getenv
#include "G4VSceneHandler.hh"
#include "G4VRML1.hh"
#include "G4VRML1SceneHandler.hh"
#include "G4VRML1Viewer.hh"
#include "G4FRClient.hh"
G4VRML1::G4VRML1() :
G4VGraphicsSystem("VRML1", "VRML1", G4VGraphicsSystem::threeD)
{
// port number
fPort = FR_VRML_DEFAULT_PORT;
char *pport = std::getenv(FR_VRML_PORT_ENV);
if (pport) {
sscanf(pport, "%d", &fPort);
}
// host name
fHostName = "localhost" ; // G4String::operator = ( const char* cs )
char *phostname = std::getenv(FR_VRML_HOST_NAME_ENV);
if (phostname) {
fHostName = phostname;
}
}
G4VRML1::~G4VRML1()
{
}
G4VSceneHandler* G4VRML1::CreateSceneHandler(const G4String& name)
{
G4VSceneHandler *p = NULL;
p = new G4VRML1SceneHandler(*this, name);
return p;
}
G4VViewer* G4VRML1::CreateViewer(G4VSceneHandler& scene, const G4String& name)
{
G4VViewer* pView = NULL;
G4VRML1SceneHandler* pScene = (G4VRML1SceneHandler*)&scene;
pView = new G4VRML1Viewer(*pScene, name);
return pView;
}
#endif
#endif
@@ -1,70 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1File.cc
// Satoshi Tanaka & Yasuhide Sawada
#include <stdio.h> // sscanf
#include <stdlib.h> // getenv
#include "G4VSceneHandler.hh"
#include "G4VRML1File.hh"
#include "G4VRML1FileSceneHandler.hh"
#include "G4VRML1FileViewer.hh"
#include "G4FRClient.hh"
G4VRML1File::G4VRML1File() :
G4VGraphicsSystem("VRML1FILE", "VRML1FILE", G4VGraphicsSystem::fileWriter)
{
}
G4VRML1File::~G4VRML1File()
{
}
G4VSceneHandler* G4VRML1File::CreateSceneHandler(const G4String& name)
{
G4VSceneHandler *p = NULL;
p = new G4VRML1FileSceneHandler(*this, name);
return p;
}
G4VViewer* G4VRML1File::CreateViewer(G4VSceneHandler& scene, const G4String& name)
{
G4VViewer* pView = NULL;
G4VRML1FileSceneHandler* pScene = (G4VRML1FileSceneHandler*)&scene;
pView = new G4VRML1FileViewer(*pScene, name);
return pView;
}
@@ -1,227 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1FileSceneHandler.cc
// Satoshi Tanaka & Yasuhide Sawada
//#define DEBUG_FR_SCENE
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <iomanip>
#include "globals.hh"
#include "G4VisManager.hh"
#include "G4Scene.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4Point3D.hh"
#include "G4VisAttributes.hh"
#include "G4Polyhedron.hh"
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Polyline.hh"
#include "G4Trd.hh"
#include "G4Tubs.hh"
#include "G4Trap.hh"
#include "G4Para.hh"
#include "G4Torus.hh"
#include "G4Sphere.hh"
#include "G4Text.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4VRML1FileSceneHandler.hh"
#include "G4VRML1FileViewer.hh"
#include "G4VRML1File.hh"
// CONST
const char WRL_FILE_HEADER [] = "g4_";
const char DEFAULT_WRL_FILE_NAME[] = "g4.wrl";
const char ENV_VRML_VIEWER [] = "G4VRMLFILE_VIEWER";
const char NO_VRML_VIEWER [] = "NONE";
const char VRMLFILE_DEST_DIR [] = "G4VRMLFILE_DEST_DIR";
const int DEFAULT_MAX_WRL_FILE_NUM = 100 ;
G4VRML1FileSceneHandler::G4VRML1FileSceneHandler(G4VRML1File& system, const G4String& name) :
G4VSceneHandler(system, fSceneIdCount++, name),
fSystem(system),
fDest() ,
fFlagDestOpen( false )
{
fCurrentDEF = "";
strcpy(fVRMLFileName, "");
if ( std::getenv( VRMLFILE_DEST_DIR ) == NULL ) {
strcpy( fVRMLFileDestDir, "" );
} else {
strcpy( fVRMLFileDestDir, std::getenv( VRMLFILE_DEST_DIR ) );
}
// maximum number of g4.wrl files in the dest directory
fMaxFileNum = DEFAULT_MAX_WRL_FILE_NUM ; // initialization
if ( std::getenv( "G4VRMLFILE_MAX_FILE_NUM" ) != NULL ) {
sscanf( std::getenv("G4VRMLFILE_MAX_FILE_NUM"), "%d", &fMaxFileNum ) ;
} else {
fMaxFileNum = DEFAULT_MAX_WRL_FILE_NUM ;
}
if( fMaxFileNum < 1 ) { fMaxFileNum = 1; }
}
G4VRML1FileSceneHandler::~G4VRML1FileSceneHandler()
{
#if defined DEBUG_FR_SCENE
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** ~G4VRML1FileSceneHandler" << G4endl;
#endif
VRMLEndModeling();
}
#define G4VRML1SCENEHANDLER G4VRML1FileSceneHandler
#define IS_CONNECTED this->isConnected()
#include "G4VRML1SceneHandlerFunc.icc"
#undef IS_CONNECTED
#undef G4VRML1SCENEHANDLER
void G4VRML1FileSceneHandler::connectPort()
{
// g4_00.wrl, g4_01.wrl, ..., g4_MAX_FILE_INDEX.wrl
const int MAX_FILE_INDEX = fMaxFileNum - 1 ;
// dest directory (null if no environmental variables is set)
strcpy ( fVRMLFileName, fVRMLFileDestDir) ;
// create (full) path name (default)
strcat ( fVRMLFileName, DEFAULT_WRL_FILE_NAME );
// Determine VRML file name
for( int i = 0 ; i < fMaxFileNum ; i++) {
// Message in the final execution
if( i == MAX_FILE_INDEX )
{
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "===========================================" << G4endl;
G4cout << "WARNING MESSAGE from VRML1FILE driver: " << G4endl;
G4cout << " This file name is the final one in the " << G4endl;
G4cout << " automatic updation of the output file name." << G4endl;
G4cout << " You may overwrite existing files, i.e. " << G4endl;
G4cout << " g4_XX.wrl. " << G4endl;
G4cout << "===========================================" << G4endl;
}
}
// re-determine file name as G4VRMLFILE_DEST_DIR/g4_XX.wrl
std::ostringstream filename;
filename
<< fVRMLFileDestDir << WRL_FILE_HEADER
<< std::setw(2) << std::setfill('0') << i << ".wrl";
strncpy(fVRMLFileName,filename.str().c_str(),sizeof(fVRMLFileName)-1);
fVRMLFileName[sizeof(fVRMLFileName)-1] = '\0';
// check validity of the file name
std::ifstream fin ;
fin.open(fVRMLFileName) ;
if(!fin) {
// new file
fin.close();
break;
} else {
// already exists (try next)
fin.close();
}
} // for
// open a VRML 1.0 file with determined file name
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "===========================================" << G4endl;
G4cout << "Output VRML 1.0 file: " << fVRMLFileName << G4endl;
G4cout << "Maximum number of files in the destination directory: " << fMaxFileNum << G4endl;
G4cout << " (Customizable with the environment variable: G4VRMLFILE_MAX_FILE_NUM) " << G4endl;
G4cout << "===========================================" << G4endl;
}
fDest.open(fVRMLFileName) ; fFlagDestOpen = true ;
}
void G4VRML1FileSceneHandler::closePort()
{
char command[256] ;
char viewer [256] ;
strcpy( viewer, NO_VRML_VIEWER ); // initialization
if( std::getenv( ENV_VRML_VIEWER ) ) {
strcpy( viewer, std::getenv( ENV_VRML_VIEWER ) ) ;
}
// close VRML file
fDest.close(); fFlagDestOpen = false ;
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "*** VRML 1.0 File " << fVRMLFileName << " is generated." << G4endl;
// Invoke viewer
if ( !strcmp(viewer, NO_VRML_VIEWER )) {
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "MESSAGE from VRML1FILE driver:" << G4endl;
G4cout << " Set an environmental variable " ;
G4cout << ENV_VRML_VIEWER << G4endl;
G4cout << " if you want to visualize the generated VRML file" << G4endl;
G4cout << " automatically. For example, " << G4endl;
G4cout << " setenv " << ENV_VRML_VIEWER << " vrweb " << G4endl;
}
} else {
std::ostringstream ossCommand;
ossCommand << viewer << ' ' << fVRMLFileName;
strncpy(command,ossCommand.str().c_str(),sizeof(command)-1);
command[sizeof(command)-1] = '\0';
int iErr = system( command );
if ( iErr != 0 ) {
G4ExceptionDescription ed;
ed << "Error " << iErr
<< " when calling system with \"" << command
<< "\".";
G4Exception("G4VRML1FileSceneHandler::closePort()",
"VRML-1006", JustWarning, ed);
}
}
}
G4int G4VRML1FileSceneHandler::fSceneIdCount = 0;
@@ -1,105 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRMLView.cc
// Satoshi Tanaka & Yasuhide Sawada
//#define DEBUG_FR_VIEW
#include "G4VisManager.hh"
#include "G4Scene.hh"
#include "G4VRML1FileViewer.hh"
#include "G4VRML1FileSceneHandler.hh"
#include "G4VRML1File.hh"
#include "G4ios.hh"
G4VRML1FileViewer::G4VRML1FileViewer(G4VRML1FileSceneHandler& sceneHandler,
const G4String& name) :
G4VViewer(sceneHandler,
sceneHandler.IncrementViewCount(),
name),
fSceneHandler(sceneHandler)
{}
G4VRML1FileViewer::~G4VRML1FileViewer()
{}
void G4VRML1FileViewer::SetView()
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML1FileViewer::SetView(): No effects" << G4endl;
#endif
}
void G4VRML1FileViewer::DrawView()
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML1FileViewer::DrawView()" << G4endl;
#endif
fSceneHandler.VRMLBeginModeling();
// Here is a minimal DrawView() function.
NeedKernelVisit();
ProcessView();
FinishView();
}
void G4VRML1FileViewer::ClearView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML1File1View::ClearView()" << G4endl;
#endif
if(fSceneHandler.fFlagDestOpen) {
fSceneHandler.fDest.close();
// Re-open with same filename...
fSceneHandler.fDest.open(fSceneHandler.fVRMLFileName);
fSceneHandler.fDest << "#VRML V1.0 ascii" << "\n";
fSceneHandler.fDest << "# Generated by VRML 1.0 driver of GEANT4\n" << "\n";
}
}
void G4VRML1FileViewer::ShowView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML1FileViewer::ShowView()" << G4endl;
#endif
fSceneHandler.VRMLEndModeling();
}
void G4VRML1FileViewer::FinishView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML1FileViewer::FinishView(): No effects" << G4endl;
#endif
}
@@ -1,142 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1SceneHandler.cc
// Yasuhide Sawada and Satoshi Tanaka
#ifndef WIN32
//=================//
#ifdef G4VIS_BUILD_VRML_DRIVER
//=================//
//#define DEBUG_FR_SCENE
#include <unistd.h>
#include <fstream>
#include "globals.hh"
#include "G4VisManager.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4Point3D.hh"
#include "G4Scene.hh"
#include "G4VisAttributes.hh"
#include "G4Polyhedron.hh"
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Polyline.hh"
#include "G4Trd.hh"
#include "G4Tubs.hh"
#include "G4Trap.hh"
#include "G4Para.hh"
#include "G4Torus.hh"
#include "G4Sphere.hh"
#include "G4Text.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4VRML1SceneHandler.hh"
#include "G4VRML1Viewer.hh"
#include "G4VRML1.hh"
G4VRML1SceneHandler::G4VRML1SceneHandler(G4VRML1& system, const G4String& name) :
G4VSceneHandler(system, fSceneIdCount++, name),
fSystem(system),
fDest()
{
fCurrentDEF = "";
}
G4VRML1SceneHandler::~G4VRML1SceneHandler()
{
#if defined DEBUG_FR_SCENE
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** ~G4VRML1SceneHandler" << G4endl;
#endif
}
#define G4VRML1SCENEHANDLER G4VRML1SceneHandler
#define IS_CONNECTED fDest.isConnected()
#include "G4VRML1SceneHandlerFunc.icc"
#undef IS_CONNECTED
#undef G4VRML1SCENEHANDLER
void G4VRML1SceneHandler::connectPort(G4int max_trial)
{
G4int trial = 0 ;
int port = fSystem.getPort();
for (trial = 0; !fDest.isConnected()&& trial < max_trial; trial++, port++ ) {
if (fDest.connect( (const char * )fSystem.getHostName(), port)) {
// INET domain connection is established
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "*** GEANT4 is connected to port ";
G4cout << fDest.getPort();
G4cout << " of server " << fSystem.getHostName() << G4endl;
}
break;
} else {
// Connection failed. Try the next port.
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "*** GEANT4 incremented targeting port to ";
G4cout << port << G4endl;
}
}
sleep (1);
} // for
if (!fDest.isConnected()) {
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "*** INET Connection failed. " << G4endl;
G4cout << " Maybe, you have not invoked viewer g4vrmlview yet, " << G4endl;
G4cout << " or too many viewers are already running in the " << G4endl;
G4cout << " server host(" << fSystem.getHostName() << "). " << G4endl;
}
}
}
void G4VRML1SceneHandler::closePort()
{
fDest.close();
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "*** INET Connection closed. " << G4endl;
}
G4int G4VRML1SceneHandler::fSceneIdCount = 0;
#endif
#endif
@@ -1,747 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML1SceneHandlerFunc.icc
// Satoshi Tanaka & Yasuhide Sawada
#include <CLHEP/Units/SystemOfUnits.h>
#include "G4VisManager.hh"
//#define DEBUG_SCENE_FUNC
// MACRO
#define ADDTHIS_WITH_NAME(Solid) \
fCurrentDEF = #Solid "_" + Solid.GetName(); \
RequestPrimitives(Solid); \
fCurrentDEF = "";
// End of MACRO
void G4VRML1SCENEHANDLER::AddSolid(const G4Trd& trd)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddSolid trd" << "\n" ;
#endif
VRMLBeginModeling () ;
ADDTHIS_WITH_NAME(trd)
}
void G4VRML1SCENEHANDLER::AddSolid(const G4Trap& trap)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddSolid trap" << "\n" ;
#endif
VRMLBeginModeling () ;
ADDTHIS_WITH_NAME(trap)
}
void G4VRML1SCENEHANDLER::AddSolid(const G4Para& para)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddSolid para" << "\n" ;
#endif
VRMLBeginModeling () ;
ADDTHIS_WITH_NAME(para)
}
void G4VRML1SCENEHANDLER::AddSolid(const G4Torus& torus )
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddSolid torus" << "\n" ;
#endif
VRMLBeginModeling () ;
ADDTHIS_WITH_NAME(torus)
}
void G4VRML1SCENEHANDLER::AddSolid(const G4VSolid& vsolid)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddSolid vsolid" << "\n" ;
#endif
VRMLBeginModeling () ;
ADDTHIS_WITH_NAME(vsolid)
}
void G4VRML1SCENEHANDLER::AddSolid(const G4Tubs& tubs)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddSolid tubs" << "\n" ;
#endif
VRMLBeginModeling () ;
// set current name
fCurrentDEF = "tubs_" + tubs.GetName();
// Get data
const G4double R = tubs.GetOuterRadius(); // outside radius
const G4double r = tubs.GetInnerRadius(); // inside radius
const G4double dz = tubs.GetZHalfLength(); // half length in z
const G4double dp = tubs.GetDeltaPhiAngle(); // angle interval
// Send data
if ( r == 0.0 && dp >= 360. * CLHEP::deg ) {
// Send a built-in VRML node (Cylinder)
fDest << "Separator {" << "\n";
SendMatrixTransformNode( fObjectTransformation );
fDest << "\t" << "DEF " << fCurrentDEF << " Separator {" << "\n";
SendMaterialNode();
SendCylinderNode(R, dz * 2);
fDest << "\t" << "}" << "\n"; // DEF Separator
fDest << "}" << "\n"; // Separator
} else {
// call AddPrimitive(Polyhedron)
RequestPrimitives(tubs);
}
// reset current name to null
fCurrentDEF = "";
}
void G4VRML1SCENEHANDLER::AddSolid(const G4Cons& cons)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddSolid cons" << "\n" ;
#endif
VRMLBeginModeling () ;
// set current name
fCurrentDEF = "cons_" + cons.GetName();
// Get data
const G4double r1 = cons.GetInnerRadiusMinusZ(); // inside radius at -dz
const G4double R1 = cons.GetOuterRadiusMinusZ(); // outside radius at -dz
const G4double r2 = cons.GetInnerRadiusPlusZ(); // inside radius at +dz
const G4double R2 = cons.GetOuterRadiusPlusZ(); // outside radius at +dz
const G4double dz = cons.GetZHalfLength(); // half length in z
//const G4double sp = cons.GetStartPhiAngle(); // starting angle
const G4double dp = cons.GetDeltaPhiAngle(); // angle width
// Send data
if ( r1 == 0.0 && r2 == 0.0 && R1 == R2 && dp >= 360. * CLHEP::deg) {
// Send a built-in VRML node (Cylinder)
fDest << "Separator {" << "\n";
SendMatrixTransformNode( fObjectTransformation );
fDest << "\t" << "DEF " << fCurrentDEF << " Separator {" << "\n";
SendMaterialNode();
SendCylinderNode(R1, dz * 2);
fDest << "\t" << "}" << "\n"; // DEF Separator
fDest << "}" << "\n"; // Separator
} else {
// call AddPrimitive(Polyhedron)
RequestPrimitives(cons);
}
// reset current name to null
fCurrentDEF = "";
}
void G4VRML1SCENEHANDLER::AddSolid(const G4Box& box)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddSolid box" << "\n" ;
#endif
VRMLBeginModeling () ;
// set current name
fCurrentDEF = "box_" + box.GetName();
// Send a built-in VRML node (Cube)
fDest << "Separator {" << "\n";
//fDest << "\t" << "renderCulling ON" << "\n";
SendMatrixTransformNode( fObjectTransformation );
fDest << "\t" << "DEF " << fCurrentDEF << " Separator {" << "\n";
SendMaterialNode();
SendCubeNode(box.GetXHalfLength() * 2, box.GetYHalfLength() * 2, box.GetZHalfLength() * 2);
fDest << "\t" << "}" << "\n"; // DEF Separator
fDest << "}" << "\n"; // Separator
// reset current name to null
fCurrentDEF = "";
}
void G4VRML1SCENEHANDLER::AddSolid(const G4Sphere& sphere)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddSolid sphere" << "\n" ;
#endif
VRMLBeginModeling () ;
// set current name
fCurrentDEF = "sphere_" + sphere.GetName();
// Get data
G4double dphi = sphere.GetDeltaPhiAngle () ;
G4double dtheta = sphere.GetDeltaThetaAngle() ;
G4double rmax = sphere.GetOuterRadius () ;
G4double rmin = sphere.GetInnerRadius () ;
// Send data
if ( (dphi >= 360. * CLHEP::deg) && (dtheta >= 180. * CLHEP::deg) && (rmin == 0.0) ) {
// Send a built-in VRML node (Sphere)
fDest << "Separator {" << "\n";
SendMatrixTransformNode( fObjectTransformation );
fDest << "\t" << "DEF " << fCurrentDEF << " Separator {" << "\n";
SendMaterialNode();
SendSphereNode( rmax );
fDest << "\t" << "}" << "\n"; // DEF Separator
fDest << "}" << "\n"; // Separator
} else {
// call AddPrimitive(Polyhedron)
RequestPrimitives( sphere );
}
// reset current name to null
fCurrentDEF = "";
}
void G4VRML1SCENEHANDLER::AddPrimitive(const G4Polyline& polyline)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddPrimitive polyline" << "\n" ;
#endif
if (fProcessing2D) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4Exception
("G4VRML1SCENEHANDLER::AddPrimitive (const G4Polyline&)",
"VRML-1001", JustWarning,
"2D polylines not implemented. Ignored.");
}
return;
}
VRMLBeginModeling () ;
fDest << "Separator {" << "\n";
SendMatrixTransformNode (fObjectTransformation );
SendMaterialNode( polyline.GetVisAttributes() );
fDest << "\t" << "Coordinate3 {" << "\n";
fDest << "\t\t" << "point [" << "\n";
G4int e, i;
for (i = 0, e = polyline.size(); e; i++, e--) {
fDest << "\t\t\t";
fDest << polyline[i].x() << " ";
fDest << polyline[i].y() << " ";
fDest << polyline[i].z() << "," << "\n";
}
fDest << "\t\t" << "]" << "\n";
fDest << "\t" << "}" << "\n"; // Coordinate3
fDest << "\t" << "IndexedLineSet {" << "\n";
fDest << "\t\t" << "coordIndex [";
for (i = 0, e = polyline.size(); e; i++, e--) {
if (i % 10 == 0)
fDest << "\n" << "\t\t\t";
fDest << i << ", ";
}
fDest << "-1" << "\n";
fDest << "\t\t" << "]" << "\n";
fDest << "\t" << "}" << "\n"; // IndexedLineSet
fDest << "}" << "\n"; // Separator
}
void G4VRML1SCENEHANDLER::AddPrimitive(const G4Polyhedron& polyhedron)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddPrimitive(G4Polyhedron)" << "\n";
#endif
if (polyhedron.GetNoFacets() == 0) return;
if (fProcessing2D) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4Exception
("G4VRML1SCENEHANDLER::AddPrimitive (const G4Polyhedron&)",
"VRML-1002", JustWarning,
"2D polyhedra not implemented. Ignored.");
}
return;
}
VRMLBeginModeling () ;
fDest << "Separator {" << "\n";
SendMatrixTransformNode( fObjectTransformation );
fDest << "\t";
if (fCurrentDEF != "")
fDest << "DEF " << fCurrentDEF << " ";
fDest << "Separator {" << "\n";
//fDest << "\t\t" << "renderCulling ON" << "\n";
fDest << "\t\t" << "ShapeHints {" << "\n";
fDest << "\t\t\t" << "vertexOrdering COUNTERCLOCKWISE" << "\n";
fDest << "\t\t\t" << "shapeType SOLID" << "\n";
fDest << "\t\t\t" << "faceType CONVEX" << "\n";
fDest << "\t\t" << "}" << "\n";
SendMaterialNode();
fDest << "\t\t" << "Coordinate3 {" << "\n";
fDest << "\t\t\t" << "point [" << "\n";
G4int i, j;
for (i = 1, j = polyhedron.GetNoVertices(); j; j--, i++) {
G4Point3D point = polyhedron.GetVertex(i);
fDest << "\t\t\t\t";
fDest << point.x() << " ";
fDest << point.y() << " ";
fDest << point.z() << "," << "\n";
}
fDest << "\t\t\t" << "]" << "\n";
fDest << "\t\t" << "}" << "\n"; // Coordinate3
fDest << "\t\t" << "IndexedFaceSet {" << "\n";
fDest << "\t\t\t" << "coordIndex [" << "\n";
// facet loop
G4int f;
for (f = polyhedron.GetNoFacets(); f; f--) {
// edge loop
G4bool notLastEdge;
G4int index = -1, edgeFlag = 1;
fDest << "\t\t\t\t";
do {
notLastEdge = polyhedron.GetNextVertexIndex(index, edgeFlag);
fDest << index - 1 << ", ";
} while (notLastEdge);
fDest << "-1," << "\n";
}
fDest << "\t\t\t" << "]" << "\n";
fDest << "\t\t" << "}" << "\n"; // IndexFaceSet
fDest << "\t" << "}" << "\n"; // (DEF) Separator
fDest << "}" << "\n"; // Separator
}
void G4VRML1SCENEHANDLER::AddPrimitive( const G4Text& )
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddPrimitive text" << "\n" ;
#endif
/*** You might need this
if (fProcessing2D) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4Exception
("G4VRML1SCENEHANDLER::AddPrimitive (const G4Text&)",
"VRML-1003", JustWarning,
"2D text not implemented. Ignored.");
}
return;
}
***/
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout <<
"***** void G4VRML1SCENEHANDLER::AddPrimitive( const G4Text& text )"
" not implemented yet."
<< "\n";
VRMLBeginModeling () ;
}
void G4VRML1SCENEHANDLER::AddPrimitive( const G4Circle& circle )
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddPrimitive circle" << "\n" ;
#endif
if (fProcessing2D) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4Exception
("G4VRML1SCENEHANDLER::AddPrimitive (const G4Circle&)",
"VRML-1004", JustWarning,
"2D circles not implemented. Ignored.");
}
return;
}
VRMLBeginModeling () ;
// begin sending a mark
fDest << "Separator {" << "\n";
// send color
SendMarkerColor ( circle ) ;
// position
SendMarkerWorldPosition ( circle ) ;
// Calc size
G4double size = GetMarkerHalfSize ( circle );
// send shape with size
fDest << "\t" << "Sphere {" << "\n";
fDest << "\t\t" << "radius " << size << "\n";
fDest << "\t" << "}" << "\n";
// end sending a mark
fDest << "}" << "\n"; // Separator
}
void G4VRML1SCENEHANDLER::AddPrimitive(const G4Square& square)
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** AddPrimitive square" << "\n" ;
#endif
if (fProcessing2D) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4Exception
("G4VRML1SCENEHANDLER::AddPrimitive (const G4Square&)",
"VRML-1005", JustWarning,
"2D squares not implemented. Ignored.");
}
return;
}
VRMLBeginModeling () ;
// begin sending a mark
fDest << "Separator {" << "\n";
// send color
SendMarkerColor ( square );
// position
SendMarkerWorldPosition ( square );
// Calc size
G4double size = GetMarkerHalfSize ( square );
size *= 2.;
// send shape with size
fDest << "\t" << "Cube {" << "\n";
fDest << "\t\t" << "width " << size << "\n";
fDest << "\t\t" << "height " << size << "\n";
fDest << "\t\t" << "depth " << size << "\n";
fDest << "\t" << "}" << "\n";
// end sending a mark
fDest << "}" << "\n"; // Separator
}
void G4VRML1SCENEHANDLER::BeginModeling()
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** BeginModeling " << "\n" ;
#endif
G4VSceneHandler::BeginModeling();
}
void G4VRML1SCENEHANDLER::EndModeling()
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** EndModeling " << "\n" ;
#endif
G4VSceneHandler::EndModeling();
}
void G4VRML1SCENEHANDLER::BeginPrimitives(const G4Transform3D& objectTransformation)
{
G4VSceneHandler::BeginPrimitives (objectTransformation);
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** BeginPrimitives " << "\n" ;
#endif
VRMLBeginModeling();
}
void G4VRML1SCENEHANDLER::EndPrimitives()
{
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** EndPrimitives " << "\n" ;
#endif
G4VSceneHandler::EndPrimitives();
}
void G4VRML1SCENEHANDLER::SendMaterialNode( const G4VisAttributes* pVA )
{
// const double TRANSPARENCY = 0.9 ;
const double TRANSPARENCY = 0.5 ;
if (!pVA)
return;
const G4Color& color = pVA->GetColor();
fDest << "\t\t" << "Material {" << "\n";
if (pVA->IsForceDrawingStyle() &&
(pVA->GetForcedDrawingStyle() == G4VisAttributes::wireframe)) {
fDest << "\t\t\t" << "transparency " << TRANSPARENCY << "\n";
}
fDest << "\t\t\t" << "diffuseColor";
fDest << " " << color.GetRed();
fDest << " " << color.GetGreen();
fDest << " " << color.GetBlue();
fDest << "\n";
fDest << "\t\t" << "}" << "\n";
}
void G4VRML1SCENEHANDLER::SendMaterialNode()
{
SendMaterialNode
( fpViewer->GetApplicableVisAttributes (fpVisAttribs) );
}
void G4VRML1SCENEHANDLER::SendMatrixTransformNode(const G4Transform3D& trans)
{
G4Point3D B (0.0, 0.0, 0.0);
G4Point3D x1 (1.0, 0.0, 0.0);
G4Point3D y1 (0.0, 1.0, 0.0);
G4Vector3D e1 (1.0, 0.0, 0.0);
G4Vector3D e2 (0.0, 1.0, 0.0);
G4Vector3D e3 (0.0, 0.0, 1.0);
//----- transformed origin of body coord
B.transform(trans);
//----- transformed base vectors of body coord
x1.transform(trans);
e1 = x1 - B;
y1.transform(trans);
e2 = y1 - B;
e3 = e1.cross(e2);
e1 = e1.unit(); // normalize again for accuracy
e2 = e2.unit(); //
e3 = e3.unit(); //
fDest << "\t" << "MatrixTransform {" << "\n";
fDest << "\t\t" << "matrix ";
fDest << e1.x() << " " << e1.y() << " " << e1.z() << " 0 ";
fDest << e2.x() << " " << e2.y() << " " << e2.z() << " 0 ";
fDest << e3.x() << " " << e3.y() << " " << e3.z() << " 0 ";
fDest << B.x() << " " << B.y() << " " << B.z() << " 1" << "\n";
fDest << "\t" << "}" << "\n";
}
void G4VRML1SCENEHANDLER::SendCubeNode(G4double w, G4double h, G4double d)
{
fDest << "\t\t" << "Cube {" << "\n";
fDest << "\t\t\t" << "width " << w << "\n";
fDest << "\t\t\t" << "height " << h << "\n";
fDest << "\t\t\t" << "depth " << d << "\n";
fDest << "\t\t" << "}" << "\n";
}
void G4VRML1SCENEHANDLER::SendCylinderNode(G4double R, G4double h)
{
fDest << "\t\t" << "Transform {" << "\n";
fDest << "\t\t\t" << "rotation 1 0 0 " << (90. * CLHEP::deg) << "\n";
fDest << "\t\t" << "}" << "\n";
fDest << "\t\t" << "Cylinder {" << "\n";
fDest << "\t\t\t" << "radius " << R << "\n";
fDest << "\t\t\t" << "height " << h << "\n";
fDest << "\t\t" << "}" << "\n";
}
void G4VRML1SCENEHANDLER::SendSphereNode(G4double R)
{
fDest << "\t\t" << "Sphere {" << "\n";
fDest << "\t\t\t" << "radius " << R << "\n";
fDest << "\t\t" << "}" << "\n";
}
void G4VRML1SCENEHANDLER::VRMLBeginModeling()
{
if (!IS_CONNECTED ) {
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** VRMLBeginModeling() (started)" << "\n" ;
#endif
this->connectPort();
fDest << "#VRML V1.0 ascii" << "\n";
fDest << "# Generated by VRML 1.0 driver of GEANT4\n" << "\n";
}
}
void G4VRML1SCENEHANDLER::VRMLEndModeling()
{
if ( IS_CONNECTED ) {
#if defined DEBUG_SCENE_FUNC
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** VRMLEndModeling() (started)" << "\n" ;
#endif
fDest << "#End of file." << "\n";
this->closePort();
}
}
void G4VRML1SCENEHANDLER::SendMarkerColor ( const G4VMarker& marker )
{
fpVisAttribs = marker.GetVisAttributes();
const G4Color& color = GetColor();
fDest << "\t" << "Material {" << "\n";
fDest << "\t\t";
fDest << "ambientColor [] ";
fDest << "specularColor [] ";
fDest << "\t\t" << "diffuseColor";
fDest << " " << color.GetRed();
fDest << " " << color.GetGreen();
fDest << " " << color.GetBlue();
fDest << "\n";
fDest << "\t\t" << "emissiveColor";
fDest << " " << color.GetRed();
fDest << " " << color.GetGreen();
fDest << " " << color.GetBlue();
fDest << "\n";
fDest << "\t" << "}" << "\n";
}
void
G4VRML1SCENEHANDLER::SendMarkerWorldPosition ( const G4VMarker& mark )
{
G4Point3D point = mark.GetPosition();
SendMatrixTransformNode( fObjectTransformation );
fDest << "\t\t" << "Transform {" << "\n";
fDest << "\t\t\t" << "translation ";
fDest << point.x() << " " << point.y() << " " << point.z() << "\n";
fDest << "\t\t" << "}" << "\n" ;
}
G4double G4VRML1SCENEHANDLER::GetMarkerHalfSize ( const G4VMarker& mark )
{
//----- return value ( marker radius in 3d units)
G4double size = 1.0 ; // initialization
//----- parameters to calculate 3d size from 2d size
const double HALF_SCREEN_SIZE_2D = 300.0 ; // pixels
double zoom_factor = fpViewer->GetViewParameters().GetZoomFactor() ;
if ( zoom_factor <= 0.0 ) { zoom_factor = 1.0 ; }
double extent_radius_3d = GetScene()->GetExtent().GetExtentRadius() ;
if ( extent_radius_3d <= 0.0 ) { extent_radius_3d = 1.0 ; }
//----- get marker radius in 3D units
if ( mark.GetWorldSize() > 0.0 ) {
// get mark radius in 3D units
size = 0.5 * mark.GetWorldSize() ;
} else if ( mark.GetScreenSize() > 0.0 ) {
// local
double mark_radius_2d = 0.5 * mark.GetScreenSize() ;
// get mark radius in 3D units
size \
= extent_radius_3d * ( mark_radius_2d / HALF_SCREEN_SIZE_2D );
size *= zoom_factor ;
} else {
// local
double mark_radius_2d \
= fpViewer->GetViewParameters().GetDefaultMarker().GetScreenSize();
mark_radius_2d *= 0.1 ; // Magic number?
// get mark radius in 3D units
size \
= extent_radius_3d * ( mark_radius_2d / HALF_SCREEN_SIZE_2D );
size *= zoom_factor ;
}
//----- global rescaling
size *= fpViewer->GetViewParameters().GetGlobalMarkerScale();
//----- return size
return size ;
}
void G4VRML1SCENEHANDLER::ClearTransientStore()
{
// This is typically called after an update and before drawing hits
// of the next event. To simulate the clearing of "transients"
// (hits, etc.) the detector is redrawn...
if (fpViewer) {
fpViewer -> SetView ();
fpViewer -> ClearView ();
fpViewer -> DrawView ();
}
}
// #undef ADDTHIS_WITH_NAME(Solid)
// #undef MAKE_NAME(Solid)
// End of file.
@@ -1,104 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRMLView.cc
// Yasuhide Sawada & Satoshi Tanaka
#ifndef WIN32
//=================//
#ifdef G4VIS_BUILD_VRML_DRIVER
//=================//
//#define DEBUG_FR_VIEW
#include "G4VisManager.hh"
#include "G4Scene.hh"
#include "G4VRML1Viewer.hh"
#include "G4VRML1SceneHandler.hh"
#include "G4VRML1.hh"
#include "G4ios.hh"
G4VRML1Viewer::G4VRML1Viewer(G4VRML1SceneHandler& scene, const G4String& name) :
G4VViewer(scene, scene.IncrementViewCount(), name), fSceneHandler(scene)
{}
G4VRML1Viewer::~G4VRML1Viewer()
{}
void G4VRML1Viewer::SetView()
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML1Viewer::SetView(): No effects" << G4endl;
#endif
}
void G4VRML1Viewer::DrawView()
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML1Viewer::DrawView()" << G4endl;
#endif
fSceneHandler.VRMLBeginModeling();
// Here is a minimal DrawView() function.
NeedKernelVisit();
ProcessView();
FinishView();
}
void G4VRML1Viewer::ClearView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML1Viewer::ClearView(): No effects" << G4endl;
#endif
}
void G4VRML1Viewer::ShowView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML1Viewer::ShowView()" << G4endl;
#endif
fSceneHandler.VRMLEndModeling();
}
void G4VRML1Viewer::FinishView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML1Viewer::FinishView(): No effects" << G4endl;
#endif
}
#endif
#endif //WIN32
-93
View File
@@ -1,93 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML2.cc
// Satoshi Tanaka & Yasuhide Sawada
#ifndef WIN32
//=================//
#ifdef G4VIS_BUILD_VRML_DRIVER
//=================//
#include <stdio.h> // sscanf
#include <stdlib.h> // getenv
#include "G4VSceneHandler.hh"
#include "G4VRML2.hh"
#include "G4VRML2SceneHandler.hh"
#include "G4VRML2Viewer.hh"
#include "G4FRClient.hh"
G4VRML2::G4VRML2() :
G4VGraphicsSystem("VRML2", "VRML2", G4VGraphicsSystem::threeD)
{
// port number
fPort = FR_VRML_DEFAULT_PORT;
char *pport = std::getenv(FR_VRML_PORT_ENV);
if (pport) {
sscanf(pport, "%d", &fPort);
}
// host name
fHostName = "localhost" ; // G4String::operator = ( const char* cs )
char *phostname = std::getenv(FR_VRML_HOST_NAME_ENV);
if (phostname) {
fHostName = phostname;
}
}
G4VRML2::~G4VRML2()
{
}
G4VSceneHandler* G4VRML2::CreateSceneHandler(const G4String& name)
{
G4VSceneHandler *p = NULL;
p = new G4VRML2SceneHandler(*this, name);
return p;
}
G4VViewer* G4VRML2::CreateViewer(G4VSceneHandler& scene, const G4String& name)
{
G4VViewer* pView = NULL;
G4VRML2SceneHandler* pScene = (G4VRML2SceneHandler*)&scene;
pView = new G4VRML2Viewer(*pScene, name);
return pView;
}
#endif
#endif //WIN32
+20 -27
View File
@@ -28,8 +28,8 @@
// G4VRML2File.cc
// Satoshi Tanaka & Yasuhide Sawada
#include <stdio.h> // sscanf
#include <stdlib.h> // getenv
#include <stdio.h> // sscanf
#include <stdlib.h> // getenv
#include "G4VSceneHandler.hh"
@@ -37,35 +37,28 @@
#include "G4VRML2FileSceneHandler.hh"
#include "G4VRML2FileViewer.hh"
#include "G4FRClient.hh"
G4VRML2File::G4VRML2File()
: G4VGraphicsSystem("VRML2FILE", "VRML2FILE", G4VGraphicsSystem::fileWriter)
{}
G4VRML2File::~G4VRML2File() {}
G4VRML2File::G4VRML2File() :
G4VGraphicsSystem("VRML2FILE", "VRML2FILE", G4VGraphicsSystem::fileWriter
)
G4VSceneHandler* G4VRML2File::CreateSceneHandler(const G4String& name)
{
G4VSceneHandler* p = NULL;
p = new G4VRML2FileSceneHandler(*this, name);
return p;
}
G4VRML2File::~G4VRML2File()
G4VViewer* G4VRML2File::CreateViewer(G4VSceneHandler& scene,
const G4String& name)
{
}
G4VSceneHandler* G4VRML2File::CreateSceneHandler(const G4String& name)
{
G4VSceneHandler *p = NULL;
p = new G4VRML2FileSceneHandler(*this, name);
return p;
}
G4VViewer* G4VRML2File::CreateViewer(G4VSceneHandler& scene, const G4String& name)
{
G4VViewer* pView = NULL;
G4VRML2FileSceneHandler* pScene = (G4VRML2FileSceneHandler*)&scene;
pView = new G4VRML2FileViewer(*pScene, name);
return pView;
G4VViewer* pView = NULL;
G4VRML2FileSceneHandler* pScene = (G4VRML2FileSceneHandler*) &scene;
pView = new G4VRML2FileViewer(*pScene, name);
return pView;
}
@@ -28,7 +28,6 @@
// G4VRML2FileSceneHandler.cc
// Satoshi Tanaka & Yasuhide Sawada
//#define DEBUG_FR_SCENE
#include <fstream>
@@ -63,179 +62,214 @@
// CONST
const char WRL_FILE_HEADER [] = "g4_";
const char DEFAULT_WRL_FILE_NAME[] = "g4.wrl";
const char ENV_VRML_VIEWER [] = "G4VRMLFILE_VIEWER";
const char NO_VRML_VIEWER [] = "NONE";
const char VRMLFILE_DEST_DIR [] = "G4VRMLFILE_DEST_DIR";
const int DEFAULT_MAX_WRL_FILE_NUM = 100 ;
const char WRL_FILE_HEADER[] = "g4_";
const char ENV_WRL_FILE_HEADER[] = "G4VRMLFILE_HEADER";
const char ENV_WRL_FILE_NAME[] = "G4VRMLFILE_FILE_NAME";
const char ENV_VRML_VIEWER[] = "G4VRMLFILE_VIEWER";
const char NO_VRML_VIEWER[] = "NONE";
const char VRMLFILE_DEST_DIR[] = "G4VRMLFILE_DEST_DIR";
const int DEFAULT_MAX_WRL_FILE_NUM = 100;
G4VRML2FileSceneHandler::G4VRML2FileSceneHandler(G4VRML2File& system, const G4String& name) :
G4VSceneHandler(system, fSceneIdCount++, name),
fSystem(system),
fFlagDestOpen( false ),
fPVPickable ( false ),
fDest()
G4VRML2FileSceneHandler::G4VRML2FileSceneHandler(G4VRML2File& system,
const G4String& name)
: G4VSceneHandler(system, fSceneIdCount++, name)
, fSystem(system)
, fFlagDestOpen(false)
, fPVPickable(false)
, fDest()
{
// output file name
strcpy(fVRMLFileName, "");
// output file name
strcpy(fVRMLFileName, "");
// destination directory
if ( std::getenv( VRMLFILE_DEST_DIR ) == NULL ) {
strcpy( fVRMLFileDestDir, "" );
} else {
strcpy( fVRMLFileDestDir, std::getenv( VRMLFILE_DEST_DIR ) );
}
// destination directory
if(std::getenv(VRMLFILE_DEST_DIR) == NULL)
{
strcpy(fVRMLFileDestDir, "");
}
else
{
strcpy(fVRMLFileDestDir, std::getenv(VRMLFILE_DEST_DIR));
}
// maximum number of g4.prim files in the dest directory
fMaxFileNum = DEFAULT_MAX_WRL_FILE_NUM; // initialization
if(std::getenv("G4VRMLFILE_MAX_FILE_NUM") != NULL)
{
sscanf(std::getenv("G4VRMLFILE_MAX_FILE_NUM"), "%d", &fMaxFileNum);
}
else
{
fMaxFileNum = DEFAULT_MAX_WRL_FILE_NUM;
}
if(fMaxFileNum < 1)
{
fMaxFileNum = 1;
}
// maximum number of g4.prim files in the dest directory
fMaxFileNum = DEFAULT_MAX_WRL_FILE_NUM ; // initialization
if ( std::getenv( "G4VRMLFILE_MAX_FILE_NUM" ) != NULL ) {
sscanf( std::getenv("G4VRMLFILE_MAX_FILE_NUM"), "%d", &fMaxFileNum ) ;
// PV name pickability
if(std::getenv("G4VRML_PV_PICKABLE") != NULL)
{
int is_pickable;
sscanf(std::getenv("G4VRML_PV_PICKABLE"), "%d", &is_pickable);
} else {
fMaxFileNum = DEFAULT_MAX_WRL_FILE_NUM ;
}
if( fMaxFileNum < 1 ) { fMaxFileNum = 1; }
// PV name pickability
if( std::getenv( "G4VRML_PV_PICKABLE" ) != NULL ) {
int is_pickable ;
sscanf( std::getenv("G4VRML_PV_PICKABLE"), "%d", &is_pickable ) ;
if ( is_pickable ) { SetPVPickability ( true ) ; }
}
// PV Transparency
SetPVTransparency ();
if(is_pickable)
{
SetPVPickability(true);
}
}
// PV Transparency
SetPVTransparency();
}
G4VRML2FileSceneHandler::~G4VRML2FileSceneHandler()
{
#if defined DEBUG_FR_SCENE
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** ~G4VRML2FileSceneHandler" << G4endl;
#endif
VRMLEndModeling();
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** ~G4VRML2FileSceneHandler" << G4endl;
#endif
VRMLEndModeling();
}
#define G4VRML2SCENEHANDLER G4VRML2FileSceneHandler
#define IS_CONNECTED this->isConnected()
#define G4VRML2SCENEHANDLER G4VRML2FileSceneHandler
#define IS_CONNECTED this->isConnected()
#include "G4VRML2SceneHandlerFunc.icc"
#undef IS_CONNECTED
#undef G4VRML2SCENEHANDLER
#undef IS_CONNECTED
#undef G4VRML2SCENEHANDLER
void G4VRML2FileSceneHandler::connectPort()
{
// g4_00.wrl, g4_01.wrl, ..., g4_MAX_FILE_INDEX.wrl
const int MAX_FILE_INDEX = fMaxFileNum - 1 ;
// g4_00.wrl, g4_01.wrl, ..., g4_MAX_FILE_INDEX.wrl
const int MAX_FILE_INDEX = fMaxFileNum - 1;
// dest directory (null if no environmental variables is set)
strcpy ( fVRMLFileName, fVRMLFileDestDir) ;
// dest directory (null if no environmental variables is set)
strcpy(fVRMLFileName, fVRMLFileDestDir);
// add filename if environment variable supplied
if(std::getenv(ENV_WRL_FILE_NAME))
{
strcat(fVRMLFileName, std::getenv(ENV_WRL_FILE_NAME));
}
else
{
// Determine VRML file name
for(int i = 0; i < fMaxFileNum; i++)
{
// Message in the final execution
if(i == MAX_FILE_INDEX)
{
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
{
G4cout << "===========================================" << G4endl;
G4cout << "WARNING MESSAGE from VRML2FILE driver: " << G4endl;
G4cout << " This file name is the final one in the " << G4endl;
G4cout << " automatic updation of the output file name." << G4endl;
G4cout << " You may overwrite existing files, i.e. " << G4endl;
G4cout << " g4_XX.wrl. " << G4endl;
G4cout << "===========================================" << G4endl;
}
}
// create full path name (default)
strcat ( fVRMLFileName, DEFAULT_WRL_FILE_NAME );
// re-determine file name as G4VRMLFILE_DEST_DIR/g4_XX.wrl
std::ostringstream filename;
filename << fVRMLFileDestDir;
if(std::getenv(ENV_WRL_FILE_HEADER) == NULL)
{
filename << WRL_FILE_HEADER;
}
else
{
filename << std::getenv(ENV_WRL_FILE_HEADER) << '_';
}
filename << std::setw(2) << std::setfill('0') << i << ".wrl";
strncpy(fVRMLFileName, filename.str().c_str(), sizeof(fVRMLFileName) - 1);
fVRMLFileName[sizeof(fVRMLFileName) - 1] = '\0';
// Determine VRML file name
for( int i = 0 ; i < fMaxFileNum ; i++) {
// check validity of the file name
std::ifstream fin;
fin.open(fVRMLFileName);
if(!fin)
{
// new file
fin.close();
break;
}
else
{
// already exists (try next)
fin.close();
}
// Message in the final execution
if( i == MAX_FILE_INDEX )
{
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "===========================================" << G4endl;
G4cout << "WARNING MESSAGE from VRML2FILE driver: " << G4endl;
G4cout << " This file name is the final one in the " << G4endl;
G4cout << " automatic updation of the output file name." << G4endl;
G4cout << " You may overwrite existing files, i.e. " << G4endl;
G4cout << " g4_XX.wrl. " << G4endl;
G4cout << "===========================================" << G4endl;
}
}
} // for
}
// re-determine file name as G4VRMLFILE_DEST_DIR/g4_XX.wrl
std::ostringstream filename;
filename
<< fVRMLFileDestDir << WRL_FILE_HEADER
<< std::setw(2) << std::setfill('0') << i << ".wrl";
strncpy(fVRMLFileName,filename.str().c_str(),sizeof(fVRMLFileName)-1);
fVRMLFileName[sizeof(fVRMLFileName)-1] = '\0';
// check validity of the file name
std::ifstream fin ;
fin.open(fVRMLFileName) ;
if(!fin) {
// new file
fin.close();
break;
} else {
// already exists (try next)
fin.close();
}
} // for
// open a VRML 2.0 file with determined file name
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "===========================================" << G4endl;
G4cout << "Output VRML 2.0 file: " << fVRMLFileName << G4endl;
G4cout << "Maximum number of files in the destination directory: " << fMaxFileNum << G4endl;
G4cout << " (Customizable with the environment variable: G4VRMLFILE_MAX_FILE_NUM) " << G4endl;
G4cout << "===========================================" << G4endl;
}
fDest.open(fVRMLFileName) ; fFlagDestOpen = true ;
// open a VRML 2.0 file with determined file name
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
{
G4cout << "===========================================" << G4endl;
G4cout << "Output VRML 2.0 file: " << fVRMLFileName << G4endl;
G4cout << "Maximum number of files in the destination directory: "
<< fMaxFileNum << G4endl;
G4cout << " (Customizable with the environment variable: "
"G4VRMLFILE_MAX_FILE_NUM) "
<< G4endl;
G4cout << "===========================================" << G4endl;
}
fDest.open(fVRMLFileName);
fFlagDestOpen = true;
}
void G4VRML2FileSceneHandler::closePort()
{
char command[256] ;
char viewer [256] ;
strcpy( viewer, NO_VRML_VIEWER ); // initialization
if( std::getenv( ENV_VRML_VIEWER ) ) {
strcpy( viewer, std::getenv( ENV_VRML_VIEWER ) ) ;
}
char command[256];
char viewer[256];
strcpy(viewer, NO_VRML_VIEWER); // initialization
if(std::getenv(ENV_VRML_VIEWER))
{
strcpy(viewer, std::getenv(ENV_VRML_VIEWER));
}
// close VRML file
fDest.close(); fFlagDestOpen = false ;
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "*** VRML 2.0 File " << fVRMLFileName << " is generated." << G4endl;
// close VRML file
fDest.close();
fFlagDestOpen = false;
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "*** VRML 2.0 File " << fVRMLFileName << " is generated."
<< G4endl;
// Invoke viewer
// Invoke viewer
if ( !strcmp(viewer, NO_VRML_VIEWER )) {
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "MESSAGE from VRML2FILE driver:" << G4endl;
G4cout << " Set an environmental variable " ;
G4cout << ENV_VRML_VIEWER << G4endl;
G4cout << " if you want to visualize the generated VRML file" << G4endl;
G4cout << " automatically. For example, " << G4endl;
G4cout << " setenv " << ENV_VRML_VIEWER << " vrwave " << G4endl;
}
} else {
std::ostringstream ossCommand;
ossCommand << viewer << ' ' << fVRMLFileName;
strncpy(command,ossCommand.str().c_str(),sizeof(command)-1);
command[sizeof(command)-1] = '\0';
int iErr = system( command );
if ( iErr != 0 ) {
G4ExceptionDescription ed;
ed << "Error " << iErr
<< " when calling system with \"" << command
<< "\".";
G4Exception("G4VRML2FileSceneHandler::closePort()",
"VRML-2006", JustWarning, ed);
}
}
if(!strcmp(viewer, NO_VRML_VIEWER))
{
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
{
G4cout << "MESSAGE from VRML2FILE driver:" << G4endl;
G4cout << " Set an environmental variable ";
G4cout << ENV_VRML_VIEWER << G4endl;
G4cout << " if you want to visualize the generated VRML file"
<< G4endl;
G4cout << " automatically. For example, " << G4endl;
G4cout << " setenv " << ENV_VRML_VIEWER << " vrwave " << G4endl;
G4cout << "ALSO you may change the file header with "
<< ENV_WRL_FILE_HEADER << G4endl;
G4cout << " or the whole filename with " << ENV_WRL_FILE_NAME
<< G4endl;
}
}
else
{
std::ostringstream ossCommand;
ossCommand << viewer << ' ' << fVRMLFileName;
strncpy(command, ossCommand.str().c_str(), sizeof(command) - 1);
command[sizeof(command) - 1] = '\0';
int iErr = system(command);
if(iErr != 0)
{
G4ExceptionDescription ed;
ed << "Error " << iErr << " when calling system with \"" << command
<< "\".";
G4Exception("G4VRML2FileSceneHandler::closePort()", "VRML-2006",
JustWarning, ed);
}
}
}
G4int G4VRML2FileSceneHandler::fSceneIdCount = 0;
@@ -28,7 +28,6 @@
// G4VRML2FileViewer.cc
// Satoshi Tanaka & Yasuhide Sawada
//#define DEBUG_FR_VIEW
#include <cmath>
@@ -42,116 +41,119 @@
#include "G4ios.hh"
G4VRML2FileViewer::G4VRML2FileViewer(G4VRML2FileSceneHandler& sceneHandler,
const G4String& name) :
G4VViewer(sceneHandler,
sceneHandler.IncrementViewCount(),
name),
fSceneHandler(sceneHandler),
fDest(sceneHandler.fDest)
const G4String& name)
: G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name)
, fSceneHandler(sceneHandler)
, fDest(sceneHandler.fDest)
{
fViewHalfAngle = 30. * deg;
fsin_VHA = std::sin ( fViewHalfAngle ) ;
fsin_VHA = std::sin(fViewHalfAngle);
}
G4VRML2FileViewer::~G4VRML2FileViewer()
{}
G4VRML2FileViewer::~G4VRML2FileViewer() {}
void G4VRML2FileViewer::SetView()
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2FileViewer::SetView(): No effects" << G4endl;
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2FileViewer::SetView(): No effects" << G4endl;
#endif
// Do nothing, since VRML a browser is running as a different process.
// SendViewParameters () will do this job instead.
// Do nothing, since VRML a browser is running as a different process.
// SendViewParameters () will do this job instead.
}
void G4VRML2FileViewer::DrawView()
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2FileViewer::DrawView()" << G4endl;
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2FileViewer::DrawView()" << G4endl;
#endif
fSceneHandler.VRMLBeginModeling() ;
fSceneHandler.VRMLBeginModeling();
// Viewpoint node
SendViewParameters();
// Viewpoint node
SendViewParameters();
// Here is a minimal DrawView() function.
NeedKernelVisit();
ProcessView();
FinishView();
// Here is a minimal DrawView() function.
NeedKernelVisit();
ProcessView();
FinishView();
}
void G4VRML2FileViewer::ClearView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2File1View::ClearView()" << G4endl;
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2File1View::ClearView()" << G4endl;
#endif
if(fSceneHandler.fFlagDestOpen) {
if(fSceneHandler.fFlagDestOpen)
{
fSceneHandler.fDest.close();
// Re-open with same filename...
fSceneHandler.fDest.open(fSceneHandler.fVRMLFileName);
fSceneHandler.fDest << "#VRML V2.0 utf8" << "\n";
fSceneHandler.fDest << "# Generated by VRML 2.0 driver of GEANT4\n" << "\n";
fSceneHandler.fDest << "#VRML V2.0 utf8"
<< "\n";
fSceneHandler.fDest << "# Generated by VRML 2.0 driver of GEANT4\n"
<< "\n";
}
}
void G4VRML2FileViewer::ShowView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2FileViewer::ShowView()" << G4endl;
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2FileViewer::ShowView()" << G4endl;
#endif
fSceneHandler.VRMLEndModeling();
fSceneHandler.VRMLEndModeling();
}
void G4VRML2FileViewer::FinishView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2FileViewer::FinishView(): No effects" << G4endl;
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2FileViewer::FinishView(): No effects" << G4endl;
#endif
}
void G4VRML2FileViewer::SendViewParameters ()
void G4VRML2FileViewer::SendViewParameters()
{
// Calculates view representation based on extent of object being
// viewed and (initial) direction of camera. (Note: it can change
// later due to user interaction via visualization system's GUI.)
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2FileViewer::SendViewParameters()\n";
#endif
if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2FileViewer::SendViewParameters()\n";
#endif
// error recovery
if ( fsin_VHA < 1.0e-6 ) { return ; }
// error recovery
if(fsin_VHA < 1.0e-6)
{
return;
}
// camera distance
G4double extent_radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
G4double camera_distance = extent_radius / fsin_VHA ;
// camera distance
G4double extent_radius =
fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
G4double camera_distance = extent_radius / fsin_VHA;
// camera position on Z axis
const G4Point3D& target_point
= fSceneHandler.GetScene()->GetStandardTargetPoint()
+ fVP.GetCurrentTargetPoint();
G4double E_z = target_point.z() + camera_distance;
G4Point3D E(0.0, 0.0, E_z );
// VRML codes are generated below
fDest << G4endl;
fDest << "#---------- CAMERA" << G4endl;
fDest << "Viewpoint {" << G4endl;
fDest << "\t" << "position " ;
fDest << E.x() << " " ;
fDest << E.y() << " " ;
fDest << E.z() << G4endl ;
fDest << "}" << G4endl;
fDest << G4endl;
// camera position on Z axis
const G4Point3D& target_point =
fSceneHandler.GetScene()->GetStandardTargetPoint() +
fVP.GetCurrentTargetPoint();
G4double E_z = target_point.z() + camera_distance;
G4Point3D E(0.0, 0.0, E_z);
// VRML codes are generated below
fDest << G4endl;
fDest << "#---------- CAMERA" << G4endl;
fDest << "Viewpoint {" << G4endl;
fDest << "\t"
<< "position ";
fDest << E.x() << " ";
fDest << E.y() << " ";
fDest << E.z() << G4endl;
fDest << "}" << G4endl;
fDest << G4endl;
}
@@ -1,155 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML2SceneHandler.cc
// Satoshi Tanaka & Yasuhide Sawada
#ifndef WIN32
//=================//
#ifdef G4VIS_BUILD_VRML_DRIVER
//=================//
//#define DEBUG_FR_SCENE
#include <unistd.h>
#include <fstream>
#include <cmath>
#include "globals.hh"
#include "G4VisManager.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4Point3D.hh"
#include "G4VModel.hh"
#include "G4Scene.hh"
#include "G4VisAttributes.hh"
#include "G4Polyhedron.hh"
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Polyline.hh"
#include "G4Trd.hh"
#include "G4Tubs.hh"
#include "G4Text.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4VRML2SceneHandler.hh"
#include "G4VRML2Viewer.hh"
#include "G4VRML2.hh"
G4VRML2SceneHandler::G4VRML2SceneHandler(G4VRML2& system, const G4String& name) :
G4VSceneHandler(system, fSceneIdCount++, name),
fSystem(system),
fPVPickable ( false ),
fDest()
{
// PV name pickability
if( std::getenv( "G4VRML_PV_PICKABLE" ) != NULL ) {
int is_pickable ;
sscanf( std::getenv("G4VRML_PV_PICKABLE"), "%d", &is_pickable ) ;
if ( is_pickable ) { SetPVPickability ( true ) ; }
}
// PV Transparency
SetPVTransparency ();
}
G4VRML2SceneHandler::~G4VRML2SceneHandler()
{
#if defined DEBUG_FR_SCENE
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** ~G4VRML2SceneHandler" << G4endl;
#endif
}
#define G4VRML2SCENEHANDLER G4VRML2SceneHandler
#define IS_CONNECTED fDest.isConnected()
#include "G4VRML2SceneHandlerFunc.icc"
#undef IS_CONNECTED
#undef G4VRML2SCENEHANDLER
void G4VRML2SceneHandler::connectPort(G4int max_trial)
{
G4int trial = 0 ;
int port = fSystem.getPort();
for (trial = 0; !fDest.isConnected()&& trial < max_trial; trial++, port++ ) {
if (fDest.connect( (const char * )fSystem.getHostName(), port)) {
// INET domain connection is established
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "*** GEANT4 is connected to port ";
G4cout << fDest.getPort();
G4cout << " of server " << fSystem.getHostName() << G4endl;
}
break;
} else {
// Connection failed. Try the next port.
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "*** GEANT4 incremented targeting port to ";
G4cout << port << G4endl;
}
}
sleep (1);
} // for
if (!fDest.isConnected()) {
if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
G4cout << "*** INET Connection failed. " << G4endl;
G4cout << " Maybe, you have not invoked viewer g4vrmlview yet, " << G4endl;
G4cout << " or too many viewers are already running in the " << G4endl;
G4cout << " server host(" << fSystem.getHostName() << "). " << G4endl;
}
}
}
void G4VRML2SceneHandler::closePort()
{
fDest.close();
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "*** INET Connection closed. " << G4endl;
}
G4int G4VRML2SceneHandler::fSceneIdCount = 0;
#endif
#endif //WIN32
File diff suppressed because it is too large Load Diff
@@ -1,158 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// G4VRML2Viewer.cc
// Satoshi Tanaka & Yasuhide Sawada
#ifndef WIN32
//=================//
#ifdef G4VIS_BUILD_VRML_DRIVER
//=================//
//#define DEBUG_FR_VIEW
#include <cmath>
#include "G4VisManager.hh"
#include "G4Scene.hh"
#include "G4VRML2Viewer.hh"
#include "G4VRML2SceneHandler.hh"
#include "G4VRML2.hh"
#include "G4ios.hh"
G4VRML2Viewer::G4VRML2Viewer(G4VRML2SceneHandler& sceneHandler, const G4String& name) :
G4VViewer(sceneHandler,
sceneHandler.IncrementViewCount(),
name),
fSceneHandler(sceneHandler),
fDest(sceneHandler.fDest)
{
fViewHalfAngle = 0.5 * 0.785398 ; // 0.5 * 45*deg
fsin_VHA = std::sin ( fViewHalfAngle ) ;
}
G4VRML2Viewer::~G4VRML2Viewer()
{}
void G4VRML2Viewer::SetView()
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2Viewer::SetView(): No effects" << G4endl;
#endif
// Do nothing, since VRML a browser is running as a different process.
// SendViewParameters () will do this job instead.
}
void G4VRML2Viewer::DrawView()
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2Viewer::DrawView()" << G4endl;
#endif
fSceneHandler.VRMLBeginModeling() ;
// Viewpoint node
SendViewParameters();
// Here is a minimal DrawView() function.
NeedKernelVisit();
ProcessView();
FinishView();
}
void G4VRML2Viewer::ClearView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2Viewer::ClearView(): No effects" << G4endl;
#endif
}
void G4VRML2Viewer::ShowView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2Viewer::ShowView()" << G4endl;
#endif
fSceneHandler.VRMLEndModeling();
}
void G4VRML2Viewer::FinishView(void)
{
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2Viewer::FinishView(): No effects" << G4endl;
#endif
}
void G4VRML2Viewer::SendViewParameters ()
{
// Calculates view representation based on extent of object being
// viewed and (initial) direction of camera. (Note: it can change
// later due to user interaction via visualization system's GUI.)
#if defined DEBUG_FR_VIEW
if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
G4cout << "***** G4VRML2Viewer::SendViewParameters()\n";
#endif
// error recovery
if ( fsin_VHA < 1.0e-6 ) { return ; }
// camera distance
G4double extent_radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
G4double camera_distance = extent_radius / fsin_VHA ;
// camera position on Z axis
const G4Point3D& target_point
= fSceneHandler.GetScene()->GetStandardTargetPoint()
+ fVP.GetCurrentTargetPoint();
G4double E_z = target_point.z() + camera_distance;
G4Point3D E(0.0, 0.0, E_z );
// VRML codes are generated below
fDest << "\n";
fDest << "#---------- CAMERA" << "\n";
fDest << "Viewpoint {" << "\n";
fDest << "\t" << "position " ;
fDest << E.x() << " " ;
fDest << E.y() << " " ;
fDest << E.z() << "\n" ;
fDest << "}" << "\n";
fDest << "\n";
}
#endif
#endif //WIN32