ROOT   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. *
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
14Geometry 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}
#define ClassImp(name)
Definition: Rtypes.h:361
A geometry iterator.
Definition: TGeoNode.h:245
TGeoNode * Next()
Returns next node.
Definition: TGeoNode.cxx:996
The manager class for any TGeo geometry.
Definition: TGeoManager.h:43
TGeoVolume * GetMasterVolume() const
Definition: TGeoManager.h:529
TGeoVolume * GetTopVolume() const
Definition: TGeoManager.h:530
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:41
TGeoVolume * GetVolume() const
Definition: TGeoNode.h:97
virtual Bool_t IsVecGeom() const
Definition: TGeoShape.h:138
Geometry converter to VecGeom.
virtual ~TGeoVGConverter()
Default destructor.
TGeoVGConverter(TGeoManager *manager)
Default constructor.
virtual void ConvertGeometry()
Main geometry conversion method.
Bridge class for using a VecGeom solid as TGeoShape.
Definition: TGeoVGShape.h:31
static TGeoVGShape * Create(TGeoShape *shape)
Factory creating TGeoVGShape from a Root shape.
Definition: TGeoVGShape.cxx:83
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:47
void SetShape(const TGeoShape *shape)
set the shape associated with this volume
TGeoShape * GetShape() const
Definition: TGeoVolume.h:186
Abstract class for geometry converters.
static void SetConverter(const TVirtualGeoConverter *conv)
Static function to set an alternative converter.