source: trunk/source/persistency/ascii/src/G4tgrSolid.cc@ 1055

Last change on this file since 1055 was 1035, checked in by garnier, 17 years ago

dossiers oublies

File size: 6.1 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id: G4tgrSolid.cc,v 1.6 2008/12/18 13:00:10 gunter Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30//
31// class G4tgrSolid
32
33// History:
34// - Created. P.Arce, CIEMAT (November 2007)
35// -------------------------------------------------------------------------
36
37#include "G4tgrSolid.hh"
38#include "G4tgrUtils.hh"
39#include "G4tgrMessenger.hh"
40#include "G4tgrVolumeMgr.hh"
41
42#include <map>
43#include <set>
44
45// -------------------------------------------------------------------------
46G4tgrSolid::G4tgrSolid()
47{
48}
49
50
51// -------------------------------------------------------------------------
52G4tgrSolid::~G4tgrSolid()
53{
54}
55
56
57// -------------------------------------------------------------------------
58G4tgrSolid::G4tgrSolid( const std::vector<G4String>& wl)
59{
60 //---------- set name
61 theName = G4tgrUtils::GetString( wl[1] );
62
63 //---------- set solid type
64 theType = G4tgrUtils::GetString( wl[2] );
65
66 //---------- create only vector<double> of theSolidParams
67 FillSolidParams( wl );
68
69 G4tgrVolumeMgr::GetInstance()->RegisterMe( this );
70
71
72#ifdef G4VERBOSE
73 if( G4tgrMessenger::GetVerboseLevel() >= 1 )
74 {
75 G4cout << " Created " << *this << G4endl;
76 }
77#endif
78
79}
80
81
82// -------------------------------------------------------------------------
83const std::vector< std::vector<G4double>* > G4tgrSolid::GetSolidParams() const
84{
85 return theSolidParams;
86}
87
88
89// -------------------------------------------------------------------------
90const G4String& G4tgrSolid::GetRelativeRotMatName() const
91{
92 return theName; // Dummy ...
93}
94
95
96// -------------------------------------------------------------------------
97G4ThreeVector G4tgrSolid::GetRelativePlace() const
98{
99 return G4ThreeVector(0,0,0); // Dummy...
100}
101
102
103// -------------------------------------------------------------------------
104void G4tgrSolid::FillSolidParams( const std::vector<G4String>& wl )
105{
106 //---- Setting which are angle parameters (for dimensions...)
107 std::map< G4String, std::set<G4int> > angleParams;
108 std::set<G4int> apar;
109 apar.clear(); apar.insert(3); apar.insert(4);
110 angleParams["TUBS"] = apar;
111 apar.clear(); apar.insert(5); apar.insert(6);
112 angleParams["CONS"] = apar;
113 apar.clear(); apar.insert(3); apar.insert(4); apar.insert(5);
114 angleParams["PARA"] = apar;
115 apar.clear(); apar.insert(1); apar.insert(2); apar.insert(6); apar.insert(10);
116 angleParams["TRAP"] = apar;
117 apar.clear(); apar.insert(2); apar.insert(3); apar.insert(4); apar.insert(5);
118 angleParams["SPHERE"] = apar;
119 apar.clear(); apar.insert(3); apar.insert(4);
120 angleParams["TORUS"] = apar;
121 apar.clear(); apar.insert(0); apar.insert(1);
122 angleParams["POLYCONE"] = apar;
123 apar.clear(); apar.insert(0); apar.insert(1);
124 angleParams["POLYHEDRA"] = apar;
125 apar.clear(); apar.insert(2); apar.insert(3);
126 angleParams["HYPE"] = apar;
127 apar.clear(); apar.insert(0);
128 angleParams["TWISTED_BOX"] = apar;
129 apar.clear(); apar.insert(0); apar.insert(2); apar.insert(3); apar.insert(10);
130 angleParams["TWISTED_TRAP"] = apar;
131 apar.clear(); apar.insert(5);
132 angleParams["TWISTED_TRD"] = apar;
133 apar.clear(); apar.insert(0); apar.insert(4);
134 angleParams["TWISTED_TUBS"] = apar;
135
136 std::vector<G4double>* vd = new std::vector<G4double>;
137 theSolidParams.push_back( vd );
138 size_t noParRead = wl.size()-3;
139
140 G4String solidType = wl[2];
141 //--- Default unit (mm) if length, deg if angle
142 for(size_t ii = 0; ii < noParRead; ii++)
143 {
144 G4bool isAngle = 0;
145 std::map< G4String, std::set<G4int> >::iterator ite
146 = angleParams.find(solidType);
147 if( ite != angleParams.end() )
148 {
149 std::set<G4int> apar = (*ite).second;
150 if( apar.find(ii) != apar.end() )
151 {
152 isAngle = 1;
153 vd->push_back( G4tgrUtils::GetDouble( wl[3+ii], deg ));
154#ifdef G4VERBOSE
155 if( G4tgrMessenger::GetVerboseLevel() >= 3 )
156 {
157 G4cout << " G4tgrSolid::FillSolidParams() - Angle param found "
158 << solidType << " " << ii << G4endl;
159 }
160#endif
161 }
162 }
163 if(!isAngle)
164 {
165 vd->push_back( G4tgrUtils::GetDouble( wl[3+ii] ) );
166 }
167 }
168}
169
170
171// -------------------------------------------------------------------------
172std::ostream& operator<<(std::ostream& os, const G4tgrSolid& sol)
173{
174 os << "G4tgrSolid= " << sol.theName
175 << " of type " << sol.theType << " PARAMS: ";
176 if( sol.theSolidParams.size() != 0 )
177 {
178 std::vector<G4double> solpar = *(sol.theSolidParams[0]);
179 for( size_t ii = 0; ii < solpar.size(); ii++)
180 {
181 os << solpar[ii] << " " ;
182 }
183 }
184 os << G4endl;
185
186 return os;
187}
Note: See TracBrowser for help on using the repository browser.