Import Geant4 10.6.0 source tree
This commit is contained in:
@@ -23,18 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4TwistTrapFlatSide implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
//
|
||||
// G4TwistTrapFlatSide.cc
|
||||
//
|
||||
// Author:
|
||||
// 30-Aug-2002 - O.Link (Oliver.Link@cern.ch)
|
||||
//
|
||||
// Author: 30-Aug-2002 - O.Link (Oliver.Link@cern.ch)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4TwistTrapFlatSide.hh"
|
||||
@@ -42,17 +33,16 @@
|
||||
//=====================================================================
|
||||
//* constructors ------------------------------------------------------
|
||||
|
||||
G4TwistTrapFlatSide::G4TwistTrapFlatSide( const G4String &name,
|
||||
G4double PhiTwist,
|
||||
G4double pDx1,
|
||||
G4double pDx2,
|
||||
G4double pDy,
|
||||
G4double pDz,
|
||||
G4double pAlpha,
|
||||
G4double pPhi,
|
||||
G4double pTheta,
|
||||
G4int handedness)
|
||||
|
||||
G4TwistTrapFlatSide::G4TwistTrapFlatSide( const G4String& name,
|
||||
G4double PhiTwist,
|
||||
G4double pDx1,
|
||||
G4double pDx2,
|
||||
G4double pDy,
|
||||
G4double pDz,
|
||||
G4double pAlpha,
|
||||
G4double pPhi,
|
||||
G4double pTheta,
|
||||
G4int handedness)
|
||||
: G4VTwistSurface(name)
|
||||
{
|
||||
fHandedness = handedness; // +z = +ve, -z = -ve
|
||||
@@ -119,12 +109,15 @@ G4TwistTrapFlatSide::~G4TwistTrapFlatSide()
|
||||
//=====================================================================
|
||||
//* GetNormal ---------------------------------------------------------
|
||||
|
||||
G4ThreeVector G4TwistTrapFlatSide::GetNormal(const G4ThreeVector & /* xx */ ,
|
||||
G4ThreeVector G4TwistTrapFlatSide::GetNormal(const G4ThreeVector& /* xx */,
|
||||
G4bool isGlobal)
|
||||
{
|
||||
if (isGlobal) {
|
||||
if (isGlobal)
|
||||
{
|
||||
return ComputeGlobalDirection(fCurrentNormal.normal);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return fCurrentNormal.normal;
|
||||
}
|
||||
}
|
||||
@@ -132,29 +125,31 @@ G4ThreeVector G4TwistTrapFlatSide::GetNormal(const G4ThreeVector & /* xx */ ,
|
||||
//=====================================================================
|
||||
//* DistanceToSurface(p, v) -------------------------------------------
|
||||
|
||||
G4int G4TwistTrapFlatSide::DistanceToSurface(const G4ThreeVector &gp,
|
||||
const G4ThreeVector &gv,
|
||||
G4ThreeVector gxx[],
|
||||
G4double distance[],
|
||||
G4int areacode[],
|
||||
G4bool isvalid[],
|
||||
EValidate validate)
|
||||
G4int G4TwistTrapFlatSide::DistanceToSurface(const G4ThreeVector& gp,
|
||||
const G4ThreeVector& gv,
|
||||
G4ThreeVector gxx[],
|
||||
G4double distance[],
|
||||
G4int areacode[],
|
||||
G4bool isvalid[],
|
||||
EValidate validate)
|
||||
{
|
||||
fCurStatWithV.ResetfDone(validate, &gp, &gv);
|
||||
|
||||
if (fCurStatWithV.IsDone()) {
|
||||
G4int i;
|
||||
for (i=0; i<fCurStatWithV.GetNXX(); i++) {
|
||||
if (fCurStatWithV.IsDone())
|
||||
{
|
||||
for (G4int i=0; i<fCurStatWithV.GetNXX(); ++i)
|
||||
{
|
||||
gxx[i] = fCurStatWithV.GetXX(i);
|
||||
distance[i] = fCurStatWithV.GetDistance(i);
|
||||
areacode[i] = fCurStatWithV.GetAreacode(i);
|
||||
isvalid[i] = fCurStatWithV.IsValid(i);
|
||||
}
|
||||
return fCurStatWithV.GetNXX();
|
||||
} else {
|
||||
// initialize
|
||||
G4int i;
|
||||
for (i=0; i<2; i++) {
|
||||
}
|
||||
else // initialize
|
||||
{
|
||||
for (auto i=0; i<2; ++i)
|
||||
{
|
||||
distance[i] = kInfinity;
|
||||
areacode[i] = sOutside;
|
||||
isvalid[i] = false;
|
||||
@@ -170,26 +165,33 @@ G4int G4TwistTrapFlatSide::DistanceToSurface(const G4ThreeVector &gp,
|
||||
// if p is on surface, distance = 0.
|
||||
//
|
||||
|
||||
if (std::fabs(p.z()) == 0.) { // if p is on the plane
|
||||
if (std::fabs(p.z()) == 0.) // if p is on the plane
|
||||
{
|
||||
distance[0] = 0;
|
||||
G4ThreeVector xx = p;
|
||||
gxx[0] = ComputeGlobalPoint(xx);
|
||||
|
||||
if (validate == kValidateWithTol) {
|
||||
if (validate == kValidateWithTol)
|
||||
{
|
||||
areacode[0] = GetAreaCode(xx);
|
||||
if (!IsOutside(areacode[0])) {
|
||||
if (!IsOutside(areacode[0]))
|
||||
{
|
||||
isvalid[0] = true;
|
||||
}
|
||||
} else if (validate == kValidateWithoutTol) {
|
||||
}
|
||||
else if (validate == kValidateWithoutTol)
|
||||
{
|
||||
areacode[0] = GetAreaCode(xx, false);
|
||||
if (IsInside(areacode[0])) {
|
||||
if (IsInside(areacode[0]))
|
||||
{
|
||||
isvalid[0] = true;
|
||||
}
|
||||
} else { // kDontValidate
|
||||
}
|
||||
else // kDontValidate
|
||||
{
|
||||
areacode[0] = sInside;
|
||||
isvalid[0] = true;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
//
|
||||
@@ -208,22 +210,28 @@ G4int G4TwistTrapFlatSide::DistanceToSurface(const G4ThreeVector &gp,
|
||||
G4ThreeVector xx = p + distance[0]*v;
|
||||
gxx[0] = ComputeGlobalPoint(xx);
|
||||
|
||||
if (validate == kValidateWithTol) {
|
||||
if (validate == kValidateWithTol)
|
||||
{
|
||||
areacode[0] = GetAreaCode(xx);
|
||||
if (!IsOutside(areacode[0])) {
|
||||
if (!IsOutside(areacode[0]))
|
||||
{
|
||||
if (distance[0] >= 0) isvalid[0] = true;
|
||||
}
|
||||
} else if (validate == kValidateWithoutTol) {
|
||||
}
|
||||
else if (validate == kValidateWithoutTol)
|
||||
{
|
||||
areacode[0] = GetAreaCode(xx, false);
|
||||
if (IsInside(areacode[0])) {
|
||||
if (IsInside(areacode[0]))
|
||||
{
|
||||
if (distance[0] >= 0) isvalid[0] = true;
|
||||
}
|
||||
} else { // kDontValidate
|
||||
}
|
||||
else // kDontValidate
|
||||
{
|
||||
areacode[0] = sInside;
|
||||
if (distance[0] >= 0) isvalid[0] = true;
|
||||
}
|
||||
|
||||
|
||||
fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
|
||||
isvalid[0], 1, validate, &gp, &gv);
|
||||
|
||||
@@ -242,7 +250,7 @@ G4int G4TwistTrapFlatSide::DistanceToSurface(const G4ThreeVector &gp,
|
||||
//=====================================================================
|
||||
//* DistanceToSurface(p) ----------------------------------------------
|
||||
|
||||
G4int G4TwistTrapFlatSide::DistanceToSurface(const G4ThreeVector &gp,
|
||||
G4int G4TwistTrapFlatSide::DistanceToSurface(const G4ThreeVector& gp,
|
||||
G4ThreeVector gxx[],
|
||||
G4double distance[],
|
||||
G4int areacode[])
|
||||
@@ -253,18 +261,20 @@ G4int G4TwistTrapFlatSide::DistanceToSurface(const G4ThreeVector &gp,
|
||||
|
||||
fCurStat.ResetfDone(kDontValidate, &gp);
|
||||
|
||||
if (fCurStat.IsDone()) {
|
||||
G4int i;
|
||||
for (i=0; i<fCurStat.GetNXX(); i++) {
|
||||
if (fCurStat.IsDone())
|
||||
{
|
||||
for (G4int i=0; i<fCurStat.GetNXX(); ++i)
|
||||
{
|
||||
gxx[i] = fCurStat.GetXX(i);
|
||||
distance[i] = fCurStat.GetDistance(i);
|
||||
areacode[i] = fCurStat.GetAreacode(i);
|
||||
}
|
||||
return fCurStat.GetNXX();
|
||||
} else {
|
||||
// initialize
|
||||
G4int i;
|
||||
for (i=0; i<2; i++) {
|
||||
}
|
||||
else // initialize
|
||||
{
|
||||
for (auto i=0; i<2; ++i)
|
||||
{
|
||||
distance[i] = kInfinity;
|
||||
areacode[i] = sOutside;
|
||||
gxx[i].set(kInfinity, kInfinity, kInfinity);
|
||||
@@ -280,7 +290,9 @@ G4int G4TwistTrapFlatSide::DistanceToSurface(const G4ThreeVector &gp,
|
||||
{ // if p is on the plane, return 1
|
||||
distance[0] = 0;
|
||||
xx = p;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
distance[0] = std::fabs(p.z());
|
||||
xx.set(p.x(), p.y(), 0);
|
||||
}
|
||||
@@ -294,48 +306,57 @@ G4int G4TwistTrapFlatSide::DistanceToSurface(const G4ThreeVector &gp,
|
||||
|
||||
}
|
||||
|
||||
G4int G4TwistTrapFlatSide::GetAreaCode(const G4ThreeVector &xx,
|
||||
G4bool withTol)
|
||||
//=====================================================================
|
||||
//* GetAreaCode() -----------------------------------------------------
|
||||
|
||||
G4int G4TwistTrapFlatSide::GetAreaCode(const G4ThreeVector& xx,
|
||||
G4bool withTol)
|
||||
{
|
||||
|
||||
static const G4double ctol = 0.5 * kCarTolerance;
|
||||
G4int areacode = sInside;
|
||||
|
||||
if (fAxis[0] == kXAxis && fAxis[1] == kYAxis) {
|
||||
|
||||
if (fAxis[0] == kXAxis && fAxis[1] == kYAxis)
|
||||
{
|
||||
G4int yaxis = 1;
|
||||
|
||||
G4double wmax = xAxisMax(xx.y(), fTAlph ) ;
|
||||
G4double wmin = -xAxisMax(xx.y(), -fTAlph ) ;
|
||||
|
||||
if (withTol) {
|
||||
|
||||
if (withTol)
|
||||
{
|
||||
G4bool isoutside = false;
|
||||
|
||||
// test boundary of x-axis
|
||||
|
||||
if (xx.x() < wmin + ctol) {
|
||||
if (xx.x() < wmin + ctol)
|
||||
{
|
||||
areacode |= (sAxis0 & (sAxisX | sAxisMin)) | sBoundary;
|
||||
if (xx.x() <= wmin - ctol) isoutside = true;
|
||||
|
||||
} else if (xx.x() > wmax - ctol) {
|
||||
}
|
||||
else if (xx.x() > wmax - ctol)
|
||||
{
|
||||
areacode |= (sAxis0 & (sAxisX | sAxisMax)) | sBoundary;
|
||||
if (xx.x() >= wmax + ctol) isoutside = true;
|
||||
}
|
||||
|
||||
// test boundary of y-axis
|
||||
|
||||
if (xx.y() < fAxisMin[yaxis] + ctol) {
|
||||
if (xx.y() < fAxisMin[yaxis] + ctol)
|
||||
{
|
||||
areacode |= (sAxis1 & (sAxisY | sAxisMin));
|
||||
|
||||
if (areacode & sBoundary) areacode |= sCorner; // xx is on the corner.
|
||||
if (areacode & sBoundary) areacode |= sCorner; // xx is on corner.
|
||||
else areacode |= sBoundary;
|
||||
if (xx.y() <= fAxisMin[yaxis] - ctol) isoutside = true;
|
||||
|
||||
} else if (xx.y() > fAxisMax[yaxis] - ctol) {
|
||||
}
|
||||
else if (xx.y() > fAxisMax[yaxis] - ctol)
|
||||
{
|
||||
areacode |= (sAxis1 & (sAxisY | sAxisMax));
|
||||
|
||||
if (areacode & sBoundary) areacode |= sCorner; // xx is on the corner.
|
||||
if (areacode & sBoundary) areacode |= sCorner; // xx is on corner.
|
||||
else areacode |= sBoundary;
|
||||
if (xx.y() >= fAxisMax[yaxis] + ctol) isoutside = true;
|
||||
}
|
||||
@@ -343,42 +364,54 @@ G4int G4TwistTrapFlatSide::GetAreaCode(const G4ThreeVector &xx,
|
||||
// if isoutside = true, clear inside bit.
|
||||
// if not on boundary, add axis information.
|
||||
|
||||
if (isoutside) {
|
||||
if (isoutside)
|
||||
{
|
||||
G4int tmpareacode = areacode & (~sInside);
|
||||
areacode = tmpareacode;
|
||||
} else if ((areacode & sBoundary) != sBoundary) {
|
||||
}
|
||||
else if ((areacode & sBoundary) != sBoundary)
|
||||
{
|
||||
areacode |= (sAxis0 & sAxisX) | (sAxis1 & sAxisY);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// boundary of x-axis
|
||||
|
||||
if (xx.x() < wmin ) {
|
||||
|
||||
if (xx.x() < wmin )
|
||||
{
|
||||
areacode |= (sAxis0 & (sAxisX | sAxisMin)) | sBoundary;
|
||||
} else if (xx.x() > wmax) {
|
||||
}
|
||||
else if (xx.x() > wmax)
|
||||
{
|
||||
areacode |= (sAxis0 & (sAxisX | sAxisMax)) | sBoundary;
|
||||
}
|
||||
|
||||
// boundary of y-axis
|
||||
|
||||
if (xx.y() < fAxisMin[yaxis]) {
|
||||
if (xx.y() < fAxisMin[yaxis])
|
||||
{
|
||||
areacode |= (sAxis1 & (sAxisY | sAxisMin));
|
||||
if (areacode & sBoundary) areacode |= sCorner; // xx is on the corner.
|
||||
if (areacode & sBoundary) areacode |= sCorner; // xx is on corner.
|
||||
else areacode |= sBoundary;
|
||||
|
||||
} else if (xx.y() > fAxisMax[yaxis]) {
|
||||
}
|
||||
else if (xx.y() > fAxisMax[yaxis])
|
||||
{
|
||||
areacode |= (sAxis1 & (sAxisY | sAxisMax)) ;
|
||||
if (areacode & sBoundary) areacode |= sCorner; // xx is on the corner.
|
||||
if (areacode & sBoundary) areacode |= sCorner; // xx is on corner.
|
||||
else areacode |= sBoundary;
|
||||
}
|
||||
|
||||
if ((areacode & sBoundary) != sBoundary) {
|
||||
if ((areacode & sBoundary) != sBoundary)
|
||||
{
|
||||
areacode |= (sAxis0 & sAxisX) | (sAxis1 & sAxisY);
|
||||
}
|
||||
}
|
||||
return areacode;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Exception("G4TwistTrapFlatSide::GetAreaCode()",
|
||||
"GeomSolids0001", FatalException,
|
||||
"Feature NOT implemented !");
|
||||
@@ -387,7 +420,6 @@ G4int G4TwistTrapFlatSide::GetAreaCode(const G4ThreeVector &xx,
|
||||
return areacode;
|
||||
}
|
||||
|
||||
|
||||
//=====================================================================
|
||||
//* SetCorners --------------------------------------------------------
|
||||
|
||||
@@ -395,8 +427,8 @@ void G4TwistTrapFlatSide::SetCorners()
|
||||
{
|
||||
// Set Corner points in local coodinate.
|
||||
|
||||
if (fAxis[0] == kXAxis && fAxis[1] == kYAxis) {
|
||||
|
||||
if (fAxis[0] == kXAxis && fAxis[1] == kYAxis)
|
||||
{
|
||||
G4double x, y, z;
|
||||
|
||||
// corner of Axis0min and Axis1min
|
||||
@@ -423,7 +455,9 @@ void G4TwistTrapFlatSide::SetCorners()
|
||||
z = 0 ;
|
||||
SetCorner(sC0Min1Max, x, y, z);
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Feature NOT implemented !" << G4endl
|
||||
<< " fAxis[0] = " << fAxis[0] << G4endl
|
||||
@@ -443,8 +477,8 @@ void G4TwistTrapFlatSide::SetBoundaries()
|
||||
|
||||
G4ThreeVector direction ;
|
||||
|
||||
if (fAxis[0] == kXAxis && fAxis[1] == kYAxis) {
|
||||
|
||||
if (fAxis[0] == kXAxis && fAxis[1] == kYAxis)
|
||||
{
|
||||
// sAxis0 & sAxisMin
|
||||
direction = - ( GetCorner(sC0Min1Max) - GetCorner(sC0Min1Min) ) ;
|
||||
direction = direction.unit();
|
||||
@@ -469,7 +503,9 @@ void G4TwistTrapFlatSide::SetBoundaries()
|
||||
SetBoundary(sAxis1 & (sAxisY | sAxisMax), direction,
|
||||
GetCorner(sC0Max1Max), sAxisX);
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Feature NOT implemented !" << G4endl
|
||||
<< " fAxis[0] = " << fAxis[0] << G4endl
|
||||
@@ -485,7 +521,6 @@ void G4TwistTrapFlatSide::SetBoundaries()
|
||||
void G4TwistTrapFlatSide::GetFacets( G4int k, G4int n, G4double xyz[][3],
|
||||
G4int faces[][4], G4int iside )
|
||||
{
|
||||
|
||||
G4double x,y ; // the two parameters for the surface equation
|
||||
G4ThreeVector p ; // a point on the surface, given by (z,u)
|
||||
|
||||
@@ -496,14 +531,12 @@ void G4TwistTrapFlatSide::GetFacets( G4int k, G4int n, G4double xyz[][3],
|
||||
|
||||
// calculate the (n-1)*(k-1) vertices
|
||||
|
||||
G4int i,j ;
|
||||
|
||||
for ( i = 0 ; i<n ; i++ ) {
|
||||
|
||||
for ( G4int i = 0 ; i<n ; ++i )
|
||||
{
|
||||
y = -fDy + i*(2*fDy)/(n-1) ;
|
||||
|
||||
for ( j = 0 ; j<k ; j++ ) {
|
||||
|
||||
for ( G4int j = 0 ; j<k ; ++j )
|
||||
{
|
||||
xmin = GetBoundaryMin(y) ;
|
||||
xmax = GetBoundaryMax(y) ;
|
||||
x = xmin + j*(xmax-xmin)/(k-1) ;
|
||||
@@ -515,22 +548,32 @@ void G4TwistTrapFlatSide::GetFacets( G4int k, G4int n, G4double xyz[][3],
|
||||
xyz[nnode][1] = p.y() ;
|
||||
xyz[nnode][2] = p.z() ;
|
||||
|
||||
if ( i<n-1 && j<k-1 ) {
|
||||
|
||||
if ( i<n-1 && j<k-1 )
|
||||
{
|
||||
nface = GetFace(i,j,k,n,iside) ;
|
||||
|
||||
if (fHandedness < 0) { // lower side
|
||||
faces[nface][0] = GetEdgeVisibility(i,j,k,n,0,1) * ( GetNode(i ,j ,k,n,iside)+1) ;
|
||||
faces[nface][1] = GetEdgeVisibility(i,j,k,n,1,1) * ( GetNode(i+1,j ,k,n,iside)+1) ;
|
||||
faces[nface][2] = GetEdgeVisibility(i,j,k,n,2,1) * ( GetNode(i+1,j+1,k,n,iside)+1) ;
|
||||
faces[nface][3] = GetEdgeVisibility(i,j,k,n,3,1) * ( GetNode(i ,j+1,k,n,iside)+1) ;
|
||||
} else { // upper side
|
||||
faces[nface][0] = GetEdgeVisibility(i,j,k,n,0,-1) * ( GetNode(i ,j ,k,n,iside)+1) ;
|
||||
faces[nface][1] = GetEdgeVisibility(i,j,k,n,1,-1) * ( GetNode(i ,j+1,k,n,iside)+1) ;
|
||||
faces[nface][2] = GetEdgeVisibility(i,j,k,n,2,-1) * ( GetNode(i+1,j+1,k,n,iside)+1) ;
|
||||
faces[nface][3] = GetEdgeVisibility(i,j,k,n,3,-1) * ( GetNode(i+1,j ,k,n,iside)+1) ;
|
||||
if (fHandedness < 0) // lower side
|
||||
{
|
||||
faces[nface][0] = GetEdgeVisibility(i,j,k,n,0,1)
|
||||
* ( GetNode(i ,j ,k,n,iside)+1) ;
|
||||
faces[nface][1] = GetEdgeVisibility(i,j,k,n,1,1)
|
||||
* ( GetNode(i+1,j ,k,n,iside)+1) ;
|
||||
faces[nface][2] = GetEdgeVisibility(i,j,k,n,2,1)
|
||||
* ( GetNode(i+1,j+1,k,n,iside)+1) ;
|
||||
faces[nface][3] = GetEdgeVisibility(i,j,k,n,3,1)
|
||||
* ( GetNode(i ,j+1,k,n,iside)+1) ;
|
||||
}
|
||||
else // upper side
|
||||
{
|
||||
faces[nface][0] = GetEdgeVisibility(i,j,k,n,0,-1)
|
||||
* ( GetNode(i ,j ,k,n,iside)+1) ;
|
||||
faces[nface][1] = GetEdgeVisibility(i,j,k,n,1,-1)
|
||||
* ( GetNode(i ,j+1,k,n,iside)+1) ;
|
||||
faces[nface][2] = GetEdgeVisibility(i,j,k,n,2,-1)
|
||||
* ( GetNode(i+1,j+1,k,n,iside)+1) ;
|
||||
faces[nface][3] = GetEdgeVisibility(i,j,k,n,3,-1)
|
||||
* ( GetNode(i+1,j ,k,n,iside)+1) ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user