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 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 // 18.04.01, G.Cosmo - Migrated to STL vector
 50 // 13.07.95, P.Kent - Initial version
 51 // --------------------------------------------------------------------
 52 #ifndef G4SMARTVOXELHEADER_HH
 53 #define G4SMARTVOXELHEADER_HH 1
 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
 64 class G4LogicalVolume;
 65 class G4VoxelLimits;
 66 class G4VPhysicalVolume;
 67 
 68 // Aliases
 69 using G4ProxyVector = std::vector<G4SmartVoxelProxy*>;
 70 using G4NodeVector = std::vector<G4SmartVoxelNode*>;
 71 using G4VolumeNosVector = std::vector<G4int>;
 72 using G4VolumeExtentVector = std::vector<G4double>;
 73 
 74 class G4SmartVoxelHeader
 75 {
 76   public:
 77 
 78     G4SmartVoxelHeader(G4LogicalVolume* pVolume, G4int pSlice = 0);
 79       // Constructor for topmost header, to begin voxel construction at a
 80       // given logical volume. pSlice is used to set max and min equivalent
 81       // slice nos for the header - they apply to the level of the header,
 82       // not its nodes.
 83 
 84     ~G4SmartVoxelHeader();
 85       // Delete all referenced nodes [but *not* referenced physical volumes].
 86     
 87     G4int GetMaxEquivalentSliceNo() const;
 88     void SetMaxEquivalentSliceNo(G4int pMax);
 89     G4int GetMinEquivalentSliceNo() const;
 90     void SetMinEquivalentSliceNo(G4int pMin);
 91       // Access functions for min/max equivalent slices (nodes & headers).
 92 
 93     EAxis GetAxis() const;
 94       // Return the current division axis.
 95     EAxis GetParamAxis() const;
 96       // Return suggested division axis for parameterised volume.
 97 
 98     G4double GetMaxExtent() const;
 99       // Return the maximum coordinate limit along the current axis.
100     G4double GetMinExtent() const;
101       // Return the minimum coordinate limit along the current axis.
102     
103     std::size_t GetNoSlices() const;
104       // Return the no of slices along the current axis.
105     
106     G4SmartVoxelProxy* GetSlice(std::size_t n) const;
107       // Return ptr to the proxy for the nth slice (numbering from 0,
108       // no bounds checking performed).
109 
110     G4bool AllSlicesEqual() const;
111       // True if all slices equal (after collection).
112 
113   public:
114 
115     G4bool operator == (const G4SmartVoxelHeader& pHead) const;
116 
117     friend std::ostream&
118     operator << (std::ostream&s, const G4SmartVoxelHeader& h);
119 
120     G4SmartVoxelHeader(G4LogicalVolume* pVolume,
121            const G4VoxelLimits& pLimits,
122            const G4VolumeNosVector* pCandidates,
123            G4int pSlice = 0);
124       // Build and refine voxels between specified limits, considering only
125       // the physical volumes numbered `pCandidates'. pSlice is used to set max
126       // and min equivalent slice nos for the header - they apply to the level
127       // of the header, not its nodes.
128 
129   protected:
130 
131     //  `Worker' / operation functions:
132 
133     void BuildVoxels(G4LogicalVolume* pVolume);
134       // Build and refine voxels for daughters of specified volume which
135       // DOES NOT contain a REPLICATED daughter.
136 
137     void BuildReplicaVoxels(G4LogicalVolume* pVolume);
138       // Build voxels for specified volume containing a single
139       // replicated volume.
140 
141     void BuildConsumedNodes(G4int nReplicas);
142       // Construct nodes in simple consuming case.
143 
144     void BuildVoxelsWithinLimits(G4LogicalVolume* pVolume,
145                                  G4VoxelLimits pLimits,
146                      const G4VolumeNosVector* pCandidates);
147       // Build and refine voxels between specified limits, considering only
148       // the physical volumes `pCandidates'. Main entry point for "construction".
149       // Hardwired to stop at third level of refinement, using the xyz cartesian
150       // axes in any order.
151 
152     void BuildEquivalentSliceNos();
153       // Calculate and Store the minimum and maximum equivalent neighbour
154       // values for all slices.
155 
156     void CollectEquivalentNodes();
157       // Collect common nodes, deleting all but one to save memory,
158       // and adjusting stored slice ptrs appropriately.
159 
160     void CollectEquivalentHeaders();
161       // Collect common headers, deleting all but one to save memory,
162       // and adjusting stored slice ptrs appropriately.
163 
164 
165     G4ProxyVector* BuildNodes(G4LogicalVolume* pVolume,
166                         G4VoxelLimits pLimits,
167                         const G4VolumeNosVector* pCandidates,
168                         EAxis pAxis);
169       // Build the nodes corresponding to the specified axis, within
170       // the specified limits, considering the daughters numbered pCandidates
171       // of the logical volume.
172 
173     G4double CalculateQuality(G4ProxyVector *pSlice);
174       // Calculate a "quality value" for the specified vector of voxels
175       // The value returned should be >0 and such that the smaller the
176       // number the higher the quality of the slice.
177       // pSlice must consist of smartvoxelnodeproxies only.
178 
179     void RefineNodes(G4LogicalVolume* pVolume,G4VoxelLimits pLimits);
180       // Examined each contained node, refine (create a replacement additional
181       // dimension of voxels) when there is more than one voxel in the slice.
182 
183     G4int fminEquivalent;
184     G4int fmaxEquivalent;
185       // Min and max equivalent slice nos for previous level.
186 
187     EAxis faxis, fparamAxis;
188       // Axis for slices.
189 
190     G4double fmaxExtent;
191     G4double fminExtent;
192       // Max and min coordinate along faxis.
193 
194     G4ProxyVector fslices;
195       // Slices along axis.
196 };
197 
198 #include "G4SmartVoxelHeader.icc"
199 
200 #endif
201