Import Geant4 2.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 15:42:07 +02:00
parent 103bda00c8
commit e7d7193284
3106 changed files with 171117 additions and 90550 deletions
@@ -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()
{;}