Import Geant4 3.0.0 source tree
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4ReduciblePolygon.cc,v 1.1 2000/04/07 11:03:04 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-02-00 $
|
||||
// $Id: G4ReduciblePolygon.cc,v 1.3 2000/11/20 18:19:00 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
@@ -28,7 +28,8 @@
|
||||
//
|
||||
// Constructor: with simple arrays
|
||||
//
|
||||
G4ReduciblePolygon::G4ReduciblePolygon( const G4double a[], const G4double b[], const G4int n )
|
||||
G4ReduciblePolygon::G4ReduciblePolygon( const G4double a[], const G4double b[],
|
||||
G4int n )
|
||||
{
|
||||
//
|
||||
// Do all of the real work in Create
|
||||
@@ -41,7 +42,7 @@ G4ReduciblePolygon::G4ReduciblePolygon( const G4double a[], const G4double b[],
|
||||
// Constructor: special PGON/PCON case
|
||||
//
|
||||
G4ReduciblePolygon::G4ReduciblePolygon( const G4double rmin[], const G4double rmax[],
|
||||
const G4double z[], const G4int n )
|
||||
const G4double z[], G4int n )
|
||||
{
|
||||
//
|
||||
// Translate
|
||||
@@ -74,7 +75,7 @@ G4ReduciblePolygon::G4ReduciblePolygon( const G4double rmin[], const G4double rm
|
||||
// To be called by constructors, fill in the list and statistics for a new
|
||||
// polygon
|
||||
//
|
||||
void G4ReduciblePolygon::Create( const G4double a[], const G4double b[], const G4int n )
|
||||
void G4ReduciblePolygon::Create( const G4double a[], const G4double b[], G4int n )
|
||||
{
|
||||
if (n<3) G4Exception( "G4ReduciblePolygon: less than 3 vertices specified" );
|
||||
|
||||
@@ -139,7 +140,7 @@ void G4ReduciblePolygon::CopyVertices( G4double a[], G4double b[] ) const
|
||||
//
|
||||
// Multiply all a values by a common scale
|
||||
//
|
||||
void G4ReduciblePolygon::ScaleA( const G4double scale )
|
||||
void G4ReduciblePolygon::ScaleA( G4double scale )
|
||||
{
|
||||
ABVertex *curr = vertexHead;
|
||||
while( curr ) {
|
||||
@@ -154,7 +155,7 @@ void G4ReduciblePolygon::ScaleA( const G4double scale )
|
||||
//
|
||||
// Multiply all b values by a common scale
|
||||
//
|
||||
void G4ReduciblePolygon::ScaleB( const G4double scale )
|
||||
void G4ReduciblePolygon::ScaleB( G4double scale )
|
||||
{
|
||||
ABVertex *curr = vertexHead;
|
||||
while( curr ) {
|
||||
@@ -170,7 +171,7 @@ void G4ReduciblePolygon::ScaleB( const G4double scale )
|
||||
// Remove adjacent vertices that are equal. Returns "false" if there
|
||||
// is a problem (too few vertices remaining).
|
||||
//
|
||||
G4bool G4ReduciblePolygon::RemoveDuplicateVertices( const G4double tolerance )
|
||||
G4bool G4ReduciblePolygon::RemoveDuplicateVertices( G4double tolerance )
|
||||
{
|
||||
ABVertex *curr = vertexHead,
|
||||
*prev = 0,
|
||||
@@ -221,7 +222,7 @@ G4bool G4ReduciblePolygon::RemoveDuplicateVertices( const G4double tolerance )
|
||||
// Remove any unneeded vertices, i.e. those vertices which
|
||||
// are on the line connecting the previous and next vertices.
|
||||
//
|
||||
G4bool G4ReduciblePolygon::RemoveRedundantVertices( const G4double tolerance )
|
||||
G4bool G4ReduciblePolygon::RemoveRedundantVertices( G4double tolerance )
|
||||
{
|
||||
//
|
||||
// Under these circumstances, we can quit now!
|
||||
@@ -234,7 +235,6 @@ G4bool G4ReduciblePolygon::RemoveRedundantVertices( const G4double tolerance )
|
||||
// Loop over all vertices
|
||||
//
|
||||
ABVertex *curr = vertexHead,
|
||||
*prev = 0,
|
||||
*next = curr->next; // A little dangerous
|
||||
while( curr ) {
|
||||
next = curr->next;
|
||||
@@ -368,7 +368,7 @@ void G4ReduciblePolygon::ReverseOrder()
|
||||
//
|
||||
// Warning: this routine is not very fast (runs as N**2)
|
||||
//
|
||||
G4bool G4ReduciblePolygon::CrossesItself( const G4double tolerance )
|
||||
G4bool G4ReduciblePolygon::CrossesItself( G4double tolerance )
|
||||
{
|
||||
G4double tolerance2 = tolerance*tolerance;
|
||||
G4double one = 1.0-tolerance,
|
||||
@@ -377,8 +377,9 @@ G4bool G4ReduciblePolygon::CrossesItself( const G4double tolerance )
|
||||
// Top loop over line segments. By the time we finish
|
||||
// with the second to last segment, we're done.
|
||||
//
|
||||
ABVertex *curr1 = vertexHead, *next1;
|
||||
while (next1 = curr1->next) {
|
||||
ABVertex *curr1 = vertexHead, *next1=0;
|
||||
while (curr1->next) {
|
||||
next1 = curr1->next;
|
||||
G4double da1 = next1->a-curr1->a,
|
||||
db1 = next1->b-curr1->b;
|
||||
|
||||
@@ -425,8 +426,8 @@ G4bool G4ReduciblePolygon::CrossesItself( const G4double tolerance )
|
||||
//
|
||||
// Decide if a line through two points crosses the polygon, within tolerance
|
||||
//
|
||||
G4bool G4ReduciblePolygon::BisectedBy( const G4double a1, const G4double b1,
|
||||
const G4double a2, const G4double b2, const G4double tolerance )
|
||||
G4bool G4ReduciblePolygon::BisectedBy( G4double a1, G4double b1,
|
||||
G4double a2, G4double b2, G4double tolerance )
|
||||
{
|
||||
G4int nNeg = 0, nPos = 0;
|
||||
|
||||
@@ -449,7 +450,8 @@ G4bool G4ReduciblePolygon::BisectedBy( const G4double a1, const G4double b1,
|
||||
if (nNeg) return true;
|
||||
nPos++;
|
||||
}
|
||||
} while( curr = curr->next );
|
||||
curr = curr->next;
|
||||
} while( curr );
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -475,7 +477,8 @@ G4double G4ReduciblePolygon::Area()
|
||||
if (next==0) next = vertexHead;
|
||||
|
||||
answer += curr->a*next->b - curr->b*next->a;
|
||||
} while( curr = curr->next );
|
||||
curr = curr->next;
|
||||
} while( curr );
|
||||
|
||||
return 0.5*answer;
|
||||
}
|
||||
@@ -489,7 +492,8 @@ void G4ReduciblePolygon::Print()
|
||||
ABVertex *curr = vertexHead;
|
||||
do {
|
||||
G4cerr << curr->a << " " << curr->b << G4endl;
|
||||
} while( curr = curr->next );
|
||||
curr = curr->next;
|
||||
} while( curr );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user