Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:05

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4SmartVoxelNode
0027 //
0028 // Class description:
0029 //
0030 // A node in the smart voxel hierarchy - a `slice' of space along a given
0031 // axis between given minima and maxima. Note that the node is not aware
0032 // of its position - this information being available/derivable by the
0033 // node's owner(s) (voxelheaders).
0034 //
0035 // Member Data:
0036 //
0037 // G4int fminEquivalent
0038 // G4int fmaxEquivalent
0039 //   - Min and maximum nodes with same contents. Set by constructor
0040 //     and set methods.
0041 // std::vector<G4int> fcontents
0042 //   - Vector of no.s of volumes inside the node.
0043 
0044 // 18.04.01, G.Cosmo - Migrated to STL vector
0045 // 12.07.95, P.Kent - Initial version
0046 // --------------------------------------------------------------------
0047 #ifndef G4SMARTVOXELNODE_HH
0048 #define G4SMARTVOXELNODE_HH 1
0049 
0050 #include <vector>
0051 
0052 #include "geomwdefs.hh"
0053 #include "G4Types.hh"
0054 #include "G4Allocator.hh"
0055 
0056 using G4SliceVector = std::vector<G4int>;
0057 
0058 class G4SmartVoxelNode
0059 {
0060   public:
0061 
0062     G4SmartVoxelNode(G4int pSlice = 0) : fminEquivalent(pSlice),
0063                                          fmaxEquivalent(pSlice) {}
0064       // Constructor. Create an empty node with slice number pSlice.
0065       // This number is not stored, but used to provide defaults for the
0066       // minimum and maximum equivalent node numbers.
0067 
0068     ~G4SmartVoxelNode() = default;
0069       // Destructor. No actions.
0070 
0071     inline G4int GetVolume(G4int pVolumeNo) const;
0072       // Return contained volume number pVolumeNo.
0073       // Note: starts from 0 and no bounds checking performed.
0074 
0075     inline void Insert(G4int pVolumeNo);
0076       // Add the specified volume number to the contents.
0077 
0078     inline std::size_t GetNoContained() const;
0079       // Return the number of volumes inside the node.
0080 
0081     inline std::size_t GetCapacity() const;
0082       // Return the maximum capacity of the buffer.
0083 
0084     inline void Reserve(G4int noSlices);
0085       // Reserve memory in the vector of slices according to the specified
0086       // quantity, relative to the maximum number of slices.
0087 
0088     inline void Shrink();
0089       // Shrink buffer capacity to actual size to reduce wasted memory.
0090 
0091     inline G4int GetMaxEquivalentSliceNo() const;
0092       // Return the maximum slice (node/header) number with the same contents,
0093       // and with all intermediate slice also having the same contents.
0094     inline void SetMaxEquivalentSliceNo(G4int pMax);
0095       // Set the maximum slice number (as above).
0096     inline G4int GetMinEquivalentSliceNo() const;
0097       // Return the minimum slice (node/header) number with the same contents,
0098       // and with all intermediate nodes also having the same contents.
0099     inline void SetMinEquivalentSliceNo(G4int pMin);
0100       // Set the minimum slice number (as above).
0101 
0102     G4bool operator == (const G4SmartVoxelNode& v) const;
0103       // Equality operator.
0104 
0105     inline void* operator new(std::size_t);
0106       // Override "new" for "G4Allocator".
0107     inline void operator delete(void* aNode);
0108       // Override "delete" for "G4Allocator".
0109 
0110   private:
0111 
0112     G4int fminEquivalent;
0113     G4int fmaxEquivalent;
0114     G4SliceVector fcontents;
0115 };
0116 
0117 #include "G4SmartVoxelNode.icc"
0118 
0119 #endif