Project
Loading...
Searching...
No Matches
FairGeoShapes.cxx
Go to the documentation of this file.
1
/********************************************************************************
2
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3
* *
4
* This software is distributed under the terms of the *
5
* GNU Lesser General Public Licence (LGPL) version 3, *
6
* copied verbatim in the file "LICENSE" *
7
********************************************************************************/
8
//*-- AUTHOR : Ilse Koenig
9
//*-- Modified : 22/06/2003 by Ilse Koenig
10
12
//
13
// FairGeoShapes
14
//
15
// Class to manage the GEANT/ROOT geometry shapes
16
//
17
// The 3D geometry in ROOT uses the ROOT library geom.
18
//
19
// This class holds a list of shape classes (type FairGeoBasicShape). They are
20
// used by all detectors when reading or writing geometry parameter containers
21
// to ascii files or to create an event display. This class is instantiated in
22
// the class HSpectrometer inside the function createDetGeomPar(Text_t* name).
23
// Every geometry parameter container gets a pointer to it.
24
//
25
// The individual shape classes are accessible with the selectShape(...)
26
// functions. The functions readPoints(...) and writePoints(...) use it
27
// internally.
28
//
29
// In the current version the following shapes are implemented:
30
// BOX TRAP TRD1 PGON PCON TUBE TUBS CONE CONS SPHE ELTU
31
// TORUS is added 06.11.06 m.al-turany
32
//
34
35
#include "
FairGeoShapes.h
"
36
37
#include "
FairGeoAssembly.h
"
38
#include "
FairGeoBasicShape.h
"
39
#include "
FairGeoBrik.h
"
40
#include "
FairGeoCone.h
"
41
#include "
FairGeoCons.h
"
42
#include "
FairGeoEltu.h
"
43
#include "
FairGeoPcon.h
"
44
#include "
FairGeoPgon.h
"
45
#include "
FairGeoSphe.h
"
46
#include "
FairGeoTorus.h
"
47
#include "
FairGeoTrap.h
"
48
#include "
FairGeoTrd1.h
"
49
#include "
FairGeoTube.h
"
50
#include "
FairGeoTubs.h
"
51
#include "
FairGeoVolume.h
"
52
53
#include <TList.h>
54
#include <fstream>
// for fstream
55
56
ClassImp
(
FairGeoShapes
);
57
58
FairGeoShapes::FairGeoShapes
()
59
:
TObject
()
60
, shapes(new TList())
61
{
62
// constructor creates empty list of shapes
63
}
64
65
FairGeoShapes::~FairGeoShapes
()
66
{
67
// destructor deletes all shapes
68
shapes
->Delete();
69
delete
shapes
;
70
}
71
72
FairGeoBasicShape
*
FairGeoShapes::selectShape
(
FairGeoVolume
* volu)
73
{
74
// returns a pointer to the shape used in the given volume
75
// calls internally selectShape(TString&) with the name of the shape
76
// returns NULL if the corresponding shape class is not implemented
77
const
TString&
name
(volu->
getShape
());
78
return
selectShape
(
name
);
79
}
80
81
FairGeoBasicShape
*
FairGeoShapes::selectShape
(
const
TString&
name
)
82
{
83
// returns a pointer to the shape given by name
84
// creates a shape object and adds it to the list of shapes if
85
// not existing
86
// returns NULL if the corresponding shape class is not implemented
87
TString allShapes[13] = {
88
"BOX "
,
"TRAP"
,
"TRD1"
,
"PGON"
,
"PCON"
,
"TUBE"
,
"TUBS"
,
"CONE"
,
"CONS"
,
"SPHE"
,
"ELTU"
,
"TORUS"
,
"ASSEMBLY"
};
89
TString sName(
name
);
90
if
(sName.Length() == 3) {
91
sName +=
" "
;
92
}
93
FairGeoBasicShape
* s =
static_cast<
FairGeoBasicShape
*
>
(
shapes
->FindObject(sName));
94
if
(s) {
95
return
s;
96
}
97
Int_t no = -1;
98
for
(Int_t
i
= 0;
i
< 13;
i
++) {
99
if
(sName.CompareTo(allShapes[
i
]) == 0) {
100
no =
i
;
101
}
102
}
103
switch
(no) {
104
case
0: {
105
s =
new
FairGeoBrik
();
106
break
;
107
}
108
case
1: {
109
s =
new
FairGeoTrap
();
110
break
;
111
}
112
case
2: {
113
s =
new
FairGeoTrd1
();
114
break
;
115
}
116
case
3: {
117
s =
new
FairGeoPgon
();
118
break
;
119
}
120
case
4: {
121
s =
new
FairGeoPcon
();
122
break
;
123
}
124
case
5: {
125
s =
new
FairGeoTube
();
126
break
;
127
}
128
case
6: {
129
s =
new
FairGeoTubs
();
130
break
;
131
}
132
case
7: {
133
s =
new
FairGeoCone
();
134
break
;
135
}
136
case
8: {
137
s =
new
FairGeoCons
();
138
break
;
139
}
140
case
9: {
141
s =
new
FairGeoSphe
();
142
break
;
143
}
144
case
10: {
145
s =
new
FairGeoEltu
();
146
break
;
147
}
148
case
11: {
149
s =
new
FairGeoTorus
();
150
break
;
151
}
152
case
12: {
153
s =
new
FairGeoAssembly
();
154
break
;
155
}
156
default
: {
157
Error(
"selectShape"
,
"shape %s not implemented"
,
name
.Data());
158
}
159
}
160
if
(s) {
161
shapes
->Add(s);
162
}
163
return
s;
164
}
165
166
Int_t
FairGeoShapes::readPoints
(std::fstream* pFile,
FairGeoVolume
* volu)
167
{
168
// reads the points of the given volume from the Ascii file
169
// returns the number of points read
170
// returns 0 if if the corresponding shape class is not implemented
171
FairGeoBasicShape
* s =
selectShape
(volu);
172
if
(s) {
173
return
s->readPoints(pFile, volu);
174
}
else
{
175
return
0;
176
}
177
}
178
179
Bool_t
FairGeoShapes::writePoints
(std::fstream* pFile,
FairGeoVolume
* volu)
180
{
181
// writes the points of the given volume to the Ascii file
182
// return kFALSE if the corresponding shape class is not implemented
183
FairGeoBasicShape
* s =
selectShape
(volu);
184
if
(s) {
185
return
s->writePoints(pFile, volu);
186
}
else
{
187
return
kFALSE;
188
}
189
}
190
191
void
FairGeoShapes::printPoints
(
FairGeoVolume
* volu)
192
{
193
// writes the points of the given volume to the Ascii file
194
// return kFALSE if the corresponding shape class is not implemented
195
FairGeoBasicShape
* s =
selectShape
(volu);
196
if
(s) {
197
return
s->printPoints(volu);
198
}
199
}
FairGeoAssembly.h
FairGeoBasicShape.h
FairGeoBrik.h
FairGeoCone.h
FairGeoCons.h
FairGeoEltu.h
FairGeoPcon.h
FairGeoPgon.h
ClassImp
ClassImp(FairGeoShapes)
FairGeoShapes.h
FairGeoSphe.h
FairGeoTorus.h
FairGeoTrap.h
FairGeoTrd1.h
FairGeoTube.h
FairGeoTubs.h
FairGeoVolume.h
i
int32_t i
Definition
GPUCommonAlgorithm.h:520
FairGeoAssembly
Definition
FairGeoAssembly.h:21
FairGeoBasicShape
Definition
FairGeoBasicShape.h:23
FairGeoBrik
Definition
FairGeoBrik.h:20
FairGeoCone
Definition
FairGeoCone.h:24
FairGeoCons
Definition
FairGeoCons.h:24
FairGeoEltu
Definition
FairGeoEltu.h:25
FairGeoPcon
Definition
FairGeoPcon.h:25
FairGeoPgon
Definition
FairGeoPgon.h:25
FairGeoShapes
Definition
FairGeoShapes.h:24
FairGeoShapes::shapes
TList * shapes
Definition
FairGeoShapes.h:30
FairGeoShapes::writePoints
Bool_t writePoints(std::fstream *, FairGeoVolume *)
Definition
FairGeoShapes.cxx:179
FairGeoShapes::FairGeoShapes
FairGeoShapes()
Definition
FairGeoShapes.cxx:58
FairGeoShapes::selectShape
FairGeoBasicShape * selectShape(FairGeoVolume *)
Definition
FairGeoShapes.cxx:72
FairGeoShapes::printPoints
void printPoints(FairGeoVolume *volu)
Definition
FairGeoShapes.cxx:191
FairGeoShapes::readPoints
Int_t readPoints(std::fstream *, FairGeoVolume *)
Definition
FairGeoShapes.cxx:166
FairGeoShapes::~FairGeoShapes
~FairGeoShapes()
Definition
FairGeoShapes.cxx:65
FairGeoSphe
Definition
FairGeoSphe.h:25
FairGeoTorus
Definition
FairGeoTorus.h:21
FairGeoTrap
Definition
FairGeoTrap.h:21
FairGeoTrd1
Definition
FairGeoTrd1.h:21
FairGeoTube
Definition
FairGeoTube.h:21
FairGeoTubs
Definition
FairGeoTubs.h:21
FairGeoVolume
Definition
FairGeoVolume.h:26
FairGeoVolume::getShape
const TString & getShape() const
Definition
FairGeoVolume.h:46
TObject
name
GLuint const GLchar * name
Definition
glcorearb.h:781
Detectors
3rdparty
FairRootBase
src
FairGeoShapes.cxx
Generated on Sat Nov 7 2026 19:53:07 for Project by
1.9.8