Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4SurfaceBoundary.cc
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//
27// $Id$
28//
29// ----------------------------------------------------------------------
30// GEANT 4 class source file
31//
32// G4SurfaceBoundary.cc
33//
34// ----------------------------------------------------------------------
35
36#include "G4SurfaceBoundary.hh"
37#include "geomdefs.hh"
38#include "G4CompositeCurve.hh"
39
40
42{
43}
44
46{
47}
48
50{
51 bounds= bounds0;
52 lastIntersection.Reset();
53
54 const G4BoundingBox3D* b= bounds[0]->BBox();
55 bBox.Init(b->GetBoxMin(), b->GetBoxMax());
56
57 size_t i;
58 for ( i=1; i<bounds.size(); i++)
59 {
60 b= bounds[i]->BBox();
61 bBox.Extend(b->GetBoxMin());
62 bBox.Extend(b->GetBoxMax());
63 }
64
65 // the points array is probably unused, so the following code is useless
66 G4int cnt= 0;
67
68 size_t entr = bounds.size();
69
70 for (i=0; i < entr; i++)
71 {
72 G4Curve* c = bounds[i];
73
74 if (c->GetEntityType() == "G4CompositeCurve")
75 {
77 const G4CurveVector& segments = cc->GetSegments();
78 cnt+= segments.size();
79 }
80 else
81 cnt++;
82 }
83
84 points.resize(cnt);
85
86 G4int j= 0;
87
88 for (i=0; i<bounds.size(); i++)
89 {
90 G4Curve* c= bounds[i];
91 if (c->GetEntityType() == "G4CompositeCurve")
92 {
94 const G4CurveVector& segments = cc->GetSegments();
95
96 for (size_t k=0; k<segments.size(); k++)
97 {
98 G4Curve* ccc = segments[k];
99 G4Point3D p = ccc->GetEnd();
100 points[j]= p;
101 j++;
102 }
103
104 }
105 else
106 {
107 G4Point3D p= c->GetEnd();
108 points[j]= p;
109 j++;
110 }
111 }
112}
113
114
116{
117 G4CurveVector newBounds;
118 G4Curve* a = 0;
119 G4Curve* c = 0;
120
121 for (size_t i=0; i<bounds.size(); i++)
122 {
123 c= bounds[i]->Project(tr);
124
125 if (c==0)
126 {
127 // Remove newBounds and delete all its contents
128 while (newBounds.size()>0)
129 {
130 a = newBounds.back();
131 newBounds.pop_back();
132 for (G4CurveVector::iterator it=newBounds.begin();
133 it!=newBounds.end();)
134 {
135 if (*it==a)
136 {
137 it = newBounds.erase(it);
138 }
139 else
140 {
141 it--;
142 }
143 }
144 if ( a ) { delete a; }
145 }
146 return 0;
147 }
148 // L. Broglia
149 c->SetSameSense( bounds[i]->GetSameSense() );
150
151 newBounds.push_back(c);
152 }
153
155 lof->Init(newBounds);
156 return lof;
157}
158
159/*
160void G4SurfaceBoundary::IntersectRay2D(const G4Ray& ray,
161 G4CurveRayIntersection& is)
162{
163 is.Reset();
164 G4int entr = bounds.entries();
165 for (G4int i=0; i < entr; i++)
166 {
167 G4Curve& c = *bounds.at(i);
168 G4CurveRayIntersection isTmp(c, ray);
169 c.IntersectRay2D(ray, isTmp);
170
171 if (std::fabs(isTmp.GetDistance()) < std::fabs(is.GetDistance()))
172 is= isTmp;
173 }
174
175 lastIntersection= is;
176}
177*/
178
180{
181 G4int nbinter = 0;
182 G4int temp = 0;
183
184 for (size_t i=0; i < bounds.size(); i++)
185 {
186 G4Curve& c = *bounds[i];
187 temp = c.IntersectRay2D(ray);
188
189 // test if the point is on the boundary
190 if ( temp == 999 )
191 nbinter = 1;
192 else
193 nbinter += temp;
194 }
195
196 return nbinter;
197}
198
199
201{
202 if (lastIntersection.GetDistance() == kInfinity)
203 return false;
204
205 return lastIntersection.GetCurve().Tangent(lastIntersection, v);
206 // should be true
207
208 // cp is ignored for the moment
209}
210
211
213 const G4Vector3D&,
216{
217 G4Exception("G4SurfaceBoundary::SplitWithPlane()", "GeomSolids0001",
218 FatalException, "Sorry, not yet implemented.");
219}
220
224{
225 G4Exception("G4SurfaceBoundary::SplitWithCylinder()", "GeomSolids0001",
226 FatalException, "Sorry, not yet implemented.");
227}
std::vector< G4Curve * > G4CurveVector
@ FatalException
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
void Init(const G4Point3D &)
G4Point3D GetBoxMin() const
void Extend(const G4Point3D &)
G4Point3D GetBoxMax() const
const G4CurveVector & GetSegments() const
G4Curve & GetCurve() const
virtual G4String GetEntityType() const
Definition: G4Curve.cc:72
void SetSameSense(G4int sameSense0)
virtual G4int IntersectRay2D(const G4Ray &ray)=0
const G4Point3D & GetEnd() const
virtual G4bool Tangent(G4CurvePoint &cp, G4Vector3D &v)=0
Definition: G4Ray.hh:49
void Init(const G4CurveVector &bounds0)
G4int IntersectRay2D(const G4Ray &ray)
G4SurfaceBoundary * Project(const G4Transform3D &tr=G4Transform3D::Identity)
G4bool Tangent(G4CurvePoint &cp, G4Vector3D &v)
void SplitWithCylinder(const G4CylindricalSurface &c, G4SurfaceBoundary *&new1, G4SurfaceBoundary *&new2)
void SplitWithPlane(const G4Point3D &p0, const G4Vector3D &n, G4SurfaceBoundary *&new1, G4SurfaceBoundary *&new2)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41