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5 ] [ 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 // class G4PhantomParameterisation
 27 //
 28 // Class description:
 29 // 
 30 // Describes regular parameterisations: a set of boxes of equal dimension
 31 // in the x, y and z dimensions. The G4PVParameterised volume using this
 32 // class must be placed inside a volume that is completely filled by these
 33 // boxes.
 34 
 35 // History:
 36 // - Created: P.Arce, May 2007
 37 //---------------------------------------------------------------------
 38 #ifndef G4PhantomParameterisation_HH
 39 #define G4PhantomParameterisation_HH
 40 
 41 #include <vector>
 42 
 43 #include "G4Types.hh"
 44 #include "G4VPVParameterisation.hh"
 45 #include "G4AffineTransform.hh"
 46 #include "G4VTouchable.hh" 
 47 
 48 class G4VPhysicalVolume;
 49 class G4VSolid;
 50 class G4Material;
 51 
 52 // Dummy forward declarations ...
 53 
 54 class G4Box;
 55 class G4Tubs;
 56 class G4Trd;
 57 class G4Trap;
 58 class G4Cons;
 59 class G4Orb;
 60 class G4Sphere;
 61 class G4Ellipsoid;
 62 class G4Torus;
 63 class G4Para;
 64 class G4Hype;
 65 class G4Polycone;
 66 class G4Polyhedra;
 67 
 68 class G4PhantomParameterisation : public G4VPVParameterisation
 69 {
 70   public:
 71 
 72     G4PhantomParameterisation();
 73    ~G4PhantomParameterisation() override;
 74 
 75     void ComputeTransformation(const G4int, G4VPhysicalVolume *) const override;
 76   
 77     G4VSolid* ComputeSolid(const G4int, G4VPhysicalVolume *) override;
 78   
 79     G4Material* ComputeMaterial(const G4int repNo, 
 80                                              G4VPhysicalVolume* currentVol,
 81                                        const G4VTouchable* parentTouch=nullptr) override;
 82   // Dummy declarations ...
 83 
 84     void ComputeDimensions (G4Box &, const G4int,
 85                             const G4VPhysicalVolume*) const override {}
 86     void ComputeDimensions (G4Tubs&, const G4int,
 87                             const G4VPhysicalVolume*) const override {}
 88     void ComputeDimensions (G4Trd&, const G4int,
 89                             const G4VPhysicalVolume*) const override {}
 90     void ComputeDimensions (G4Trap&, const G4int,
 91                             const G4VPhysicalVolume*) const override {}
 92     void ComputeDimensions (G4Cons&, const G4int,
 93                             const G4VPhysicalVolume*) const override {}
 94     void ComputeDimensions (G4Orb&, const G4int,
 95                             const G4VPhysicalVolume*) const override {}
 96     void ComputeDimensions (G4Sphere&, const G4int,
 97                             const G4VPhysicalVolume*) const override {}
 98     void ComputeDimensions (G4Ellipsoid&,const G4int,
 99                             const G4VPhysicalVolume*) const override {}
100     void ComputeDimensions (G4Torus&, const G4int,
101                             const G4VPhysicalVolume*) const override {}
102     void ComputeDimensions (G4Para&, const G4int,
103                             const G4VPhysicalVolume*) const override {}
104     void ComputeDimensions (G4Hype&, const G4int,
105                             const G4VPhysicalVolume*) const override {}
106     void ComputeDimensions (G4Polycone&, const G4int,
107                             const G4VPhysicalVolume*) const override {}
108     void ComputeDimensions (G4Polyhedra&, const G4int,
109                             const G4VPhysicalVolume*) const override {}
110   
111     void BuildContainerSolid( G4VPhysicalVolume* pPhysicalVol );
112     void BuildContainerSolid( G4VSolid* pMotherSolid );
113       // Save as container solid the parent of the voxels. Check that the
114       // voxels fill it completely.
115 
116     virtual G4int GetReplicaNo( const G4ThreeVector& localPoint,
117                                 const G4ThreeVector& localDir );
118       // Get the voxel number corresponding to the point in the container
119       // frame. Use 'localDir' to avoid precision problems at the surfaces.
120 
121     // Set and Get methods
122 
123     inline void SetMaterials(std::vector<G4Material*>& mates );
124 
125     inline void SetMaterialIndices( std::size_t* matInd );
126 
127     void SetVoxelDimensions( G4double halfx, G4double halfy, G4double halfz );
128     void SetNoVoxels( std::size_t nx, std::size_t ny, std::size_t nz );
129     
130     inline G4double GetVoxelHalfX() const;
131     inline G4double GetVoxelHalfY() const;
132     inline G4double GetVoxelHalfZ() const;
133     inline std::size_t GetNoVoxelsX() const;
134     inline std::size_t GetNoVoxelsY() const;
135     inline std::size_t GetNoVoxelsZ() const;
136     inline std::size_t GetNoVoxels() const;
137 
138     inline std::vector<G4Material*> GetMaterials() const;
139     inline std::size_t* GetMaterialIndices() const;
140     inline G4VSolid* GetContainerSolid() const;
141 
142     G4ThreeVector GetTranslation(const G4int copyNo ) const;
143 
144     G4bool SkipEqualMaterials() const;
145     void SetSkipEqualMaterials( G4bool skip );
146 
147     std::size_t GetMaterialIndex( std::size_t nx, std::size_t ny, std::size_t nz) const;
148     std::size_t GetMaterialIndex( std::size_t copyNo) const;
149 
150     G4Material* GetMaterial( std::size_t nx, std::size_t ny, std::size_t nz) const;
151     G4Material* GetMaterial( std::size_t copyNo ) const;
152 
153     void CheckVoxelsFillContainer( G4double contX, G4double contY,
154                                    G4double contZ ) const;
155       // Check that the voxels fill it completely.
156 
157   private:
158 
159     void ComputeVoxelIndices(const G4int copyNo, std::size_t& nx,
160                                    std::size_t& ny, std::size_t& nz ) const;
161       // Convert the copyNo to voxel numbers in x, y and z.
162 
163     void CheckCopyNo( const G4long copyNo ) const;
164       // Check that the copy number is within limits.
165 
166   protected:
167 
168     G4double fVoxelHalfX = 0.0, fVoxelHalfY = 0.0, fVoxelHalfZ = 0.0;
169       // Half dimension of voxels (assume they are boxes).
170     std::size_t fNoVoxelsX = 0, fNoVoxelsY = 0, fNoVoxelsZ = 0;
171       // Number of voxel in x, y and z dimensions.
172     std::size_t fNoVoxelsXY = 0;
173       // Number of voxels in x times number of voxels in y (for speed-up).
174     std::size_t fNoVoxels = 0;
175       // Total number of voxels (for speed-up).
176 
177     std::vector<G4Material*> fMaterials;
178       // List of materials of the voxels.
179     std::size_t* fMaterialIndices = nullptr;
180       // Index in fMaterials that correspond to each voxel.
181 
182     G4VSolid* fContainerSolid = nullptr;
183       // Save as container solid the parent of the voxels.
184       // Check that the voxels fill it completely.
185 
186     G4double fContainerWallX=0.0, fContainerWallY=0.0, fContainerWallZ=0.0;
187       // Save position of container wall for speed-up.
188 
189     G4double kCarTolerance;
190       // Relative surface tolerance.
191 
192     G4bool bSkipEqualMaterials = true;
193       // Flag to skip surface when two voxel have same material or not
194 };
195 
196 #include "G4PhantomParameterisation.icc"
197 
198 #endif
199