Geant4  10.02.p01
G4SmartVoxelHeader.hh
Go to the documentation of this file.
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: G4SmartVoxelHeader.hh 84209 2014-10-10 14:46:37Z gcosmo $
28 //
29 // class G4SmartVoxelHeader
30 //
31 // Class description:
32 //
33 // Represents a set of voxels, created by a single axis of virtual division.
34 // Contains the individual voxels, which are potentially further divided
35 // along different axes.
36 //
37 // Member data:
38 //
39 // EAxis faxis
40 // - The (cartesian) slicing/division axis
41 // G4double fmaxExtent
42 // G4double fminExtent
43 // - Minimum and maximum coordiantes along the axis
44 // std::vector<G4SmartVoxelProxy*> fslices
45 // - The slices along the axis
46 //
47 // G4int fminEquivalent
48 // G4int fmaxEquivalent
49 // - Minimum and maximum equivalent slice nos.
50 // [Applies to the level of the header, not its nodes]
51 
52 // History:
53 // 18.04.01 G.Cosmo Migrated to STL vector
54 // 13.07.95 P.Kent Initial version
55 // --------------------------------------------------------------------
56 #ifndef G4SMARTVOXELHEADER_HH
57 #define G4SMARTVOXELHEADER_HH
58 
59 #include "G4Types.hh"
60 #include "geomdefs.hh"
61 
62 #include "G4SmartVoxelProxy.hh"
63 #include "G4SmartVoxelNode.hh"
64 
65 #include <vector>
66 
67 // Forward declarations
68 class G4LogicalVolume;
69 class G4VoxelLimits;
71 
72 // Typedefs
73 typedef std::vector<G4SmartVoxelProxy*> G4ProxyVector;
74 typedef std::vector<G4SmartVoxelNode*> G4NodeVector;
75 typedef std::vector<G4int> G4VolumeNosVector;
76 typedef std::vector<G4double> G4VolumeExtentVector;
77 
79 {
80  public: // with description
81 
82  G4SmartVoxelHeader(G4LogicalVolume* pVolume, G4int pSlice=0);
83  // Constructor for topmost header, to begin voxel construction at a
84  // given logical volume. pSlice is used to set max and min equivalent
85  // slice nos for the header - they apply to the level of the header,
86  // not its nodes.
87 
89  // Delete all referenced nodes [but *not* referenced physical volumes].
90 
92  void SetMaxEquivalentSliceNo(G4int pMax);
94  void SetMinEquivalentSliceNo(G4int pMin);
95  // Access functions for min/max equivalent slices (nodes & headers).
96 
97  EAxis GetAxis() const;
98  // Return the current division axis.
99  EAxis GetParamAxis() const;
100  // Return suggested division axis for parameterised volume.
101 
102  G4double GetMaxExtent() const;
103  // Return the maximum coordinate limit along the current axis.
104  G4double GetMinExtent() const;
105  // Return the minimum coordinate limit along the current axis.
106 
107  G4int GetNoSlices() const;
108  // Return the no of slices along the current axis.
109 
111  // Return ptr to the proxy for the nth slice (numbering from 0,
112  // no bounds checking performed).
113 
114  G4bool AllSlicesEqual() const;
115  // True if all slices equal (after collection).
116 
117  public: // without description
118 
119  G4bool operator == (const G4SmartVoxelHeader& pHead) const;
120 
121  friend std::ostream&
122  operator << (std::ostream&s, const G4SmartVoxelHeader& h);
123 
125  const G4VoxelLimits& pLimits,
126  const G4VolumeNosVector* pCandidates,
127  G4int pSlice=0);
128  // Build and refine voxels between specified limits, considering only
129  // the physical volumes numbered `pCandidates'. pSlice is used to set max
130  // and min equivalent slice nos for the header - they apply to the level
131  // of the header, not its nodes.
132 
133  protected:
134 
135  // `Worker' / operation functions:
136 
137  void BuildVoxels(G4LogicalVolume* pVolume);
138  // Build and refine voxels for daughters of specified volume which
139  // DOES NOT contain a REPLICATED daughter.
140 
141  void BuildReplicaVoxels(G4LogicalVolume* pVolume);
142  // Build voxels for specified volume containing a single
143  // replicated volume.
144 
145  void BuildConsumedNodes(G4int nReplicas);
146  // Construct nodes in simple consuming case.
147 
149  G4VoxelLimits pLimits,
150  const G4VolumeNosVector* pCandidates);
151  // Build and refine voxels between specified limits, considering only
152  // the physical volumes `pCandidates'. Main entry point for "construction".
153  // Hardwired to stop at third level of refinement, using the xyz cartesian
154  // axes in any order.
155 
157  // Calculate and Store the minimum and maximum equivalent neighbour
158  // values for all slices.
159 
160  void CollectEquivalentNodes();
161  // Collect common nodes, deleting all but one to save memory,
162  // and adjusting stored slice ptrs appropriately.
163 
165  // Collect common headers, deleting all but one to save memory,
166  // and adjusting stored slice ptrs appropriately.
167 
168 
170  G4VoxelLimits pLimits,
171  const G4VolumeNosVector* pCandidates,
172  EAxis pAxis);
173  // Build the nodes corresponding to the specified axis, within
174  // the specified limits, considering the daughters numbered pCandidates
175  // of the logical volume.
176 
178  // Calculate a "quality value" for the specified vector of voxels
179  // The value returned should be >0 and such that the smaller the
180  // number the higher the quality of the slice.
181  // pSlice must consist of smartvoxelnodeproxies only.
182 
183  void RefineNodes(G4LogicalVolume* pVolume,G4VoxelLimits pLimits);
184  // Examined each contained node, refine (create a replacement additional
185  // dimension of voxels) when there is more than one voxel in the slice.
186 
189  // Min and max equivalent slice nos for previous level.
190 
192  // Axis for slices.
193 
196  // Max and min coordinate along faxis.
197 
199  // Slices along axis.
200 };
201 
202 #include "G4SmartVoxelHeader.icc"
203 
204 #endif
G4int GetMaxEquivalentSliceNo() const
friend std::ostream & operator<<(std::ostream &s, const G4SmartVoxelHeader &h)
void BuildVoxelsWithinLimits(G4LogicalVolume *pVolume, G4VoxelLimits pLimits, const G4VolumeNosVector *pCandidates)
std::vector< G4int > G4VolumeNosVector
G4double CalculateQuality(G4ProxyVector *pSlice)
EAxis GetParamAxis() const
void BuildConsumedNodes(G4int nReplicas)
int G4int
Definition: G4Types.hh:78
static const double s
Definition: G4SIunits.hh:168
EAxis GetAxis() const
G4double GetMinExtent() const
bool G4bool
Definition: G4Types.hh:79
G4bool AllSlicesEqual() const
std::vector< G4double > G4VolumeExtentVector
G4int GetNoSlices() const
G4double GetMaxExtent() const
const G4int n
std::vector< G4SmartVoxelProxy * > G4ProxyVector
EAxis
Definition: geomdefs.hh:54
G4SmartVoxelHeader(G4LogicalVolume *pVolume, G4int pSlice=0)
G4ProxyVector * BuildNodes(G4LogicalVolume *pVolume, G4VoxelLimits pLimits, const G4VolumeNosVector *pCandidates, EAxis pAxis)
G4bool operator==(const G4SmartVoxelHeader &pHead) const
void BuildReplicaVoxels(G4LogicalVolume *pVolume)
std::vector< G4SmartVoxelNode * > G4NodeVector
void RefineNodes(G4LogicalVolume *pVolume, G4VoxelLimits pLimits)
void SetMinEquivalentSliceNo(G4int pMin)
G4SmartVoxelProxy * GetSlice(G4int n) const
double G4double
Definition: G4Types.hh:76
G4int GetMinEquivalentSliceNo() const
void SetMaxEquivalentSliceNo(G4int pMax)
void BuildVoxels(G4LogicalVolume *pVolume)