source: trunk/examples/extended/medical/DICOM/src/DicomNestedPhantomParameterisation.cc @ 1230

Last change on this file since 1230 was 1230, checked in by garnier, 14 years ago

update to geant4.9.3

File size: 4.6 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26// $Id: DicomNestedPhantomParameterisation.cc,v 1.5 2009/01/27 10:44:58 gcosmo Exp $
27// GEANT4 tag $Name: geant4-09-03-cand-01 $
28//
29// --------------------------------------------------------------------
30#include "DicomNestedPhantomParameterisation.hh"
31
32#include "G4VPhysicalVolume.hh"
33#include "G4VTouchable.hh"
34#include "G4ThreeVector.hh"
35#include "G4Box.hh"
36#include "G4LogicalVolume.hh"
37#include "G4Material.hh"
38
39DicomNestedPhantomParameterisation::
40DicomNestedPhantomParameterisation(const G4ThreeVector& voxelSize,
41                                         std::vector<G4Material*>& mat):
42  G4VNestedParameterisation(), fdX(voxelSize.x()),
43  fdY(voxelSize.y()), fdZ(voxelSize.z()), fMaterials(mat)
44{
45  // Position of voxels.
46  // x and y positions are already defined in DetectorConstruction by using
47  // replicated volume. Here only we need to define is z positions of voxels.
48}
49
50DicomNestedPhantomParameterisation::~DicomNestedPhantomParameterisation()
51{
52}
53
54void DicomNestedPhantomParameterisation::
55SetNoVoxel( size_t nx, size_t ny, size_t nz )
56{
57  fnX = nx;
58  fnY = ny;
59  fnZ = nz;
60}
61
62//
63// Material assignment to geometry.
64//
65G4Material* DicomNestedPhantomParameterisation::
66ComputeMaterial(G4VPhysicalVolume*, const G4int copyNoZ, 
67                                    const G4VTouchable* parentTouch)
68{
69  // protection for initialization and vis at idle state
70  //
71  if(parentTouch==0) return fMaterials[0];
72
73  // Copy number of voxels.
74  // Copy number of X and Y are obtained from replication number.
75  // Copy nymber of Z is the copy number of current voxel.
76  G4int ix = parentTouch->GetReplicaNumber(0);
77  G4int iy = parentTouch->GetReplicaNumber(1);
78  G4int iz = copyNoZ;
79
80  G4int copyNo = ix + fnX*iy + fnX*fnY*iz;
81
82  size_t matIndex = GetMaterialIndex(copyNo);
83
84  return fMaterials[ matIndex ];
85}
86
87//------------------------------------------------------------------
88size_t DicomNestedPhantomParameterisation::
89GetMaterialIndex( size_t copyNo ) const
90{
91  return *(fMaterialIndices+copyNo);
92}
93
94//
95// Number of Materials
96// Material scanner is required for preparing physics tables and so on before
97// starting simulation, so that G4 has to know number of materials.
98//
99G4int DicomNestedPhantomParameterisation::GetNumberOfMaterials() const
100{
101  return fMaterials.size();
102}
103
104//
105// GetMaterial
106//  This is needed for material scanner and realizing geometry.
107//
108G4Material* DicomNestedPhantomParameterisation::GetMaterial(G4int i) const
109{
110  return fMaterials[i];
111}
112
113//
114// Transformation of voxels.
115//
116void DicomNestedPhantomParameterisation::
117ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const
118{
119  G4ThreeVector position(0.,0.,(2*copyNo+1)*fdZ - fdZ*fnZ);
120  physVol->SetTranslation(position);
121}
122
123//
124// Dimensions are always same in this RE02 example.
125//
126void DicomNestedPhantomParameterisation::
127ComputeDimensions( G4Box& box, const G4int, const G4VPhysicalVolume* ) const
128{
129  box.SetXHalfLength(fdX);
130  box.SetYHalfLength(fdY);
131  box.SetZHalfLength(fdZ);
132}
Note: See TracBrowser for help on using the repository browser.