Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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// G4SmartVoxelHeader
27//
28// Class description:
29//
30// Represents a set of voxels, created by a single axis of virtual division.
31// Contains the individual voxels, which are potentially further divided
32// along different axes.
33//
34// Member data:
35//
36// EAxis faxis
37// - The (cartesian) slicing/division axis
38// G4double fmaxExtent
39// G4double fminExtent
40// - Minimum and maximum coordiantes along the axis
41// std::vector<G4SmartVoxelProxy*> fslices
42// - The slices along the axis
43//
44// G4int fminEquivalent
45// G4int fmaxEquivalent
46// - Minimum and maximum equivalent slice nos.
47// [Applies to the level of the header, not its nodes]
48
49// Author: Paul Kent (CERN), 13.07.1995 - Initial version
50// Gabriele Cosmo (CERN), 18.04.2001 - Migrated to STL vector
51// --------------------------------------------------------------------
52#ifndef G4SMARTVOXELHEADER_HH
53#define G4SMARTVOXELHEADER_HH
54
55#include <vector>
56
57#include "G4Types.hh"
58#include "geomdefs.hh"
59
60#include "G4SmartVoxelProxy.hh"
61#include "G4SmartVoxelNode.hh"
62
63// Forward declarations
64class G4LogicalVolume;
65class G4VoxelLimits;
67
68// Aliases
69using G4ProxyVector = std::vector<G4SmartVoxelProxy*>;
70using G4NodeVector = std::vector<G4SmartVoxelNode*>;
71using G4VolumeNosVector = std::vector<G4int>;
72using G4VolumeExtentVector = std::vector<G4double>;
73
74/**
75 * @brief G4SmartVoxelHeader represents a set of voxels, created by a single
76 * axis of virtual division. It contains the individual voxels, which are
77 * potentially further divided along different axes.
78 */
79
81{
82 public:
83
84 /**
85 * Constructor for the topmost header, to begin voxel construction at a
86 * given logical volume; 'pSlice' is used to set max and min equivalent
87 * slice numbers for the header - they apply to the level of the header,
88 * not its nodes.
89 * @param[in] pVolume Pointer to the logical volume to voxelise.
90 * @param[in] pSlice Max & min equivalent slice numbers for the header.
91 */
92 G4SmartVoxelHeader(G4LogicalVolume* pVolume, G4int pSlice = 0);
93
94 /**
95 * Constructor for building and refine voxels between specified limits,
96 * considering only the physical volumes numbered 'pCandidates'; 'pSlice'
97 * is used to set max and min equivalent slice numbers for the header;
98 * they apply to the level of the header, not its nodes.
99 * @param[in] pVolume Pointer to the logical volume to voxelise.
100 * @param[in] pLimits Refinement limits for building the voxels.
101 * @param[in] pCandidates Candidate volumes to be considered.
102 * @param[in] pSlice Max & min equivalent slice numbers for the header.
103 */
105 const G4VoxelLimits& pLimits,
106 const G4VolumeNosVector* pCandidates,
107 G4int pSlice = 0);
108 //
109
110 /**
111 * Destructor. Deletes all referenced nodes [but *not* the referenced
112 * physical volumes].
113 */
115
116 /**
117 * Equality operator.
118 */
119 G4bool operator == (const G4SmartVoxelHeader& pHead) const;
120
121 /**
122 * Streaming operator.
123 */
124 friend std::ostream&
125 operator << (std::ostream&s, const G4SmartVoxelHeader& h);
126
127 /**
128 * Access functions for min/max equivalent slices (nodes & headers).
129 */
134
135 /**
136 * Returns the current division axis.
137 */
138 EAxis GetAxis() const;
139
140 /**
141 * Returns the suggested division axis for parameterised volume.
142 */
144
145 /**
146 * Returns the maximum coordinate limit along the current axis.
147 */
149
150 /**
151 * Returns the minimum coordinate limit along the current axis.
152 */
154
155 /**
156 * Returns the number of slices along the current axis.
157 */
158 std::size_t GetNoSlices() const;
159
160 /**
161 * Returns the pointer to the proxy for the n-th slice
162 * (numbering from 0, no bounds checking is performed).
163 */
164 G4SmartVoxelProxy* GetSlice(std::size_t n) const;
165
166 /**
167 * Returns true if all slices are equal (after collection).
168 */
169 G4bool AllSlicesEqual() const;
170
171 private: // 'Worker' / operation functions
172
173 /**
174 * Builds and refine voxels for daughters of a specified volume 'pVolume'
175 * which DOES NOT contain a REPLICATED daughter.
176 */
177 void BuildVoxels(G4LogicalVolume* pVolume);
178
179 /**
180 * Builds voxels for a specified volume 'pVolume' containing a single
181 * replicated volume.
182 */
183 void BuildReplicaVoxels(G4LogicalVolume* pVolume);
184
185 /**
186 * Constructs nodes in simple consuming case.
187 */
188 void BuildConsumedNodes(G4int nReplicas);
189
190 /**
191 * Builds and refines voxels between specified limits 'pLimits',
192 * considering only the physical volumes 'pCandidates'. Main entry point
193 * for "construction". Hardwired to stop at third level of refinement,
194 * using the XYZ Cartesian axes in any order.
195 */
196 void BuildVoxelsWithinLimits(G4LogicalVolume* pVolume,
197 G4VoxelLimits pLimits,
198 const G4VolumeNosVector* pCandidates);
199
200 /**
201 * Calculates and stores the minimum and maximum equivalent neighbour
202 * values for all slices.
203 */
204 void BuildEquivalentSliceNos();
205
206 /**
207 * Collects the common nodes, deleting all but one to save memory
208 * and adjusting stored slice pointers appropriately.
209 */
210 void CollectEquivalentNodes();
211
212 /**
213 * Collects the common headers, deleting all but one to save memory
214 * and adjusting stored slice pointers appropriately.
215 */
216 void CollectEquivalentHeaders();
217
218 /**
219 * Builds the nodes corresponding to the specified axis 'pAxis', within
220 * the specified limits 'pLimits', considering the daughters numbered
221 * 'pCandidates' of the logical volume 'pVolume'.
222 */
223 G4ProxyVector* BuildNodes(G4LogicalVolume* pVolume,
224 G4VoxelLimits pLimits,
225 const G4VolumeNosVector* pCandidates,
226 EAxis pAxis);
227
228 /**
229 * Calculates a "quality value" for the specified vector of voxels.
230 * The value returned should be greater than zero and such that the
231 * smaller the number the higher the quality of the slice; 'pSlice'
232 * must consist of smart voxel node proxies only.
233 */
234 G4double CalculateQuality(G4ProxyVector* pSlice);
235
236 /**
237 * Examined each contained node, refines (creates a replacement additional
238 * dimension of voxels) when there is more than one voxel in the slice.
239 */
240 void RefineNodes(G4LogicalVolume* pVolume, G4VoxelLimits pLimits);
241
242 private:
243
244 /** Min and max equivalent slice nos for previous level. */
245 G4int fminEquivalent;
246 G4int fmaxEquivalent;
247
248 /** Axis for slices. */
249 EAxis faxis, fparamAxis;
250
251 /** Max and min coordinate along faxis. */
252 G4double fmaxExtent;
253 G4double fminExtent;
254
255 /** Slices along axis. */
256 G4ProxyVector fslices;
257};
258
259#include "G4SmartVoxelHeader.icc"
260
261#endif
std::vector< G4SmartVoxelProxy * > G4ProxyVector
std::vector< G4SmartVoxelNode * > G4NodeVector
std::vector< G4double > G4VolumeExtentVector
std::vector< G4int > G4VolumeNosVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4LogicalVolume represents a leaf node or unpositioned subtree in the geometry hierarchy....
G4int GetMaxEquivalentSliceNo() const
friend std::ostream & operator<<(std::ostream &s, const G4SmartVoxelHeader &h)
std::size_t GetNoSlices() const
G4double GetMaxExtent() const
void SetMinEquivalentSliceNo(G4int pMin)
G4double GetMinExtent() const
G4SmartVoxelProxy * GetSlice(std::size_t n) const
EAxis GetAxis() const
G4SmartVoxelHeader(G4LogicalVolume *pVolume, G4int pSlice=0)
G4bool operator==(const G4SmartVoxelHeader &pHead) const
EAxis GetParamAxis() const
G4bool AllSlicesEqual() const
G4int GetMinEquivalentSliceNo() const
void SetMaxEquivalentSliceNo(G4int pMax)
G4SmartVoxelProxy is a class for proxying smart voxels. The class represents either a header (in turn...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
EAxis
Definition geomdefs.hh:54