ROOT logo
//*-- AUTHOR : Ilse Koenig
//*-- Modified : 22/06/2003 by Ilse Koenig

//_HADES_CLASS_DESCRIPTION 
///////////////////////////////////////////////////////////////////////////////
//
// HGeomShapes
//
// Class to manage the GEANT/ROOT geometry shapes
//
// The 3D geometry in ROOT uses the ROOT library geom.
//
// This class holds a list of shape classes (type HGeomBasicShape). They are
// used by all detectors when reading or writing geometry parameter containers
// to ascii files or to create an event display. This class is instantiated in
// the class HSpectrometer inside the function createDetGeomPar(Text_t* name).
// Every geometry parameter container gets a pointer to it.
//
// The individual shape classes are accessible with the selectShape(...)
// functions. The functions readPoints(...) and writePoints(...) use it
// internally.
//
// In the current version the following shapes are implemented:
//     BOX  TRAP  TRD1  PGON  PCON TUBE TUBS CONE CONS SPHE  ELTU
//
///////////////////////////////////////////////////////////////////////////////

#include"hgeomshapes.h"
#include "hgeomvolume.h"
#include "hgeombasicshape.h"
#include "hgeombrik.h"
#include "hgeomtrap.h"
#include "hgeomtrd1.h"
#include "hgeompgon.h"
#include "hgeompcon.h"
#include "hgeomtube.h"
#include "hgeomtubs.h"
#include "hgeomcone.h"
#include "hgeomcons.h"
#include "hgeomsphe.h"
#include "hgeomeltu.h"

ClassImp(HGeomShapes) 

HGeomShapes::HGeomShapes() {
  // constructor creates empty list of shapes
  shapes=new TList();
}


HGeomShapes::~HGeomShapes() {
  // destructor deletes all shapes
  shapes->Delete();
  delete shapes;
}


HGeomBasicShape* HGeomShapes::selectShape(HGeomVolume * volu) {
  // returns a pointer to the shape used in the given volume
  // calls internally selectShape(TString&) with the name of the shape
  // returns NULL if the corresponding shape class is not implemented 
  const TString& name(volu->getShape());
  return selectShape(name);
}


HGeomBasicShape* HGeomShapes::selectShape(const TString& name) {
  // returns a pointer to the shape given by name
  // creates a shape object and adds it to the list of shapes if
  // not existing
  // returns NULL if the corresponding shape class is not implemented 
  TString allShapes[11]={"BOX ","TRAP","TRD1","PGON","PCON","TUBE","TUBS",
                         "CONE","CONS","SPHE","ELTU"};
  TString sName(name);
  if (sName.Length()==3) sName+=" ";
  HGeomBasicShape* s=(HGeomBasicShape*)shapes->FindObject(sName);
  if (s) return s;
  Int_t no=-1;
  for(Int_t i=0;i<11;i++) {if (sName.CompareTo(allShapes[i])==0) no=i;}
  switch(no) {
    case 0:  {s= new HGeomBrik();  break;}
    case 1:  {s= new HGeomTrap();  break;}
    case 2:  {s= new HGeomTrd1();  break;}
    case 3:  {s= new HGeomPgon();  break;}
    case 4:  {s= new HGeomPcon();  break;}
    case 5:  {s= new HGeomTube();  break;}
    case 6:  {s= new HGeomTubs();  break;}
    case 7:  {s= new HGeomCone();  break;}
    case 8:  {s= new HGeomCons();  break;}
    case 9:  {s= new HGeomSphe();  break;}
    case 10: {s= new HGeomEltu();  break;}
    default: {
      Error("selectShape","shape %s not implemented",name.Data());
    }
  }
  if (s) shapes->Add(s);
  return s;
}
 
 
Int_t HGeomShapes::readPoints(fstream* pFile,HGeomVolume* volu) {
  // reads the points of the given volume from the Ascii file
  // returns the number of points read
  // returns 0 if if the corresponding shape class is not implemented
  HGeomBasicShape* s=selectShape(volu);
  if (s) return s->readPoints(pFile,volu);
  else return 0;
}

  
Bool_t HGeomShapes::writePoints(fstream* pFile,HGeomVolume* volu) {
  // writes the points of the given volume to the Ascii file
  // return kFALSE if the corresponding shape class is not implemented
  HGeomBasicShape* s=selectShape(volu);
  if (s) return s->writePoints(pFile,volu);
  else return kFALSE;
}


void HGeomShapes::printPoints(HGeomVolume* volu) {
  // writes the points of the given volume to the Ascii file
  // return kFALSE if the corresponding shape class is not implemented
  HGeomBasicShape* s=selectShape(volu);
  if (s) s->printPoints(volu);
}
 hgeomshapes.cc:1
 hgeomshapes.cc:2
 hgeomshapes.cc:3
 hgeomshapes.cc:4
 hgeomshapes.cc:5
 hgeomshapes.cc:6
 hgeomshapes.cc:7
 hgeomshapes.cc:8
 hgeomshapes.cc:9
 hgeomshapes.cc:10
 hgeomshapes.cc:11
 hgeomshapes.cc:12
 hgeomshapes.cc:13
 hgeomshapes.cc:14
 hgeomshapes.cc:15
 hgeomshapes.cc:16
 hgeomshapes.cc:17
 hgeomshapes.cc:18
 hgeomshapes.cc:19
 hgeomshapes.cc:20
 hgeomshapes.cc:21
 hgeomshapes.cc:22
 hgeomshapes.cc:23
 hgeomshapes.cc:24
 hgeomshapes.cc:25
 hgeomshapes.cc:26
 hgeomshapes.cc:27
 hgeomshapes.cc:28
 hgeomshapes.cc:29
 hgeomshapes.cc:30
 hgeomshapes.cc:31
 hgeomshapes.cc:32
 hgeomshapes.cc:33
 hgeomshapes.cc:34
 hgeomshapes.cc:35
 hgeomshapes.cc:36
 hgeomshapes.cc:37
 hgeomshapes.cc:38
 hgeomshapes.cc:39
 hgeomshapes.cc:40
 hgeomshapes.cc:41
 hgeomshapes.cc:42
 hgeomshapes.cc:43
 hgeomshapes.cc:44
 hgeomshapes.cc:45
 hgeomshapes.cc:46
 hgeomshapes.cc:47
 hgeomshapes.cc:48
 hgeomshapes.cc:49
 hgeomshapes.cc:50
 hgeomshapes.cc:51
 hgeomshapes.cc:52
 hgeomshapes.cc:53
 hgeomshapes.cc:54
 hgeomshapes.cc:55
 hgeomshapes.cc:56
 hgeomshapes.cc:57
 hgeomshapes.cc:58
 hgeomshapes.cc:59
 hgeomshapes.cc:60
 hgeomshapes.cc:61
 hgeomshapes.cc:62
 hgeomshapes.cc:63
 hgeomshapes.cc:64
 hgeomshapes.cc:65
 hgeomshapes.cc:66
 hgeomshapes.cc:67
 hgeomshapes.cc:68
 hgeomshapes.cc:69
 hgeomshapes.cc:70
 hgeomshapes.cc:71
 hgeomshapes.cc:72
 hgeomshapes.cc:73
 hgeomshapes.cc:74
 hgeomshapes.cc:75
 hgeomshapes.cc:76
 hgeomshapes.cc:77
 hgeomshapes.cc:78
 hgeomshapes.cc:79
 hgeomshapes.cc:80
 hgeomshapes.cc:81
 hgeomshapes.cc:82
 hgeomshapes.cc:83
 hgeomshapes.cc:84
 hgeomshapes.cc:85
 hgeomshapes.cc:86
 hgeomshapes.cc:87
 hgeomshapes.cc:88
 hgeomshapes.cc:89
 hgeomshapes.cc:90
 hgeomshapes.cc:91
 hgeomshapes.cc:92
 hgeomshapes.cc:93
 hgeomshapes.cc:94
 hgeomshapes.cc:95
 hgeomshapes.cc:96
 hgeomshapes.cc:97
 hgeomshapes.cc:98
 hgeomshapes.cc:99
 hgeomshapes.cc:100
 hgeomshapes.cc:101
 hgeomshapes.cc:102
 hgeomshapes.cc:103
 hgeomshapes.cc:104
 hgeomshapes.cc:105
 hgeomshapes.cc:106
 hgeomshapes.cc:107
 hgeomshapes.cc:108
 hgeomshapes.cc:109
 hgeomshapes.cc:110
 hgeomshapes.cc:111
 hgeomshapes.cc:112
 hgeomshapes.cc:113
 hgeomshapes.cc:114
 hgeomshapes.cc:115
 hgeomshapes.cc:116
 hgeomshapes.cc:117
 hgeomshapes.cc:118
 hgeomshapes.cc:119
 hgeomshapes.cc:120
 hgeomshapes.cc:121
 hgeomshapes.cc:122
 hgeomshapes.cc:123
 hgeomshapes.cc:124
 hgeomshapes.cc:125