00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "G4PhysicalVolumeSearchScene.hh"
00034
00035 #include "G4VSolid.hh"
00036 #include "G4Vector3D.hh"
00037 #include "G4PhysicalVolumeModel.hh"
00038
00039 G4PhysicalVolumeSearchScene::G4PhysicalVolumeSearchScene
00040 (G4PhysicalVolumeModel* pPVModel,
00041 const G4String& requiredPhysicalVolumeName,
00042 G4int requiredCopyNo):
00043 fpPVModel (pPVModel),
00044 fRequiredPhysicalVolumeName (requiredPhysicalVolumeName),
00045 fRequiredCopyNo (requiredCopyNo),
00046 fpCurrentObjectTransformation (0),
00047 fFoundDepth (0),
00048 fpFoundPV (0),
00049 fpFoundLV (0),
00050 fMultipleOccurrence (false)
00051 {}
00052
00053 G4PhysicalVolumeSearchScene::~G4PhysicalVolumeSearchScene () {}
00054
00055 void G4PhysicalVolumeSearchScene::FindVolume (const G4VSolid&) {
00056
00057 typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID;
00058 typedef std::vector<PVNodeID> PVPath;
00059 const PVPath& fullPVPath = fpPVModel->GetFullPVPath();
00060 G4int currentDepth = fpPVModel->GetCurrentDepth();
00061 G4VPhysicalVolume* pCurrentPV = fpPVModel->GetCurrentPV();
00062 G4LogicalVolume* pCurrentLV = fpPVModel->GetCurrentLV();
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 if (fRequiredPhysicalVolumeName == pCurrentPV -> GetName () &&
00074 (fRequiredCopyNo < 0 ||
00075 fRequiredCopyNo == pCurrentPV -> GetCopyNo ())) {
00076
00077 if (!fpFoundPV) {
00078 fFoundFullPVPath = fullPVPath;
00079 fFoundDepth = currentDepth;
00080 fpFoundPV = pCurrentPV;
00081 fpFoundLV = pCurrentLV;
00082 fFoundObjectTransformation = *fpCurrentObjectTransformation;
00083 }
00084 else {
00085 if (!fMultipleOccurrence) {
00086 fMultipleOccurrence = true;
00087 G4cout << "G4PhysicalVolumeSearchScene::FindVolume:"
00088 << "\n Required volume \""
00089 << fRequiredPhysicalVolumeName
00090 << "\"";
00091 if (fRequiredCopyNo >= 0) {
00092 G4cout << ", copy no. " << fRequiredCopyNo << ",";
00093 }
00094 G4cout << " found more than once."
00095 "\n This function is not smart enough to distinguish identical"
00096 "\n physical volumes which have different parentage. It is"
00097 "\n tricky to specify in general. This function gives you access"
00098 "\n to the first occurrence only."
00099 << G4endl;
00100 }
00101 }
00102 }
00103 }