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: G4tgrVolumeDivision.cc,v 1.6 2008/12/18 13:00:20 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
29 | // |
---|
30 | // |
---|
31 | // class G4tgrVolumeDivision |
---|
32 | |
---|
33 | // History: |
---|
34 | // - Created. P.Arce, CIEMAT (November 2007) |
---|
35 | // ------------------------------------------------------------------------- |
---|
36 | |
---|
37 | #include "G4tgrVolumeDivision.hh" |
---|
38 | #include "G4tgrUtils.hh" |
---|
39 | #include "G4tgrVolumeMgr.hh" |
---|
40 | #include "G4tgrPlace.hh" |
---|
41 | #include "G4tgrFileReader.hh" |
---|
42 | #include "G4tgrPlaceDivRep.hh" |
---|
43 | #include "G4tgrMessenger.hh" |
---|
44 | |
---|
45 | |
---|
46 | G4mmss G4tgrVolumeDivision::theSupportedAxis; |
---|
47 | |
---|
48 | |
---|
49 | //------------------------------------------------------------- |
---|
50 | G4tgrVolumeDivision::~G4tgrVolumeDivision() |
---|
51 | { |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | //------------------------------------------------------------- |
---|
56 | G4tgrVolumeDivision::G4tgrVolumeDivision( const std::vector<G4String>& wl ) |
---|
57 | { |
---|
58 | // wl: NAME PARENT MATERIAL AXIS STEP/NDIV OFFSET |
---|
59 | |
---|
60 | G4tgrUtils::CheckWLsize( wl, 6, WLSIZE_GE, |
---|
61 | "G4tgrVolumeDivision::G4tgrVolumeDivision" ); |
---|
62 | G4tgrUtils::CheckWLsize( wl, 8, WLSIZE_LE, |
---|
63 | "G4tgrVolumeDivision::G4tgrVolumeDivision" ); |
---|
64 | |
---|
65 | theType = "VOLDivision"; |
---|
66 | |
---|
67 | // :DIV NAME PARENT MATERIAL AXIS STEP/NDIV OFFSET |
---|
68 | |
---|
69 | //---------- set name |
---|
70 | theName = G4tgrUtils::GetString( wl[1] ); |
---|
71 | |
---|
72 | //---------- set the pointer to the parent DU |
---|
73 | G4String parentName = G4tgrUtils::GetString(wl[2]); |
---|
74 | G4tgrVolumeMgr::GetInstance()->FindVolume( parentName, 1); // check existance |
---|
75 | |
---|
76 | //---------- initialize G4tgrPlace |
---|
77 | thePlaceDiv = new G4tgrPlaceDivRep(); |
---|
78 | thePlaceDiv->SetParentName( parentName ); |
---|
79 | thePlaceDiv->SetType("PlaceDivision"); |
---|
80 | thePlaceDiv->SetVolume( this ); |
---|
81 | |
---|
82 | //---------- set material name |
---|
83 | theMaterialName = G4tgrUtils::GetString( wl[3] ); |
---|
84 | |
---|
85 | //----- set axis of replica |
---|
86 | thePlaceDiv->SetAxis( thePlaceDiv->BuildAxis(G4tgrUtils::GetString(wl[4])) ); |
---|
87 | |
---|
88 | //------ register parent - child |
---|
89 | G4tgrVolumeMgr::GetInstance()->RegisterParentChild( parentName, thePlaceDiv ); |
---|
90 | #ifdef G4VERBOSE |
---|
91 | if( G4tgrMessenger::GetVerboseLevel() >= 3 ) |
---|
92 | { |
---|
93 | G4cout << " G4tgrVolumeDivision::G4tgrVolumeDivision() -" |
---|
94 | << " Replica register parent - child " << G4endl; |
---|
95 | } |
---|
96 | #endif |
---|
97 | |
---|
98 | //---------- set if division is given by number of divisions of by width |
---|
99 | G4String wl0 = wl[0]; |
---|
100 | for( size_t ii = 0; ii < wl0.length(); ii++ ) |
---|
101 | { |
---|
102 | wl0[ii] = toupper( wl0[ii] ); |
---|
103 | } |
---|
104 | |
---|
105 | if( wl0 == ":DIV_NDIV" ) |
---|
106 | { |
---|
107 | thePlaceDiv->SetDivType( DivByNdiv ); |
---|
108 | thePlaceDiv->SetNDiv( G4tgrUtils::GetInt( wl[5] ) ); |
---|
109 | if( wl.size() == 7 ) |
---|
110 | { |
---|
111 | thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[6] )*mm ); |
---|
112 | } |
---|
113 | } |
---|
114 | else if( wl0 == ":DIV_WIDTH" ) |
---|
115 | { |
---|
116 | thePlaceDiv->SetDivType( DivByWidth ); |
---|
117 | thePlaceDiv->SetWidth( G4tgrUtils::GetDouble( wl[5] )*mm ); |
---|
118 | if( wl.size() == 7 ) |
---|
119 | { |
---|
120 | thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[6] )*mm ); |
---|
121 | } |
---|
122 | } |
---|
123 | else if( wl0 == ":DIV_NDIV_WIDTH" ) |
---|
124 | { |
---|
125 | thePlaceDiv->SetDivType( DivByNdivAndWidth ); |
---|
126 | thePlaceDiv->SetNDiv( G4tgrUtils::GetInt( wl[5] ) ); |
---|
127 | thePlaceDiv->SetWidth( G4tgrUtils::GetDouble( wl[6] )*mm ); |
---|
128 | if( wl.size() == 8 ) |
---|
129 | { |
---|
130 | thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[7] )*mm ); |
---|
131 | } |
---|
132 | } |
---|
133 | else |
---|
134 | { |
---|
135 | G4String ErrMessage = "Division type not supported, sorry... " + wl[0]; |
---|
136 | G4Exception("G4tgrVolumeDivision::G4tgrVolumeDivision()", |
---|
137 | "NotImplemented", FatalException, ErrMessage); |
---|
138 | } |
---|
139 | |
---|
140 | theVisibility = 1; |
---|
141 | theRGBColour = new G4double[3]; |
---|
142 | for(size_t ii=0; ii<3; ii++) { theRGBColour[ii] = -1.; } |
---|
143 | |
---|
144 | #ifdef G4VERBOSE |
---|
145 | if( G4tgrMessenger::GetVerboseLevel() >= 1 ) |
---|
146 | { |
---|
147 | G4cout << " Created " << *this << G4endl; |
---|
148 | } |
---|
149 | #endif |
---|
150 | |
---|
151 | theSolid = 0; |
---|
152 | } |
---|
153 | |
---|
154 | |
---|
155 | // ------------------------------------------------------------------------- |
---|
156 | std::ostream& operator<<(std::ostream& os, const G4tgrVolumeDivision& obj) |
---|
157 | { |
---|
158 | os << "G4tgrVolumeDivision= " << obj.theName |
---|
159 | << " Placement= " << *(obj.thePlaceDiv) << G4endl; |
---|
160 | |
---|
161 | return os; |
---|
162 | } |
---|