Import Geant4 2.0.0 source tree
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# $Id: GNUmakefile,v 1.3 2000/04/07 13:32:41 gcosmo Exp $
|
||||
|
||||
name := G4RayTracer
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
|
||||
include $(G4INSTALL)/config/interactivity.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/graphics_reps/include \
|
||||
-I$(G4BASE)/event/include \
|
||||
-I$(G4BASE)/digits+hits/detector/include \
|
||||
-I$(G4BASE)/global/management/include \
|
||||
-I$(G4BASE)/global/HEPRandom/include \
|
||||
-I$(G4BASE)/global/HEPGeometry/include \
|
||||
-I$(G4BASE)/track/include \
|
||||
-I$(G4BASE)/tracking/include \
|
||||
-I$(G4BASE)/processes/management/include \
|
||||
-I$(G4BASE)/processes/electromagnetic/utils/include \
|
||||
-I$(G4BASE)/particles/management/include \
|
||||
-I$(G4BASE)/particles/leptons/include \
|
||||
-I$(G4BASE)/particles/leptons/include \
|
||||
-I$(G4BASE)/particles/bosons/include \
|
||||
-I$(G4BASE)/particles/hadrons/barions/include \
|
||||
-I$(G4BASE)/particles/hadrons/ions/include \
|
||||
-I$(G4BASE)/particles/hadrons/mesons/include \
|
||||
-I$(G4BASE)/materials/include \
|
||||
-I$(G4BASE)/geometry/management/include \
|
||||
-I$(G4BASE)/geometry/volumes/include \
|
||||
-I$(G4BASE)/geometry/solids/CSG/include \
|
||||
-I$(G4BASE)/geometry/solids/specific/include \
|
||||
-I$(G4BASE)/digits+hits/detector/include \
|
||||
-I$(G4BASE)/digits+hits/hits/include \
|
||||
-I$(G4BASE)/digits+hits/digits/include \
|
||||
-I$(G4BASE)/intercoms/include \
|
||||
-I$(G4BASE)/visualization/management/include \
|
||||
-I$(G4BASE)/visualization/modeling/include
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -0,0 +1,65 @@
|
||||
$Id: History,v 1.7 2000/05/02 10:07:08 johna Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
Category History file
|
||||
---------------------
|
||||
This file should be used by G4 developers and category coordinators
|
||||
to briefly summarize all major modifications introduced in the code
|
||||
and keep track of all category-tags.
|
||||
It DOES NOT substitute the CVS log-message one should put at every
|
||||
committal in the CVS repository !
|
||||
|
||||
*************************************************************
|
||||
* Note that modeling and test have their own History files. *
|
||||
*************************************************************
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
History file for visualization category
|
||||
---------------------------------------
|
||||
|
||||
2nd May 2000 John Allison
|
||||
- G4RayTracer: set out-of-world ray to black.
|
||||
- G4RayTracerViewer: corrected trapping of orthogonal projection.
|
||||
|
||||
10th March 2000 Makoto Asai
|
||||
- Added some comments for copyright notice and for the software reference manual.
|
||||
|
||||
24th February 2000 John Allison
|
||||
- Added protection for null viewer in G4RTSteppingAction.cc and
|
||||
G4RayTrajectory.cc.
|
||||
- Corrected for zoom, etc., in G4RayTracerViewer.cc.
|
||||
|
||||
23rd February 2000 John Allison
|
||||
- Added G4RayTracerSceneHandler and Viewer.
|
||||
- Some modifications to other RayTracer routines for vis compliance.
|
||||
- (Note: headAngle still not right - ray traced views are sometimes tipped.)
|
||||
|
||||
22nd February 2000 John Allison (raytracer-V01-00-01a)
|
||||
- Added G4std:: in a few places to obtain ISO compliance.
|
||||
- Change "char*" to "const char*" in G4OutBitStream::CopyByte(...).
|
||||
|
||||
22nd February 2000 Makoto Asai (raytracer-V01-00-01)
|
||||
- Change "char*" to "const char*"
|
||||
- use g4std/fstream
|
||||
|
||||
17th February 2000 Makoto Asai (raytracer-V01-00-00)
|
||||
- Primary tag of sub-category
|
||||
|
||||
29th January 2000 Makoto Asai
|
||||
- Introduction of G4RayTracer (visualization/RayTracer/...)
|
||||
- Migration of G4RayTracer
|
||||
affected files :
|
||||
visualization/GNUmakefile
|
||||
visualization/management/include/MyVisManager.cc
|
||||
visualization/management/src/G4VisManager.cc
|
||||
affected files in other directory :
|
||||
config/G4VIS_BUILD.gmk
|
||||
config/G4VIS_USE.gmk
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
|
||||
G4RayTracer version 1.0 (29/Jan/00)
|
||||
|
||||
1. Introduction
|
||||
|
||||
G4RayTracer is a "ray tracing" package which uses Geant4 kernel mechanism
|
||||
of tracking/navigation. It visualizes any kinds of solids that Geant4
|
||||
kernel can navigate.
|
||||
|
||||
2. Building a library
|
||||
|
||||
G4RayTracer is one of visualization driver which Geant4 supports. To build
|
||||
a library of G4RayTracer (library name G4RayTracer), set an environment
|
||||
variable G4VIS_BUILD_RAYTRACER_DRIVER.
|
||||
|
||||
$ setenv G4VIS_BUILD_RAYTRACER_DRIVER 1
|
||||
|
||||
3. Using G4RayTracer
|
||||
|
||||
To use G4RayTracer, set an environment variable G4VIS_USE_RAYTRACER.
|
||||
|
||||
$ setenv G4VIS_USE_RAYTRACER 1
|
||||
|
||||
Also, G4RayTracer has to be registored to the user's concrete VisManager.
|
||||
Refer an example given in
|
||||
geant4/source/visualization/management/include/MyVisManager.cc.
|
||||
|
||||
4. Notes
|
||||
|
||||
a) G4RayTracer generates JPEG file(s). To visualize these files, use your
|
||||
local program such as NetScape or xview, etc.
|
||||
|
||||
b) The eye position must be inside of the defined world volume. If you want
|
||||
to draw your detector setup from very far position, you need to enlarge
|
||||
your world volume.
|
||||
|
||||
c) G4RayTracer ignores volumes without G4VisAttributes, volumes which are
|
||||
set as "forced wire frame", and volumes which are set as "invisible".
|
||||
|
||||
d) In case you get unexpected figure, check
|
||||
d.1) eye position and target position are properly set,
|
||||
d.2) light direction is properly set (note light direction is from
|
||||
illumination light source to the objects),
|
||||
d.3) span angle (given by angle for 100 pixels) is reasonable,
|
||||
d.4) there is no surrounding volume(s) without transparency.
|
||||
|
||||
e) G4RayTracer can be executed ONLY AT "Idle" state.
|
||||
|
||||
5. Basic UI commands
|
||||
|
||||
a) /vis/rayTracer/eyePosition x y z unit
|
||||
eye position
|
||||
|
||||
b) /vis/rayTracer/target x y z unit
|
||||
target position
|
||||
in default it is set to the origine
|
||||
|
||||
c) /vis/rayTracer/lightDirection ex ey ez
|
||||
vector of the illuminating light (need not to be a unit vector)
|
||||
note light direction is from illumination light source to the objects
|
||||
|
||||
d) /vis/rayTracer/column nColumn
|
||||
number of holizontal pixels
|
||||
in default 640 pixels
|
||||
|
||||
e) /vis/rayTracer/row nRow
|
||||
number of virtical pixels
|
||||
in default 640 pixels
|
||||
|
||||
f) /vis/rayTracer/span angle unit
|
||||
angle for 100 pixels
|
||||
in default 5 degree
|
||||
|
||||
g) /vis/rayTracer/trace fileName
|
||||
execution of G4RayTracer
|
||||
"fileName" is the out put JPEG file name
|
||||
in default "g4RayTracer.jpeg"
|
||||
NOTE THAT THIS COMMAND IS AVAILABLE ONLY AT IDLE STATE
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTJpeg.hh,v 1.4 2000/03/09 17:38:31 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This header file defines some static constant variables and error classes
|
||||
// used internally by G4JpegMaker and related classes
|
||||
//
|
||||
|
||||
#ifndef G4RTJpeg_H
|
||||
#define G4RTJpeg_H 1
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned int u_int;
|
||||
|
||||
const char JFIF[] = "JFIF";
|
||||
const char JFXX[] = "JFXX";
|
||||
|
||||
const double Sqrt2 = 1.41421356;
|
||||
const double DisSqrt2 = 1.0 / Sqrt2;
|
||||
const double PaiDiv16 = 3.14159265 / 16;
|
||||
|
||||
//Zigzag
|
||||
static const int Zigzag[64] = {
|
||||
0, 1, 8, 16, 9, 2, 3, 10,
|
||||
17, 24, 32, 25, 18, 11, 4, 5,
|
||||
12, 19, 26, 33, 40, 48, 41, 34,
|
||||
27, 20, 13, 6, 7, 14, 21, 28,
|
||||
35, 42, 49, 56, 57, 50, 43, 36,
|
||||
29, 22, 15, 23, 30, 37, 44, 51,
|
||||
58, 59, 52, 45, 38, 31, 39, 46,
|
||||
53, 60, 61, 54, 47, 55, 62, 63
|
||||
};
|
||||
|
||||
//ProcessResult
|
||||
enum
|
||||
jProcessResult{
|
||||
M_NoError = 0,
|
||||
M_RuntimeError = -1,
|
||||
M_DataError = -2
|
||||
};
|
||||
|
||||
// JpegMarkerCode
|
||||
enum
|
||||
jMarker{
|
||||
|
||||
M_SOF0 = 0xc0,
|
||||
M_SOF1 = 0xc1,
|
||||
M_SOF2 = 0xc2,
|
||||
M_SOF3 = 0xc3,
|
||||
|
||||
M_SOF5 = 0xc5,
|
||||
M_SOF6 = 0xc6,
|
||||
M_SOF7 = 0xc7,
|
||||
|
||||
M_JPG = 0xc8,
|
||||
M_SOF9 = 0xc9,
|
||||
M_SOF10 = 0xca,
|
||||
M_SOF11 = 0xcb,
|
||||
|
||||
M_SOF13 = 0xcd,
|
||||
M_SOF14 = 0xce,
|
||||
M_SOF15 = 0xcf,
|
||||
|
||||
M_DHT = 0xc4,
|
||||
|
||||
M_DAC = 0xcc,
|
||||
|
||||
M_RST0 = 0xd0, M_RST1 = 0xd1,
|
||||
M_RST2 = 0xd2, M_RST3 = 0xd3,
|
||||
M_RST4 = 0xd4, M_RST5 = 0xd5,
|
||||
M_RST6 = 0xd6, M_RST7 = 0xd7,
|
||||
|
||||
M_SOI = 0xd8,
|
||||
M_EOI = 0xd9,
|
||||
M_SOS = 0xda,
|
||||
M_DQT = 0xdb,
|
||||
M_DNL = 0xdc,
|
||||
M_DRI = 0xdd,
|
||||
M_DHP = 0xde,
|
||||
M_EXP = 0xdf,
|
||||
M_COM = 0xfe,
|
||||
|
||||
M_APP0 = 0xe0, M_APP1 = 0xe1,
|
||||
M_APP2 = 0xe2, M_APP3 = 0xe3,
|
||||
M_APP4 = 0xe4, M_APP5 = 0xe5,
|
||||
M_APP6 = 0xe6, M_APP7 = 0xe7,
|
||||
M_APP8 = 0xe8, M_APP9 = 0xe9,
|
||||
M_APP10 = 0xea, M_APP11 = 0xeb,
|
||||
M_APP12 = 0xec, M_APP13 = 0xed,
|
||||
M_APP14 = 0xee, M_APP15 = 0xef,
|
||||
|
||||
|
||||
M_JPG0 = 0xf0, M_JPG1 = 0xf1,
|
||||
M_JPG2 = 0xf2, M_JPG3 = 0xf3,
|
||||
M_JPG4 = 0xf4, M_JPG5 = 0xf5,
|
||||
M_JPG6 = 0xf6, M_JPG7 = 0xf7,
|
||||
M_JPG8 = 0xf8, M_JPG9 = 0xf9,
|
||||
M_JPG10 = 0xfa, M_JPG11 = 0xfb,
|
||||
M_JPG12 = 0xfc, M_JPG13 = 0xfd,
|
||||
|
||||
|
||||
M_TEM = 0x01,
|
||||
M_RESst = 0x02,
|
||||
M_RESend = 0xbf,
|
||||
|
||||
M_Error = 0xff,
|
||||
M_Marker = 0xff
|
||||
};
|
||||
|
||||
//JpegProperty
|
||||
struct
|
||||
G4JpegProperty{
|
||||
int nRow;
|
||||
int nColumn;
|
||||
int Dimension;
|
||||
int SamplePrecision;
|
||||
const char * Comment;
|
||||
int Format;
|
||||
u_char MajorRevisions;
|
||||
u_char MinorRevisions;
|
||||
int Units;
|
||||
int HDensity;
|
||||
int VDensity;
|
||||
int HThumbnail;
|
||||
int VThumbnail;
|
||||
int ExtensionCode;
|
||||
};
|
||||
|
||||
|
||||
//MemoryError
|
||||
class G4MemoryError
|
||||
{
|
||||
public:
|
||||
G4MemoryError(int size, const char* message)
|
||||
{mSize = size; mMessage = message;};
|
||||
int mSize;
|
||||
const char* mMessage;
|
||||
};
|
||||
|
||||
//IndexError
|
||||
class G4IndexError
|
||||
{
|
||||
public:
|
||||
G4IndexError(int maxIndex, int errorIndex, const char* mes)
|
||||
{mMaxIndex = maxIndex; mErrorIndex = errorIndex; mMessage = mes;};
|
||||
int mMaxIndex;
|
||||
int mErrorIndex;
|
||||
const char* mMessage;
|
||||
};
|
||||
|
||||
//BufferError
|
||||
class G4BufferError
|
||||
{
|
||||
public:
|
||||
G4BufferError(const char* mes)
|
||||
{mMessage = mes;};
|
||||
const char* mMessage;
|
||||
};
|
||||
|
||||
//DataFormatError
|
||||
class G4DataFormatError
|
||||
{
|
||||
public:
|
||||
G4DataFormatError(void* address, const char* message)
|
||||
{mAddress = address; mMessage = message;};
|
||||
void* mAddress;
|
||||
const char* mMessage;
|
||||
};
|
||||
|
||||
|
||||
//NotSupported
|
||||
class G4NotSupported
|
||||
{
|
||||
public:
|
||||
G4NotSupported(jMarker aMark, void* address)
|
||||
{mMark = aMark; mAddress = address;};
|
||||
jMarker mMark;
|
||||
void* mAddress;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTJpegCoder.hh,v 1.4 2000/03/09 17:38:31 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This class converts 8 bit unsighned ints array to JPEG code.
|
||||
//
|
||||
|
||||
#ifndef G4RTJpegCoder_H
|
||||
#define G4RTJpegCoder_H 1
|
||||
#include "G4RTJpeg.hh"
|
||||
|
||||
//HuffmanTable
|
||||
struct
|
||||
G4HuffmanCodeTable
|
||||
{
|
||||
int numOfElement;
|
||||
int* SizeT;
|
||||
int* CodeT;
|
||||
};
|
||||
|
||||
class G4OutBitStream;
|
||||
|
||||
class G4JpegCoder
|
||||
{
|
||||
public:
|
||||
G4JpegCoder(u_char* colorR,u_char* colorG,u_char* colorB);
|
||||
~G4JpegCoder(void);
|
||||
|
||||
void GetJpegData(char** aJpegData,int& size);
|
||||
|
||||
void SetJpegProperty(const G4JpegProperty& aProperty);
|
||||
|
||||
int DoCoding(void);
|
||||
|
||||
|
||||
protected:
|
||||
u_char* mRgb[3];
|
||||
int mYBlock[4][64];
|
||||
int mCbBlock[64];
|
||||
int mCrBlock[64];
|
||||
double mCosT[8][8];
|
||||
int mDCTData[64];
|
||||
int mPreDC[3];
|
||||
|
||||
G4JpegProperty mProperty;
|
||||
int mNumVUnits;
|
||||
int mNumHUnits;
|
||||
|
||||
G4OutBitStream *mOBSP;
|
||||
|
||||
void CodeMCU();
|
||||
|
||||
void makeYCC(int ux,int uy);
|
||||
|
||||
void CodeHuffman(int cs);
|
||||
|
||||
void ForwardDCT(int* picData);
|
||||
|
||||
void Quantization(int cs);
|
||||
|
||||
void WriteHeader(void);
|
||||
void WriteEOI(void);
|
||||
};
|
||||
|
||||
const u_int JFIFLength = 16;
|
||||
const u_int JFIFVersion = 0x0102; //JFIF Ver 1.02
|
||||
const u_char YSampleF = 0x22;
|
||||
const u_char CSampleF = 0x11;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,316 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTJpegCoderTables.hh,v 1.4 2000/03/09 17:38:32 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This header file defines some hard coded numbers used by G4RTJpegCoder
|
||||
// to convert 8 bits RGB to JPEG.
|
||||
//
|
||||
|
||||
#ifndef G4RTJpegCoderTable_H
|
||||
#define G4RTJpegCoderTable_H 1
|
||||
|
||||
#include "G4RTJpeg.hh"
|
||||
|
||||
//QuantumTable
|
||||
|
||||
static const int YQuantumT[] = {
|
||||
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
};
|
||||
|
||||
static const int CQuantumT[] = {
|
||||
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
};
|
||||
|
||||
//HuffmanCode
|
||||
|
||||
static const int YDcSizeT[] = {
|
||||
0x0002, 0x0003, 0x0003, 0x0003,
|
||||
0x0003, 0x0003, 0x0004, 0x0005,
|
||||
0x0006, 0x0007, 0x0008, 0x0009 };
|
||||
static const int YDcCodeT[] = {
|
||||
0x0000, 0x0002, 0x0003, 0x0004,
|
||||
0x0005, 0x0006, 0x000e, 0x001e,
|
||||
0x003e, 0x007e, 0x00fe, 0x01fe };
|
||||
static const G4HuffmanCodeTable YDcHuffmanT = {
|
||||
12,
|
||||
(int*)YDcSizeT,
|
||||
(int*)YDcCodeT
|
||||
};
|
||||
|
||||
|
||||
static const int CDcSizeT[] = {
|
||||
0x0002, 0x0002, 0x0002, 0x0003,
|
||||
0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000a, 0x000b };
|
||||
static const int CDcCodeT[] = {
|
||||
0x0000, 0x0001, 0x0002, 0x0006,
|
||||
0x000e, 0x001e, 0x003e, 0x007e,
|
||||
0x00fe, 0x01fe, 0x03fe, 0x07fe };
|
||||
static const G4HuffmanCodeTable CDcHuffmanT = {
|
||||
12,
|
||||
(int*)CDcSizeT,
|
||||
(int*)CDcCodeT
|
||||
};
|
||||
|
||||
|
||||
static const int YAcSizeT[] = {
|
||||
4, 2, 2, 3, 4, 5, 7, 8,
|
||||
10, 16, 16, 4, 5, 7, 9, 11,
|
||||
16, 16, 16, 16, 16, 5, 8, 10,
|
||||
12, 16, 16, 16, 16, 16, 16, 6,
|
||||
9, 12, 16, 16, 16, 16, 16, 16,
|
||||
16, 6, 10, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 7, 11, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 7, 12, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 8,
|
||||
12, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 9, 15, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 9, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 9, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 10,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 10, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 11, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 11,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16 };
|
||||
static const int YAcCodeT[] = {
|
||||
0x000a, 0x0000, 0x0001, 0x0004,
|
||||
0x000b, 0x001a, 0x0078, 0x00f8,
|
||||
0x03f6, 0xff82, 0xff83, 0x000c,
|
||||
0x001b, 0x0079, 0x01f6, 0x07f6,
|
||||
0xff84, 0xff85, 0xff86, 0xff87,
|
||||
0xff88, 0x001c, 0x00f9, 0x03f7,
|
||||
0x0ff4, 0xff89, 0xff8a, 0xff8b,
|
||||
0xff8c, 0xff8d, 0xff8e, 0x003a,
|
||||
0x01f7, 0x0ff5, 0xff8f, 0xff90,
|
||||
0xff91, 0xff92, 0xff93, 0xff94,
|
||||
0xff95, 0x003b, 0x03f8, 0xff96,
|
||||
0xff97, 0xff98, 0xff99, 0xff9a,
|
||||
0xff9b, 0xff9c, 0xff9d, 0x007a,
|
||||
0x07f7, 0xff9e, 0xff9f, 0xffa0,
|
||||
0xffa1, 0xffa2, 0xffa3, 0xffa4,
|
||||
0xffa5, 0x007b, 0x0ff6, 0xffa6,
|
||||
0xffa7, 0xffa8, 0xffa9, 0xffaa,
|
||||
0xffab, 0xffac, 0xffad, 0x00fa,
|
||||
0x0ff7, 0xffae, 0xffaf, 0xffb0,
|
||||
0xffb1, 0xffb2, 0xffb3, 0xffb4,
|
||||
0xffb5, 0x01f8, 0x7fc0, 0xffb6,
|
||||
0xffb7, 0xffb8, 0xffb9, 0xffba,
|
||||
0xffbb, 0xffbc, 0xffbd, 0x01f9,
|
||||
0xffbe, 0xffbf, 0xffc0, 0xffc1,
|
||||
0xffc2, 0xffc3, 0xffc4, 0xffc5,
|
||||
0xffc6, 0x01fa, 0xffc7, 0xffc8,
|
||||
0xffc9, 0xffca, 0xffcb, 0xffcc,
|
||||
0xffcd, 0xffce, 0xffcf, 0x03f9,
|
||||
0xffd0, 0xffd1, 0xffd2, 0xffd3,
|
||||
0xffd4, 0xffd5, 0xffd6, 0xffd7,
|
||||
0xffd8, 0x03fa, 0xffd9, 0xffda,
|
||||
0xffdb, 0xffdc, 0xffdd, 0xffde,
|
||||
0xffdf, 0xffe0, 0xffe1, 0x07f8,
|
||||
0xffe2, 0xffe3, 0xffe4, 0xffe5,
|
||||
0xffe6, 0xffe7, 0xffe8, 0xffe9,
|
||||
0xffea, 0xffeb, 0xffec, 0xffed,
|
||||
0xffee, 0xffef, 0xfff0, 0xfff1,
|
||||
0xfff2, 0xfff3, 0xfff4, 0x07f9,
|
||||
0xfff5, 0xfff6, 0xfff7, 0xfff8,
|
||||
0xfff9, 0xfffa, 0xfffb, 0xfffc,
|
||||
0xfffd, 0xfffe };
|
||||
static const G4HuffmanCodeTable YAcHuffmanT = {
|
||||
162,
|
||||
(int*)YAcSizeT,
|
||||
(int*)YAcCodeT
|
||||
};
|
||||
|
||||
static const int YEOBidx = 0;
|
||||
static const int YZRLidx = 151;
|
||||
|
||||
|
||||
static const int CAcSizeT[] = {
|
||||
2, 2, 3, 4, 5, 5, 6, 7,
|
||||
9, 10, 12, 4, 6, 8, 9, 11,
|
||||
12, 16, 16, 16, 16, 5, 8, 10,
|
||||
12, 15, 16, 16, 16, 16, 16, 5,
|
||||
8, 10, 12, 16, 16, 16, 16, 16,
|
||||
16, 6, 9, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 6, 10, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 7, 11, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 7,
|
||||
11, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 8, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 9, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 9, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 9,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 9, 16, 16, 16, 16, 16, 16,
|
||||
16, 16, 16, 11, 16, 16, 16, 16,
|
||||
16, 16, 16, 16, 16, 14, 16, 16,
|
||||
16, 16, 16, 16, 16, 16, 16, 10,
|
||||
15, 16, 16, 16, 16, 16, 16, 16,
|
||||
16, 16 };
|
||||
static const int CAcCodeT[] = {
|
||||
0x0000, 0x0001, 0x0004, 0x000a,
|
||||
0x0018, 0x0019, 0x0038, 0x0078,
|
||||
0x01f4, 0x03f6, 0x0ff4, 0x000b,
|
||||
0x0039, 0x00f6, 0x01f5, 0x07f6,
|
||||
0x0ff5, 0xff88, 0xff89, 0xff8a,
|
||||
0xff8b, 0x001a, 0x00f7, 0x03f7,
|
||||
0x0ff6, 0x7fc2, 0xff8c, 0xff8d,
|
||||
0xff8e, 0xff8f, 0xff90, 0x001b,
|
||||
0x00f8, 0x03f8, 0x0ff7, 0xff91,
|
||||
0xff92, 0xff93, 0xff94, 0xff95,
|
||||
0xff96, 0x003a, 0x01f6, 0xff97,
|
||||
0xff98, 0xff99, 0xff9a, 0xff9b,
|
||||
0xff9c, 0xff9d, 0xff9e, 0x003b,
|
||||
0x03f9, 0xff9f, 0xffa0, 0xffa1,
|
||||
0xffa2, 0xffa3, 0xffa4, 0xffa5,
|
||||
0xffa6, 0x0079, 0x07f7, 0xffa7,
|
||||
0xffa8, 0xffa9, 0xffaa, 0xffab,
|
||||
0xffac, 0xffad, 0xffae, 0x007a,
|
||||
0x07f8, 0xffaf, 0xffb0, 0xffb1,
|
||||
0xffb2, 0xffb3, 0xffb4, 0xffb5,
|
||||
0xffb6, 0x00f9, 0xffb7, 0xffb8,
|
||||
0xffb9, 0xffba, 0xffbb, 0xffbc,
|
||||
0xffbd, 0xffbe, 0xffbf, 0x01f7,
|
||||
0xffc0, 0xffc1, 0xffc2, 0xffc3,
|
||||
0xffc4, 0xffc5, 0xffc6, 0xffc7,
|
||||
0xffc8, 0x01f8, 0xffc9, 0xffca,
|
||||
0xffcb, 0xffcc, 0xffcd, 0xffce,
|
||||
0xffcf, 0xffd0, 0xffd1, 0x01f9,
|
||||
0xffd2, 0xffd3, 0xffd4, 0xffd5,
|
||||
0xffd6, 0xffd7, 0xffd8, 0xffd9,
|
||||
0xffda, 0x01fa, 0xffdb, 0xffdc,
|
||||
0xffdd, 0xffde, 0xffdf, 0xffe0,
|
||||
0xffe1, 0xffe2, 0xffe3, 0x07f9,
|
||||
0xffe4, 0xffe5, 0xffe6, 0xffe7,
|
||||
0xffe8, 0xffe9, 0xffea, 0xffeb,
|
||||
0xffec, 0x3fe0, 0xffed, 0xffee,
|
||||
0xffef, 0xfff0, 0xfff1, 0xfff2,
|
||||
0xfff3, 0xfff4, 0xfff5, 0x03fa,
|
||||
0x7fc3, 0xfff6, 0xfff7, 0xfff8,
|
||||
0xfff9, 0xfffa, 0xfffb, 0xfffc,
|
||||
0xfffd, 0xfffe };
|
||||
static const G4HuffmanCodeTable CAcHuffmanT = {
|
||||
162,
|
||||
(int*)CAcSizeT,
|
||||
(int*)CAcCodeT
|
||||
};
|
||||
|
||||
static const int CEOBidx = 0;
|
||||
static const int CZRLidx = 151;
|
||||
|
||||
//HuffmanCode
|
||||
|
||||
static const int DcDhtLength = 0x21;
|
||||
static const int AcDhtLength = 0xb7;
|
||||
|
||||
static const u_char YDcDht[] = {
|
||||
0xff, 0xc4,
|
||||
0x00, 0x1f,
|
||||
0x00,
|
||||
0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b
|
||||
};
|
||||
|
||||
static const u_char CDcDht[] = {
|
||||
0xff, 0xc4,
|
||||
0x00, 0x1f,
|
||||
0x01,
|
||||
0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b
|
||||
};
|
||||
|
||||
static const u_char YAcDht[] = {
|
||||
0xff, 0xc4,
|
||||
0x00, 0xb5,
|
||||
0x10,
|
||||
|
||||
0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03,
|
||||
0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d,
|
||||
|
||||
0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
|
||||
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
|
||||
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
|
||||
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
|
||||
0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
|
||||
0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
|
||||
0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
|
||||
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
|
||||
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
|
||||
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
|
||||
0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
|
||||
0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
|
||||
0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
|
||||
0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
|
||||
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
|
||||
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
|
||||
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
|
||||
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa
|
||||
};
|
||||
|
||||
static const u_char CAcDht[] = {
|
||||
0xff, 0xc4,
|
||||
0x00, 0xb5,
|
||||
0x11,
|
||||
|
||||
0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04,
|
||||
0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77,
|
||||
|
||||
0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
|
||||
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
|
||||
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
|
||||
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
|
||||
0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
|
||||
0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
|
||||
0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
|
||||
0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
|
||||
0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
|
||||
0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
|
||||
0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
|
||||
0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
|
||||
0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
|
||||
0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
|
||||
0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
|
||||
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
|
||||
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
|
||||
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTJpegMaker.hh,v 1.4 2000/03/09 17:38:32 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a concrete class of G4VFigureFileMaker.
|
||||
// This class converts 8 bits unsighned integer arrays which represent RGB of
|
||||
// each pixel to JPEG code and stores it to a file. The only one public method
|
||||
// of this class will be invoked by G4RayTracer.
|
||||
//
|
||||
|
||||
#ifndef G4RTJpegMaker_H
|
||||
#define G4RTJpegMaker_H 1
|
||||
|
||||
#include "G4VFigureFileMaker.hh"
|
||||
#include "G4RTJpeg.hh"
|
||||
|
||||
class G4RTJpegMaker : public G4VFigureFileMaker
|
||||
{
|
||||
public:
|
||||
G4RTJpegMaker();
|
||||
virtual ~G4RTJpegMaker();
|
||||
|
||||
public:
|
||||
virtual void CreateFigureFile(G4String fileName,
|
||||
int nColumn,int nRow,
|
||||
u_char* colorR, u_char* colorG,
|
||||
u_char* colorB);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTMessenger.hh,v 1.3 2000/03/09 17:38:32 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a concrete class of G4UImessenger. This class defines various
|
||||
// UI commands which are unique to G4RayTracer.
|
||||
//
|
||||
|
||||
|
||||
#ifndef G4RTMessenger_HH
|
||||
#define G4RTMessenger_HH 1
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithABool;
|
||||
class G4UIcmdWith3Vector;
|
||||
class G4UIcmdWith3VectorAndUnit;
|
||||
class G4UIcmdWithADoubleAndUnit;
|
||||
class G4UIcmdWithAnInteger;
|
||||
class G4UIcmdWithAString;
|
||||
class G4RayTracer;
|
||||
class G4RTSteppingAction;
|
||||
|
||||
class G4RTMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
G4RTMessenger(G4RayTracer* p1,G4RTSteppingAction* p2);
|
||||
virtual ~G4RTMessenger();
|
||||
|
||||
virtual G4String GetCurrentValue(G4UIcommand * command);
|
||||
virtual void SetNewValue(G4UIcommand * command,G4String newValue);
|
||||
|
||||
private:
|
||||
G4RayTracer* theTracer;
|
||||
G4RTSteppingAction* theSteppingAction;
|
||||
|
||||
G4UIdirectory* rayDirectory;
|
||||
G4UIcmdWithAnInteger* columnCmd;
|
||||
G4UIcmdWithAnInteger* rowCmd;
|
||||
G4UIcmdWith3VectorAndUnit* targetCmd;
|
||||
G4UIcmdWith3VectorAndUnit* eyePosCmd;
|
||||
G4UIcmdWith3Vector* lightCmd;
|
||||
G4UIcmdWithADoubleAndUnit* spanXCmd;
|
||||
G4UIcmdWithADoubleAndUnit* headCmd;
|
||||
G4UIcmdWithADoubleAndUnit* attCmd;
|
||||
G4UIcmdWithABool* distCmd;
|
||||
G4UIcmdWithABool* transCmd;
|
||||
G4UIcmdWithAString* fileCmd;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTOutBitStream.hh,v 1.5 2000/03/09 17:38:32 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This class represents a line of JPEG code. This class must be used exclusively
|
||||
// by G4RTJpegCoder.
|
||||
//
|
||||
|
||||
#ifndef G4RTOutBitStream_H
|
||||
#define G4RTOutBitStream_H 1
|
||||
#include "G4RTJpeg.hh"
|
||||
|
||||
static const u_char BitFullMaskT[8] = {0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f
|
||||
, 0xff};
|
||||
|
||||
class G4OutBitStream
|
||||
{
|
||||
public:
|
||||
G4OutBitStream(int size);
|
||||
void SetBits(int v, int numBits);
|
||||
void SetByte(u_char dat);
|
||||
void SetWord(u_int dat);
|
||||
void CopyByte(const char* src, int n);
|
||||
|
||||
u_char* GetStreamAddress(void){return mHeadOfBuf;};
|
||||
int GetStreamSize(void){return mBuf - mHeadOfBuf;};
|
||||
|
||||
|
||||
protected:
|
||||
u_char* mHeadOfBuf;
|
||||
u_char* mBuf;
|
||||
u_char* mEndOfBuf;
|
||||
int mBitPos;
|
||||
int mWriteFlag;
|
||||
|
||||
void IncBuf(void);
|
||||
void FullBit(void);
|
||||
void Set8Bits(u_char v, int numBits);
|
||||
void SetFewBits(u_char v, int numBits);
|
||||
void SetBits2Byte(u_char v, int numBits);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTSteppingAction.hh,v 1.3 2000/03/09 17:38:32 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a concrete class of G4UserSteppingAction. This class is used
|
||||
// by G4RayTracer for managing a ray tracked through volumes. An object
|
||||
// of this class is constructed by G4RayTracer and set to G4SteppingManager
|
||||
// with replacement of user defined stepping action during the period of
|
||||
// ray tracing.
|
||||
//
|
||||
|
||||
//////////////////////
|
||||
//G4RTSteppingAction
|
||||
/////////////////////
|
||||
|
||||
|
||||
#ifndef G4RTSteppingAction_h
|
||||
#define G4RTSteppingAction_h 1
|
||||
|
||||
|
||||
#include "G4UserSteppingAction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4RTSteppingAction : public G4UserSteppingAction
|
||||
{
|
||||
public:
|
||||
G4RTSteppingAction();
|
||||
virtual ~G4RTSteppingAction(){;}
|
||||
|
||||
virtual void UserSteppingAction(const G4Step*);
|
||||
|
||||
private:
|
||||
G4bool ignoreTransparency;
|
||||
|
||||
public:
|
||||
inline void SetIgnoreTransparency(G4bool val)
|
||||
{ ignoreTransparency = val; }
|
||||
inline G4bool GetIgnoreTransparency() const
|
||||
{ return ignoreTransparency; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTTrackingAction.hh,v 1.3 2000/03/09 17:38:32 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a concrete class of G4UserTrackingAction. This class is used
|
||||
// by G4RayTracer for managing a ray tracked through volumes. An object
|
||||
// of this class is constructed by G4RayTracer and set to G4TrackingManager
|
||||
// with replacement of user defined tracking action during the period of
|
||||
// ray tracing.
|
||||
//
|
||||
|
||||
///////////////////////
|
||||
//G4RTTrackingAction.hh
|
||||
///////////////////////
|
||||
|
||||
|
||||
#ifndef G4RTTrackingAction_h
|
||||
#define G4RTTrackingAction_h 1
|
||||
|
||||
#include "G4UserTrackingAction.hh"
|
||||
|
||||
class G4Track;
|
||||
|
||||
///////////////////////////
|
||||
class G4RTTrackingAction : public G4UserTrackingAction
|
||||
///////////////////////////
|
||||
{
|
||||
|
||||
//--------
|
||||
public:
|
||||
//--------
|
||||
|
||||
// Constructor & Destructor
|
||||
G4RTTrackingAction(){;}
|
||||
virtual ~G4RTTrackingAction(){;}
|
||||
|
||||
// Member functions
|
||||
virtual void PreUserTrackingAction(const G4Track* aTrack);
|
||||
virtual void PostUserTrackingAction(const G4Track* aTrack){;}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayShooter.hh,v 1.2 2000/03/09 17:38:33 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// the object of this class shoots a ray (actually geantino) primary particle
|
||||
// associated with a G4Event object. This slass must be used exclusively by
|
||||
// G4RayTracer.
|
||||
//
|
||||
|
||||
#ifndef G4RayShooter_h
|
||||
#define G4RayShooter_h 1
|
||||
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4PrimaryVertex.hh"
|
||||
#include "G4ParticleMomentum.hh"
|
||||
|
||||
class G4Event;
|
||||
|
||||
class G4RayShooter
|
||||
{
|
||||
public:
|
||||
G4RayShooter();
|
||||
public:
|
||||
virtual ~G4RayShooter();
|
||||
|
||||
public: // with description
|
||||
void Shoot(G4Event* evt,G4ThreeVector vtx,G4ThreeVector direc);
|
||||
// This method generates a primary vertex and a primary particle at the
|
||||
// given vertex point and with the given direction. This method is invoked
|
||||
// by G4RayTracer.
|
||||
|
||||
private:
|
||||
void SetInitialValues();
|
||||
|
||||
G4ParticleDefinition* particle_definition;
|
||||
G4ParticleMomentum particle_momentum_direction;
|
||||
G4double particle_energy;
|
||||
G4ThreeVector particle_position;
|
||||
G4double particle_time;
|
||||
G4ThreeVector particle_polarization;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTracer.hh,v 1.5 2000/03/09 17:38:33 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#ifndef G4RayTracer_H
|
||||
#define G4RayTracer_H 1
|
||||
|
||||
// class description:
|
||||
//
|
||||
// G4RayTracer
|
||||
// This is a graphics driver of Geant4 which generates a figure file by
|
||||
// ray tracing technique. The format of output figure file can be selected
|
||||
// by assigning a pointer of G4VFigureFileMaker concrete class object.
|
||||
// The main entry of ray tracing is Trace() method, which is available
|
||||
// only at Idle state. G4RayTracer shoots rays and controls its own event
|
||||
// loop. It generates G4Event objects used for its own purpose. When ray
|
||||
// tracing is working, all sensitive detectors are inactivated and all
|
||||
// user action classes are swapped out. Still, verbosities set to Geant4
|
||||
// manager classes are concerned. Thus, it is recommended to set verbosities
|
||||
// to minimum (usually zero).
|
||||
// G4RayTracer can visualise absolutely all kinds of geometrical shapes
|
||||
// which G4Navigator can deal with. Instead, it can NOT visualise hits
|
||||
// nor trajectories generated by usual simulation.
|
||||
// To make G4RayTracer library, G4VIS_BUILD_RAYTRACER_DRIVER environment
|
||||
// variable must be set before compiling visualization category. To use
|
||||
// G4RayTracer with your program, G4VIS_USE_RAYTRACER environment variable
|
||||
// must be set before compiling your program and your VisManager concrete
|
||||
// implementation must contain
|
||||
// RegisterGraphicsSystem (new G4RayTracer);
|
||||
//
|
||||
|
||||
#if defined (G4VIS_BUILD_RAYTRACER_DRIVER) || defined (G4VIS_USE_RAYTRACER)
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4VGraphicsSystem.hh"
|
||||
|
||||
class G4Event;
|
||||
class G4EventManager;
|
||||
class G4UserEventAction;
|
||||
class G4UserStackingAction;
|
||||
class G4UserTrackingAction;
|
||||
class G4UserSteppingAction;
|
||||
class G4RTTrackingAction;
|
||||
class G4RTSteppingAction;
|
||||
class G4Colour;
|
||||
class G4RTMessenger;
|
||||
class G4RayShooter;
|
||||
class G4VFigureFileMaker;
|
||||
class G4RayTrajectoryPoint;
|
||||
class G4VisAttributes;
|
||||
|
||||
|
||||
class G4RayTracer : public G4VGraphicsSystem
|
||||
{
|
||||
public: // with description
|
||||
G4RayTracer(G4VFigureFileMaker* figMaker = 0);
|
||||
// Constructor. The argument is the pointer to G4VFigureFileMaker concrete
|
||||
// class object. If it is not set and SetFigureFileMaker() method is not
|
||||
// invoked before Trace() command is invoked, then G4RTJpegMaker will be
|
||||
// used and JPEG file will be generated.
|
||||
|
||||
public:
|
||||
~G4RayTracer();
|
||||
|
||||
public: // with description
|
||||
void Trace(G4String fileName);
|
||||
// The main entry point which triggers ray tracing. "fileName" is output
|
||||
// file name, and it must contain extention (e.g. myFigure.jpg). This
|
||||
// method is available only if Geant4 is at Idle state.
|
||||
|
||||
public:
|
||||
virtual G4VSceneHandler* CreateSceneHandler (const G4String& );
|
||||
virtual G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& );
|
||||
|
||||
private:
|
||||
G4bool CreateBitMap();
|
||||
// Event loop
|
||||
void CreateFigureFile(G4String fileName);
|
||||
// Create figure file after an event loop
|
||||
G4bool GenerateColour(G4Event* anEvent);
|
||||
// Calcurate RGB for one trajectory
|
||||
void StoreUserActions();
|
||||
void RestoreUserActions();
|
||||
// Store and restore user action classes if defined
|
||||
|
||||
G4Colour GetSurfaceColour(G4RayTrajectoryPoint* point);
|
||||
G4Colour GetMixedColour(G4Colour surfCol,G4Colour transCol,G4double weight=0.5);
|
||||
G4Colour Attenuate(G4RayTrajectoryPoint* point, G4Colour sourceCol);
|
||||
G4bool ValidColour(const G4VisAttributes* visAtt);
|
||||
|
||||
public: // with description
|
||||
inline void SetFigureFileMaker(G4VFigureFileMaker* figMaker)
|
||||
// Set a concrete class of G4VFigureFileMaker for assigning the format of
|
||||
// output figure file.
|
||||
{ theFigMaker = figMaker; }
|
||||
|
||||
private:
|
||||
G4RayShooter * theRayShooter;
|
||||
G4VFigureFileMaker * theFigMaker;
|
||||
G4RTMessenger * theMessenger;
|
||||
|
||||
G4EventManager * theEventManager;
|
||||
|
||||
G4UserEventAction * theUserEventAction;
|
||||
G4UserStackingAction * theUserStackingAction;
|
||||
G4UserTrackingAction * theUserTrackingAction;
|
||||
G4UserSteppingAction * theUserSteppingAction;
|
||||
|
||||
G4UserEventAction * theRayTracerEventAction;
|
||||
G4UserStackingAction * theRayTracerStackingAction;
|
||||
G4RTTrackingAction * theRayTracerTrackingAction;
|
||||
G4RTSteppingAction * theRayTracerSteppingAction;
|
||||
|
||||
unsigned char* colorR;
|
||||
unsigned char* colorG;
|
||||
unsigned char* colorB;
|
||||
|
||||
G4int nColumn;
|
||||
G4int nRow;
|
||||
|
||||
G4ThreeVector eyePosition;
|
||||
G4ThreeVector targetPosition;
|
||||
G4ThreeVector eyeDirection;
|
||||
G4ThreeVector lightDirection;
|
||||
G4double headAngle;
|
||||
G4double viewSpan; // Angle per 100 pixels
|
||||
G4double attenuationLength;
|
||||
|
||||
G4bool distortionOn;
|
||||
|
||||
public:
|
||||
inline void SetNColumn(G4int val) { nColumn = val; }
|
||||
inline G4int GetNColumn() const { return nColumn; }
|
||||
inline void SetNRow(G4int val) { nRow = val; }
|
||||
inline G4int GetNRow() const { return nRow; }
|
||||
inline void SetEyePosition(G4ThreeVector val) { eyePosition = val; }
|
||||
inline G4ThreeVector GetEyePosition() const { return eyePosition; }
|
||||
inline void SetTargetPosition(G4ThreeVector val) { targetPosition = val; }
|
||||
inline G4ThreeVector GetTargetPosition() const { return targetPosition; }
|
||||
inline void SetLightDirection(G4ThreeVector val) { lightDirection = val.unit(); }
|
||||
inline G4ThreeVector GetLightDirection() const { return lightDirection; }
|
||||
inline void SetHeadAngle(G4double val) { headAngle = val; }
|
||||
inline G4double GetHeadAngle() const { return headAngle; }
|
||||
inline void SetViewSpan(G4double val) { viewSpan = val; }
|
||||
inline G4double GetViewSpan() const { return viewSpan; }
|
||||
inline void SetAttenuationLength(G4double val) { attenuationLength = val; }
|
||||
inline G4double GetAttenuationLength() const { return attenuationLength; }
|
||||
inline void SetDistortion(G4bool val) { distortionOn = val; }
|
||||
inline G4bool GetDistortion() const { return distortionOn; }
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTracerFeatures.hh,v 1.2 2000/03/09 15:36:35 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#ifndef G4RayTracerFeatures_HH
|
||||
#define G4RayTracerFeatures_HH 1
|
||||
|
||||
// To make John Allison happy...........
|
||||
|
||||
const char RAYTRACER_FEATURES[] =
|
||||
"Low quality high speed visualization using Geant4 kernel tracking mechanism.\
|
||||
\n Features: Generate JPEG file(s) as default \
|
||||
\n Visualize all kinds of solids including boolean solids \
|
||||
\n Disadvantages : Conceptually trajectories and hits cannot be drawn \
|
||||
\n No direct visualization";
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTracerSceneHandler.hh,v 1.2 2000/02/28 15:19:49 johna Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
|
||||
// John Allison 17th March 2000
|
||||
|
||||
#ifndef G4RAYTRACERSCENEHANDLER_HH
|
||||
#define G4RAYTRACERSCENEHANDLER_HH
|
||||
|
||||
#include "G4VSceneHandler.hh"
|
||||
|
||||
class G4RayTracerSceneHandler: public G4VSceneHandler {
|
||||
|
||||
public:
|
||||
|
||||
G4RayTracerSceneHandler(G4VGraphicsSystem& system,
|
||||
const G4String& name = "");
|
||||
virtual ~G4RayTracerSceneHandler();
|
||||
|
||||
void AddPrimitive(const G4Polyline&){}
|
||||
void AddPrimitive(const G4Text&){}
|
||||
void AddPrimitive(const G4Circle&){}
|
||||
void AddPrimitive(const G4Square&){}
|
||||
void AddPrimitive(const G4Polyhedron&){}
|
||||
void AddPrimitive(const G4NURBS&){}
|
||||
void AddPrimitive(const G4Polymarker&){}
|
||||
|
||||
void AddThis(const G4Box&){}
|
||||
void AddThis(const G4Cons&){}
|
||||
void AddThis(const G4Tubs&){}
|
||||
void AddThis(const G4Trd&){}
|
||||
void AddThis(const G4Trap&){}
|
||||
void AddThis(const G4Sphere&){}
|
||||
void AddThis(const G4Para&){}
|
||||
void AddThis(const G4Torus&){}
|
||||
void AddThis(const G4Polycone&){}
|
||||
void AddThis(const G4Polyhedra&){}
|
||||
void AddThis(const G4VSolid&){}
|
||||
|
||||
static G4int GetSceneCount();
|
||||
|
||||
private:
|
||||
static G4int fSceneIdCount; // Counter for RayTracer scene handlers.
|
||||
static G4int fSceneCount; // No. of extanct scenes.
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTracerViewer.hh,v 1.2 2000/02/28 15:19:49 johna Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
|
||||
// John Allison 17th March 2000
|
||||
|
||||
#ifndef G4RAYTRACERVIEWER_HH
|
||||
#define G4RAYTRACERVIEWER_HH
|
||||
|
||||
#include "G4VViewer.hh"
|
||||
|
||||
class G4RayTracerViewer: virtual public G4VViewer {
|
||||
public:
|
||||
G4RayTracerViewer(G4VSceneHandler&,const G4String& name);
|
||||
virtual ~G4RayTracerViewer();
|
||||
void SetView();
|
||||
void ClearView();
|
||||
void DrawView();
|
||||
private:
|
||||
G4int fFileCount;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTrajectory.hh,v 1.5 2000/03/09 17:38:33 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a concrete class of G4VTrajectory which represents a trajectory of a ray.
|
||||
// This class is used by G4RayTracer. Objects of this class are created by G4RTTrackingAction.
|
||||
// This class does not have concrete implementations of draw and print methods but
|
||||
// information stored in this class is used by determining a colour of a pixel of the picture.
|
||||
//
|
||||
|
||||
///////////////////
|
||||
//G4RayTrajectory.hh
|
||||
///////////////////
|
||||
|
||||
#ifndef G4RayTrajectory_h
|
||||
#define G4RayTrajectory_h 1
|
||||
|
||||
class G4Step;
|
||||
|
||||
#include "G4VTrajectory.hh"
|
||||
#include "G4Allocator.hh"
|
||||
#include <stdlib.h>
|
||||
#include <g4rw/tpordvec.h>
|
||||
#include "globals.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4RayTrajectoryPoint.hh"
|
||||
|
||||
|
||||
class G4RayTrajectory : public G4VTrajectory
|
||||
{
|
||||
public:
|
||||
|
||||
G4RayTrajectory();
|
||||
G4RayTrajectory(G4RayTrajectory & right);
|
||||
virtual ~G4RayTrajectory();
|
||||
|
||||
inline void* operator new(size_t);
|
||||
inline void operator delete(void*);
|
||||
inline int operator == (const G4RayTrajectory& right){return (this==&right);}
|
||||
|
||||
virtual void AppendStep(const G4Step*);
|
||||
virtual void ShowTrajectory() const;
|
||||
virtual void DrawTrajectory(G4int i_mode=0) const {;}
|
||||
virtual int GetPointEntries() const {return positionRecord->entries();}
|
||||
virtual G4VTrajectoryPoint* GetPoint(G4int i) const
|
||||
{ return (*positionRecord)[i]; }
|
||||
G4RayTrajectoryPoint* GetPointC(G4int i) const
|
||||
{ return (*positionRecord)[i]; }
|
||||
virtual void MergeTrajectory(G4VTrajectory* secondTrajectory);
|
||||
|
||||
private:
|
||||
|
||||
G4RWTPtrOrderedVector<G4RayTrajectoryPoint>* positionRecord;
|
||||
};
|
||||
|
||||
|
||||
extern G4Allocator<G4RayTrajectory> G4RayTrajectoryAllocator;
|
||||
|
||||
inline void* G4RayTrajectory::operator new(size_t)
|
||||
{
|
||||
void* aTrajectory;
|
||||
aTrajectory = (void*)G4RayTrajectoryAllocator.MallocSingle();
|
||||
return aTrajectory;
|
||||
}
|
||||
|
||||
inline void G4RayTrajectory::operator delete(void* aTrajectory)
|
||||
{
|
||||
G4RayTrajectoryAllocator.FreeSingle((G4RayTrajectory*)aTrajectory);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTrajectoryPoint.hh,v 1.3 2000/03/09 17:38:33 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a concrete class of G4VTrajectoryPoint which represents a point where
|
||||
// a ray crosses upon a surface of a volume regardless of its visibility. Objects
|
||||
// of this class are created by G4RayTrajectory class object.
|
||||
//
|
||||
|
||||
/////////////////////////
|
||||
//G4RayTrajectoryPoint.hh
|
||||
/////////////////////////
|
||||
|
||||
#ifndef G4RayTrajectoryPoint_h
|
||||
#define G4RayTrajectoryPoint_h 1
|
||||
|
||||
class G4VisAttributes;
|
||||
#include "globals.hh"
|
||||
#include "G4VTrajectoryPoint.hh"
|
||||
#include "G4Allocator.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
class G4RayTrajectoryPoint :public G4VTrajectoryPoint
|
||||
{
|
||||
public:
|
||||
G4RayTrajectoryPoint();
|
||||
virtual ~G4RayTrajectoryPoint();
|
||||
|
||||
inline void *operator new(size_t);
|
||||
inline void operator delete(void *aTrajectoryPoint);
|
||||
inline int operator==(const G4RayTrajectoryPoint& right) const
|
||||
{ return (this==&right); };
|
||||
|
||||
private:
|
||||
const G4VisAttributes* preStepAtt;
|
||||
const G4VisAttributes* postStepAtt;
|
||||
G4ThreeVector surfaceNormal;
|
||||
G4double stepLength;
|
||||
|
||||
public:
|
||||
inline void SetPreStepAtt(const G4VisAttributes* val) { preStepAtt = val; }
|
||||
inline const G4VisAttributes* GetPreStepAtt() const { return preStepAtt; }
|
||||
inline void SetPostStepAtt(const G4VisAttributes* val) { postStepAtt = val; }
|
||||
inline const G4VisAttributes* GetPostStepAtt() const { return postStepAtt; }
|
||||
inline void SetSurfaceNormal(G4ThreeVector val) { surfaceNormal = val; }
|
||||
inline G4ThreeVector GetSurfaceNormal() const { return surfaceNormal; }
|
||||
inline void SetStepLength(G4double val) { stepLength = val; }
|
||||
inline G4double GetStepLength() const { return stepLength; }
|
||||
|
||||
};
|
||||
|
||||
extern G4Allocator<G4RayTrajectoryPoint> G4RayTrajectoryPointAllocator;
|
||||
|
||||
inline void* G4RayTrajectoryPoint::operator new(size_t)
|
||||
{
|
||||
void *aTrajectoryPoint;
|
||||
aTrajectoryPoint = (void *) G4RayTrajectoryPointAllocator.MallocSingle();
|
||||
return aTrajectoryPoint;
|
||||
}
|
||||
|
||||
inline void G4RayTrajectoryPoint::operator delete(void *aTrajectoryPoint)
|
||||
{
|
||||
G4RayTrajectoryPointAllocator.FreeSingle((G4RayTrajectoryPoint *) aTrajectoryPoint);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VFigureFileMaker.hh,v 1.3 2000/03/09 17:38:33 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is an abstract class represents a class which generates a figure file
|
||||
// converting from RGB 8 bits unsigned integers to a kind of picture format.
|
||||
//
|
||||
|
||||
#ifndef G4VFigureFileMaker_H
|
||||
#define G4VFigureFileMaker_H 1
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
class G4VFigureFileMaker
|
||||
{
|
||||
public:
|
||||
G4VFigureFileMaker() {;}
|
||||
virtual ~G4VFigureFileMaker() {;}
|
||||
|
||||
public:
|
||||
virtual void CreateFigureFile(G4String fileName,
|
||||
int nColumn,int nRow,
|
||||
unsigned char* colorR, unsigned char* colorG,
|
||||
unsigned char* colorB) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,363 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTJpegCoder.cc,v 1.3 2000/03/09 15:36:37 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "G4RTJpeg.hh"
|
||||
#include "G4RTOutBitStream.hh"
|
||||
#include "G4RTJpegMaker.hh"
|
||||
#include "G4RTJpegCoder.hh"
|
||||
#include "G4RTJpegCoderTables.hh"
|
||||
|
||||
|
||||
G4JpegCoder::G4JpegCoder(u_char* colorR,u_char* colorG,u_char* colorB)
|
||||
{
|
||||
mRgb[0] = colorR;
|
||||
mRgb[1] = colorG;
|
||||
mRgb[2] = colorB;
|
||||
|
||||
mPreDC[0] = mPreDC[1] = mPreDC[2] = 0;
|
||||
mOBSP = 0;
|
||||
|
||||
for(int n=0; n<8; n++)
|
||||
for(int m=0; m<8; m++)
|
||||
mCosT[n][m] = cos((2 * m + 1) * n * PaiDiv16);
|
||||
}
|
||||
|
||||
G4JpegCoder::~G4JpegCoder(void)
|
||||
{
|
||||
if(mOBSP != 0)
|
||||
delete mOBSP;
|
||||
}
|
||||
|
||||
void
|
||||
G4JpegCoder::GetJpegData(char** aJpegData, int& size)
|
||||
{
|
||||
if (mOBSP != 0){
|
||||
*aJpegData = (char*)mOBSP->GetStreamAddress();
|
||||
size = mOBSP->GetStreamSize();
|
||||
}
|
||||
else{
|
||||
*aJpegData = 0;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
G4JpegCoder::DoCoding(void)
|
||||
{
|
||||
mNumVUnits = (mProperty.nRow / 16) + ((mProperty.nRow % 16) ? 1 : 0);
|
||||
mNumHUnits = (mProperty.nColumn / 16) + ((mProperty.nColumn % 16) ? 1 : 0);
|
||||
|
||||
int size = mProperty.nColumn * mProperty.nRow * 3;
|
||||
if(size < 10240)
|
||||
size = 10240;
|
||||
|
||||
try{
|
||||
mOBSP = new G4OutBitStream(size);
|
||||
WriteHeader();
|
||||
for(int yu=0; yu<mNumVUnits; yu++){
|
||||
for(int xu=0; xu<mNumHUnits; xu++){
|
||||
makeYCC(xu, yu);
|
||||
|
||||
//mRgb->YCrCb
|
||||
#ifdef GRAY
|
||||
for(int i=0; i<64; i++)
|
||||
mCbBlock[i] = mCrBlock[i] = 0;
|
||||
#endif
|
||||
CodeMCU();
|
||||
}
|
||||
}
|
||||
WriteEOI();
|
||||
return M_NoError;
|
||||
}
|
||||
|
||||
catch(G4MemoryError &me){
|
||||
return M_RuntimeError;
|
||||
}
|
||||
catch(G4BufferError &be){
|
||||
return M_RuntimeError;
|
||||
}
|
||||
catch(G4IndexError &ie){
|
||||
return M_RuntimeError;
|
||||
}
|
||||
}
|
||||
|
||||
//MCU
|
||||
void
|
||||
G4JpegCoder::CodeMCU(void)
|
||||
{
|
||||
for(int n=0; n<4; n++){
|
||||
ForwardDCT(mYBlock[n]);
|
||||
Quantization(0);
|
||||
CodeHuffman(0);
|
||||
}
|
||||
ForwardDCT(mCbBlock);
|
||||
Quantization(1);
|
||||
CodeHuffman(1);
|
||||
|
||||
ForwardDCT(mCrBlock);
|
||||
Quantization(2);
|
||||
CodeHuffman(2);
|
||||
}
|
||||
|
||||
void
|
||||
G4JpegCoder::makeYCC(int ux, int uy)
|
||||
{
|
||||
u_char rv, gv, bv;
|
||||
int tCrBlock[4][64];
|
||||
int tCbBlock[4][64];
|
||||
|
||||
for(int u=0; u<4; u++){
|
||||
int *yp = mYBlock[u];
|
||||
int *cbp = tCbBlock[u];
|
||||
int *crp = tCrBlock[u];
|
||||
|
||||
int sx = ux * 16 + ((u&1) ? 8 : 0);
|
||||
int ex = sx + 8;
|
||||
int sy = uy * 16 + ((u>1) ? 8 : 0);
|
||||
int ey = sy + 8;
|
||||
|
||||
for(int iv=sy; iv<ey; iv++){
|
||||
int ii = iv < mProperty.nRow ? iv : mProperty.nRow - 1;
|
||||
for(int ih=sx; ih<ex; ih++){
|
||||
int jj = ih < mProperty.nColumn ? ih : mProperty.nColumn - 1;
|
||||
int index = ii * mProperty.nColumn + jj;
|
||||
rv = mRgb[0][index];
|
||||
gv = mRgb[1][index];
|
||||
bv = mRgb[2][index];
|
||||
|
||||
*yp++ = int((0.2990 * rv) + (0.5870 * gv) + (0.1140 * bv) - 128)
|
||||
;
|
||||
*cbp++ = int(-(0.1687 * rv) - (0.3313 * gv) + (0.5000 * bv));
|
||||
*crp++ = int((0.5000 * rv) - (0.4187 * gv) - (0.0813 * bv));
|
||||
} // ih
|
||||
} //iv
|
||||
} //u
|
||||
|
||||
int n = 0;
|
||||
for(int b=0; b<4; b++){
|
||||
switch(b){
|
||||
case 0: n=0; break;
|
||||
case 1: n=4; break;
|
||||
case 2: n=32; break;
|
||||
case 3: n=36;
|
||||
}
|
||||
for(int y=0; y<8; y+=2){
|
||||
for(int x=0; x<8; x+=2){
|
||||
int idx = y * 8 + x;
|
||||
mCrBlock[n] = tCrBlock[b][idx];
|
||||
mCbBlock[n] = tCbBlock[b][idx];
|
||||
n++;
|
||||
}
|
||||
n += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
G4JpegCoder::CodeHuffman(int cs)
|
||||
{
|
||||
const G4HuffmanCodeTable& dcT = cs ? CDcHuffmanT : YDcHuffmanT;
|
||||
const G4HuffmanCodeTable& acT = cs ? CAcHuffmanT : YAcHuffmanT;
|
||||
const int eobIdx = cs ? CEOBidx : YEOBidx;
|
||||
const int zrlIdx = cs ? CZRLidx : YZRLidx;
|
||||
|
||||
int diff = mDCTData[0] - mPreDC[cs];
|
||||
mPreDC[cs] = mDCTData[0];
|
||||
int absDiff = abs(diff);
|
||||
int dIdx = 0;
|
||||
|
||||
while(absDiff > 0){
|
||||
absDiff >>= 1;
|
||||
dIdx++;
|
||||
}
|
||||
if(dIdx > dcT.numOfElement)
|
||||
throw(G4IndexError(dcT.numOfElement, dIdx, "CodeHuffman:DC"));
|
||||
mOBSP->SetBits((dcT.CodeT)[dIdx], (dcT.SizeT)[dIdx]);
|
||||
|
||||
if(dIdx){
|
||||
if(diff < 0)
|
||||
diff--;
|
||||
mOBSP->SetBits(diff, dIdx);
|
||||
}
|
||||
|
||||
int run = 0;
|
||||
for(int n=1; n<64; n++){
|
||||
int absCoefficient = abs( mDCTData[ Zigzag[n] ] );
|
||||
if( absCoefficient ){
|
||||
while( run > 15 ){
|
||||
mOBSP->SetBits((acT.CodeT)[zrlIdx], (acT.SizeT)[zrlIdx]);
|
||||
run -= 16;
|
||||
}
|
||||
int s = 0;
|
||||
while( absCoefficient > 0 ){
|
||||
absCoefficient >>= 1;
|
||||
s++;
|
||||
}
|
||||
int aIdx = run * 10 + s + (run == 15);
|
||||
if( aIdx >= acT.numOfElement )
|
||||
throw( G4IndexError( acT.numOfElement, aIdx, "CodeHuffman:AC" )
|
||||
);
|
||||
mOBSP->SetBits( (acT.CodeT)[aIdx], (acT.SizeT)[aIdx] );
|
||||
int v = mDCTData[ Zigzag[n] ];
|
||||
if( v < 0 )
|
||||
v--;
|
||||
mOBSP->SetBits( v, s );
|
||||
run = 0;
|
||||
}
|
||||
else{
|
||||
if(n == 63)
|
||||
mOBSP->SetBits( (acT.CodeT)[eobIdx], (acT.SizeT)[eobIdx] );
|
||||
else
|
||||
run++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
G4JpegCoder::Quantization(int cs)
|
||||
{
|
||||
int* qt = (int*)(cs ? CQuantumT : YQuantumT);
|
||||
for( int i=0; i<64; i++ ){
|
||||
mDCTData[i] /= qt[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
G4JpegCoder::ForwardDCT(int* picData)
|
||||
{
|
||||
for( int v=0; v<8; v++ ){
|
||||
double cv = v ? 1.0 : DisSqrt2;
|
||||
for( int u=0; u<8; u++ ){
|
||||
double cu = u ? 1.0 : DisSqrt2;
|
||||
double sum = 0;
|
||||
|
||||
for( int y=0; y<8; y++ )
|
||||
for( int x=0; x<8; x++ )
|
||||
sum += picData[ y * 8 + x ] * mCosT[u][x] * mCosT[v][y];
|
||||
mDCTData[ v * 8 + u ] = int( sum * cu * cv / 4 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
G4JpegCoder::WriteHeader( void )
|
||||
{
|
||||
int i = 0; //counter
|
||||
//SOI
|
||||
mOBSP->SetByte( M_Marker ); //FF
|
||||
mOBSP->SetByte( M_SOI ); //SOI
|
||||
|
||||
//APP0(JFIF Header)
|
||||
mOBSP->SetByte( M_Marker ); //FF
|
||||
mOBSP->SetByte( M_APP0 ); //APP0
|
||||
mOBSP->SetWord( JFIFLength ); //parameter
|
||||
mOBSP->CopyByte( (char*)JFIF, 5 ); //"JFIF\0"
|
||||
mOBSP->SetWord( JFIFVersion ); //Version
|
||||
mOBSP->SetByte( mProperty.Units );
|
||||
mOBSP->SetWord( mProperty.HDensity );
|
||||
mOBSP->SetWord( mProperty.VDensity );
|
||||
mOBSP->SetByte( 0 );
|
||||
mOBSP->SetByte( 0 );
|
||||
|
||||
//comment
|
||||
if( mProperty.Comment != 0 ){
|
||||
mOBSP->SetByte( M_Marker ); //FF
|
||||
mOBSP->SetByte( M_COM ); //comment
|
||||
int length = strlen( mProperty.Comment ) + 1;
|
||||
mOBSP->SetWord( length + 2 );
|
||||
mOBSP->CopyByte( mProperty.Comment, length );
|
||||
}
|
||||
|
||||
//DQT
|
||||
mOBSP->SetByte( M_Marker );
|
||||
mOBSP->SetByte( M_DQT );
|
||||
mOBSP->SetWord( 67 );
|
||||
mOBSP->SetByte( 0 );
|
||||
for( i=0; i<64; i++ )
|
||||
mOBSP->SetByte( u_char( YQuantumT[Zigzag[i]] ) );
|
||||
mOBSP->SetByte( M_Marker );
|
||||
mOBSP->SetByte( M_DQT );
|
||||
mOBSP->SetWord( 67 );
|
||||
mOBSP->SetByte( 1 );
|
||||
for( i=0; i<64; i++ )
|
||||
mOBSP->SetByte( u_char( CQuantumT[Zigzag[i]] ) );
|
||||
// DHT
|
||||
mOBSP->CopyByte( (char*)YDcDht, DcDhtLength );
|
||||
mOBSP->CopyByte( (char*)CDcDht, DcDhtLength );
|
||||
mOBSP->CopyByte( (char*)YAcDht, AcDhtLength );
|
||||
mOBSP->CopyByte( (char*)CAcDht, AcDhtLength );
|
||||
|
||||
// Frame Header
|
||||
mOBSP->SetByte( M_Marker ); // FF
|
||||
mOBSP->SetByte( M_SOF0 );
|
||||
mOBSP->SetWord( 3 * mProperty.Dimension + 8 );
|
||||
mOBSP->SetByte( mProperty.SamplePrecision );
|
||||
mOBSP->SetWord( mProperty.nRow );
|
||||
mOBSP->SetWord( mProperty.nColumn );
|
||||
mOBSP->SetByte( mProperty.Dimension );
|
||||
|
||||
mOBSP->SetByte( 0 );
|
||||
mOBSP->SetByte( YSampleF );
|
||||
mOBSP->SetByte( 0 );
|
||||
|
||||
mOBSP->SetByte( 1 );
|
||||
mOBSP->SetByte( CSampleF );
|
||||
|
||||
mOBSP->SetByte( 1 );
|
||||
mOBSP->SetByte( 2 );
|
||||
mOBSP->SetByte( CSampleF );
|
||||
mOBSP->SetByte( 1 );
|
||||
|
||||
//Scan Header
|
||||
mOBSP->SetByte( M_Marker );
|
||||
mOBSP->SetByte( M_SOS );
|
||||
mOBSP->SetWord( 2 * mProperty.Dimension + 6 );
|
||||
mOBSP->SetByte( mProperty.Dimension );
|
||||
for( i=0; i<mProperty.Dimension; i++ ){
|
||||
mOBSP->SetByte( i );
|
||||
mOBSP->SetByte( i==0 ? 0 : 0x11 );
|
||||
}
|
||||
mOBSP->SetByte( 0 ); //Ss
|
||||
mOBSP->SetByte( 63 ); //Se
|
||||
mOBSP->SetByte( 0 ); //Ah,Al
|
||||
}
|
||||
|
||||
//EOI
|
||||
void
|
||||
G4JpegCoder::WriteEOI( void )
|
||||
{
|
||||
mOBSP->SetByte( M_Marker );
|
||||
mOBSP->SetByte( M_EOI );
|
||||
}
|
||||
|
||||
//SetJpegProperty
|
||||
void
|
||||
G4JpegCoder::SetJpegProperty(const G4JpegProperty& aProperty )
|
||||
{
|
||||
mProperty = aProperty;
|
||||
mProperty.Dimension = 3;
|
||||
mProperty.SamplePrecision = 8;
|
||||
mProperty.Format = 1;
|
||||
mProperty.MajorRevisions = 1;
|
||||
mProperty.MinorRevisions = 2;
|
||||
mProperty.HThumbnail = 0;
|
||||
mProperty.VThumbnail = 0;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTJpegMaker.cc,v 1.4 2000/03/09 15:36:37 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#include "G4RTJpeg.hh"
|
||||
#include "G4RTJpegMaker.hh"
|
||||
#include "G4RTJpegCoder.hh"
|
||||
#include <g4std/fstream>
|
||||
|
||||
G4RTJpegMaker::G4RTJpegMaker()
|
||||
{;}
|
||||
|
||||
G4RTJpegMaker::~G4RTJpegMaker()
|
||||
{;}
|
||||
|
||||
void G4RTJpegMaker::CreateFigureFile(G4String fileName,
|
||||
int nColumn, int nRow,
|
||||
u_char* colorR,
|
||||
u_char* colorG,
|
||||
u_char* colorB)
|
||||
{
|
||||
G4JpegCoder aFigure(colorR,colorG,colorB);
|
||||
G4JpegProperty aProperty;
|
||||
aProperty.nColumn = nColumn;
|
||||
aProperty.nRow = nRow;
|
||||
aProperty.Units = 0;
|
||||
aProperty.HDensity = 1;
|
||||
aProperty.VDensity = 1;
|
||||
aProperty.ExtensionCode = 0;
|
||||
aProperty.Comment = "Geant4 Ray Tracer Version 1.0 by M.Asai K.Minamimoto C.Kishinaga";
|
||||
|
||||
aFigure.SetJpegProperty(aProperty);
|
||||
aFigure.DoCoding();
|
||||
|
||||
char* jpegAddress;
|
||||
int jpegSize;
|
||||
|
||||
aFigure.GetJpegData(&jpegAddress,jpegSize);
|
||||
|
||||
G4std::ofstream ofs;
|
||||
ofs.open(fileName,G4std::ios::out);
|
||||
ofs.write(jpegAddress,jpegSize);
|
||||
ofs.close();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTMessenger.cc,v 1.4 2000/06/07 02:52:45 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#include "G4RTMessenger.hh"
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWith3Vector.hh"
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4RayTracer.hh"
|
||||
#include "G4RTSteppingAction.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
G4RTMessenger::G4RTMessenger(G4RayTracer* p1,G4RTSteppingAction* p2)
|
||||
{
|
||||
theTracer = p1;
|
||||
theSteppingAction = p2;
|
||||
|
||||
rayDirectory = new G4UIdirectory("/vis/rayTracer/");
|
||||
rayDirectory->SetGuidance("RayTracer commands.");
|
||||
|
||||
fileCmd = new G4UIcmdWithAString("/vis/rayTracer/trace",this);
|
||||
fileCmd->SetGuidance("Start the ray tracing.");
|
||||
fileCmd->SetGuidance("Define the name of output JPEG file.");
|
||||
fileCmd->SetParameterName("fileName",true);
|
||||
fileCmd->SetDefaultValue("g4RayTracer.jpeg");
|
||||
fileCmd->AvailableForStates(Idle);
|
||||
|
||||
columnCmd = new G4UIcmdWithAnInteger("/vis/rayTracer/column",this);
|
||||
columnCmd->SetGuidance("Define the number of horizontal pixels.");
|
||||
columnCmd->SetParameterName("nPixel",false);
|
||||
columnCmd->SetRange("nPixel > 0");
|
||||
|
||||
rowCmd = new G4UIcmdWithAnInteger("/vis/rayTracer/row",this);
|
||||
rowCmd->SetGuidance("Define the number of virtical pixels.");
|
||||
rowCmd->SetParameterName("nPixel",false);
|
||||
rowCmd->SetRange("nPixel > 0");
|
||||
|
||||
targetCmd = new G4UIcmdWith3VectorAndUnit("/vis/rayTracer/target",this);
|
||||
targetCmd->SetGuidance("Define the center position of the target.");
|
||||
targetCmd->SetParameterName("X","Y","Z",true);
|
||||
targetCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
|
||||
targetCmd->SetDefaultUnit("m");
|
||||
|
||||
eyePosCmd = new G4UIcmdWith3VectorAndUnit("/vis/rayTracer/eyePosition",this);
|
||||
eyePosCmd->SetGuidance("Define the eye position.");
|
||||
eyePosCmd->SetGuidance("Eye direction is calsurated from (target - eyePosition).");
|
||||
eyePosCmd->SetParameterName("X","Y","Z",true);
|
||||
eyePosCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
|
||||
eyePosCmd->SetDefaultUnit("m");
|
||||
|
||||
lightCmd = new G4UIcmdWith3Vector("/vis/rayTracer/lightDirection",this);
|
||||
lightCmd->SetGuidance("Define the direction of illumination light.");
|
||||
lightCmd->SetGuidance("The vector needs not to be a unit vector, but it must not be a zero vector.");
|
||||
lightCmd->SetParameterName("Px","Py","Pz",true);
|
||||
lightCmd->SetDefaultValue(G4ThreeVector(0.1,0.2,0.3));
|
||||
lightCmd->SetRange("Px != 0 || Py != 0 || Pz != 0");
|
||||
|
||||
spanXCmd = new G4UIcmdWithADoubleAndUnit("/vis/rayTracer/span",this);
|
||||
spanXCmd->SetGuidance("Define the angle per 100 pixels.");
|
||||
spanXCmd->SetParameterName("span",true);
|
||||
spanXCmd->SetDefaultValue(50.);
|
||||
spanXCmd->SetDefaultUnit("deg");
|
||||
spanXCmd->SetRange("span>0.");
|
||||
|
||||
headCmd = new G4UIcmdWithADoubleAndUnit("/vis/rayTracer/headAngle",this);
|
||||
headCmd->SetGuidance("Define the head direction.");
|
||||
headCmd->SetParameterName("headAngle",true);
|
||||
headCmd->SetDefaultValue(270.);
|
||||
headCmd->SetDefaultUnit("deg");
|
||||
headCmd->SetRange("headAngle>=0. && headAngle<360.");
|
||||
|
||||
attCmd = new G4UIcmdWithADoubleAndUnit("/vis/rayTracer/attenuation",this);
|
||||
attCmd->SetGuidance("Define the attenuation length for transparent material.");
|
||||
attCmd->SetGuidance("Note that this value is independent to the attenuation length for the optical photon processes.");
|
||||
attCmd->SetParameterName("Length",true);
|
||||
attCmd->SetDefaultValue(1.0);
|
||||
attCmd->SetDefaultUnit("m");
|
||||
attCmd->SetRange("Length > 0.");
|
||||
|
||||
distCmd = new G4UIcmdWithABool("/vis/rayTracer/distortion",this);
|
||||
distCmd->SetGuidance("Distortion effect of the fish eye lens.");
|
||||
distCmd->SetParameterName("flag",true);
|
||||
distCmd->SetDefaultValue(false);
|
||||
|
||||
transCmd = new G4UIcmdWithABool("/vis/rayTracer/ignoreTransparency",this);
|
||||
transCmd->SetGuidance("Ignore transparency even if the alpha of G4Colour < 1.");
|
||||
transCmd->SetParameterName("flag",true);
|
||||
transCmd->SetDefaultValue(false);
|
||||
}
|
||||
|
||||
G4RTMessenger::~G4RTMessenger()
|
||||
{
|
||||
delete columnCmd;
|
||||
delete rowCmd;
|
||||
delete targetCmd;
|
||||
delete eyePosCmd;
|
||||
delete lightCmd;
|
||||
delete spanXCmd;
|
||||
delete headCmd;
|
||||
delete attCmd;
|
||||
delete distCmd;
|
||||
delete transCmd;
|
||||
delete fileCmd;
|
||||
delete rayDirectory;
|
||||
}
|
||||
|
||||
G4String G4RTMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
{
|
||||
G4String currentValue;
|
||||
if(command==columnCmd)
|
||||
{ currentValue = columnCmd->ConvertToString(theTracer->GetNColumn()); }
|
||||
else if(command==rowCmd)
|
||||
{ currentValue = rowCmd->ConvertToString(theTracer->GetNRow()); }
|
||||
else if(command==targetCmd)
|
||||
{ currentValue = targetCmd->ConvertToString(theTracer->GetTargetPosition(),"m"); }
|
||||
else if(command==eyePosCmd)
|
||||
{ currentValue = eyePosCmd->ConvertToString(theTracer->GetEyePosition(),"m"); }
|
||||
else if(command==lightCmd)
|
||||
{ currentValue = lightCmd->ConvertToString(theTracer->GetLightDirection()); }
|
||||
else if(command==spanXCmd)
|
||||
{ currentValue = spanXCmd->ConvertToString(theTracer->GetViewSpan(),"deg"); }
|
||||
else if(command==headCmd)
|
||||
{ currentValue = headCmd->ConvertToString(theTracer->GetHeadAngle(),"deg"); }
|
||||
else if(command==attCmd)
|
||||
{ currentValue = attCmd->ConvertToString(theTracer->GetAttenuationLength(),"m");}
|
||||
else if(command==distCmd)
|
||||
{ currentValue = distCmd->ConvertToString(theTracer->GetDistortion()); }
|
||||
else if(command==transCmd)
|
||||
{ currentValue = transCmd->ConvertToString(theSteppingAction->GetIgnoreTransparency()); }
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
void G4RTMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
if(command==columnCmd)
|
||||
{ theTracer->SetNColumn(columnCmd->GetNewIntValue(newValue)); }
|
||||
else if(command==rowCmd)
|
||||
{ theTracer->SetNRow(rowCmd->GetNewIntValue(newValue)); }
|
||||
else if(command==targetCmd)
|
||||
{ theTracer->SetTargetPosition(targetCmd->GetNew3VectorValue(newValue)); }
|
||||
else if(command==eyePosCmd)
|
||||
{ theTracer->SetEyePosition(eyePosCmd->GetNew3VectorValue(newValue)); }
|
||||
else if(command==lightCmd)
|
||||
{ theTracer->SetLightDirection(lightCmd->GetNew3VectorValue(newValue)); }
|
||||
else if(command==spanXCmd)
|
||||
{ theTracer->SetViewSpan(spanXCmd->GetNewDoubleValue(newValue)); }
|
||||
else if(command==headCmd)
|
||||
{ theTracer->SetHeadAngle(headCmd->GetNewDoubleValue(newValue)); }
|
||||
else if(command==attCmd)
|
||||
{ theTracer->SetAttenuationLength(attCmd->GetNewDoubleValue(newValue)); }
|
||||
else if(command==distCmd)
|
||||
{ theTracer->SetDistortion(distCmd->GetNewBoolValue(newValue)); }
|
||||
else if(command==transCmd)
|
||||
{ theSteppingAction->SetIgnoreTransparency(transCmd->GetNewBoolValue(newValue)); }
|
||||
else if(command==fileCmd)
|
||||
{ theTracer->Trace(newValue); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTOutBitStream.cc,v 1.3 2000/03/09 15:36:37 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h>
|
||||
#include "G4RTJpeg.hh"
|
||||
#include "G4RTOutBitStream.hh"
|
||||
|
||||
|
||||
|
||||
G4OutBitStream::G4OutBitStream(int size)
|
||||
{
|
||||
if(size < 1)
|
||||
throw( G4MemoryError( size, "G4OutBitStream" ) );
|
||||
|
||||
mHeadOfBuf = mBuf = new u_char[size];
|
||||
if( mHeadOfBuf == 0 )
|
||||
throw( G4MemoryError( size, "G4OutBitStream" ) );
|
||||
|
||||
mEndOfBuf = mBuf + size;
|
||||
|
||||
memset( mHeadOfBuf, 0, size );
|
||||
|
||||
mBitPos = 7;
|
||||
mWriteFlag = 1;
|
||||
}
|
||||
|
||||
void
|
||||
G4OutBitStream::IncBuf( void )
|
||||
{
|
||||
if( ++mBuf >= mEndOfBuf )
|
||||
mWriteFlag = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
G4OutBitStream::SetBits(int v, int numBits)
|
||||
{
|
||||
if( numBits == 0 )
|
||||
return;
|
||||
if( numBits > 16 )
|
||||
throw( G4BufferError( "SetBits:Max Bit Over" ) );
|
||||
if( numBits > 8 ){
|
||||
Set8Bits( u_char(v>>8), numBits-8 );
|
||||
numBits = 8;
|
||||
}
|
||||
Set8Bits( u_char(v), numBits );
|
||||
}
|
||||
|
||||
void
|
||||
G4OutBitStream::SetFewBits(u_char v, int numBits)
|
||||
{
|
||||
v &= BitFullMaskT[numBits-1];
|
||||
*mBuf |= v << (mBitPos + 1 - numBits);
|
||||
if( (mBitPos -= numBits) < 0 ){
|
||||
if( *mBuf == 0xff ){
|
||||
IncBuf();
|
||||
*mBuf = 0;
|
||||
}
|
||||
IncBuf();
|
||||
mBitPos = 7;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
G4OutBitStream::SetBits2Byte(u_char v, int numBits)
|
||||
{
|
||||
v &= BitFullMaskT[numBits-1];
|
||||
int nextBits = numBits - (mBitPos + 1);
|
||||
*mBuf |= ( v >> nextBits ) & BitFullMaskT[mBitPos];
|
||||
if( *mBuf == 0xff ){
|
||||
IncBuf();
|
||||
*mBuf = 0;
|
||||
}
|
||||
IncBuf();
|
||||
|
||||
*mBuf = v << 8 - nextBits;
|
||||
mBitPos = 7 - nextBits;
|
||||
}
|
||||
|
||||
void
|
||||
G4OutBitStream::Set8Bits(u_char v, int numBits)
|
||||
{
|
||||
if( mBitPos + 1 >= numBits )
|
||||
SetFewBits( (u_char)v, numBits );
|
||||
else
|
||||
SetBits2Byte( (u_char)v, numBits );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
G4OutBitStream::FullBit( void )
|
||||
{
|
||||
if( mBitPos != 7 )
|
||||
SetFewBits( BitFullMaskT[mBitPos], mBitPos+1 );
|
||||
}
|
||||
|
||||
void
|
||||
G4OutBitStream::SetByte(u_char dat)
|
||||
{
|
||||
if( mWriteFlag ){
|
||||
FullBit();
|
||||
*mBuf = dat;
|
||||
IncBuf();
|
||||
return;
|
||||
}
|
||||
throw( G4BufferError( "SetByte" ) );
|
||||
}
|
||||
|
||||
void
|
||||
G4OutBitStream::SetWord(u_int dat)
|
||||
{
|
||||
if( mWriteFlag ){
|
||||
FullBit();
|
||||
*mBuf = (dat >> 8) & 0xff;
|
||||
IncBuf();
|
||||
*mBuf = dat & 0xff;
|
||||
IncBuf();
|
||||
return;
|
||||
}
|
||||
throw( G4BufferError( "SetWord" ) );
|
||||
}
|
||||
|
||||
void
|
||||
G4OutBitStream::CopyByte(const char* src, int n)
|
||||
{
|
||||
if( mBuf+n < mEndOfBuf ){
|
||||
FullBit();
|
||||
memcpy( mBuf, src, n );
|
||||
mBuf += n;
|
||||
return;
|
||||
}
|
||||
throw( G4BufferError( "CopyByte" ) );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTSteppingAction.cc,v 1.5 2000/03/09 15:36:37 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#include "G4RTSteppingAction.hh"
|
||||
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4VisManager.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4StepStatus.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
G4RTSteppingAction::G4RTSteppingAction()
|
||||
{
|
||||
ignoreTransparency=false;
|
||||
}
|
||||
|
||||
void G4RTSteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
{
|
||||
// Stop the ray particle if it reaches to the coloured volume with its alpha = 1
|
||||
// or coloured volume and the user request to ignore transparency
|
||||
|
||||
G4StepPoint* fpStepPoint = aStep -> GetPostStepPoint();
|
||||
G4VPhysicalVolume* postVolume_phys=fpStepPoint->GetPhysicalVolume();
|
||||
|
||||
if(!postVolume_phys) return; // Reach to out of the world
|
||||
|
||||
const G4LogicalVolume* postVolume_log = postVolume_phys->GetLogicalVolume();
|
||||
const G4VisAttributes* postVisAtt = postVolume_log -> GetVisAttributes();
|
||||
G4VisManager* visManager = G4VisManager::GetInstance();
|
||||
if(visManager) {
|
||||
G4VViewer* viewer = visManager->GetCurrentViewer();
|
||||
if (viewer) {
|
||||
postVisAtt = viewer->GetApplicableVisAttributes(postVisAtt);
|
||||
}
|
||||
}
|
||||
if((!postVisAtt) || (!(postVisAtt->IsVisible()))) return; // Invisible volume, continue tracking
|
||||
|
||||
if((postVisAtt->IsForceDrawingStyle())
|
||||
&&(postVisAtt->GetForcedDrawingStyle()==G4VisAttributes::wireframe)) return;
|
||||
// Wire frame volume, continue tracking
|
||||
|
||||
G4double postAlpha=(postVisAtt->GetColour()).GetAlpha();
|
||||
|
||||
if(postAlpha==1.0 || ignoreTransparency) // Stop stepping
|
||||
{
|
||||
G4Track* currentTrack = aStep -> GetTrack();
|
||||
currentTrack -> SetTrackStatus(fStopAndKill);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RTTrackingAction.cc,v 1.2 2000/03/09 15:36:38 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
///////////////////////
|
||||
//G4RTTrackingAction.cc
|
||||
///////////////////////
|
||||
|
||||
|
||||
#include "G4RTTrackingAction.hh"
|
||||
#include "G4RayTrajectory.hh"
|
||||
#include "G4TrackingManager.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
|
||||
void G4RTTrackingAction :: PreUserTrackingAction(const G4Track* aTrack)
|
||||
{
|
||||
G4RayTrajectory* aTrajectory=new G4RayTrajectory;
|
||||
fpTrackingManager->SetTrajectory(aTrajectory);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayShooter.cc,v 1.1 2000/01/29 00:44:53 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
|
||||
#include "G4RayShooter.hh"
|
||||
#include "G4PrimaryParticle.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4Geantino.hh"
|
||||
|
||||
G4RayShooter::G4RayShooter()
|
||||
{
|
||||
SetInitialValues();
|
||||
}
|
||||
|
||||
void G4RayShooter::SetInitialValues()
|
||||
{
|
||||
particle_definition = G4Geantino::GeantinoDefinition();
|
||||
G4ThreeVector zero;
|
||||
particle_momentum_direction = (G4ParticleMomentum)zero;
|
||||
particle_energy = 1.0*GeV;
|
||||
particle_position = zero;
|
||||
particle_time = 0.0;
|
||||
particle_polarization = zero;
|
||||
}
|
||||
|
||||
G4RayShooter::~G4RayShooter()
|
||||
{
|
||||
}
|
||||
|
||||
void G4RayShooter::Shoot(G4Event* evt,G4ThreeVector vtx,G4ThreeVector direc)
|
||||
{
|
||||
// create a new vertex
|
||||
G4PrimaryVertex* vertex = new G4PrimaryVertex(vtx,particle_time);
|
||||
|
||||
// create new primaries and set them to the vertex
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
G4double energy = particle_energy + mass;
|
||||
G4double pmom = sqrt(energy*energy-mass*mass);
|
||||
G4double px = pmom*direc.x();
|
||||
G4double py = pmom*direc.y();
|
||||
G4double pz = pmom*direc.z();
|
||||
G4PrimaryParticle* particle =
|
||||
new G4PrimaryParticle(particle_definition,px,py,pz);
|
||||
particle->SetMass( mass );
|
||||
particle->SetPolarization(particle_polarization.x(),
|
||||
particle_polarization.y(),
|
||||
particle_polarization.z());
|
||||
vertex->SetPrimary( particle );
|
||||
|
||||
evt->AddPrimaryVertex( vertex );
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,358 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTracer.cc,v 1.6 2000/06/07 02:52:45 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#include "G4RayTracer.hh"
|
||||
#include "G4RayTracerFeatures.hh"
|
||||
#include "G4RayTracerSceneHandler.hh"
|
||||
#include "G4RayTracerViewer.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4RTMessenger.hh"
|
||||
#include "G4RayShooter.hh"
|
||||
#include "G4VFigureFileMaker.hh"
|
||||
#include "G4RTTrackingAction.hh"
|
||||
#include "G4RTSteppingAction.hh"
|
||||
#include "G4RayTrajectory.hh"
|
||||
#include "G4RayTrajectoryPoint.hh"
|
||||
#include "G4RTJpegMaker.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4TrajectoryContainer.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
G4RayTracer::G4RayTracer(G4VFigureFileMaker* figMaker)
|
||||
:G4VGraphicsSystem("RayTracer","RayTracer",RAYTRACER_FEATURES,
|
||||
G4VGraphicsSystem::threeD)
|
||||
{
|
||||
theFigMaker = figMaker;
|
||||
if(!theFigMaker) theFigMaker = new G4RTJpegMaker();
|
||||
theRayShooter = new G4RayShooter();
|
||||
theRayTracerEventAction = 0;
|
||||
theRayTracerStackingAction = 0;
|
||||
theRayTracerTrackingAction = new G4RTTrackingAction();
|
||||
theRayTracerSteppingAction = new G4RTSteppingAction();
|
||||
theMessenger = new G4RTMessenger(this,theRayTracerSteppingAction);
|
||||
theEventManager = G4EventManager::GetEventManager();
|
||||
|
||||
nColumn = 640;
|
||||
nRow = 640;
|
||||
|
||||
eyePosition = G4ThreeVector(1.*m,1.*m,1.*m);
|
||||
targetPosition = G4ThreeVector(0.,0.,0.);
|
||||
lightDirection = G4ThreeVector(-0.1,-0.2,-0.3).unit();
|
||||
viewSpan = 5.0*deg;
|
||||
headAngle = 270.*deg;
|
||||
attenuationLength = 1.0*m;
|
||||
|
||||
distortionOn = false;
|
||||
}
|
||||
|
||||
G4RayTracer::~G4RayTracer()
|
||||
{
|
||||
delete theRayShooter;
|
||||
delete theRayTracerTrackingAction;
|
||||
delete theRayTracerSteppingAction;
|
||||
delete theMessenger;
|
||||
}
|
||||
|
||||
void G4RayTracer::Trace(G4String fileName)
|
||||
{
|
||||
G4StateManager* theStateMan = G4StateManager::GetStateManager();
|
||||
G4ApplicationState currentState = theStateMan->GetCurrentState();
|
||||
if(currentState!=Idle)
|
||||
{
|
||||
G4cerr << "Illegal application state - Trace() ignored." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!theFigMaker)
|
||||
{
|
||||
G4cerr << "Figure file maker class is not specified - Trace() ignored." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
G4int storeTrajectory = UI->GetCurrentIntValue("/tracking/storeTrajectory");
|
||||
if(storeTrajectory==0) UI->ApplyCommand("/tracking/storeTrajectory 1");
|
||||
|
||||
|
||||
G4ThreeVector tmpVec = targetPosition - eyePosition;
|
||||
eyeDirection = tmpVec.unit();
|
||||
colorR = new unsigned char[nColumn*nRow];
|
||||
colorG = new unsigned char[nColumn*nRow];
|
||||
colorB = new unsigned char[nColumn*nRow];
|
||||
|
||||
StoreUserActions();
|
||||
G4bool succeeded = CreateBitMap();
|
||||
if(succeeded)
|
||||
{ CreateFigureFile(fileName); }
|
||||
else
|
||||
{ G4cerr << "Could not create figure file" << G4endl;
|
||||
G4cerr << "You might set the eye position outside of the world volume" << G4endl; }
|
||||
RestoreUserActions();
|
||||
|
||||
if(storeTrajectory==0) UI->ApplyCommand("/tracking/storeTrajectory 0");
|
||||
|
||||
delete [] colorR;
|
||||
delete [] colorG;
|
||||
delete [] colorB;
|
||||
}
|
||||
|
||||
G4VSceneHandler* G4RayTracer::CreateSceneHandler (const G4String& name) {
|
||||
G4VSceneHandler* pScene = new G4RayTracerSceneHandler (*this, name);
|
||||
G4cout << G4RayTracerSceneHandler::GetSceneCount ()
|
||||
<< ' ' << fName << " scenes extanct." << G4endl;
|
||||
return pScene;
|
||||
}
|
||||
|
||||
G4VViewer* G4RayTracer::CreateViewer (G4VSceneHandler& sceneHandler,
|
||||
const G4String& name) {
|
||||
G4VViewer* pView = new G4RayTracerViewer (sceneHandler, name);
|
||||
return pView;
|
||||
}
|
||||
|
||||
void G4RayTracer::StoreUserActions()
|
||||
{
|
||||
theUserEventAction = theEventManager->GetUserEventAction();
|
||||
theUserStackingAction = theEventManager->GetUserStackingAction();
|
||||
theUserTrackingAction = theEventManager->GetUserTrackingAction();
|
||||
theUserSteppingAction = theEventManager->GetUserSteppingAction();
|
||||
|
||||
theEventManager->SetUserAction(theRayTracerEventAction);
|
||||
theEventManager->SetUserAction(theRayTracerStackingAction);
|
||||
theEventManager->SetUserAction(theRayTracerTrackingAction);
|
||||
theEventManager->SetUserAction(theRayTracerSteppingAction);
|
||||
|
||||
G4SDManager* theSDMan = G4SDManager::GetSDMpointerIfExist();
|
||||
if(theSDMan)
|
||||
{ theSDMan->Activate("/",false); }
|
||||
|
||||
G4GeometryManager* theGeomMan = G4GeometryManager::GetInstance();
|
||||
theGeomMan->OpenGeometry();
|
||||
theGeomMan->CloseGeometry(true);
|
||||
}
|
||||
|
||||
void G4RayTracer::RestoreUserActions()
|
||||
{
|
||||
theEventManager->SetUserAction(theUserEventAction);
|
||||
theEventManager->SetUserAction(theUserStackingAction);
|
||||
theEventManager->SetUserAction(theUserTrackingAction);
|
||||
theEventManager->SetUserAction(theUserSteppingAction);
|
||||
|
||||
G4SDManager* theSDMan = G4SDManager::GetSDMpointerIfExist();
|
||||
if(theSDMan)
|
||||
{ theSDMan->Activate("/",true); }
|
||||
}
|
||||
|
||||
G4bool G4RayTracer::CreateBitMap()
|
||||
{
|
||||
G4int iEvent = 0;
|
||||
G4double stepAngle = viewSpan/100.;
|
||||
G4double viewSpanX = stepAngle*nColumn;
|
||||
G4double viewSpanY = stepAngle*nRow;
|
||||
G4bool succeeded;
|
||||
for(int iRow=0;iRow<nRow;iRow++)
|
||||
{
|
||||
for(int iColumn=0;iColumn<nColumn;iColumn++)
|
||||
{
|
||||
G4Event* anEvent = new G4Event(iEvent++);
|
||||
|
||||
G4double angleX = -(viewSpanX/2. - iColumn*stepAngle);
|
||||
G4double angleY = viewSpanY/2. - iRow*stepAngle;
|
||||
G4ThreeVector rayDirection;
|
||||
if(distortionOn)
|
||||
{
|
||||
rayDirection = G4ThreeVector(tan(angleX)/cos(angleY),-tan(angleY)/cos(angleX),1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
rayDirection = G4ThreeVector(tan(angleX),-tan(angleY),1.0);
|
||||
}
|
||||
rayDirection.rotateZ(headAngle);
|
||||
rayDirection.rotateUz(eyeDirection);
|
||||
G4ThreeVector rayPosition(eyePosition);
|
||||
G4bool interceptable = true;
|
||||
// Check if rayPosition is in the world.
|
||||
G4VPhysicalVolume* pWorld =
|
||||
G4TransportationManager::GetTransportationManager()->
|
||||
GetNavigatorForTracking()->GetWorldVolume ();
|
||||
EInside whereisit =
|
||||
pWorld->GetLogicalVolume()->GetSolid()->Inside(rayPosition);
|
||||
if (whereisit != kInside) {
|
||||
// It's outside the world, so move it inside.
|
||||
G4double outsideDistance =
|
||||
pWorld->GetLogicalVolume()->GetSolid()->
|
||||
DistanceToIn(rayPosition,rayDirection);
|
||||
if (outsideDistance != kInfinity) {
|
||||
rayPosition = rayPosition+outsideDistance*rayDirection;
|
||||
}
|
||||
else {
|
||||
interceptable = false;
|
||||
}
|
||||
}
|
||||
if (interceptable) {
|
||||
theRayShooter->Shoot(anEvent,rayPosition,rayDirection);
|
||||
theEventManager->ProcessOneEvent(anEvent);
|
||||
succeeded = GenerateColour(anEvent);
|
||||
//G4cout << iColumn << " " << iRow << " " << anEvent->GetEventID() << G4endl;
|
||||
}
|
||||
else { // Ray does not intercept world at all.
|
||||
// Generate background colour...
|
||||
G4int iEvent = anEvent->GetEventID();
|
||||
colorR[iEvent] = 0;
|
||||
colorG[iEvent] = 0;
|
||||
colorB[iEvent] = 0;
|
||||
succeeded = true;
|
||||
}
|
||||
delete anEvent;
|
||||
if(!succeeded) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void G4RayTracer::CreateFigureFile(G4String fileName)
|
||||
{
|
||||
//G4cout << nColumn << " " << nRow << G4endl;
|
||||
theFigMaker->CreateFigureFile(fileName,nColumn,nRow,colorR,colorG,colorB);
|
||||
}
|
||||
|
||||
G4bool G4RayTracer::GenerateColour(G4Event* anEvent)
|
||||
{
|
||||
G4TrajectoryContainer * trajectoryContainer = anEvent->GetTrajectoryContainer();
|
||||
|
||||
G4RayTrajectory* trajectory = (G4RayTrajectory*)( (*trajectoryContainer)[0] );
|
||||
if(!trajectory) return false;
|
||||
|
||||
G4int nPoint = trajectory->GetPointEntries();
|
||||
if(nPoint==0) return false;
|
||||
|
||||
G4Colour rayColour;
|
||||
G4Colour initialColour(1.,1.,1.);
|
||||
if( trajectory->GetPointC(nPoint-1)->GetPostStepAtt() )
|
||||
{ initialColour = GetSurfaceColour(trajectory->GetPointC(nPoint-1)); }
|
||||
rayColour = Attenuate(trajectory->GetPointC(nPoint-1),initialColour);
|
||||
|
||||
for(int i=nPoint-2;i>=0;i--)
|
||||
{
|
||||
G4Colour surfaceColour = GetSurfaceColour(trajectory->GetPointC(i));
|
||||
G4double weight = 1.0 - surfaceColour.GetAlpha();
|
||||
G4Colour mixedColour = GetMixedColour(rayColour,surfaceColour,weight);
|
||||
rayColour = Attenuate(trajectory->GetPointC(i),mixedColour);
|
||||
}
|
||||
|
||||
G4int iEvent = anEvent->GetEventID();
|
||||
colorR[iEvent] = (unsigned char)(int(255*rayColour.GetRed()));
|
||||
colorG[iEvent] = (unsigned char)(int(255*rayColour.GetGreen()));
|
||||
colorB[iEvent] = (unsigned char)(int(255*rayColour.GetBlue()));
|
||||
return true;
|
||||
}
|
||||
|
||||
G4Colour G4RayTracer::GetMixedColour(G4Colour surfCol,G4Colour transCol,G4double weight)
|
||||
{
|
||||
G4double r = weight*surfCol.GetRed() + (1.-weight)*transCol.GetRed();
|
||||
G4double g = weight*surfCol.GetGreen() + (1.-weight)*transCol.GetGreen();
|
||||
G4double b = weight*surfCol.GetBlue() + (1.-weight)*transCol.GetBlue();
|
||||
G4double a = weight*surfCol.GetAlpha() + (1.-weight)*transCol.GetAlpha();
|
||||
return G4Colour(r,g,b,a);
|
||||
}
|
||||
|
||||
G4Colour G4RayTracer::GetSurfaceColour(G4RayTrajectoryPoint* point)
|
||||
{
|
||||
const G4VisAttributes* preAtt = point->GetPreStepAtt();
|
||||
const G4VisAttributes* postAtt = point->GetPostStepAtt();
|
||||
|
||||
G4bool preVis = ValidColour(preAtt);
|
||||
G4bool postVis = ValidColour(postAtt);
|
||||
|
||||
G4Colour transparent(1.,1.,1.,0.);
|
||||
|
||||
if(!preVis&&!postVis) return transparent;
|
||||
|
||||
G4ThreeVector normal = point->GetSurfaceNormal();
|
||||
|
||||
G4Colour preCol(1.,1.,1.);
|
||||
G4Colour postCol(1.,1.,1.);
|
||||
|
||||
if(preVis)
|
||||
{
|
||||
G4double brill = (1.0-(-lightDirection).dot(normal))/2.0;
|
||||
G4double r = preAtt->GetColour().GetRed();
|
||||
G4double g = preAtt->GetColour().GetGreen();
|
||||
G4double b = preAtt->GetColour().GetBlue();
|
||||
preCol = G4Colour(r*brill,g*brill,b*brill,preAtt->GetColour().GetAlpha());
|
||||
}
|
||||
else
|
||||
{ preCol = transparent; }
|
||||
|
||||
if(postVis)
|
||||
{
|
||||
G4double brill = (1.0-(-lightDirection).dot(-normal))/2.0;
|
||||
G4double r = postAtt->GetColour().GetRed();
|
||||
G4double g = postAtt->GetColour().GetGreen();
|
||||
G4double b = postAtt->GetColour().GetBlue();
|
||||
postCol = G4Colour(r*brill,g*brill,b*brill,postAtt->GetColour().GetAlpha());
|
||||
}
|
||||
else
|
||||
{ postCol = transparent; }
|
||||
|
||||
if(!preVis) return postCol;
|
||||
if(!postVis) return preCol;
|
||||
|
||||
G4double weight = 0.5;
|
||||
return GetMixedColour(preCol,postCol,weight);
|
||||
}
|
||||
|
||||
G4Colour G4RayTracer::Attenuate(G4RayTrajectoryPoint* point, G4Colour sourceCol)
|
||||
{
|
||||
const G4VisAttributes* preAtt = point->GetPreStepAtt();
|
||||
|
||||
G4bool visible = ValidColour(preAtt);
|
||||
if(!visible) return sourceCol;
|
||||
|
||||
G4Colour objCol = preAtt->GetColour();
|
||||
G4double stepRed = objCol.GetRed();
|
||||
G4double stepGreen = objCol.GetGreen();
|
||||
G4double stepBlue = objCol.GetBlue();
|
||||
G4double stepAlpha = objCol.GetAlpha();
|
||||
G4double stepLength = point->GetStepLength();
|
||||
|
||||
G4double attenuationFuctor = -stepAlpha/(1.0-stepAlpha)*stepLength/attenuationLength;
|
||||
G4double KtRed = exp((1.0-stepRed)*attenuationFuctor);
|
||||
G4double KtGreen = exp((1.0-stepGreen)*attenuationFuctor);
|
||||
G4double KtBlue = exp((1.0-stepBlue)*attenuationFuctor);
|
||||
if(KtRed>1.0){KtRed=1.0;}
|
||||
if(KtGreen>1.0){KtGreen=1.0;}
|
||||
if(KtBlue>1.0){KtBlue=1.0;}
|
||||
return G4Colour(sourceCol.GetRed()*KtRed,
|
||||
sourceCol.GetGreen()*KtGreen,sourceCol.GetBlue()*KtBlue);
|
||||
}
|
||||
|
||||
G4bool G4RayTracer::ValidColour(const G4VisAttributes* visAtt)
|
||||
{
|
||||
G4bool val = true;
|
||||
if(!visAtt)
|
||||
{ val = false; }
|
||||
else if(!(visAtt->IsVisible()))
|
||||
{ val = false; }
|
||||
else if(visAtt->IsForceDrawingStyle()
|
||||
&&(visAtt->GetForcedDrawingStyle()==G4VisAttributes::wireframe))
|
||||
{ val = false; }
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTracerSceneHandler.cc,v 1.1 2000/02/23 16:03:53 johna Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
|
||||
#include "G4RayTracerSceneHandler.hh"
|
||||
|
||||
G4RayTracerSceneHandler::G4RayTracerSceneHandler(G4VGraphicsSystem& system,
|
||||
const G4String& name):
|
||||
G4VSceneHandler(system, fSceneIdCount++, name)
|
||||
{
|
||||
fSceneCount++;
|
||||
}
|
||||
|
||||
G4RayTracerSceneHandler::~G4RayTracerSceneHandler()
|
||||
{
|
||||
fSceneCount--;
|
||||
}
|
||||
|
||||
G4int G4RayTracerSceneHandler::GetSceneCount() {
|
||||
return fSceneCount;
|
||||
}
|
||||
|
||||
G4int G4RayTracerSceneHandler::fSceneIdCount = 0;
|
||||
|
||||
G4int G4RayTracerSceneHandler::fSceneCount = 0;
|
||||
@@ -0,0 +1,74 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTracerViewer.cc,v 1.6 2000/05/13 10:55:56 johna Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
|
||||
#include "G4RayTracerViewer.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "g4std/strstream"
|
||||
|
||||
#include "G4VSceneHandler.hh"
|
||||
#include "G4Scene.hh"
|
||||
#include "G4RayTracer.hh"
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
G4RayTracerViewer::G4RayTracerViewer
|
||||
(G4VSceneHandler& sceneHandler, const G4String& name):
|
||||
fFileCount(0),
|
||||
G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name) {}
|
||||
|
||||
G4RayTracerViewer::~G4RayTracerViewer() {}
|
||||
|
||||
void G4RayTracerViewer::SetView() {
|
||||
G4RayTracer* theTracer =
|
||||
(G4RayTracer*) fSceneHandler.GetGraphicsSystem();
|
||||
|
||||
// Get radius of scene, etc. (See G4OpenGLViewer::SetView().)
|
||||
// Note that this procedure properly takes into account zoom, dolly and pan.
|
||||
const G4Point3D& targetPoint
|
||||
= fSceneHandler.GetScene()->GetStandardTargetPoint()
|
||||
+ fVP.GetCurrentTargetPoint();
|
||||
G4double radius = // See G4ViewParameters for following procedure.
|
||||
fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
|
||||
if(radius<=0.) radius = 1.;
|
||||
const G4double cameraDistance = fVP.GetCameraDistance(radius);
|
||||
const G4Point3D cameraPosition =
|
||||
targetPoint + cameraDistance * fVP.GetViewpointDirection().unit();
|
||||
const G4double nearDistance = fVP.GetNearDistance(cameraDistance,radius);
|
||||
const G4double frontHalfHeight = fVP.GetFrontHalfHeight(nearDistance,radius);
|
||||
const G4double frontHalfAngle = atan(frontHalfHeight / nearDistance);
|
||||
|
||||
// Calculate and set ray tracer parameters.
|
||||
theTracer->
|
||||
SetViewSpan(200. * frontHalfAngle / theTracer->GetNColumn());
|
||||
theTracer->SetTargetPosition(targetPoint);
|
||||
theTracer->SetEyePosition(cameraPosition);
|
||||
theTracer->SetHeadAngle(fVP.GetViewpointDirection().phi());
|
||||
theTracer->SetLightDirection(-fVP.GetActualLightpointDirection());
|
||||
}
|
||||
|
||||
|
||||
void G4RayTracerViewer::ClearView() {}
|
||||
|
||||
void G4RayTracerViewer::DrawView() {
|
||||
if (fVP.GetFieldHalfAngle() == 0.) { // Orthogonal (parallel) projection.
|
||||
G4cout <<
|
||||
"G4RayTracerViewer::SetView: orthogonal projection not yet implemented."
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
SetView(); // Special graphics system - bypass ProcessView().
|
||||
G4RayTracer* theTracer =
|
||||
(G4RayTracer*) fSceneHandler.GetGraphicsSystem();
|
||||
char fileName [100];
|
||||
G4std::ostrstream ost(fileName, 100);
|
||||
ost << "g4RayTracer." << fShortName << '_' << fFileCount++ << ".jpeg"
|
||||
<< G4std::ends;
|
||||
theTracer->Trace(fileName);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTrajectory.cc,v 1.4 2000/03/09 15:36:38 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
///////////////////
|
||||
//G4RayTrajectory.cc
|
||||
///////////////////
|
||||
|
||||
|
||||
#include "G4RayTrajectory.hh"
|
||||
#include "G4RayTrajectoryPoint.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VisManager.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4Allocator<G4RayTrajectory> G4RayTrajectoryAllocator;
|
||||
|
||||
|
||||
G4RayTrajectory :: G4RayTrajectory()
|
||||
{
|
||||
positionRecord = new G4RWTPtrOrderedVector<G4RayTrajectoryPoint>;
|
||||
}
|
||||
|
||||
G4RayTrajectory :: G4RayTrajectory(G4RayTrajectory & right)
|
||||
{
|
||||
positionRecord = new G4RWTPtrOrderedVector<G4RayTrajectoryPoint>;
|
||||
for(int i=0;i<right.positionRecord->entries();i++)
|
||||
{
|
||||
G4RayTrajectoryPoint* rightPoint = (G4RayTrajectoryPoint*)
|
||||
((*(right.positionRecord))[i]);
|
||||
positionRecord->insert(new G4RayTrajectoryPoint(*rightPoint));
|
||||
}
|
||||
}
|
||||
|
||||
G4RayTrajectory :: ~G4RayTrajectory()
|
||||
{
|
||||
positionRecord->clearAndDestroy();
|
||||
delete positionRecord;
|
||||
}
|
||||
|
||||
void G4RayTrajectory::AppendStep(const G4Step* aStep)
|
||||
{
|
||||
G4RayTrajectoryPoint* trajectoryPoint = new G4RayTrajectoryPoint();
|
||||
|
||||
trajectoryPoint->SetStepLength(aStep->GetStepLength());
|
||||
|
||||
G4Navigator* theNavigator
|
||||
= G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
|
||||
G4bool valid;
|
||||
G4ThreeVector theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
|
||||
if(valid) { theLocalNormal = -theLocalNormal; }
|
||||
G4ThreeVector theGrobalNormal
|
||||
= theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
|
||||
trajectoryPoint->SetSurfaceNormal(theGrobalNormal);
|
||||
|
||||
G4VPhysicalVolume* prePhys = aStep->GetPreStepPoint()->GetPhysicalVolume();
|
||||
const G4VisAttributes* preVisAtt = prePhys->GetLogicalVolume()->GetVisAttributes();
|
||||
G4VisManager* visManager = G4VisManager::GetInstance();
|
||||
if(visManager) {
|
||||
G4VViewer* viewer = visManager->GetCurrentViewer();
|
||||
if (viewer) {
|
||||
preVisAtt = viewer->GetApplicableVisAttributes(preVisAtt);
|
||||
}
|
||||
}
|
||||
trajectoryPoint->SetPreStepAtt(preVisAtt);
|
||||
|
||||
const G4VPhysicalVolume* postPhys = aStep->GetPostStepPoint()->GetPhysicalVolume();
|
||||
const G4VisAttributes* postVisAtt = NULL;
|
||||
if(postPhys) {
|
||||
postVisAtt = postPhys->GetLogicalVolume()->GetVisAttributes();
|
||||
if(visManager) {
|
||||
G4VViewer* viewer = visManager->GetCurrentViewer();
|
||||
if (viewer) {
|
||||
postVisAtt = viewer->GetApplicableVisAttributes(postVisAtt);
|
||||
}
|
||||
}
|
||||
}
|
||||
trajectoryPoint->SetPostStepAtt(postVisAtt);
|
||||
|
||||
positionRecord->append(trajectoryPoint);
|
||||
}
|
||||
|
||||
void G4RayTrajectory::ShowTrajectory() const
|
||||
{ }
|
||||
|
||||
void G4RayTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
|
||||
{
|
||||
if(!secondTrajectory) return;
|
||||
|
||||
G4RayTrajectory* seco = (G4RayTrajectory*)secondTrajectory;
|
||||
G4int ent = seco->GetPointEntries();
|
||||
for(G4int i=0;i<ent;i++)
|
||||
{ positionRecord->append(seco->positionRecord->removeAt(0)); }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RayTrajectoryPoint.cc,v 1.2 2000/03/09 15:36:38 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
///////////////////////
|
||||
//G4RayTrajectoryPoint.cc
|
||||
///////////////////////
|
||||
|
||||
|
||||
#include"G4RayTrajectoryPoint.hh"
|
||||
|
||||
G4Allocator<G4RayTrajectoryPoint> G4RayTrajectoryPointAllocator;
|
||||
|
||||
G4RayTrajectoryPoint :: G4RayTrajectoryPoint()
|
||||
{;}
|
||||
|
||||
G4RayTrajectoryPoint :: ~G4RayTrajectoryPoint()
|
||||
{;}
|
||||
|
||||
Reference in New Issue
Block a user