Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TVirtualGeoConverter.cxx
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Mihaela Gheata 30/03/16
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TVirtualGeoConverter
13 \ingroup Geometry_classes
14 
15 Abstract class for geometry converters
16 */
17 
18 #include "TVirtualGeoConverter.h"
19 
20 #include "TError.h"
21 #include "TROOT.h"
22 #include "TPluginManager.h"
23 #include "TGeoManager.h"
24 
25 TVirtualGeoConverter *TVirtualGeoConverter::fgGeoConverter = 0;
26 
27 ClassImp(TVirtualGeoConverter);
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// Geometry converter default constructor
31 
32 TVirtualGeoConverter::TVirtualGeoConverter(TGeoManager *geom)
33  :TObject(), fGeom(geom)
34 {
35 }
36 
37 ////////////////////////////////////////////////////////////////////////////////
38 /// Geometry converter default destructor
39 
40 TVirtualGeoConverter::~TVirtualGeoConverter()
41 {
42  fgGeoConverter = 0;
43 }
44 
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// Static function returning a pointer to the current geometry converter.
48 /// The converter implements the ConvertGeometry function.
49 /// If the geometry converter does not exist a default converter is created.
50 
51 TVirtualGeoConverter *TVirtualGeoConverter::Instance(TGeoManager *geom)
52 {
53  // if no converter set yet, create a default converter via the PluginManager
54  TGeoManager *mgr = geom;
55  if (!mgr) mgr = gGeoManager;
56  if (!fgGeoConverter) {
57  TPluginHandler *h;
58  if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoConverter"))) {
59  if (h->LoadPlugin() == -1) {
60  ::Error("TVirtualGeoConverter::Instance()",
61  "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
62  "It appears that you are missing or having outdated support for VecGeom package. "
63  "To enable it, configure ROOT with:\n"
64  " -Dvecgeom -DCMAKE_PREFIX_PATH=<vecgeom_prefix_path>/lib/CMake/VecGeom"
65  "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
66  return 0;
67  }
68  fgGeoConverter = (TVirtualGeoConverter*)h->ExecPlugin(1,mgr);
69  }
70  }
71  if (fgGeoConverter) fgGeoConverter->SetGeometry(mgr);
72  return fgGeoConverter;
73 }
74 
75 ////////////////////////////////////////////////////////////////////////////////
76 /// Static function to set an alternative converter.
77 
78 void TVirtualGeoConverter::SetConverter(const TVirtualGeoConverter *converter)
79 {
80  fgGeoConverter = (TVirtualGeoConverter*)converter;
81 }