Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4BoundingBox3D Class Reference

#include <G4BoundingBox3D.hh>

Public Member Functions

 G4BoundingBox3D ()
 
 G4BoundingBox3D (const G4Point3D &)
 
 G4BoundingBox3D (const G4Point3D &, const G4Point3D &)
 
 ~G4BoundingBox3D ()
 
 G4BoundingBox3D (const G4BoundingBox3D &right)
 
G4BoundingBox3Doperator= (const G4BoundingBox3D &right)
 
void Init (const G4Point3D &)
 
void Init (const G4Point3D &, const G4Point3D &)
 
void Extend (const G4Point3D &)
 
G4Point3D GetBoxMin () const
 
G4Point3D GetBoxMax () const
 
G4double GetDistance () const
 
void SetDistance (G4double distance0)
 
G4int Inside (const G4Point3D &) const
 
G4int GetTestResult () const
 
G4int Test (const G4Ray &)
 

Static Public Attributes

static const G4BoundingBox3D space
 

Detailed Description

Definition at line 46 of file G4BoundingBox3D.hh.

Constructor & Destructor Documentation

◆ G4BoundingBox3D() [1/4]

G4BoundingBox3D::G4BoundingBox3D ( )

Definition at line 46 of file G4BoundingBox3D.cc.

47{
48 distance = 0;
49 test_result = 0;
51}
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()

◆ G4BoundingBox3D() [2/4]

G4BoundingBox3D::G4BoundingBox3D ( const G4Point3D p)

Definition at line 58 of file G4BoundingBox3D.cc.

59{
60 Init(p);
61}
void Init(const G4Point3D &)

◆ G4BoundingBox3D() [3/4]

G4BoundingBox3D::G4BoundingBox3D ( const G4Point3D p1,
const G4Point3D p2 
)

Definition at line 53 of file G4BoundingBox3D.cc.

54{
55 Init(p1, p2);
56}

◆ ~G4BoundingBox3D()

G4BoundingBox3D::~G4BoundingBox3D ( )

Definition at line 63 of file G4BoundingBox3D.cc.

64{
65}

◆ G4BoundingBox3D() [4/4]

G4BoundingBox3D::G4BoundingBox3D ( const G4BoundingBox3D right)

Definition at line 67 of file G4BoundingBox3D.cc.

68 : box_min(right.box_min), box_max(right.box_max),
69 distance(right.distance), test_result(right.test_result),
70 MiddlePoint(right.MiddlePoint), GeantBox(right.GeantBox),
71 kCarTolerance(right.kCarTolerance)
72{
73}

Member Function Documentation

◆ Extend()

void G4BoundingBox3D::Extend ( const G4Point3D p)

Definition at line 125 of file G4BoundingBox3D.cc.

126{
127
128 // L. Broglia
129 // Maybe temporary
130 // Create a BBox bigger than the reality
131
132 if (p.x() < box_min.x())
133 box_min.setX( p.x() - kCarTolerance );
134 else if (p.x() > box_max.x())
135 box_max.setX( p.x() + kCarTolerance );
136
137 if (p.y() < box_min.y())
138 box_min.setY( p.y() - kCarTolerance );
139 else if (p.y() > box_max.y())
140 box_max.setY( p.y() + kCarTolerance );
141
142 if (p.z() < box_min.z())
143 box_min.setZ( p.z() - kCarTolerance );
144 else if (p.z() > box_max.z())
145 box_max.setZ( p.z() + kCarTolerance );
146
147 // L. Broglia
148 // Now re-calculate GeantBox and MiddlePoint
149 GeantBox = (box_max - box_min)*0.5;
150 MiddlePoint = (box_min + box_max)*0.5;
151
152}

Referenced by G4FConicalSurface::CalcBBox(), G4FCylindricalSurface::CalcBBox(), G4SurfaceBoundary::Init(), G4BSplineCurve::InitBounded(), G4CircularCurve::InitBounded(), G4CompositeCurve::InitBounded(), G4Ellipse::InitBounded(), G4Hyperbola::InitBounded(), and G4Parabola::InitBounded().

◆ GetBoxMax()

◆ GetBoxMin()

◆ GetDistance()

G4double G4BoundingBox3D::GetDistance ( ) const

◆ GetTestResult()

G4int G4BoundingBox3D::GetTestResult ( ) const

◆ Init() [1/2]

void G4BoundingBox3D::Init ( const G4Point3D p)

Definition at line 113 of file G4BoundingBox3D.cc.

114{
115 box_min= box_max= MiddlePoint= p;
116 GeantBox= G4Point3D(0, 0, 0);
117 test_result = 0;
118 distance= 0;
120}
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35

Referenced by G4FConicalSurface::CalcBBox(), G4FCylindricalSurface::CalcBBox(), G4BoundingBox3D(), G4SurfaceBoundary::Init(), G4BSplineCurve::InitBounded(), G4CircularCurve::InitBounded(), G4CompositeCurve::InitBounded(), G4Ellipse::InitBounded(), G4Hyperbola::InitBounded(), and G4Parabola::InitBounded().

◆ Init() [2/2]

void G4BoundingBox3D::Init ( const G4Point3D p1,
const G4Point3D p2 
)

Definition at line 89 of file G4BoundingBox3D.cc.

90{
91 // L. Broglia
92 // Maybe temporary
93 // Create a BBox bigger than the reality
94
96
97 box_min.setX( std::min(p1.x(), p2.x()) - kCarTolerance );
98 box_min.setY( std::min(p1.y(), p2.y()) - kCarTolerance );
99 box_min.setZ( std::min(p1.z(), p2.z()) - kCarTolerance );
100 box_max.setX( std::max(p1.x(), p2.x()) + kCarTolerance );
101 box_max.setY( std::max(p1.y(), p2.y()) + kCarTolerance );
102 box_max.setZ( std::max(p1.z(), p2.z()) + kCarTolerance );
103
104 // Calc half spaces
105 GeantBox = (box_max - box_min)*0.5;
106 MiddlePoint = (box_min + box_max)*0.5;
107
108 test_result = 0;
109 distance = 0;
110}

◆ Inside()

G4int G4BoundingBox3D::Inside ( const G4Point3D Pt) const

Definition at line 383 of file G4BoundingBox3D.cc.

384{
385 if( ( Pt.x() >= box_min.x() && Pt.x() <= box_max.x() ) &&
386 ( Pt.y() >= box_min.y() && Pt.y() <= box_max.y() ) &&
387 ( Pt.z() >= box_min.z() && Pt.z() <= box_max.z() ) )
388 return 1;
389 else
390 return 0;
391}

◆ operator=()

G4BoundingBox3D & G4BoundingBox3D::operator= ( const G4BoundingBox3D right)

Definition at line 75 of file G4BoundingBox3D.cc.

76{
77 if (&right == this) return *this;
78 box_min = right.box_min;
79 box_max = right.box_max;
80 distance = right.distance;
81 test_result = right.test_result;
82 MiddlePoint = right.MiddlePoint;
83 GeantBox = right.GeantBox;
84 kCarTolerance = right.kCarTolerance;
85
86 return *this;
87}

◆ SetDistance()

void G4BoundingBox3D::SetDistance ( G4double  distance0)

Referenced by G4BREPSolid::Intersect().

◆ Test()

G4int G4BoundingBox3D::Test ( const G4Ray rayref)

Definition at line 157 of file G4BoundingBox3D.cc.

158{
159 const G4Point3D& tmp_ray_start = rayref.GetStart();
160 const G4Vector3D& tmp_ray_dir = rayref.GetDir();
161
162 G4Point3D ray_start = tmp_ray_start ;
163 G4Vector3D ray_dir = tmp_ray_dir ;
164
165 G4double rayx,rayy,rayz;
166 rayx = ray_start.x();
167 rayy = ray_start.y();
168 rayz = ray_start.z();
169
170 // Test if ray starting point is in the bbox or not
171 if((rayx < box_min.x()) || (rayx > box_max.x()) ||
172 (rayy < box_min.y()) || (rayy > box_max.y()) ||
173 (rayz < box_min.z()) || (rayz > box_max.z()) )
174 {
175 // Outside, check for intersection with bbox
176
177 // Adapt ray_starting point to box
178
179 const G4Point3D ray_start2 = G4Point3D( ray_start - MiddlePoint );
180 distance = DistanceToIn(ray_start2, ray_dir);
181
182 if(!distance)
183 test_result = 0; // Miss
184 else
185 test_result = 1; // Starting point outside box & hits box
186 }
187 else
188 {
189 // Inside
190 // G4cout << "\nRay starting point Inside bbox.";
191 test_result = 1;
192 distance = 0;
193 }
194
195 return test_result;
196}
double G4double
Definition: G4Types.hh:64
const G4Vector3D & GetDir() const
const G4Point3D & GetStart() const

Referenced by G4BREPSolid::TestSurfaceBBoxes().

Member Data Documentation

◆ space

const G4BoundingBox3D G4BoundingBox3D::space
static

Definition at line 81 of file G4BoundingBox3D.hh.


The documentation for this class was generated from the following files: