Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
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/// Main geometry conversion method.
37/// Convert all geometry shapes connected to volumes to VecGeom shapes
38
40{
41 // First convert the top volume
43 TGeoVGShape *vgshape = nullptr;
44 if (!top->GetShape()->IsVecGeom())
45 vgshape = TGeoVGShape::Create(top->GetShape());
46 Int_t nconverted = 0;
47 // If shape of top volume not known by VecGeom, keep old one
48 if (vgshape) {
49 nconverted++;
50 top->SetShape(vgshape);
51 }
52 // Now iterate the active geometry tree
54 TGeoNode *node;
55 while ((node = next.Next())) {
56 TGeoVolume *vol = node->GetVolume();
57 // If shape not already converted, convert it
58 if (vol->GetShape()->IsVecGeom())
59 continue;
60 // printf("Converting %s\n", vol->GetName());
61 vgshape = TGeoVGShape::Create(vol->GetShape());
62 if (vgshape) {
63 nconverted++;
64 vol->SetShape(vgshape);
65 }
66 }
67 printf("# Converted %d shapes to VecGeom ones\n", nconverted);
68}
#define ClassImp(name)
Definition Rtypes.h:377
A geometry iterator.
Definition TGeoNode.h:248
TGeoNode * Next()
Returns next node.
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
TGeoVolume * GetMasterVolume() const
TGeoVolume * GetTopVolume() const
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
virtual Bool_t IsVecGeom() const
Definition TGeoShape.h:141
Geometry converter to VecGeom.
TGeoVGConverter(TGeoManager *manager)
Default constructor.
void ConvertGeometry() override
Main geometry conversion method.
~TGeoVGConverter() override
Default destructor.
Bridge class for using a VecGeom solid as TGeoShape.
Definition TGeoVGShape.h:30
static TGeoVGShape * Create(TGeoShape *shape)
Factory creating TGeoVGShape from a Root shape.
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
void SetShape(const TGeoShape *shape)
set the shape associated with this volume
TGeoShape * GetShape() const
Definition TGeoVolume.h:190
Abstract class for geometry converters.
static void SetConverter(const TVirtualGeoConverter *conv)
Static function to set an alternative converter.