Import Geant4 3.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 15:55:53 +02:00
parent e7d7193284
commit cfcb558cfe
3050 changed files with 91703 additions and 48310 deletions
@@ -5,9 +5,16 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4SurfaceList.cc,v 1.3 2000/02/14 17:49:32 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
// $Id: G4SurfaceList.cc,v 1.5 2000/11/08 14:22:11 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4SurfaceList.cc
//
// ----------------------------------------------------------------------
#include "G4SurfaceList.hh"
G4SurfaceList::G4SurfaceList()
@@ -17,14 +24,17 @@ G4SurfaceList::G4SurfaceList()
}
G4SurfaceList::~G4SurfaceList() { EmptyList(); }
G4SurfaceList::~G4SurfaceList()
{
EmptyList();
}
void G4SurfaceList::MoveToFirst(G4Surface* srf)
{
if(number_of_elements)
{
RemovePointer();
srf->next = first;
srf->SetNextNode(first);
first = srf;
index=first;
number_of_elements++;
@@ -39,13 +49,13 @@ void G4SurfaceList::AddSurface(G4Surface* srf)
index = srf;
first = srf;
last = srf;
first->next = (G4Surface*)0;
first->SetNextNode(0);
}
else
{
srf->next = last->next;
last->next = srf;
last = last->next;
srf->SetNextNode(last->GetNextNode());
last->SetNextNode(srf);
last = last->GetNextNode();
}
number_of_elements++;
@@ -59,17 +69,17 @@ G4Surface* G4SurfaceList::GetSurface()
}
G4Surface* G4SurfaceList::GetSurface(int number)
const G4Surface* G4SurfaceList::GetSurface(G4int number)
{
index = first;
for(int a=0;a<number;a++)
for(G4int a=0;a<number;a++)
Step();
return index;
}
G4Surface* G4SurfaceList::GetLastSurface()
const G4Surface* G4SurfaceList::GetLastSurface() const
{
return last;
}
@@ -84,7 +94,7 @@ void G4SurfaceList::RemoveSurface(G4Surface* srf)
if(srf == first)
{
first=first->next;
first=first->GetNextNode();
index = first;
if(number_of_elements == 0)last = first;
delete srf;
@@ -92,9 +102,9 @@ void G4SurfaceList::RemoveSurface(G4Surface* srf)
}
else
{
while(temp->next != srf) temp = temp->next;
index = srf->next;
temp->next = index;
while(temp->GetNextNode() != srf) temp = temp->GetNextNode();
index = srf->GetNextNode();
temp->SetNextNode(index);
if(srf == last) last = temp;
index = first;
delete srf;
@@ -113,18 +123,18 @@ void G4SurfaceList::RemovePointer()
temp = first;
// Find previous
while(temp->next != index) temp = temp->next;
while(temp->GetNextNode() != index) temp = temp->GetNextNode();
// Hop over the one to be removed
temp->next = index->next;
temp->SetNextNode(index->GetNextNode());
// Correct the index pointer
index = temp->next;
index = temp->GetNextNode();
}
else
{
// Hop over the first
first = first->next;
first = first->GetNextNode();
index = first;
}
@@ -138,7 +148,7 @@ void G4SurfaceList::EmptyList()
while (first != (G4Surface*)0)
{
temp = first;
first = first->next;
first = first->GetNextNode();
delete temp;
number_of_elements--;
}
@@ -156,7 +166,7 @@ void G4SurfaceList::MoveToFirst()
void G4SurfaceList::Step()
{
if(index!=(G4Surface*)0)
index = index->next;
index = index->GetNextNode();
}
@@ -167,7 +177,7 @@ void G4SurfaceList::G4SortList()
// First create a vector of the surface distances
// to the ray origin
G4Surface** distances = new G4Surface*[number_of_elements];
int x = 0;
G4int x = 0;
MoveToFirst();
// Copy surface pointers to vector
@@ -176,7 +186,7 @@ void G4SurfaceList::G4SortList()
while(x < number_of_elements)
{
distances[x] = index;
index = index->next;
index = index->GetNextNode();
x++;
}
@@ -194,12 +204,12 @@ void G4SurfaceList::G4SortList()
while (x < number_of_elements)
{
last->next = distances[x];
last = last ->next;
last->SetNextNode(distances[x]);
last = last->GetNextNode();
x++;
}
last->next = (G4Surface*)0;
last->SetNextNode(0);
MoveToFirst();
}
@@ -207,20 +217,20 @@ void G4SurfaceList::G4SortList()
}
void G4SurfaceList::QuickG4Sort(G4Surface** Dist, int left, int right)
void G4SurfaceList::QuickG4Sort(G4Surface** Dist, G4int left, G4int right)
{
register int i=left;
register int j=right;
register G4int i=left;
register G4int j=right;
G4Surface* elem1;
G4Surface* elem2 = Dist[(left+right)/2];
do
{
while ( (Dist[i]->Distance() < elem2->Distance()) && (i < right) )
while ( (Dist[i]->GetDistance() < elem2->GetDistance()) && (i < right) )
i++;
while ( (elem2->Distance() < Dist[j]->Distance()) && (j > left))
while ( (elem2->GetDistance() < Dist[j]->GetDistance()) && (j > left))
j--;
if(i<=j)
@@ -231,7 +241,7 @@ void G4SurfaceList::QuickG4Sort(G4Surface** Dist, int left, int right)
i++;
j--;
}
} while (i<=j);
} while (i<=j);
if( left < j )
QuickG4Sort(Dist, left, j );