source: trunk/source/geometry/management/include/G4SmartVoxelHeader.hh @ 1202

Last change on this file since 1202 was 1058, checked in by garnier, 15 years ago

file release beta

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