source: trunk/source/visualization/modeling/include/G4PhysicalVolumeModel.hh@ 1290

Last change on this file since 1290 was 1258, checked in by garnier, 16 years ago

cvs update

File size: 9.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: G4PhysicalVolumeModel.hh,v 1.36 2010/05/11 11:16:51 allison Exp $
28// GEANT4 tag $Name: $
29//
30//
31// John Allison 31st December 1997.
32//
33// Class Description:
34//
35// Model for physical volumes. It describes a physical volume and its
36// daughters to any desired depth. Note: the "requested depth" is
37// specified in the modeling parameters; enum {UNLIMITED = -1}.
38//
39// For access to base class information, e.g., modeling parameters,
40// use GetModelingParameters() inherited from G4VModel. See Class
41// Description of the base class G4VModel.
42//
43// G4PhysicalVolumeModel assumes the modeling parameters have been set
44// up with meaningful information - default vis attributes and culling
45// policy in particular.
46
47#ifndef G4PHYSICALVOLUMEMODEL_HH
48#define G4PHYSICALVOLUMEMODEL_HH
49
50#include "G4VModel.hh"
51#include "G4VTouchable.hh"
52
53#include "G4Transform3D.hh"
54#include "G4Plane3D.hh"
55#include <iostream>
56#include <vector>
57#include <map>
58
59class G4VPhysicalVolume;
60class G4LogicalVolume;
61class G4VSolid;
62class G4Material;
63class G4VisAttributes;
64class G4AttDef;
65class G4AttValue;
66
67class G4PhysicalVolumeModel: public G4VModel {
68
69public: // With description
70
71 enum {UNLIMITED = -1};
72
73 enum ClippingMode {subtraction, intersection};
74
75 class G4PhysicalVolumeNodeID {
76 public:
77 G4PhysicalVolumeNodeID
78 (G4VPhysicalVolume* pPV = 0,
79 G4int iCopyNo = 0,
80 G4int depth = 0,
81 const G4Transform3D& transform = G4Transform3D()):
82 fpPV(pPV),
83 fCopyNo(iCopyNo),
84 fNonCulledDepth(depth),
85 fTransform(transform) {}
86 G4VPhysicalVolume* GetPhysicalVolume() const {return fpPV;}
87 G4int GetCopyNo() const {return fCopyNo;}
88 G4int GetNonCulledDepth() const {return fNonCulledDepth;}
89 const G4Transform3D& GetTransform() const {return fTransform;}
90 G4bool operator< (const G4PhysicalVolumeNodeID& right) const;
91 private:
92 G4VPhysicalVolume* fpPV;
93 G4int fCopyNo;
94 G4int fNonCulledDepth;
95 G4Transform3D fTransform;
96 };
97 // Nested class for identifying physical volume nodes.
98
99 class G4PhysicalVolumeModelTouchable: public G4VTouchable {
100 public:
101 G4PhysicalVolumeModelTouchable
102 (const std::vector<G4PhysicalVolumeNodeID>& fullPVPath);
103 const G4ThreeVector& GetTranslation(G4int depth) const;
104 const G4RotationMatrix* GetRotation(G4int depth) const;
105 G4VPhysicalVolume* GetVolume(G4int depth) const;
106 G4VSolid* GetSolid(G4int depth) const;
107 G4int GetReplicaNumber(G4int depth) const;
108 G4int GetHistoryDepth() const {return fFullPVPath.size();}
109 private:
110 const std::vector<G4PhysicalVolumeNodeID>& fFullPVPath;
111 };
112 // Nested class for handling nested parameterisations.
113
114 G4PhysicalVolumeModel
115 (G4VPhysicalVolume*,
116 G4int requestedDepth = UNLIMITED,
117 const G4Transform3D& modelTransformation = G4Transform3D(),
118 const G4ModelingParameters* = 0,
119 G4bool useFullExtent = false);
120
121 virtual ~G4PhysicalVolumeModel ();
122
123 void DescribeYourselfTo (G4VGraphicsScene&);
124 // The main task of a model is to describe itself to the graphics scene
125 // handler (a object which inherits G4VSceneHandler, which inherits
126 // G4VGraphicsScene).
127
128 G4String GetCurrentDescription () const;
129 // A description which depends on the current state of the model.
130
131 G4String GetCurrentTag () const;
132 // A tag which depends on the current state of the model.
133
134 G4VPhysicalVolume* GetTopPhysicalVolume () const {return fpTopPV;}
135
136 G4int GetRequestedDepth () const {return fRequestedDepth;}
137
138 const G4VSolid* GetClippingSolid () const
139 {return fpClippingSolid;}
140
141 G4int GetCurrentDepth() const {return fCurrentDepth;}
142 // Current depth of geom. hierarchy.
143
144 G4VPhysicalVolume* GetCurrentPV() const {return fpCurrentPV;}
145 // Current physical volume.
146
147 G4LogicalVolume* GetCurrentLV() const {return fpCurrentLV;}
148 // Current logical volume.
149
150 G4Material* GetCurrentMaterial() const {return fpCurrentMaterial;}
151 // Current material.
152
153 const std::vector<G4PhysicalVolumeNodeID>& GetDrawnPVPath() const
154 {return fDrawnPVPath;}
155 // Path of the current drawn (non-culled) volume in terms of drawn
156 // (non-culled) ancesters. It is a vector of physical volume node
157 // identifiers corresponding to the geometry hierarchy actually
158 // selected, i.e., not culled. It is guaranteed that volumes are
159 // presented to the scene handlers in top-down hierarchy order,
160 // i.e., ancesters first, mothers before daughters, so the scene
161 // handler can be assured that, if it is building its own scene
162 // graph tree, a mother, if any, will have already been encountered
163 // and there will already be a node in place on which to hang the
164 // current volume.
165
166 const std::map<G4String,G4AttDef>* GetAttDefs() const;
167 // Attribute definitions for current solid.
168
169 std::vector<G4AttValue>* CreateCurrentAttValues() const;
170 // Attribute values for current solid. Each must refer to an
171 // attribute definition in the above map; its name is the key. The
172 // user must test the validity of this pointer (it must be non-zero
173 // and conform to the G4AttDefs, which may be checked with
174 // G4AttCheck) and delete the list after use. See
175 // G4XXXStoredSceneHandler::PreAddSolid for how to access and
176 // G4VTrajectory::ShowTrajectory for an example of the use of
177 // G4Atts.
178
179 void SetRequestedDepth (G4int requestedDepth) {
180 fRequestedDepth = requestedDepth;
181 }
182
183 void SetClippingSolid (G4VSolid* pClippingSolid) {
184 fpClippingSolid = pClippingSolid;
185 }
186
187 void SetClippingMode (ClippingMode mode) {
188 fClippingMode = mode;
189 }
190
191 G4bool Validate (G4bool warn);
192 // Validate, but allow internal changes (hence non-const function).
193
194 void CurtailDescent() {fCurtailDescent = true;}
195
196protected:
197
198 void VisitGeometryAndGetVisReps (G4VPhysicalVolume*,
199 G4int requestedDepth,
200 const G4Transform3D&,
201 G4VGraphicsScene&);
202
203 void DescribeAndDescend (G4VPhysicalVolume*,
204 G4int requestedDepth,
205 G4LogicalVolume*,
206 G4VSolid*,
207 G4Material*,
208 const G4Transform3D&,
209 G4VGraphicsScene&);
210
211 virtual void DescribeSolid (const G4Transform3D& theAT,
212 G4VSolid* pSol,
213 const G4VisAttributes* pVisAttribs,
214 G4VGraphicsScene& sceneHandler);
215
216 void CalculateExtent ();
217
218 /////////////////////////////////////////////////////////
219 // Data members...
220
221 G4VPhysicalVolume* fpTopPV; // The physical volume.
222 G4String fTopPVName; // ...of the physical volume.
223 G4int fTopPVCopyNo; // ...of the physical volume.
224 G4int fRequestedDepth;
225 // Requested depth of geom. hierarchy search.
226 G4bool fUseFullExtent; // ...if requested.
227 G4int fCurrentDepth; // Current depth of geom. hierarchy.
228 G4VPhysicalVolume* fpCurrentPV; // Current physical volume.
229 G4LogicalVolume* fpCurrentLV; // Current logical volume.
230 G4Material* fpCurrentMaterial; // Current material.
231 G4Transform3D* fpCurrentTransform; // Current transform.
232 std::vector<G4PhysicalVolumeNodeID> fFullPVPath;
233 std::vector<G4PhysicalVolumeNodeID> fDrawnPVPath;
234 G4bool fCurtailDescent;// Can be set to curtail descent.
235 G4VSolid* fpClippingSolid;
236 ClippingMode fClippingMode;
237
238private:
239
240 // Private copy constructor and assigment operator - copying and
241 // assignment not allowed. Keeps CodeWizard happy.
242 G4PhysicalVolumeModel (const G4PhysicalVolumeModel&);
243 G4PhysicalVolumeModel& operator = (const G4PhysicalVolumeModel&);
244};
245
246std::ostream& operator<<
247 (std::ostream& os, const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID);
248
249#endif
Note: See TracBrowser for help on using the repository browser.