showGeometry.cpp
Go to the documentation of this file.
1 #include "TGeoManager.h"
2 #include "TGLViewer.h"
3 #include "TPad.h"
4 #include "TApplication.h"
5 
6 #include <iostream>
7 #include <stdlib.h>
8 
9 void showGeometry(std::string file, int vislevel, bool checkOverlaps)
10 {
11  TGeoManager *geo = new TGeoManager();
12  geo->Import(file.c_str());
13  geo->DefaultColors();
14 
15  if(checkOverlaps){
16  geo->CheckOverlaps(1e-5,"d100000000");
17  geo->PrintOverlaps();
18  }
19 
20  geo->SetVisOption(1);
21  geo->SetVisLevel(vislevel);
22 
23  geo->GetTopVolume()->Draw("ogl");
24 
25  TGLViewer * v = (TGLViewer *)gPad->GetViewer3D();
26  v->SetStyle(TGLRnrCtx::kOutline);
27  v->SetSmoothPoints(kTRUE);
28  v->SetLineScale(0.5);
29  v->UpdateScene();
30 }
31 
32 int main(int argc, char **argv)
33 {
34  if(argc < 4)
35  {
36  std::cout << "./showGeometry <file> <vislevel: 1 to 7> <checkOverlaps: 0 or 1>" << std::endl;
37  return -1;
38  }
39 
40  bool checkOverlaps = false;
41  std::string file = argv[1];
42  std::cout << "Geometry file " << file << std::endl;
43  int vislevel = std::atoi(argv[2]);
44  if(vislevel < 1 || vislevel > 7){
45  std::cout << "Set Visibility level to default" << std::endl;
46  vislevel = 5;
47  }
48  std::cout << "VisLevel set to " << vislevel << std::endl;
49  std::string checkOverlaps_str = argv[3];
50  if( (checkOverlaps_str != "0" && checkOverlaps_str != "1") || checkOverlaps_str == "0" )
51  std::cout << "Check for Overlaps set to false" << std::endl;
52  else{
53  std::cout << "Check for Overlaps set to true" << std::endl;
54  checkOverlaps = true;
55  }
56 
57  TApplication theApp("theApp", &argc, argv) ;
58  showGeometry(file, vislevel, checkOverlaps);
59  theApp.Run();
60 
61  return 0;
62 }
std::string string
Definition: nybbler.cc:12
int main(int argc, char **argv)
const double e
LArSoft geometry interface.
Definition: ChannelGeo.h:16
QTextStream & endl(QTextStream &s)
void showGeometry(std::string file, int vislevel, bool checkOverlaps)
Definition: showGeometry.cpp:9