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

#include <G4SurfaceList.hh>

Public Member Functions

 G4SurfaceList ()
 
 ~G4SurfaceList ()
 
void MoveToFirst (G4Surface *srf)
 
void AddSurface (G4Surface *srf)
 
G4SurfaceGetSurface ()
 
const G4SurfaceGetSurface (G4int number)
 
const G4SurfaceGetLastSurface () const
 
void RemoveSurface (G4Surface *srf)
 
void RemovePointer ()
 
void MoveToFirst ()
 
void Step ()
 
void EmptyList ()
 
void G4SortList ()
 
void QuickG4Sort (G4Surface **, G4int, G4int)
 
const G4SurfaceGetFirst () const
 
const G4SurfaceGetNext () const
 
G4int GetSize () const
 

Detailed Description

Definition at line 43 of file G4SurfaceList.hh.

Constructor & Destructor Documentation

◆ G4SurfaceList()

G4SurfaceList::G4SurfaceList ( )

Definition at line 38 of file G4SurfaceList.cc.

39{
40 first = index = last = next = temp = (G4Surface*)0;
41 number_of_elements=0;
42}

◆ ~G4SurfaceList()

G4SurfaceList::~G4SurfaceList ( )

Definition at line 45 of file G4SurfaceList.cc.

46{
47 EmptyList();
48}

Member Function Documentation

◆ AddSurface()

void G4SurfaceList::AddSurface ( G4Surface srf)

Definition at line 63 of file G4SurfaceList.cc.

64{
65 if(first == (G4Surface*)0)
66 {
67 index = srf;
68 first = srf;
69 last = srf;
70 first->SetNextNode(0);
71 }
72 else
73 {
74 srf->SetNextNode(last->GetNextNode());
75 last->SetNextNode(srf);
76 last = last->GetNextNode();
77 }
78
79 number_of_elements++;
80 index=first;
81}
void SetNextNode(G4Surface *)
G4Surface * GetNextNode()

◆ EmptyList()

void G4SurfaceList::EmptyList ( )

Definition at line 165 of file G4SurfaceList.cc.

166{
167 //Deletes all surfaces in List
168 while (first != (G4Surface*)0)
169 {
170 temp = first;
171 first = first->GetNextNode();
172 delete temp;
173 number_of_elements--;
174 }
175
176 last = index = first;
177}

Referenced by ~G4SurfaceList().

◆ G4SortList()

void G4SurfaceList::G4SortList ( )

Definition at line 193 of file G4SurfaceList.cc.

194{
195 if(number_of_elements == 1) return;
196
197 // First create a vector of the surface distances
198 // to the ray origin
199 G4Surface** distances = new G4Surface*[number_of_elements];
200 G4int x = 0;
201 MoveToFirst();
202
203 // Copy surface pointers to vector
204 if(number_of_elements > 1)
205 {
206 while(x < number_of_elements)
207 {
208 distances[x] = index;
209 index = index->GetNextNode();
210 x++;
211 }
212
213 MoveToFirst();
214
215 // Sort List of pointers using quick G4Sort
216 QuickG4Sort( distances, 0, number_of_elements-1 );
217
218 // Organize the linked List of surfaces according
219 // to the quickG4Sorted List.
220 x = 0;
221 first = distances[x];
222 last = first;
223 x++;
224
225 while (x < number_of_elements)
226 {
227 last->SetNextNode(distances[x]);
228 last = last->GetNextNode();
229 x++;
230 }
231
232 last->SetNextNode(0);
233 MoveToFirst();
234 }
235
236 delete[] distances;
237}
int G4int
Definition: G4Types.hh:66
void QuickG4Sort(G4Surface **, G4int, G4int)

◆ GetFirst()

const G4Surface * G4SurfaceList::GetFirst ( ) const
inline

Definition at line 69 of file G4SurfaceList.hh.

69{ return first; }

◆ GetLastSurface()

const G4Surface * G4SurfaceList::GetLastSurface ( ) const

Definition at line 100 of file G4SurfaceList.cc.

101{
102 return last;
103}

◆ GetNext()

const G4Surface * G4SurfaceList::GetNext ( ) const
inline

Definition at line 70 of file G4SurfaceList.hh.

70{ return next; }

◆ GetSize()

G4int G4SurfaceList::GetSize ( ) const
inline

Definition at line 71 of file G4SurfaceList.hh.

71{ return number_of_elements; }

Referenced by G4BSplineSurface::Intersect().

◆ GetSurface() [1/2]

G4Surface * G4SurfaceList::GetSurface ( )

Definition at line 84 of file G4SurfaceList.cc.

85{
86 return index;
87}

Referenced by G4BSplineSurface::Intersect().

◆ GetSurface() [2/2]

const G4Surface * G4SurfaceList::GetSurface ( G4int  number)

Definition at line 90 of file G4SurfaceList.cc.

91{
92 index = first;
93 for(G4int a=0;a<number;a++)
94 Step();
95
96 return index;
97}

◆ MoveToFirst() [1/2]

void G4SurfaceList::MoveToFirst ( )

Definition at line 180 of file G4SurfaceList.cc.

181{
182 index = first;
183}

Referenced by G4SortList().

◆ MoveToFirst() [2/2]

void G4SurfaceList::MoveToFirst ( G4Surface srf)

Definition at line 50 of file G4SurfaceList.cc.

51{
52 if(number_of_elements)
53 {
55 srf->SetNextNode(first);
56 first = srf;
57 index=first;
58 number_of_elements++;
59 }
60}
void RemovePointer()

Referenced by G4BSplineSurface::Intersect().

◆ QuickG4Sort()

void G4SurfaceList::QuickG4Sort ( G4Surface **  Dist,
G4int  left,
G4int  right 
)

Definition at line 240 of file G4SurfaceList.cc.

241{
242 register G4int i=left;
243 register G4int j=right;
244
245 G4Surface* elem1;
246 G4Surface* elem2 = Dist[(left+right)/2];
247
248 do
249 {
250 while ( (Dist[i]->GetDistance() < elem2->GetDistance()) && (i < right) )
251 i++;
252
253 while ( (elem2->GetDistance() < Dist[j]->GetDistance()) && (j > left))
254 j--;
255
256 if(i<=j)
257 {
258 elem1 = Dist[i];
259 Dist[i] = Dist[j];
260 Dist[j] = elem1;
261 i++;
262 j--;
263 }
264 } while (i<=j);
265
266 if( left < j )
267 QuickG4Sort(Dist, left, j );
268
269 if( i < right )
270 QuickG4Sort(Dist, i, right);
271}
G4double GetDistance() const

Referenced by G4SortList(), and QuickG4Sort().

◆ RemovePointer()

void G4SurfaceList::RemovePointer ( )

Definition at line 134 of file G4SurfaceList.cc.

135{
136 // Remove the current pointer from the List
137 // Do not delete the object itself
138 if(number_of_elements)
139 {
140 if(first != index)
141 {
142 temp = first;
143
144 // Find previous
145 while(temp->GetNextNode() != index) temp = temp->GetNextNode();
146
147 // Hop over the one to be removed
148 temp->SetNextNode(index->GetNextNode());
149
150 // Correct the index pointer
151 index = temp->GetNextNode();
152 }
153 else
154 {
155 // Hop over the first
156 first = first->GetNextNode();
157 index = first;
158 }
159 }
160
161 number_of_elements--;
162}

Referenced by MoveToFirst().

◆ RemoveSurface()

void G4SurfaceList::RemoveSurface ( G4Surface srf)

Definition at line 106 of file G4SurfaceList.cc.

107{
108 if(srf!=(G4Surface*)0)
109 {
110 number_of_elements--;
111 temp = first;
112
113 if(srf == first)
114 {
115 first=first->GetNextNode();
116 index = first;
117 if(number_of_elements == 0)last = first;
118 delete srf;
119 return;
120 }
121 else
122 {
123 while(temp->GetNextNode() != srf) temp = temp->GetNextNode();
124 index = srf->GetNextNode();
125 temp->SetNextNode(index);
126 if(srf == last) last = temp;
127 index = first;
128 delete srf;
129 }
130 }
131}

Referenced by G4BezierSurface::ClipBothDirs().

◆ Step()

void G4SurfaceList::Step ( )

Definition at line 186 of file G4SurfaceList.cc.

187{
188 if(index!=(G4Surface*)0)
189 index = index->GetNextNode();
190}

Referenced by GetSurface(), and G4BSplineSurface::Intersect().


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