VGM Version 5.3
Loading...
Searching...
No Matches
VolumeMap.cxx
Go to the documentation of this file.
1// $Id$
2
3// -----------------------------------------------------------------------
4// The RootGM package of the Virtual Geometry Model
5// Copyright (C) 2007, Ivana Hrivnacova
6// All rights reserved.
7//
8// For the licensing terms see vgm/LICENSE.
9// Contact: ivana@ipno.in2p3.fr
10// -----------------------------------------------------------------------
11
12//
13// Class VolumeMap
14// ------------------
15// The map between VGM and Root volumes.
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
19#include "VGM/volumes/IVolume.h"
20
22
23#include "TGeoVolume.h"
24
25RootGM::VolumeMap* RootGM::VolumeMap::fgInstance = 0;
26
27//_____________________________________________________________________________
29{
31
32 if (!fgInstance) new RootGM::VolumeMap();
33
34 return fgInstance;
35}
36
37//_____________________________________________________________________________
38RootGM::VolumeMap::VolumeMap() : fRootVolumes(), fVgmVolumes()
39{
41
42 fgInstance = this;
43}
44
45//_____________________________________________________________________________
47{
49}
50
51//_____________________________________________________________________________
53{
54 //
55 fgInstance = 0;
56}
57
58//
59// public methods
60//
61
62//_____________________________________________________________________________
63void RootGM::VolumeMap::AddVolume(VGM::IVolume* iVolume, TGeoVolume* rootVolume)
64{
66
67 fRootVolumes[iVolume] = rootVolume;
68 fVgmVolumes[rootVolume] = iVolume;
69}
70
71//_____________________________________________________________________________
73{
75
76 std::cout << "Root Volumes Map: " << std::endl;
77
78 int counter = 0;
80 for (i = fRootVolumes.begin(); i != fRootVolumes.end(); i++) {
81 VGM::IVolume* iVolume = (*i).first;
82 TGeoVolume* rootVolume = (*i).second;
83
84 std::cout << " " << counter++ << "th entry:"
85 << " vgmVolume " << iVolume << " " << iVolume->Name()
86 << " rootVolume " << rootVolume << " " << rootVolume->GetName()
87 << std::endl;
88 }
89}
90
91//_____________________________________________________________________________
92TGeoVolume* RootGM::VolumeMap::GetVolume(VGM::IVolume* iVolume) const
93{
95
96 RootVolumeMapCIterator i = fRootVolumes.find(iVolume);
97 if (i != fRootVolumes.end())
98 return (*i).second;
99 else
100 return 0;
101}
102
103//_____________________________________________________________________________
104VGM::IVolume* RootGM::VolumeMap::GetVolume(TGeoVolume* rootVolume) const
105{
107
108 VgmVolumeMapCIterator i = fVgmVolumes.find(rootVolume);
109 if (i != fVgmVolumes.end())
110 return (*i).second;
111 else
112 return 0;
113}
The map between VGM and Root volumes.
Definition VolumeMap.h:36
static VolumeMap * Instance()
Definition VolumeMap.cxx:28
void Print() const
Definition VolumeMap.cxx:72
TGeoVolume * GetVolume(VGM::IVolume *iVolume) const
Definition VolumeMap.cxx:92
void AddVolume(VGM::IVolume *, TGeoVolume *)
Definition VolumeMap.cxx:63
VgmVolumeMap::const_iterator VgmVolumeMapCIterator
Definition VolumeMap.h:42
virtual ~VolumeMap()
Definition VolumeMap.cxx:52
RootVolumeMap::const_iterator RootVolumeMapCIterator
Definition VolumeMap.h:39
The VGM interface to volumes.
Definition IVolume.h:32
virtual std::string Name() const =0
Return the name of this volume.