Logo ROOT   6.14/05
Reference Guide
TGeoVGConverter.cxx
Go to the documentation of this file.
1 // @(#)root/vecgeom:$Id:$
2 // Author: Mihaela Gheata 30/03/16
3 /*************************************************************************
4  * Copyright (C) 1995-2016, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 /** \class TGeoVGConverter
12 \ingroup Geometry_classes
13 
14 Geometry converter to VecGeom
15 */
16 
17 #include "TGeoVGConverter.h"
18 #include "TGeoVGShape.h"
19 
21 
22 ////////////////////////////////////////////////////////////////////////////////
23 /// Default constructor.
24 
26 {
28 }
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// Default destructor.
32 
34 {
35 }
36 
37 ////////////////////////////////////////////////////////////////////////////////
38 /// Main geometry conversion method.
39 /// Convert all geometry shapes connected to volumes to VecGeom shapes
40 
42 {
43  // First convert the top volume
45  TGeoVGShape *vgshape = nullptr;
46  if ( !top->GetShape()->IsVecGeom() )
47  vgshape = TGeoVGShape::Create(top->GetShape());
48  Int_t nconverted=0;
49  // If shape of top volume not known by VecGeom, keep old one
50  if (vgshape) {
51  nconverted++;
52  top->SetShape(vgshape);
53  }
54  // Now iterate the active geometry tree
56  TGeoNode *node;
57  while ((node = next.Next())) {
58  TGeoVolume *vol = node->GetVolume();
59  // If shape not already converted, convert it
60  if ( vol->GetShape()->IsVecGeom() ) continue;
61  // printf("Converting %s\n", vol->GetName());
62  vgshape = TGeoVGShape::Create(vol->GetShape());
63  if (vgshape) {
64  nconverted++;
65  vol->SetShape(vgshape);
66  }
67  }
68  printf("# Converted %d shapes to VecGeom ones\n", nconverted);
69 }
static void SetConverter(const TVirtualGeoConverter *conv)
Static function to set an alternative converter.
Bridge class for using a VecGeom solid as TGeoShape.
Definition: TGeoVGShape.h:30
virtual Bool_t IsVecGeom() const
Definition: TGeoShape.h:138
The manager class for any TGeo geometry.
Definition: TGeoManager.h:38
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:48
int Int_t
Definition: RtypesCore.h:41
TGeoVolume * GetMasterVolume() const
Definition: TGeoManager.h:502
Geometry converter to VecGeom.
A geometry iterator.
Definition: TGeoNode.h:243
virtual void ConvertGeometry()
Main geometry conversion method.
virtual ~TGeoVGConverter()
Default destructor.
void SetShape(const TGeoShape *shape)
set the shape associated with this volume
TGeoVGConverter(TGeoManager *manager)
Default constructor.
#define ClassImp(name)
Definition: Rtypes.h:359
static TGeoVGShape * Create(TGeoShape *shape)
Factory creating TGeoVGShape from a Root shape.
Definition: TGeoVGShape.cxx:83
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:39
Abstract class for geometry converters.
TGeoVolume * GetTopVolume() const
Definition: TGeoManager.h:503
TGeoShape * GetShape() const
Definition: TGeoVolume.h:191