G4SmartVoxelHeader.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // class G4SmartVoxelHeader
00030 //
00031 // Class description:
00032 //
00033 // Represents a set of voxels, created by a single axis of virtual division.
00034 // Contains the individual voxels, which are potentially further divided
00035 // along different axes.
00036 //
00037 // Member data:
00038 //
00039 // EAxis faxis
00040 //   - The (cartesian) slicing/division axis
00041 // G4double fmaxExtent
00042 // G4double fminExtent
00043 //   - Minimum and maximum coordiantes along the axis
00044 // std::vector<G4SmartVoxelProxy*> fslices
00045 //   - The slices along the axis
00046 //
00047 // G4int fminEquivalent
00048 // G4int fmaxEquivalent
00049 //   - Minimum and maximum equivalent slice nos.
00050 //     [Applies to the level of the header, not its nodes]
00051 
00052 // History:
00053 // 18.04.01 G.Cosmo Migrated to STL vector
00054 // 13.07.95 P.Kent  Initial version
00055 // --------------------------------------------------------------------
00056 #ifndef G4SMARTVOXELHEADER_HH
00057 #define G4SMARTVOXELHEADER_HH
00058 
00059 #include "G4Types.hh"
00060 #include "geomdefs.hh"
00061 
00062 #include "G4SmartVoxelProxy.hh"
00063 #include "G4SmartVoxelNode.hh"
00064 
00065 #include <vector>
00066 
00067 // Forward declarations
00068 class G4LogicalVolume;
00069 class G4VoxelLimits;
00070 class G4VPhysicalVolume;
00071 
00072 // Typedefs
00073 typedef std::vector<G4SmartVoxelProxy*> G4ProxyVector;
00074 typedef std::vector<G4SmartVoxelNode*> G4NodeVector;
00075 typedef std::vector<G4int> G4VolumeNosVector;
00076 typedef std::vector<G4double> G4VolumeExtentVector;
00077 
00078 class G4SmartVoxelHeader
00079 {
00080   public:  // with description
00081 
00082     G4SmartVoxelHeader(G4LogicalVolume* pVolume, G4int pSlice=0);
00083       // Constructor for topmost header, to begin voxel construction at a
00084       // given logical volume. pSlice is used to set max and min equivalent
00085       // slice nos for the header - they apply to the level of the header,
00086       // not its nodes.
00087 
00088     ~G4SmartVoxelHeader();
00089       // Delete all referenced nodes [but *not* referenced physical volumes].
00090     
00091     G4int GetMaxEquivalentSliceNo() const;
00092     void SetMaxEquivalentSliceNo(G4int pMax);
00093     G4int GetMinEquivalentSliceNo() const;
00094     void SetMinEquivalentSliceNo(G4int pMin);
00095       // Access functions for min/max equivalent slices (nodes & headers).
00096 
00097     EAxis GetAxis() const;
00098       // Return the current division axis.
00099     EAxis GetParamAxis() const;
00100       // Return suggested division axis for parameterised volume.
00101 
00102     G4double GetMaxExtent() const;
00103       // Return the maximum coordinate limit along the current axis.
00104     G4double GetMinExtent() const;
00105       // Return the minimum coordinate limit along the current axis.
00106     
00107     G4int GetNoSlices() const;
00108       // Return the no of slices along the current axis.
00109     
00110     G4SmartVoxelProxy* GetSlice(G4int n) const;
00111       // Return ptr to the proxy for the nth slice (numbering from 0,
00112       // no bounds checking performed).
00113 
00114     G4bool AllSlicesEqual() const;
00115       // True if all slices equal (after collection).
00116 
00117   public:  // without description
00118 
00119     G4bool operator == (const G4SmartVoxelHeader& pHead) const;
00120 
00121     friend std::ostream&
00122     operator << (std::ostream&s, const G4SmartVoxelHeader& h);
00123 
00124   protected:
00125 
00126     G4SmartVoxelHeader(G4LogicalVolume* pVolume,
00127                        const G4VoxelLimits& pLimits,
00128                        const G4VolumeNosVector* pCandidates,
00129                        G4int pSlice=0);
00130       // Build and refine voxels between specified limits, considering only
00131       // the physical volumes numbered `pCandidates'. pSlice is used to set max
00132       // and min equivalent slice nos for the header - they apply to the level
00133       // of the header, not its nodes.
00134 
00135     //  `Worker' / operation functions:
00136 
00137     void BuildVoxels(G4LogicalVolume* pVolume);
00138       // Build and refine voxels for daughters of specified volume which
00139       // DOES NOT contain a REPLICATED daughter.
00140 
00141     void BuildReplicaVoxels(G4LogicalVolume* pVolume);
00142       // Build voxels for specified volume containing a single
00143       // replicated volume.
00144 
00145     void BuildConsumedNodes(G4int nReplicas);
00146       // Construct nodes in simple consuming case.
00147 
00148     void BuildVoxelsWithinLimits(G4LogicalVolume* pVolume,
00149                                  G4VoxelLimits pLimits,
00150                                  const G4VolumeNosVector* pCandidates);
00151       // Build and refine voxels between specified limits, considering only
00152       // the physical volumes `pCandidates'. Main entry point for "construction".
00153       // Hardwired to stop at third level of refinement, using the xyz cartesian
00154       // axes in any order.
00155 
00156     void BuildEquivalentSliceNos();
00157       // Calculate and Store the minimum and maximum equivalent neighbour
00158       // values for all slices.
00159 
00160     void CollectEquivalentNodes();
00161       // Collect common nodes, deleting all but one to save memory,
00162       // and adjusting stored slice ptrs appropriately.
00163 
00164     void CollectEquivalentHeaders();
00165       // Collect common headers, deleting all but one to save memory,
00166       // and adjusting stored slice ptrs appropriately.
00167 
00168 
00169     G4ProxyVector* BuildNodes(G4LogicalVolume* pVolume,
00170                               G4VoxelLimits pLimits,
00171                               const G4VolumeNosVector* pCandidates,
00172                               EAxis pAxis);
00173       // Build the nodes corresponding to the specified axis, within
00174       // the specified limits, considering the daughters numbered pCandidates
00175       // of the logical volume.
00176 
00177     G4double CalculateQuality(G4ProxyVector *pSlice);
00178       // Calculate a "quality value" for the specified vector of voxels
00179       // The value returned should be >0 and such that the smaller the
00180       // number the higher the quality of the slice.
00181       // pSlice must consist of smartvoxelnodeproxies only.
00182 
00183     void RefineNodes(G4LogicalVolume* pVolume,G4VoxelLimits pLimits);
00184       // Examined each contained node, refine (create a replacement additional
00185       // dimension of voxels) when there is more than one voxel in the slice.
00186 
00187     G4int fminEquivalent;
00188     G4int fmaxEquivalent;
00189       // Min and max equivalent slice nos for previous level.
00190 
00191     EAxis faxis, fparamAxis;
00192       // Axis for slices.
00193 
00194     G4double fmaxExtent;
00195     G4double fminExtent;
00196       // Max and min coordinate along faxis.
00197 
00198     G4ProxyVector fslices;
00199       // Slices along axis.
00200 };
00201 
00202 #include "G4SmartVoxelHeader.icc"
00203 
00204 #endif

Generated on Mon May 27 17:49:51 2013 for Geant4 by  doxygen 1.4.7