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

Last change on this file since 1038 was 954, checked in by garnier, 17 years ago

remise a jour

File size: 8.3 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.34 2007/04/03 13:46:49 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
52#include "G4Transform3D.hh"
53#include "G4Plane3D.hh"
54#include <iostream>
55#include <vector>
56#include <map>
57
58class G4VPhysicalVolume;
59class G4LogicalVolume;
60class G4VSolid;
61class G4Material;
62class G4VisAttributes;
63class G4Polyhedron;
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, G4int iCopyNo = 0, G4int depth = 0):
79 fpPV(pPV), fCopyNo(iCopyNo), fNonCulledDepth(depth) {}
80 G4VPhysicalVolume* GetPhysicalVolume() const {return fpPV;}
81 G4int GetCopyNo() const {return fCopyNo;}
82 G4int GetNonCulledDepth() const {return fNonCulledDepth;}
83 G4bool operator< (const G4PhysicalVolumeNodeID& right) const;
84 private:
85 G4VPhysicalVolume* fpPV;
86 G4int fCopyNo;
87 G4int fNonCulledDepth;
88 };
89 // Nested class for identifying physical volume nodes.
90
91 G4PhysicalVolumeModel
92 (G4VPhysicalVolume*,
93 G4int requestedDepth = UNLIMITED,
94 const G4Transform3D& modelTransformation = G4Transform3D(),
95 const G4ModelingParameters* = 0,
96 G4bool useFullExtent = false);
97
98 virtual ~G4PhysicalVolumeModel ();
99
100 void DescribeYourselfTo (G4VGraphicsScene&);
101 // The main task of a model is to describe itself to the graphics scene
102 // handler (a object which inherits G4VSceneHandler, which inherits
103 // G4VGraphicsScene).
104
105 G4String GetCurrentDescription () const;
106 // A description which depends on the current state of the model.
107
108 G4String GetCurrentTag () const;
109 // A tag which depends on the current state of the model.
110
111 G4VPhysicalVolume* GetTopPhysicalVolume () const {return fpTopPV;}
112
113 G4int GetRequestedDepth () const {return fRequestedDepth;}
114
115 const G4Polyhedron* GetClippingPolyhedron () const
116 {return fpClippingPolyhedron;}
117
118 G4int GetCurrentDepth() const {return fCurrentDepth;}
119 // Current depth of geom. hierarchy.
120
121 G4VPhysicalVolume* GetCurrentPV() const {return fpCurrentPV;}
122 // Current physical volume.
123
124 G4LogicalVolume* GetCurrentLV() const {return fpCurrentLV;}
125 // Current logical volume.
126
127 G4Material* GetCurrentMaterial() const {return fpCurrentMaterial;}
128 // Current material.
129
130 const std::vector<G4PhysicalVolumeNodeID>& GetDrawnPVPath() const
131 {return fDrawnPVPath;}
132 // Path of the current drawn (non-culled) volume in terms of drawn
133 // (non-culled) ancesters. It is a vector of physical volume node
134 // identifiers corresponding to the geometry hierarchy actually
135 // selected, i.e., not culled. It is guaranteed that volumes are
136 // presented to the scene handlers in top-down hierarchy order,
137 // i.e., ancesters first, mothers before daughters, so the scene
138 // handler can be assured that, if it is building its own scene
139 // graph tree, a mother, if any, will have already been encountered
140 // and there will already be a node in place on which to hang the
141 // current volume.
142
143 const std::map<G4String,G4AttDef>* GetAttDefs() const;
144 // Attribute definitions for current solid.
145
146 std::vector<G4AttValue>* CreateCurrentAttValues() const;
147 // Attribute values for current solid. Each must refer to an
148 // attribute definition in the above map; its name is the key. The
149 // user must test the validity of this pointer (it must be non-zero
150 // and conform to the G4AttDefs, which may be checked with
151 // G4AttCheck) and delete the list after use. See
152 // G4XXXStoredSceneHandler::PreAddSolid for how to access and
153 // G4VTrajectory::ShowTrajectory for an example of the use of
154 // G4Atts.
155
156 void SetRequestedDepth (G4int requestedDepth) {
157 fRequestedDepth = requestedDepth;
158 }
159
160 void SetClippingPolyhedron (const G4Polyhedron* pClippingPolyhedron) {
161 fpClippingPolyhedron = pClippingPolyhedron;
162 }
163
164 void SetClippingMode (ClippingMode mode) {
165 fClippingMode = mode;
166 }
167
168 G4bool Validate (G4bool warn);
169 // Validate, but allow internal changes (hence non-const function).
170
171 void CurtailDescent() {fCurtailDescent = true;}
172
173protected:
174
175 void VisitGeometryAndGetVisReps (G4VPhysicalVolume*,
176 G4int requestedDepth,
177 const G4Transform3D&,
178 G4VGraphicsScene&);
179
180 void DescribeAndDescend (G4VPhysicalVolume*,
181 G4int requestedDepth,
182 G4LogicalVolume*,
183 G4VSolid*,
184 G4Material*,
185 const G4Transform3D&,
186 G4VGraphicsScene&);
187
188 virtual void DescribeSolid (const G4Transform3D& theAT,
189 G4VSolid* pSol,
190 const G4VisAttributes* pVisAttribs,
191 G4VGraphicsScene& sceneHandler);
192
193 void CalculateExtent ();
194
195 /////////////////////////////////////////////////////////
196 // Data members...
197
198 G4VPhysicalVolume* fpTopPV; // The physical volume.
199 G4String fTopPVName; // ...of the physical volume.
200 G4int fTopPVCopyNo; // ...of the physical volume.
201 G4int fRequestedDepth;
202 // Requested depth of geom. hierarchy search.
203 G4bool fUseFullExtent; // ...if requested.
204 G4int fCurrentDepth; // Current depth of geom. hierarchy.
205 G4VPhysicalVolume* fpCurrentPV; // Current physical volume.
206 G4LogicalVolume* fpCurrentLV; // Current logical volume.
207 G4Material* fpCurrentMaterial; // Current material.
208 G4Transform3D* fpCurrentTransform; // Current transform.
209 std::vector<G4PhysicalVolumeNodeID> fFullPVPath;
210 std::vector<G4PhysicalVolumeNodeID> fDrawnPVPath;
211 G4bool fCurtailDescent;// Can be set to curtail descent.
212 const G4Polyhedron*fpClippingPolyhedron;
213 ClippingMode fClippingMode;
214
215private:
216
217 // Private copy constructor and assigment operator - copying and
218 // assignment not allowed. Keeps CodeWizard happy.
219 G4PhysicalVolumeModel (const G4PhysicalVolumeModel&);
220 G4PhysicalVolumeModel& operator = (const G4PhysicalVolumeModel&);
221};
222
223std::ostream& operator<<
224 (std::ostream& os, const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID);
225
226#endif
Note: See TracBrowser for help on using the repository browser.