Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VoxelLimits.hh
Go to the documentation of this file.
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// G4VoxelLimits
27//
28// Class description:
29//
30// Represents limitation/restrictions of space, where restrictions
31// are only made perpendicular to the cartesian axes.
32//
33// Member data:
34//
35// G4double fxAxisMin,fxAxisMax
36// G4double fyAxisMin,fyAxisMax
37// G4double fzAxisMin,fzAxisMax
38// - The min and max values along each axis. +-kInfinity if not restricted.
39
40// Author: Paul Kent (CERN), 13.07.1995 - Initial version.
41// --------------------------------------------------------------------
42#ifndef G4VOXELLIMITS_HH
43#define G4VOXELLIMITS_HH
44
45#include "G4Types.hh"
46#include "geomdefs.hh"
47
48#include "G4ThreeVector.hh"
49
50#include <assert.h>
51
52/**
53 * @brief G4VoxelLimits represents limitation/restrictions of space, where
54 * restrictions are only made perpendicular to the Cartesian axes.
55 */
56
58{
59 public:
60
61 /**
62 * Default Constructor & Destructor.
63 * Constructor initialises to be unlimited. Volume unrestricted.
64 */
65 G4VoxelLimits() = default;
66 ~G4VoxelLimits() = default;
67
68 /**
69 * Restricts the volume to between specified min and max along the
70 * given axis. Cartesian axes only, pMin<=pMax.
71 */
72 void AddLimit(const EAxis pAxis, const G4double pMin, const G4double pMax);
73
74 /**
75 * Accessors for max extent
76 */
80
81 /**
82 * Accessors for min extent
83 */
87
88 /**
89 * Accessors for the extent of the volume along the specified axis.
90 */
91 G4double GetMaxExtent(const EAxis pAxis) const;
92 G4double GetMinExtent(const EAxis pAxis) const;
93
94 /**
95 * Return true if the X/Y/Z axis is limited.
96 */
100
101 /**
102 * Return true if limited along any axis.
103 */
105
106 /**
107 * Return true if the specified axis is restricted/limited.
108 */
109 G4bool IsLimited(const EAxis pAxis) const;
110
111 /**
112 * Clips the line segment pStart->pEnd to the volume described by the
113 * current limits. Returns true if the line remains after clipping,
114 * else false, and leaves the vectors in an undefined state.
115 */
116 G4bool ClipToLimits(G4ThreeVector& pStart, G4ThreeVector& pEnd) const;
117
118 /**
119 * Returns true if the specified vector is inside/on boundaries of limits.
120 */
121 G4bool Inside(const G4ThreeVector& pVec) const;
122
123 /**
124 * Calculates the 'outcode' for the specified vector.
125 * Intended for use during clipping against the limits.
126 * The bits are set given the following conditions:
127 * 0 pVec.x()<fxAxisMin && IsXLimited()
128 * 1 pVec.x()>fxAxisMax && IsXLimited()
129 * 2 pVec.y()<fyAxisMin && IsYLimited()
130 * 3 pVec.y()>fyAxisMax && IsYLimited()
131 * 4 pVec.z()<fzAxisMin && IsZLimited()
132 * 5 pVec.z()>fzAxisMax && IsZLimited()
133 */
134 G4int OutCode(const G4ThreeVector& pVec) const;
135
136 private:
137
138 G4double fxAxisMin = -kInfinity, fxAxisMax = kInfinity;
139 G4double fyAxisMin = -kInfinity, fyAxisMax = kInfinity;
140 G4double fzAxisMin = -kInfinity, fzAxisMax = kInfinity;
141};
142
143/**
144 * Prints the limits to the stream in the form:
145 * "{(xmin,xmax) (ymin,ymax) (zmin,zmax)}"
146 * Replaces (xmin,xmax) by (-,-) when not limited.
147 */
148std::ostream& operator << (std::ostream& os, const G4VoxelLimits& pLim);
149
150#include "G4VoxelLimits.icc"
151
152#endif
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
std::ostream & operator<<(std::ostream &os, const G4VoxelLimits &pLim)
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
G4double GetMinExtent(const EAxis pAxis) const
G4int OutCode(const G4ThreeVector &pVec) const
G4bool IsYLimited() const
G4bool ClipToLimits(G4ThreeVector &pStart, G4ThreeVector &pEnd) const
~G4VoxelLimits()=default
G4double GetMinZExtent() const
void AddLimit(const EAxis pAxis, const G4double pMin, const G4double pMax)
G4VoxelLimits()=default
G4bool IsXLimited() const
G4double GetMaxExtent(const EAxis pAxis) const
G4bool IsLimited(const EAxis pAxis) const
G4double GetMaxYExtent() const
G4bool Inside(const G4ThreeVector &pVec) const
G4double GetMaxZExtent() const
G4double GetMinYExtent() const
G4double GetMinXExtent() const
G4bool IsZLimited() const
G4bool IsLimited() const
G4double GetMaxXExtent() const
EAxis
Definition geomdefs.hh:54