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

Last change on this file since 812 was 807, checked in by garnier, 16 years ago

update

File size: 4.4 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///////////////////////////////////////////////////////////////////////////////
27#include "DicomNestedPhantomParameterisation.hh"
28
29#include "G4VPhysicalVolume.hh"
30#include "G4VTouchable.hh"
31#include "G4ThreeVector.hh"
32#include "G4Box.hh"
33#include "G4LogicalVolume.hh"
34#include "G4Material.hh"
35
36DicomNestedPhantomParameterisation::DicomNestedPhantomParameterisation(
37                                                     const G4ThreeVector& voxelSize,
38                                                     std::vector<G4Material*>& mat):
39  G4VNestedParameterisation(),fdX(voxelSize.x()),fdY(voxelSize.y()),fdZ(voxelSize.z()),fMaterials(mat)
40{
41  // Position of voxels.
42  // x and y positions are already defined in DetectorConstruction
43  // by using replicated volume. Here only we need to define is z positions of voxes.
44}
45
46DicomNestedPhantomParameterisation::~DicomNestedPhantomParameterisation()
47{
48}
49
50void DicomNestedPhantomParameterisation::SetNoVoxel( size_t nx, size_t ny, size_t nz )
51{
52  fnX = nx;
53  fnY = ny;
54  fnZ = nz;
55}
56
57//
58// Material assignment to geometry.
59//
60G4Material* DicomNestedPhantomParameterisation::ComputeMaterial(G4VPhysicalVolume* ,
61                                                         const G4int copyNoZ, 
62                                                         const G4VTouchable* parentTouch)
63{
64  if(parentTouch==0) return fMaterials[0]; // protection for initialization and vis at idle state
65  // Copy number of voxels.
66  // Copy number of X and Y are obtained from replication number.
67  // Copy nymber of Z is the copy number of current voxel.
68  G4int ix = parentTouch->GetReplicaNumber(0);
69  G4int iy = parentTouch->GetReplicaNumber(1);
70  G4int iz = copyNoZ;
71
72  G4int copyNo = ix + fnZ*iy + fnX*fnY*iz;
73
74  size_t matIndex = GetMaterialIndex(copyNo);
75
76  return fMaterials[ matIndex ];
77
78}
79
80//------------------------------------------------------------------
81size_t DicomNestedPhantomParameterisation::
82GetMaterialIndex( size_t copyNo ) const
83{
84  return *(fMaterialIndices+copyNo);
85}
86
87//
88//  Number of Materials
89//  Material scanner is required for preparing physics tables and so on before
90//  stating simulation, so that G4 has to know number of materials.
91G4int       DicomNestedPhantomParameterisation::GetNumberOfMaterials() const{
92  return fMaterials.size();
93}
94
95//
96// GetMaterial
97//  This is needed for material scanner and realizing geometry.
98//
99G4Material* DicomNestedPhantomParameterisation::GetMaterial(G4int i) const{
100  return fMaterials[i];
101}
102
103//
104// Transformation of voxels.
105//
106void DicomNestedPhantomParameterisation::ComputeTransformation(const G4int copyNo, 
107                                                  G4VPhysicalVolume* physVol)const{
108  G4ThreeVector position(0.,0.,(2*copyNo+1)*fdZ - fdZ*fnZ);
109
110  physVol->SetTranslation(position);
111}
112
113//
114// Dimensions are always same in this RE02 example.
115//
116void DicomNestedPhantomParameterisation::ComputeDimensions(G4Box& box, 
117                                               const G4int ,
118                                               const G4VPhysicalVolume* ) const{
119  box.SetXHalfLength(fdX);
120  box.SetYHalfLength(fdY);
121  box.SetZHalfLength(fdZ);
122}
Note: See TracBrowser for help on using the repository browser.