Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
G4VTwistSurface Class Referenceabstract

#include <G4VTwistSurface.hh>

Inheritance diagram for G4VTwistSurface:
G4TwistBoxSide G4TwistTrapAlphaSide G4TwistTrapFlatSide G4TwistTrapParallelSide G4TwistTubsFlatSide G4TwistTubsHypeSide G4TwistTubsSide

Data Structures

class  Boundary
 
class  CurrentStatus
 
class  G4SurfCurNormal
 

Public Types

enum  EValidate { kDontValidate = 0, kValidateWithTol = 1, kValidateWithoutTol = 2, kUninitialized = 3 }
 

Public Member Functions

 G4VTwistSurface (const G4String &name)
 
 G4VTwistSurface (const G4String &name, const G4RotationMatrix &rot, const G4ThreeVector &tlate, G4int handedness, const EAxis axis1, const EAxis axis2, G4double axis0min=-kInfinity, G4double axis1min=-kInfinity, G4double axis0max=kInfinity, G4double axis1max=kInfinity)
 
virtual ~G4VTwistSurface ()
 
virtual G4int AmIOnLeftSide (const G4ThreeVector &me, const G4ThreeVector &vec, G4bool withTol=true)
 
virtual G4double DistanceToBoundary (G4int areacode, G4ThreeVector &xx, const G4ThreeVector &p)
 
virtual G4double DistanceToIn (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
 
virtual G4double DistanceToOut (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
 
virtual G4double DistanceTo (const G4ThreeVector &gp, G4ThreeVector &gxx)
 
virtual G4int DistanceToSurface (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)=0
 
virtual G4int DistanceToSurface (const G4ThreeVector &gp, G4ThreeVector gxx[], G4double distance[], G4int areacode[])=0
 
void DebugPrint () const
 
virtual G4ThreeVector GetNormal (const G4ThreeVector &xx, G4bool isGlobal)=0
 
virtual G4String GetName () const
 
virtual void GetBoundaryParameters (const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const
 
virtual G4ThreeVector GetBoundaryAtPZ (G4int areacode, const G4ThreeVector &p) const
 
G4double DistanceToPlaneWithV (const G4ThreeVector &p, const G4ThreeVector &v, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
 
G4double DistanceToPlane (const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
 
G4double DistanceToPlane (const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &t1, const G4ThreeVector &t2, G4ThreeVector &xx, G4ThreeVector &n)
 
G4double DistanceToLine (const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &d, G4ThreeVector &xx)
 
G4bool IsAxis0 (G4int areacode) const
 
G4bool IsAxis1 (G4int areacode) const
 
G4bool IsOutside (G4int areacode) const
 
G4bool IsInside (G4int areacode, G4bool testbitmode=false) const
 
G4bool IsBoundary (G4int areacode, G4bool testbitmode=false) const
 
G4bool IsCorner (G4int areacode, G4bool testbitmode=false) const
 
G4bool IsValidNorm () const
 
G4bool IsSameBoundary (G4VTwistSurface *surface1, G4int areacode1, G4VTwistSurface *surface2, G4int areacode2) const
 
G4int GetAxisType (G4int areacode, G4int whichaxis) const
 
G4ThreeVector ComputeGlobalPoint (const G4ThreeVector &lp) const
 
G4ThreeVector ComputeLocalPoint (const G4ThreeVector &gp) const
 
G4ThreeVector ComputeGlobalDirection (const G4ThreeVector &lp) const
 
G4ThreeVector ComputeLocalDirection (const G4ThreeVector &gp) const
 
void SetAxis (G4int i, const EAxis axis)
 
void SetNeighbours (G4VTwistSurface *axis0min, G4VTwistSurface *axis1min, G4VTwistSurface *axis0max, G4VTwistSurface *axis1max)
 
virtual G4ThreeVector SurfacePoint (G4double, G4double, G4bool isGlobal=false)=0
 
virtual G4double GetBoundaryMin (G4double)=0
 
virtual G4double GetBoundaryMax (G4double)=0
 
virtual G4double GetSurfaceArea ()=0
 
virtual void GetFacets (G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside)=0
 
G4int GetNode (G4int i, G4int j, G4int m, G4int n, G4int iside)
 
G4int GetFace (G4int i, G4int j, G4int m, G4int n, G4int iside)
 
G4int GetEdgeVisibility (G4int i, G4int j, G4int m, G4int n, G4int number, G4int orientation)
 
 G4VTwistSurface (__void__ &)
 

Static Public Attributes

static const G4int sOutside = 0x00000000
 
static const G4int sInside = 0x10000000
 
static const G4int sBoundary = 0x20000000
 
static const G4int sCorner = 0x40000000
 
static const G4int sC0Min1Min = 0x40000101
 
static const G4int sC0Max1Min = 0x40000201
 
static const G4int sC0Max1Max = 0x40000202
 
static const G4int sC0Min1Max = 0x40000102
 
static const G4int sAxisMin = 0x00000101
 
static const G4int sAxisMax = 0x00000202
 
static const G4int sAxisX = 0x00000404
 
static const G4int sAxisY = 0x00000808
 
static const G4int sAxisZ = 0x00000C0C
 
static const G4int sAxisRho = 0x00001010
 
static const G4int sAxisPhi = 0x00001414
 
static const G4int sAxis0 = 0x0000FF00
 
static const G4int sAxis1 = 0x000000FF
 
static const G4int sSizeMask = 0x00000303
 
static const G4int sAxisMask = 0x0000FCFC
 
static const G4int sAreaMask = 0XF0000000
 

Protected Member Functions

G4VTwistSurface ** GetNeighbours ()
 
G4int GetNeighbours (G4int areacode, G4VTwistSurface *surfaces[])
 
G4ThreeVector GetCorner (G4int areacode) const
 
void GetBoundaryAxis (G4int areacode, EAxis axis[]) const
 
void GetBoundaryLimit (G4int areacode, G4double limit[]) const
 
virtual G4int GetAreaCode (const G4ThreeVector &xx, G4bool withtol=true)=0
 
virtual void SetBoundary (const G4int &axiscode, const G4ThreeVector &direction, const G4ThreeVector &x0, const G4int &boundarytype)
 
void SetCorner (G4int areacode, G4double x, G4double y, G4double z)
 

Protected Attributes

EAxis fAxis [2]
 
G4double fAxisMin [2]
 
G4double fAxisMax [2]
 
CurrentStatus fCurStatWithV
 
CurrentStatus fCurStat
 
G4RotationMatrix fRot
 
G4ThreeVector fTrans
 
G4int fHandedness
 
G4SurfCurNormal fCurrentNormal
 
G4bool fIsValidNorm
 
G4double kCarTolerance
 

Detailed Description

Definition at line 59 of file G4VTwistSurface.hh.

Member Enumeration Documentation

Enumerator
kDontValidate 
kValidateWithTol 
kValidateWithoutTol 
kUninitialized 

Definition at line 63 of file G4VTwistSurface.hh.

Constructor & Destructor Documentation

G4VTwistSurface::G4VTwistSurface ( const G4String name)

Definition at line 75 of file G4VTwistSurface.cc.

References fAxis, fAxisMax, fAxisMin, fCurrentNormal, fHandedness, G4GeometryTolerance::GetInstance(), G4GeometryTolerance::GetSurfaceTolerance(), kCarTolerance, kUndefined, G4VTwistSurface::G4SurfCurNormal::p, and CLHEP::Hep3Vector::set().

76  : fIsValidNorm(false), fName(name)
77 {
78 
79  fAxis[0] = kUndefined;
80  fAxis[1] = kUndefined;
81  fAxisMin[0] = kInfinity;
82  fAxisMin[1] = kInfinity;
83  fAxisMax[0] = kInfinity;
84  fAxisMax[1] = kInfinity;
85  fHandedness = 1;
86 
87  for (G4int i=0; i<4; i++)
88  {
89  fCorners[i].set(kInfinity, kInfinity, kInfinity);
90  fNeighbours[i] = 0;
91  }
92 
93  fCurrentNormal.p.set(kInfinity, kInfinity, kInfinity);
94 
95  fAmIOnLeftSide.me.set(kInfinity, kInfinity, kInfinity);
96  fAmIOnLeftSide.vec.set(kInfinity, kInfinity, kInfinity);
98 }
void set(double x, double y, double z)
G4SurfCurNormal fCurrentNormal
G4double fAxisMax[2]
G4double GetSurfaceTolerance() const
int G4int
Definition: G4Types.hh:78
G4double fAxisMin[2]
static G4GeometryTolerance * GetInstance()
G4VTwistSurface::G4VTwistSurface ( const G4String name,
const G4RotationMatrix rot,
const G4ThreeVector tlate,
G4int  handedness,
const EAxis  axis1,
const EAxis  axis2,
G4double  axis0min = -kInfinity,
G4double  axis1min = -kInfinity,
G4double  axis0max = kInfinity,
G4double  axis1max = kInfinity 
)

Definition at line 100 of file G4VTwistSurface.cc.

References fAxis, fAxisMax, fAxisMin, fCurrentNormal, fHandedness, fRot, fTrans, G4GeometryTolerance::GetInstance(), G4GeometryTolerance::GetSurfaceTolerance(), kCarTolerance, G4VTwistSurface::G4SurfCurNormal::p, and CLHEP::Hep3Vector::set().

110  : fIsValidNorm(false), fName(name)
111 {
112  fAxis[0] = axis0;
113  fAxis[1] = axis1;
114  fAxisMin[0] = axis0min;
115  fAxisMin[1] = axis1min;
116  fAxisMax[0] = axis0max;
117  fAxisMax[1] = axis1max;
118  fHandedness = handedness;
119  fRot = rot;
120  fTrans = tlate;
121 
122  for (G4int i=0; i<4; i++)
123  {
124  fCorners[i].set(kInfinity, kInfinity, kInfinity);
125  fNeighbours[i] = 0;
126  }
127 
128  fCurrentNormal.p.set(kInfinity, kInfinity, kInfinity);
129 
130  fAmIOnLeftSide.me.set(kInfinity, kInfinity, kInfinity);
131  fAmIOnLeftSide.vec.set(kInfinity, kInfinity, kInfinity);
133 }
void set(double x, double y, double z)
G4SurfCurNormal fCurrentNormal
G4double fAxisMax[2]
G4double GetSurfaceTolerance() const
int G4int
Definition: G4Types.hh:78
G4RotationMatrix fRot
G4ThreeVector fTrans
G4double fAxisMin[2]
static G4GeometryTolerance * GetInstance()
G4VTwistSurface::~G4VTwistSurface ( )
virtual

Definition at line 151 of file G4VTwistSurface.cc.

152 {
153 }
G4VTwistSurface::G4VTwistSurface ( __void__ &  )

Definition at line 138 of file G4VTwistSurface.cc.

References fAxis, fAxisMax, fAxisMin, and kXAxis.

139  : fHandedness(0), fIsValidNorm(false), kCarTolerance(0.),
140  fName("")
141 {
142  fAxis[0] = fAxis[1] = kXAxis;
143  fAxisMin[0] = fAxisMin[1] = 0.;
144  fAxisMax[0] = fAxisMax[1] = 0.;
145  fNeighbours[0] = fNeighbours[1] = fNeighbours[2] = fNeighbours[3] = 0;
146 }
G4double fAxisMax[2]
G4double fAxisMin[2]

Member Function Documentation

G4int G4VTwistSurface::AmIOnLeftSide ( const G4ThreeVector me,
const G4ThreeVector vec,
G4bool  withTol = true 
)
virtual

Definition at line 158 of file G4VTwistSurface.cc.

References CLHEP::Hep3Vector::cross(), G4cout, G4endl, G4GeometryTolerance::GetAngularTolerance(), G4GeometryTolerance::GetInstance(), CLHEP::HepRotation::rotateZ(), CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::y().

Referenced by G4TwistTubsSide::DistanceToSurface(), and G4TwistTubsFlatSide::GetAreaCode().

161 {
162  // AmIOnLeftSide returns phi-location of "me"
163  // (phi relation between me and vec projected on z=0 plane).
164  // If "me" is on -ve-phi-side of "vec", it returns 1.
165  // On the other hand, if "me" is on +ve-phi-side of "vec",
166  // it returns -1.
167  // (The return value represents z-coordinate of normal vector
168  // of me.cross(vec).)
169  // If me is on boundary of vec, return 0.
170 
171  const G4double kAngTolerance
173 
174  G4RotationMatrix unitrot;
175  static const G4RotationMatrix rottol = unitrot.rotateZ(0.5*kAngTolerance);
176  static const G4RotationMatrix invrottol = unitrot.rotateZ(-1.*kAngTolerance);
177 
178  if (fAmIOnLeftSide.me == me
179  && fAmIOnLeftSide.vec == vec
180  && fAmIOnLeftSide.withTol == withtol) {
181  return fAmIOnLeftSide.amIOnLeftSide;
182  }
183 
184  fAmIOnLeftSide.me = me;
185  fAmIOnLeftSide.vec = vec;
186  fAmIOnLeftSide.withTol = withtol;
187 
188  G4ThreeVector met = (G4ThreeVector(me.x(), me.y(), 0.)).unit();
189  G4ThreeVector vect = (G4ThreeVector(vec.x(), vec.y(), 0.)).unit();
190 
191  G4ThreeVector ivect = invrottol * vect;
192  G4ThreeVector rvect = rottol * vect;
193 
194  G4double metcrossvect = met.x() * vect.y() - met.y() * vect.x();
195 
196  if (withtol) {
197  if (met.x() * ivect.y() - met.y() * ivect.x() > 0 &&
198  metcrossvect >= 0) {
199  fAmIOnLeftSide.amIOnLeftSide = 1;
200  } else if (met.x() * rvect.y() - met.y() * rvect.x() < 0 &&
201  metcrossvect <= 0) {
202  fAmIOnLeftSide.amIOnLeftSide = -1;
203  } else {
204  fAmIOnLeftSide.amIOnLeftSide = 0;
205  }
206  } else {
207  if (metcrossvect > 0) {
208  fAmIOnLeftSide.amIOnLeftSide = 1;
209  } else if (metcrossvect < 0 ) {
210  fAmIOnLeftSide.amIOnLeftSide = -1;
211  } else {
212  fAmIOnLeftSide.amIOnLeftSide = 0;
213  }
214  }
215 
216 #ifdef G4TWISTDEBUG
217  G4cout << " === G4VTwistSurface::AmIOnLeftSide() =============="
218  << G4endl;
219  G4cout << " Name , returncode : " << fName << " "
220  << fAmIOnLeftSide.amIOnLeftSide << G4endl;
221  G4cout << " me, vec : " << std::setprecision(14) << me
222  << " " << vec << G4endl;
223  G4cout << " met, vect : " << met << " " << vect << G4endl;
224  G4cout << " ivec, rvec : " << ivect << " " << rvect << G4endl;
225  G4cout << " met x vect : " << metcrossvect << G4endl;
226  G4cout << " met x ivec : " << met.cross(ivect) << G4endl;
227  G4cout << " met x rvec : " << met.cross(rvect) << G4endl;
228  G4cout << " =============================================="
229  << G4endl;
230 #endif
231 
232  return fAmIOnLeftSide.amIOnLeftSide;
233 }
CLHEP::Hep3Vector G4ThreeVector
double x() const
G4GLOB_DLL std::ostream G4cout
double y() const
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:92
#define G4endl
Definition: G4ios.hh:61
Hep3Vector cross(const Hep3Vector &) const
double G4double
Definition: G4Types.hh:76
G4double GetAngularTolerance() const
static G4GeometryTolerance * GetInstance()
G4ThreeVector G4VTwistSurface::ComputeGlobalDirection ( const G4ThreeVector lp) const
inline
G4ThreeVector G4VTwistSurface::ComputeGlobalPoint ( const G4ThreeVector lp) const
inline
G4ThreeVector G4VTwistSurface::ComputeLocalDirection ( const G4ThreeVector gp) const
inline
G4ThreeVector G4VTwistSurface::ComputeLocalPoint ( const G4ThreeVector gp) const
inline
void G4VTwistSurface::DebugPrint ( ) const

Definition at line 1091 of file G4VTwistSurface.cc.

References fAxis, fAxisMax, fAxisMin, fRot, fTrans, G4cout, G4endl, GetCorner(), sC0Max1Max, sC0Max1Min, sC0Min1Max, and sC0Min1Min.

1092 {
1097 
1098  G4cout << "/* G4VTwistSurface::DebugPrint():-------------------------------"
1099  << G4endl;
1100  G4cout << "/* Name = " << fName << G4endl;
1101  G4cout << "/* Axis = " << std::hex << fAxis[0] << " "
1102  << std::hex << fAxis[1]
1103  << " (0,1,2,3,5 = kXAxis,kYAxis,kZAxis,kRho,kPhi)"
1104  << std::dec << G4endl;
1105  G4cout << "/* BoundaryLimit(in local) fAxis0(min, max) = ("<<fAxisMin[0]
1106  << ", " << fAxisMax[0] << ")" << G4endl;
1107  G4cout << "/* BoundaryLimit(in local) fAxis1(min, max) = ("<<fAxisMin[1]
1108  << ", " << fAxisMax[1] << ")" << G4endl;
1109  G4cout << "/* Cornar point sC0Min1Min = " << A << G4endl;
1110  G4cout << "/* Cornar point sC0Max1Min = " << B << G4endl;
1111  G4cout << "/* Cornar point sC0Max1Max = " << C << G4endl;
1112  G4cout << "/* Cornar point sC0Min1Max = " << D << G4endl;
1113  G4cout << "/*---------------------------------------------------------"
1114  << G4endl;
1115 }
static const G4int sC0Min1Max
G4double fAxisMax[2]
G4ThreeVector GetCorner(G4int areacode) const
G4RotationMatrix fRot
G4ThreeVector fTrans
G4double fAxisMin[2]
static const G4int sC0Min1Min
G4GLOB_DLL std::ostream G4cout
static const G4int sC0Max1Max
#define G4endl
Definition: G4ios.hh:61
static const G4int sC0Max1Min
G4double G4VTwistSurface::DistanceTo ( const G4ThreeVector gp,
G4ThreeVector gxx 
)
virtual

Definition at line 553 of file G4VTwistSurface.cc.

References DistanceToSurface(), G4cout, G4endl, G4VSURFACENXX, and sOutside.

Referenced by G4VTwistedFaceted::DistanceToIn(), G4TwistedTubs::DistanceToIn(), G4VTwistedFaceted::DistanceToOut(), G4TwistedTubs::DistanceToOut(), G4VTwistedFaceted::SurfaceNormal(), and G4TwistedTubs::SurfaceNormal().

555 {
556 #ifdef G4TWISTDEBUG
557  G4cout << "~~~~~ G4VTwistSurface::DistanceTo(p) - Start ~~~~~~~~~" << G4endl;
558  G4cout << " Name : " << fName << G4endl;
559  G4cout << " gp : " << gp << G4endl;
560  G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
561 #endif
562 
563 
565  G4double distance[G4VSURFACENXX] ;
566  G4int areacode[G4VSURFACENXX] ;
567 
568  for (G4int i = 0 ; i<G4VSURFACENXX ; i++ ) {
569  distance[i] = kInfinity ;
570  areacode[i] = sOutside ;
571  }
572 
573 
574  DistanceToSurface(gp, gxx, distance, areacode);
575  gxxbest = gxx[0];
576 
577 #ifdef G4TWISTDEBUG
578  G4cout << "~~~~~ G4VTwistSurface::DistanceTo(p) - return ~~~~~~~~" << G4endl;
579  G4cout << " Name : " << fName << G4endl;
580  G4cout << " gxx : " << gxxbest << G4endl;
581  G4cout << " bestdist : " << distance[0] << G4endl;
582  G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
583 #endif
584 
585  return distance[0];
586 }
virtual G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)=0
static const G4int sOutside
int G4int
Definition: G4Types.hh:78
#define G4VSURFACENXX
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double G4VTwistSurface::DistanceToBoundary ( G4int  areacode,
G4ThreeVector xx,
const G4ThreeVector p 
)
virtual

Definition at line 238 of file G4VTwistSurface.cc.

References DistanceToLine(), FatalException, G4endl, G4Exception(), GetBoundaryParameters(), CLHEP::Hep3Vector::getRho(), IsAxis0(), IsAxis1(), sAxisPhi, CLHEP::Hep3Vector::set(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by G4TwistTubsSide::DistanceToSurface().

241 {
242  // DistanceToBoundary
243  //
244  // return distance to nearest boundary from arbitrary point p
245  // in local coodinate.
246  // Argument areacode must be one of them:
247  // sAxis0 & sAxisMin, sAxis0 & sAxisMax,
248  // sAxis1 & sAxisMin, sAxis1 & sAxisMax.
249  //
250 
251  G4ThreeVector d; // direction vector of the boundary
252  G4ThreeVector x0; // reference point of the boundary
253  G4double dist = kInfinity;
254  G4int boundarytype;
255 
256  if (IsAxis0(areacode) && IsAxis1(areacode)) {
257  std::ostringstream message;
258  message << "Point is in the corner area." << G4endl
259  << " Point is in the corner area. This function returns"
260  << G4endl
261  << " a direction vector of a boundary line." << G4endl
262  << " areacode = " << areacode;
263  G4Exception("G4VTwistSurface::DistanceToBoundary()", "GeomSolids0003",
264  FatalException, message);
265  } else if (IsAxis0(areacode) || IsAxis1(areacode)) {
266  GetBoundaryParameters(areacode, d, x0, boundarytype);
267  if (boundarytype == sAxisPhi) {
268  G4double t = x0.getRho() / p.getRho();
269  xx.set(t*p.x(), t*p.y(), x0.z());
270  dist = (xx - p).mag();
271  } else {
272  // linear boundary
273  // sAxisX, sAxisY, sAxisZ, sAxisRho
274  dist = DistanceToLine(p, x0, d, xx);
275  }
276  } else {
277  std::ostringstream message;
278  message << "Bad areacode of boundary." << G4endl
279  << " areacode = " << areacode;
280  G4Exception("G4VTwistSurface::DistanceToBoundary()", "GeomSolids0003",
281  FatalException, message);
282  }
283  return dist;
284 }
void set(double x, double y, double z)
static const G4int sAxisPhi
double x() const
const char * p
Definition: xmltok.h:285
G4bool IsAxis0(G4int areacode) const
double getRho() const
int G4int
Definition: G4Types.hh:78
double z() const
virtual void GetBoundaryParameters(const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const
G4double DistanceToLine(const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &d, G4ThreeVector &xx)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double y() const
#define G4endl
Definition: G4ios.hh:61
G4bool IsAxis1(G4int areacode) const
double G4double
Definition: G4Types.hh:76
G4double G4VTwistSurface::DistanceToIn ( const G4ThreeVector gp,
const G4ThreeVector gv,
G4ThreeVector gxxbest 
)
virtual

Definition at line 289 of file G4VTwistSurface.cc.

References DistanceToSurface(), G4cout, G4endl, G4VSURFACENXX, GetNeighbours(), GetNormal(), IsInside(), IsSameBoundary(), kValidateWithTol, and sOutside.

Referenced by G4VTwistedFaceted::DistanceToIn(), and G4TwistedTubs::DistanceToIn().

292 {
293 #ifdef G4TWISTDEBUG
294  G4cout << " ~~~~~ G4VTwistSurface::DistanceToIn(p,v) - Start ~~~~~" << G4endl;
295  G4cout << " Name : " << fName << G4endl;
296  G4cout << " gp : " << gp << G4endl;
297  G4cout << " gv : " << gv << G4endl;
298  G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
299 #endif
300 
302  G4double distance[G4VSURFACENXX] ;
303  G4int areacode[G4VSURFACENXX] ;
304  G4bool isvalid[G4VSURFACENXX] ;
305 
306  for (G4int i = 0 ; i<G4VSURFACENXX ; i++ ) {
307  distance[i] = kInfinity ;
308  areacode[i] = sOutside ;
309  isvalid[i] = false ;
310  }
311 
312  G4double bestdistance = kInfinity;
313 #ifdef G4TWISTDEBUG
314  G4int besti = -1;
315 #endif
316  G4ThreeVector bestgxx(kInfinity, kInfinity, kInfinity);
317 
318  G4int nxx = DistanceToSurface(gp, gv, gxx, distance, areacode,
319  isvalid, kValidateWithTol);
320 
321  for (G4int i=0; i< nxx; i++) {
322 
323  // skip this intersection if:
324  // - invalid intersection
325  // - particle goes outword the surface
326 
327  if (!isvalid[i]) {
328  // xx[i] is sOutside or distance[i] < 0
329  continue;
330  }
331 
332  G4ThreeVector normal = GetNormal(gxx[i], true);
333 
334  if ((normal * gv) >= 0) {
335 
336 #ifdef G4TWISTDEBUG
337  G4cout << " G4VTwistSurface::DistanceToIn(p,v): "
338  << "particle goes outword the surface." << G4endl;
339 #endif
340  continue;
341  }
342 
343  //
344  // accept this intersection if the intersection is inside.
345  //
346 
347  if (IsInside(areacode[i])) {
348  if (distance[i] < bestdistance) {
349  bestdistance = distance[i];
350  bestgxx = gxx[i];
351 #ifdef G4TWISTDEBUG
352  besti = i;
353  G4cout << " G4VTwistSurface::DistanceToIn(p,v): "
354  << " areacode sInside name, distance = "
355  << fName << " "<< bestdistance << G4endl;
356 #endif
357  }
358 
359  //
360  // else, the intersection is on boundary or corner.
361  //
362 
363  } else {
364 
365  G4VTwistSurface *neighbours[2];
366  G4bool isaccepted[2] = {false, false};
367  G4int nneighbours = GetNeighbours(areacode[i], neighbours);
368 
369  for (G4int j=0; j< nneighbours; j++) {
370  // if on corner, nneighbours = 2.
371  // if on boundary, nneighbours = 1.
372 
374  G4double tmpdist[G4VSURFACENXX] ;
375  G4int tmpareacode[G4VSURFACENXX] ;
376  G4bool tmpisvalid[G4VSURFACENXX] ;
377 
378  for (G4int l = 0 ; l<G4VSURFACENXX ; l++ ) {
379  tmpdist[l] = kInfinity ;
380  tmpareacode[l] = sOutside ;
381  tmpisvalid[l] = false ;
382  }
383 
384  G4int tmpnxx = neighbours[j]->DistanceToSurface(
385  gp, gv, tmpgxx, tmpdist,
386  tmpareacode, tmpisvalid,
388  G4ThreeVector neighbournormal;
389 
390  for (G4int k=0; k< tmpnxx; k++) {
391 
392  //
393  // if tmpxx[k] is valid && sInside, the final winner must
394  // be neighbour surface. return kInfinity.
395  // else , choose tmpxx on same boundary of xx, then check normal
396  //
397 
398  if (IsInside(tmpareacode[k])) {
399 
400 #ifdef G4TWISTDEBUG
401  G4cout << " G4VTwistSurface:DistanceToIn(p,v): "
402  << " intersection "<< tmpgxx[k] << G4endl
403  << " is inside of neighbour surface of " << fName
404  << " . returning kInfinity." << G4endl;
405  G4cout << "~~~~~ G4VTwistSurface::DistanceToIn(p,v) - return ~~~~"
406  << G4endl;
407  G4cout << " No intersections " << G4endl;
408  G4cout << " Name : " << fName << G4endl;
409  G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
410  << G4endl;
411 #endif
412  if (tmpisvalid[k]) return kInfinity;
413  continue;
414 
415  //
416  // if tmpxx[k] is valid && sInside, the final winner must
417  // be neighbour surface. return .
418  //
419 
420  } else if (IsSameBoundary(this,areacode[i],
421  neighbours[j], tmpareacode[k])) {
422  // tmpxx[k] is same boundary (or corner) of xx.
423 
424  neighbournormal = neighbours[j]->GetNormal(tmpgxx[k], true);
425  if (neighbournormal * gv < 0) isaccepted[j] = true;
426  }
427  }
428 
429  // if nneighbours = 1, chabge isaccepted[1] before
430  // exiting neighboursurface loop.
431 
432  if (nneighbours == 1) isaccepted[1] = true;
433 
434  } // neighboursurface loop end
435 
436  // now, we can accept xx intersection
437 
438  if (isaccepted[0] == true && isaccepted[1] == true) {
439  if (distance[i] < bestdistance) {
440  bestdistance = distance[i];
441  gxxbest = gxx[i];
442 #ifdef G4TWISTDEBUG
443  besti = i;
444  G4cout << " G4VTwistSurface::DistanceToIn(p,v): "
445  << " areacode sBoundary & sBoundary distance = "
446  << fName << " " << distance[i] << G4endl;
447 #endif
448  }
449  }
450 
451  } // else end
452  } // intersection loop end
453 
454  gxxbest = bestgxx;
455 
456 #ifdef G4TWISTDEBUG
457  if (besti < 0) {
458  G4cout << "~~~~~ G4VTwistSurface::DistanceToIn(p,v) - return ~~~~" << G4endl;
459  G4cout << " No intersections " << G4endl;
460  G4cout << " Name : " << fName << G4endl;
461  G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
462  } else {
463  G4cout << "~~~~~ G4VTwistSurface::DistanceToIn(p,v) : return ~~~~" << G4endl;
464  G4cout << " Name, i : " << fName << " , " << besti << G4endl;
465  G4cout << " gxx[i] : " << gxxbest << G4endl;
466  G4cout << " bestdist : " << bestdistance << G4endl;
467  G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
468  }
469 
470 #endif
471 
472  return bestdistance;
473 }
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal)=0
virtual G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)=0
static const G4int sOutside
G4bool IsSameBoundary(G4VTwistSurface *surface1, G4int areacode1, G4VTwistSurface *surface2, G4int areacode2) const
int G4int
Definition: G4Types.hh:78
#define G4VSURFACENXX
G4VTwistSurface ** GetNeighbours()
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
G4bool IsInside(G4int areacode, G4bool testbitmode=false) const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double G4VTwistSurface::DistanceToLine ( const G4ThreeVector p,
const G4ThreeVector x0,
const G4ThreeVector d,
G4ThreeVector xx 
)
inline
G4double G4VTwistSurface::DistanceToOut ( const G4ThreeVector gp,
const G4ThreeVector gv,
G4ThreeVector gxxbest 
)
virtual

Definition at line 478 of file G4VTwistSurface.cc.

References DistanceToSurface(), G4cout, G4endl, G4VSURFACENXX, GetNormal(), kValidateWithTol, and sOutside.

Referenced by G4VTwistedFaceted::DistanceToOut(), and G4TwistedTubs::DistanceToOut().

481 {
482 #ifdef G4TWISTDEBUG
483  G4cout << "~~~~~ G4VTwistSurface::DistanceToOut(p,v) - Start ~~~~" << G4endl;
484  G4cout << " Name : " << fName << G4endl;
485  G4cout << " gp : " << gp << G4endl;
486  G4cout << " gv : " << gv << G4endl;
487  G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
488 #endif
489 
491  G4double distance[G4VSURFACENXX] ;
492  G4int areacode[G4VSURFACENXX] ;
493  G4bool isvalid[G4VSURFACENXX] ;
494  G4int i;
495 
496  for ( i = 0 ; i<G4VSURFACENXX ; i++ )
497  {
498  distance[i] = kInfinity ;
499  areacode[i] = sOutside ;
500  isvalid[i] = false ;
501  }
502 
503  G4int nxx;
504  G4double bestdistance = kInfinity;
505 
506  nxx = DistanceToSurface(gp, gv, gxx, distance, areacode,
507  isvalid, kValidateWithTol);
508 
509  for (i=0; i<nxx; i++) {
510  if (!(isvalid[i])) {
511  continue;
512  }
513 
514  G4ThreeVector normal = GetNormal(gxx[i], true);
515  if (normal * gv <= 0) {
516  // particle goes toword inside of solid, return kInfinity
517 #ifdef G4TWISTDEBUG
518  G4cout << " G4VTwistSurface::DistanceToOut(p,v): normal*gv < 0, normal "
519  << fName << " " << normal
520  << G4endl;
521 #endif
522  } else {
523  // gxx[i] is accepted.
524  if (distance[i] < bestdistance) {
525  bestdistance = distance[i];
526  gxxbest = gxx[i];
527  }
528  }
529  }
530 
531 #ifdef G4TWISTDEBUG
532  if (besti < 0) {
533  G4cout << "~~~~~ G4VTwistSurface::DistanceToOut(p,v) - return ~~~" << G4endl;
534  G4cout << " No intersections " << G4endl;
535  G4cout << " Name : " << fName << G4endl;
536  G4cout << " bestdist : " << bestdistance << G4endl;
537  G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
538  } else {
539  G4cout << "~~~~~ G4VTwistSurface::DistanceToOut(p,v) : return ~~~" << G4endl;
540  G4cout << " Name, i : " << fName << " , " << i << G4endl;
541  G4cout << " gxx[i] : " << gxxbest << G4endl;
542  G4cout << " bestdist : " << bestdistance << G4endl;
543  G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
544  }
545 #endif
546 
547  return bestdistance;
548 }
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal)=0
virtual G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)=0
static const G4int sOutside
int G4int
Definition: G4Types.hh:78
#define G4VSURFACENXX
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double G4VTwistSurface::DistanceToPlane ( const G4ThreeVector p,
const G4ThreeVector x0,
const G4ThreeVector n0,
G4ThreeVector xx 
)
inline
G4double G4VTwistSurface::DistanceToPlane ( const G4ThreeVector p,
const G4ThreeVector x0,
const G4ThreeVector t1,
const G4ThreeVector t2,
G4ThreeVector xx,
G4ThreeVector n 
)
inline
G4double G4VTwistSurface::DistanceToPlaneWithV ( const G4ThreeVector p,
const G4ThreeVector v,
const G4ThreeVector x0,
const G4ThreeVector n0,
G4ThreeVector xx 
)
inline
virtual G4int G4VTwistSurface::DistanceToSurface ( const G4ThreeVector gp,
const G4ThreeVector gv,
G4ThreeVector  gxx[],
G4double  distance[],
G4int  areacode[],
G4bool  isvalid[],
EValidate  validate = kValidateWithTol 
)
pure virtual
virtual G4int G4VTwistSurface::DistanceToSurface ( const G4ThreeVector gp,
G4ThreeVector  gxx[],
G4double  distance[],
G4int  areacode[] 
)
pure virtual
virtual G4int G4VTwistSurface::GetAreaCode ( const G4ThreeVector xx,
G4bool  withtol = true 
)
protectedpure virtual
G4int G4VTwistSurface::GetAxisType ( G4int  areacode,
G4int  whichaxis 
) const
inline
G4ThreeVector G4VTwistSurface::GetBoundaryAtPZ ( G4int  areacode,
const G4ThreeVector p 
) const
virtual

Definition at line 675 of file G4VTwistSurface.cc.

References FatalException, G4endl, G4Exception(), GetBoundaryParameters(), sAxis0, sAxis1, sAxisPhi, sAxisRho, and CLHEP::Hep3Vector::z().

Referenced by G4TwistTubsSide::DistanceToSurface(), G4TwistTubsHypeSide::GetBoundaryMax(), and G4TwistTubsHypeSide::GetBoundaryMin().

677 {
678  // areacode must be one of them:
679  // sAxis0 & sAxisMin, sAxis0 & sAxisMax,
680  // sAxis1 & sAxisMin, sAxis1 & sAxisMax.
681 
682  if (areacode & sAxis0 && areacode & sAxis1) {
683  std::ostringstream message;
684  message << "Point is in the corner area." << G4endl
685  << " This function returns "
686  << "a direction vector of a boundary line." << G4endl
687  << " areacode = " << areacode;
688  G4Exception("G4VTwistSurface::GetBoundaryAtPZ()", "GeomSolids0003",
689  FatalException, message);
690  }
691 
692  G4ThreeVector d;
693  G4ThreeVector x0;
694  G4int boundarytype;
695  G4bool found = false;
696 
697  for (G4int i=0; i<4; i++) {
698  if (fBoundaries[i].GetBoundaryParameters(areacode, d, x0,
699  boundarytype)){
700  found = true;
701  continue;
702  }
703  }
704 
705  if (!found) {
706  std::ostringstream message;
707  message << "Not registered boundary." << G4endl
708  << " Boundary at areacode " << areacode << G4endl
709  << " is not registered.";
710  G4Exception("G4VTwistSurface::GetBoundaryAtPZ()", "GeomSolids0002",
711  FatalException, message);
712  }
713 
714  if (((boundarytype & sAxisPhi) == sAxisPhi) ||
715  ((boundarytype & sAxisRho) == sAxisRho)) {
716  std::ostringstream message;
717  message << "Not a z-depended line boundary." << G4endl
718  << " Boundary at areacode " << areacode << G4endl
719  << " is not a z-depended line.";
720  G4Exception("G4VTwistSurface::GetBoundaryAtPZ()", "GeomSolids0002",
721  FatalException, message);
722  }
723  return ((p.z() - x0.z()) / d.z()) * d + x0;
724 }
static const G4int sAxisPhi
int G4int
Definition: G4Types.hh:78
double z() const
virtual void GetBoundaryParameters(const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const
static const G4int sAxis1
bool G4bool
Definition: G4Types.hh:79
static const G4int sAxis0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
static const G4int sAxisRho
void G4VTwistSurface::GetBoundaryAxis ( G4int  areacode,
EAxis  axis[] 
) const
protected

Definition at line 753 of file G4VTwistSurface.cc.

References FatalException, G4endl, G4Exception(), kPhi, kRho, kXAxis, kYAxis, kZAxis, sAxis0, sAxis1, sAxisMask, sAxisPhi, sAxisRho, sAxisX, sAxisY, sAxisZ, and sBoundary.

754 {
755  if ((areacode & sBoundary) != sBoundary) {
756  G4Exception("G4VTwistSurface::GetBoundaryAxis()", "GeomSolids0003",
757  FatalException, "Not located on a boundary!");
758  }
759  G4int i;
760  for (i=0; i<2; i++) {
761 
762  G4int whichaxis = 0 ;
763  if (i == 0) {
764  whichaxis = sAxis0;
765  } else if (i == 1) {
766  whichaxis = sAxis1;
767  }
768 
769  // extracted axiscode of whichaxis
770  G4int axiscode = whichaxis & sAxisMask & areacode ;
771  if (axiscode) {
772  if (axiscode == (whichaxis & sAxisX)) {
773  axis[i] = kXAxis;
774  } else if (axiscode == (whichaxis & sAxisY)) {
775  axis[i] = kYAxis;
776  } else if (axiscode == (whichaxis & sAxisZ)) {
777  axis[i] = kZAxis;
778  } else if (axiscode == (whichaxis & sAxisRho)) {
779  axis[i] = kRho;
780  } else if (axiscode == (whichaxis & sAxisPhi)) {
781  axis[i] = kPhi;
782  } else {
783  std::ostringstream message;
784  message << "Not supported areacode." << G4endl
785  << " areacode " << areacode;
786  G4Exception("G4VTwistSurface::GetBoundaryAxis()", "GeomSolids0001",
787  FatalException, message);
788  }
789  }
790  }
791 }
static const G4int sAxisZ
Definition: geomdefs.hh:54
static const G4int sAxisPhi
static const G4int sAxisMask
int G4int
Definition: G4Types.hh:78
static const G4int sAxisX
static const G4int sAxis1
static const G4int sBoundary
static const G4int sAxis0
static const G4int sAxisY
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
Definition: geomdefs.hh:54
static const G4int sAxisRho
void G4VTwistSurface::GetBoundaryLimit ( G4int  areacode,
G4double  limit[] 
) const
protected

Definition at line 796 of file G4VTwistSurface.cc.

References fAxisMax, fAxisMin, G4endl, G4Exception(), JustWarning, sAxis0, sAxis1, sAxisMax, sAxisMin, sBoundary, sC0Max1Max, sC0Max1Min, sC0Min1Max, sC0Min1Min, and sCorner.

797 {
798  if (areacode & sCorner) {
799  if (areacode & sC0Min1Min) {
800  limit[0] = fAxisMin[0];
801  limit[1] = fAxisMin[1];
802  } else if (areacode & sC0Max1Min) {
803  limit[0] = fAxisMax[0];
804  limit[1] = fAxisMin[1];
805  } else if (areacode & sC0Max1Max) {
806  limit[0] = fAxisMax[0];
807  limit[1] = fAxisMax[1];
808  } else if (areacode & sC0Min1Max) {
809  limit[0] = fAxisMin[0];
810  limit[1] = fAxisMax[1];
811  }
812  } else if (areacode & sBoundary) {
813  if (areacode & (sAxis0 | sAxisMin)) {
814  limit[0] = fAxisMin[0];
815  } else if (areacode & (sAxis1 | sAxisMin)) {
816  limit[0] = fAxisMin[1];
817  } else if (areacode & (sAxis0 | sAxisMax)) {
818  limit[0] = fAxisMax[0];
819  } else if (areacode & (sAxis1 | sAxisMax)) {
820  limit[0] = fAxisMax[1];
821  }
822  } else {
823  std::ostringstream message;
824  message << "Not located on a boundary!" << G4endl
825  << " areacode " << areacode;
826  G4Exception("G4VTwistSurface::GetBoundaryLimit()", "GeomSolids1002",
827  JustWarning, message);
828  }
829 }
static const G4int sC0Min1Max
G4double fAxisMax[2]
G4double fAxisMin[2]
static const G4int sC0Min1Min
static const G4int sAxis1
static const G4int sC0Max1Max
static const G4int sBoundary
static const G4int sAxis0
static const G4int sAxisMin
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static const G4int sCorner
static const G4int sAxisMax
#define G4endl
Definition: G4ios.hh:61
static const G4int sC0Max1Min
virtual G4double G4VTwistSurface::GetBoundaryMax ( G4double  )
pure virtual
virtual G4double G4VTwistSurface::GetBoundaryMin ( G4double  )
pure virtual
void G4VTwistSurface::GetBoundaryParameters ( const G4int areacode,
G4ThreeVector d,
G4ThreeVector x0,
G4int boundarytype 
) const
virtual

Definition at line 646 of file G4VTwistSurface.cc.

References FatalException, G4endl, and G4Exception().

Referenced by DistanceToBoundary(), G4TwistTubsSide::DistanceToSurface(), GetBoundaryAtPZ(), and IsSameBoundary().

650 {
651  // areacode must be one of them:
652  // sAxis0 & sAxisMin, sAxis0 & sAxisMax,
653  // sAxis1 & sAxisMin, sAxis1 & sAxisMax.
654 
655  G4int i;
656  for (i=0; i<4; i++) {
657  if (fBoundaries[i].GetBoundaryParameters(areacode, d, x0,
658  boundarytype)) {
659  return;
660  }
661  }
662 
663  std::ostringstream message;
664  message << "Not registered boundary." << G4endl
665  << " Boundary at areacode " << std::hex << areacode
666  << std::dec << G4endl
667  << " is not registered.";
668  G4Exception("G4VTwistSurface::GetBoundaryParameters()", "GeomSolids0002",
669  FatalException, message);
670 }
int G4int
Definition: G4Types.hh:78
virtual void GetBoundaryParameters(const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
G4ThreeVector G4VTwistSurface::GetCorner ( G4int  areacode) const
inlineprotected
G4int G4VTwistSurface::GetEdgeVisibility ( G4int  i,
G4int  j,
G4int  m,
G4int  n,
G4int  number,
G4int  orientation 
)

Definition at line 987 of file G4VTwistSurface.cc.

References FatalException, G4Exception(), and GetName().

Referenced by G4TwistTrapFlatSide::GetFacets(), G4TwistTubsFlatSide::GetFacets(), G4TwistTubsSide::GetFacets(), and G4TwistTubsHypeSide::GetFacets().

988 {
989 
990  // clockwise filling -> positive orientation
991  // counter clockwise filling -> negative orientation
992 
993  //
994  // d C c
995  // +------+
996  // | |
997  // | |
998  // | |
999  // D | |B
1000  // | |
1001  // | |
1002  // | |
1003  // +------+
1004  // a A b
1005  //
1006  // a = +--+ A = ---+
1007  // b = --++ B = --+-
1008  // c = -++- C = -+--
1009  // d = ++-- D = +---
1010 
1011 
1012  // check first invisible faces
1013 
1014  if ( ( i>0 && i<n-2 ) && ( j>0 && j<k-2 ) ) {
1015  return -1 ; // always invisible, signs: ----
1016  }
1017 
1018  // change first the vertex number (depends on the orientation)
1019  // 0,1,2,3 -> 3,2,1,0
1020  if ( orientation < 0 ) { number = ( 3 - number ) ; }
1021 
1022  // check true edges
1023  if ( ( j>=1 && j<=k-3 ) ) {
1024 
1025  if ( i == 0 ) { // signs (A): ---+
1026  return ( number == 3 ) ? 1 : -1 ;
1027  }
1028 
1029  else if ( i == n-2 ) { // signs (C): -+--
1030  return ( number == 1 ) ? 1 : -1 ;
1031  }
1032 
1033  else {
1034  std::ostringstream message;
1035  message << "Not correct face number: " << GetName() << " !";
1036  G4Exception("G4TwistSurface::G4GetEdgeVisibility()",
1037  "GeomSolids0003", FatalException, message);
1038  }
1039  }
1040 
1041  if ( ( i>=1 && i<=n-3 ) ) {
1042 
1043  if ( j == 0 ) { // signs (D): +---
1044  return ( number == 0 ) ? 1 : -1 ;
1045  }
1046 
1047  else if ( j == k-2 ) { // signs (B): --+-
1048  return ( number == 2 ) ? 1 : -1 ;
1049  }
1050 
1051  else {
1052  std::ostringstream message;
1053  message << "Not correct face number: " << GetName() << " !";
1054  G4Exception("G4TwistSurface::G4GetEdgeVisibility()",
1055  "GeomSolids0003", FatalException, message);
1056  }
1057  }
1058 
1059  // now the corners
1060  if ( i == 0 && j == 0 ) { // signs (a) : +--+
1061  return ( number == 0 || number == 3 ) ? 1 : -1 ;
1062  }
1063  else if ( i == 0 && j == k-2 ) { // signs (b) : --++
1064  return ( number == 2 || number == 3 ) ? 1 : -1 ;
1065  }
1066  else if ( i == n-2 && j == k-2 ) { // signs (c) : -++-
1067  return ( number == 1 || number == 2 ) ? 1 : -1 ;
1068  }
1069  else if ( i == n-2 && j == 0 ) { // signs (d) : ++--
1070  return ( number == 0 || number == 1 ) ? 1 : -1 ;
1071  }
1072  else {
1073  std::ostringstream message;
1074  message << "Not correct face number: " << GetName() << " !";
1075  G4Exception("G4TwistSurface::G4GetEdgeVisibility()",
1076  "GeomSolids0003", FatalException, message);
1077  }
1078 
1079  std::ostringstream message;
1080  message << "Not correct face number: " << GetName() << " !";
1081  G4Exception("G4TwistSurface::G4GetEdgeVisibility()", "GeomSolids0003",
1082  FatalException, message);
1083 
1084  return 0 ;
1085 }
const G4int n
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4String GetName() const
G4int G4VTwistSurface::GetFace ( G4int  i,
G4int  j,
G4int  m,
G4int  n,
G4int  iside 
)

Definition at line 873 of file G4VTwistSurface.cc.

References FatalException, G4endl, G4Exception(), and GetName().

Referenced by G4TwistTrapFlatSide::GetFacets(), G4TwistTubsFlatSide::GetFacets(), G4TwistTubsSide::GetFacets(), and G4TwistTubsHypeSide::GetFacets().

875 {
876  // this is the face mapping function
877  // (i,j) -> face number
878 
879  if ( iside == 0 ) {
880  return i * ( k - 1 ) + j ;
881  }
882 
883  else if ( iside == 1 ) {
884  return (k-1)*(k-1) + i*(k-1) + j ;
885  }
886 
887  else if ( iside == 2 ) {
888  return 2*(k-1)*(k-1) + i*(k-1) + j ;
889  }
890 
891  else if ( iside == 3 ) {
892  return 2*(k-1)*(k-1) + (n-1)*(k-1) + i*(k-1) + j ;
893  }
894 
895  else if ( iside == 4 ) {
896  return 2*(k-1)*(k-1) + 2*(n-1)*(k-1) + i*(k-1) + j ;
897  }
898 
899  else if ( iside == 5 ) {
900  return 2*(k-1)*(k-1) + 3*(n-1)*(k-1) + i*(k-1) + j ;
901  }
902 
903  else {
904 
905  std::ostringstream message;
906  message << "Not correct side number: "
907  << GetName() << G4endl
908  << "iside is " << iside << " but should be "
909  << "0,1,2,3,4 or 5" << ".";
910  G4Exception("G4TwistSurface::G4GetFace()", "GeomSolids0002",
911  FatalException, message);
912 
913 
914  }
915 
916  return -1 ; // wrong face
917 }
const G4int n
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4String GetName() const
#define G4endl
Definition: G4ios.hh:61
virtual void G4VTwistSurface::GetFacets ( G4int  m,
G4int  n,
G4double  xyz[][3],
G4int  faces[][4],
G4int  iside 
)
pure virtual
virtual G4String G4VTwistSurface::GetName ( void  ) const
inlinevirtual
G4VTwistSurface** G4VTwistSurface::GetNeighbours ( )
inlineprotected

Definition at line 195 of file G4VTwistSurface.hh.

Referenced by DistanceToIn().

195 { return fNeighbours; }
G4int G4VTwistSurface::GetNeighbours ( G4int  areacode,
G4VTwistSurface surfaces[] 
)
inlineprotected
G4int G4VTwistSurface::GetNode ( G4int  i,
G4int  j,
G4int  m,
G4int  n,
G4int  iside 
)

Definition at line 922 of file G4VTwistSurface.cc.

References FatalException, G4endl, G4Exception(), and GetName().

Referenced by G4TwistTrapFlatSide::GetFacets(), G4TwistTubsFlatSide::GetFacets(), G4TwistTubsSide::GetFacets(), and G4TwistTubsHypeSide::GetFacets().

924 {
925  // this is the node mapping function
926  // (i,j) -> node number
927  // Depends on the side iside and the used meshing of the surface
928 
929  if ( iside == 0 ) {
930  // lower endcap is kxk squared.
931  // n = k
932  return i * k + j ;
933  }
934 
935  if ( iside == 1 ) {
936  // upper endcap is kxk squared. Shift by k*k
937  // n = k
938  return k*k + i*k + j ;
939  }
940 
941  else if ( iside == 2 ) {
942  // front side.
943  if ( i == 0 ) { return j ; }
944  else if ( i == n-1 ) { return k*k + j ; }
945  else { return 2*k*k + 4*(i-1)*(k-1) + j ; }
946  }
947 
948  else if ( iside == 3 ) {
949  // right side
950  if ( i == 0 ) { return (j+1)*k - 1 ; }
951  else if ( i == n-1 ) { return k*k + (j+1)*k - 1 ; }
952  else { return 2*k*k + 4*(i-1)*(k-1) + (k-1) + j ; }
953  }
954  else if ( iside == 4 ) {
955  // back side.
956  if ( i == 0 ) { return k*k - 1 - j ; } // reversed order
957  else if ( i == n-1 ) { return 2*k*k - 1 - j ; } // reversed order
958  else { return 2*k*k + 4*(i-1)*(k-1) + 2*(k-1) + j ; // normal order
959  }
960  }
961  else if ( iside == 5 ) {
962  // left side
963  if ( i == 0 ) { return k*k - (j+1)*k ; } // reversed order
964  else if ( i == n-1) { return 2*k*k - (j+1)*k ; } // reverded order
965  else {
966  if ( j == k-1 ) { return 2*k*k + 4*(i-1)*(k-1) ; } // special case
967  else { return 2*k*k + 4*(i-1)*(k-1) + 3*(k-1) + j ; } // normal order
968  }
969  }
970 
971  else {
972 
973  std::ostringstream message;
974  message << "Not correct side number: "
975  << GetName() << G4endl
976  << "iside is " << iside << " but should be "
977  << "0,1,2,3,4 or 5" << ".";
978  G4Exception("G4TwistSurface::G4GetNode()", "GeomSolids0002",
979  FatalException, message);
980  }
981  return -1 ; // wrong node
982 }
const G4int n
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4String GetName() const
#define G4endl
Definition: G4ios.hh:61
virtual G4ThreeVector G4VTwistSurface::GetNormal ( const G4ThreeVector xx,
G4bool  isGlobal 
)
pure virtual
virtual G4double G4VTwistSurface::GetSurfaceArea ( )
pure virtual
G4bool G4VTwistSurface::IsAxis0 ( G4int  areacode) const
inline

Referenced by DistanceToBoundary().

G4bool G4VTwistSurface::IsAxis1 ( G4int  areacode) const
inline

Referenced by DistanceToBoundary().

G4bool G4VTwistSurface::IsBoundary ( G4int  areacode,
G4bool  testbitmode = false 
) const
inline
G4bool G4VTwistSurface::IsCorner ( G4int  areacode,
G4bool  testbitmode = false 
) const
inline

Referenced by IsSameBoundary().

G4bool G4VTwistSurface::IsInside ( G4int  areacode,
G4bool  testbitmode = false 
) const
inline
G4bool G4VTwistSurface::IsOutside ( G4int  areacode) const
inline
G4bool G4VTwistSurface::IsSameBoundary ( G4VTwistSurface surface1,
G4int  areacode1,
G4VTwistSurface surface2,
G4int  areacode2 
) const

Definition at line 591 of file G4VTwistSurface.cc.

References ComputeGlobalDirection(), ComputeGlobalPoint(), GetBoundaryParameters(), GetCorner(), IsBoundary(), IsCorner(), and kCarTolerance.

Referenced by DistanceToIn().

593 {
594  //
595  // IsSameBoundary
596  //
597  // checking tool whether two boundaries on different surfaces are same or not.
598  //
599 
600  G4bool testbitmode = true;
601  G4bool iscorner[2] = {IsCorner(areacode1, testbitmode),
602  IsCorner(areacode2, testbitmode)};
603 
604  if (iscorner[0] && iscorner[1]) {
605  // on corner
606  G4ThreeVector corner1 =
607  surface1->ComputeGlobalPoint(surface1->GetCorner(areacode1));
608  G4ThreeVector corner2 =
609  surface2->ComputeGlobalPoint(surface2->GetCorner(areacode2));
610 
611  if ((corner1 - corner2).mag() < kCarTolerance) {
612  return true;
613  } else {
614  return false;
615  }
616 
617  } else if ((IsBoundary(areacode1, testbitmode) && (!iscorner[0])) &&
618  (IsBoundary(areacode2, testbitmode) && (!iscorner[1]))) {
619  // on boundary
620  G4ThreeVector d1, d2, ld1, ld2;
621  G4ThreeVector x01, x02, lx01, lx02;
622  G4int type1, type2;
623  surface1->GetBoundaryParameters(areacode1, ld1, lx01, type1);
624  surface2->GetBoundaryParameters(areacode2, ld2, lx02, type2);
625 
626  x01 = surface1->ComputeGlobalPoint(lx01);
627  x02 = surface2->ComputeGlobalPoint(lx02);
628  d1 = surface1->ComputeGlobalDirection(ld1);
629  d2 = surface2->ComputeGlobalDirection(ld2);
630 
631  if ((x01 - x02).mag() < kCarTolerance &&
632  (d1 - d2).mag() < kCarTolerance) {
633  return true;
634  } else {
635  return false;
636  }
637 
638  } else {
639  return false;
640  }
641 }
G4ThreeVector ComputeGlobalDirection(const G4ThreeVector &lp) const
G4ThreeVector GetCorner(G4int areacode) const
G4bool IsBoundary(G4int areacode, G4bool testbitmode=false) const
G4ThreeVector ComputeGlobalPoint(const G4ThreeVector &lp) const
int G4int
Definition: G4Types.hh:78
virtual void GetBoundaryParameters(const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const
bool G4bool
Definition: G4Types.hh:79
G4bool IsCorner(G4int areacode, G4bool testbitmode=false) const
G4bool G4VTwistSurface::IsValidNorm ( ) const
inline

Definition at line 156 of file G4VTwistSurface.hh.

References fIsValidNorm.

Referenced by G4VTwistedFaceted::DistanceToOut(), and G4TwistedTubs::DistanceToOut().

156 { return fIsValidNorm; }
void G4VTwistSurface::SetAxis ( G4int  i,
const EAxis  axis 
)
inline

Definition at line 168 of file G4VTwistSurface.hh.

References fAxis.

168 { fAxis[i] = axis; }
void G4VTwistSurface::SetBoundary ( const G4int axiscode,
const G4ThreeVector direction,
const G4ThreeVector x0,
const G4int boundarytype 
)
protectedvirtual

Definition at line 834 of file G4VTwistSurface.cc.

References FatalException, G4endl, G4Exception(), sAxis0, sAxis1, sAxisMask, sAxisMax, sAxisMin, and G4VTwistSurface::Boundary::SetFields().

838 {
839  G4int code = (~sAxisMask) & axiscode;
840  if ((code == (sAxis0 & sAxisMin)) ||
841  (code == (sAxis0 & sAxisMax)) ||
842  (code == (sAxis1 & sAxisMin)) ||
843  (code == (sAxis1 & sAxisMax))) {
844 
845  G4int i;
846  G4bool done = false;
847  for (i=0; i<4; i++) {
848  if (fBoundaries[i].IsEmpty()) {
849  fBoundaries[i].SetFields(axiscode, direction,
850  x0, boundarytype);
851  done = true;
852  break;
853  }
854  }
855 
856  if (!done) {
857  G4Exception("G4VTwistSurface::SetBoundary()", "GeomSolids0003",
858  FatalException, "Number of boundary exceeding 4!");
859  }
860  } else {
861  std::ostringstream message;
862  message << "Invalid axis-code." << G4endl
863  << " axiscode = "
864  << std::hex << axiscode << std::dec;
865  G4Exception("G4VTwistSurface::SetBoundary()", "GeomSolids0003",
866  FatalException, message);
867  }
868 }
static const G4int sAxisMask
int G4int
Definition: G4Types.hh:78
static const G4int sAxis1
bool G4bool
Definition: G4Types.hh:79
static const G4int sAxis0
static const G4int sAxisMin
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Definition: inftrees.h:24
void SetFields(const G4int &areacode, const G4ThreeVector &d, const G4ThreeVector &x0, const G4int &boundarytype)
static const G4int sAxisMax
#define G4endl
Definition: G4ios.hh:61
void G4VTwistSurface::SetCorner ( G4int  areacode,
G4double  x,
G4double  y,
G4double  z 
)
protected

Definition at line 729 of file G4VTwistSurface.cc.

References FatalException, G4endl, G4Exception(), sC0Max1Max, sC0Max1Min, sC0Min1Max, sC0Min1Min, sCorner, and CLHEP::Hep3Vector::set().

730 {
731  if ((areacode & sCorner) != sCorner){
732  std::ostringstream message;
733  message << "Area code must represents corner." << G4endl
734  << " areacode " << areacode;
735  G4Exception("G4VTwistSurface::SetCorner()", "GeomSolids0002",
736  FatalException, message);
737  }
738 
739  if ((areacode & sC0Min1Min) == sC0Min1Min) {
740  fCorners[0].set(x, y, z);
741  } else if ((areacode & sC0Max1Min) == sC0Max1Min) {
742  fCorners[1].set(x, y, z);
743  } else if ((areacode & sC0Max1Max) == sC0Max1Max) {
744  fCorners[2].set(x, y, z);
745  } else if ((areacode & sC0Min1Max) == sC0Min1Max) {
746  fCorners[3].set(x, y, z);
747  }
748 }
void set(double x, double y, double z)
static const G4int sC0Min1Max
G4double z
Definition: TRTMaterials.hh:39
static const G4int sC0Min1Min
static const G4int sC0Max1Max
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static const G4int sCorner
#define G4endl
Definition: G4ios.hh:61
static const G4int sC0Max1Min
void G4VTwistSurface::SetNeighbours ( G4VTwistSurface axis0min,
G4VTwistSurface axis1min,
G4VTwistSurface axis0max,
G4VTwistSurface axis1max 
)
inline
virtual G4ThreeVector G4VTwistSurface::SurfacePoint ( G4double  ,
G4double  ,
G4bool  isGlobal = false 
)
pure virtual

Field Documentation

EAxis G4VTwistSurface::fAxis[2]
protected
G4double G4VTwistSurface::fAxisMax[2]
protected
G4double G4VTwistSurface::fAxisMin[2]
protected
G4SurfCurNormal G4VTwistSurface::fCurrentNormal
protected
CurrentStatus G4VTwistSurface::fCurStat
protected
CurrentStatus G4VTwistSurface::fCurStatWithV
protected
G4int G4VTwistSurface::fHandedness
protected
G4bool G4VTwistSurface::fIsValidNorm
protected
G4RotationMatrix G4VTwistSurface::fRot
protected
G4ThreeVector G4VTwistSurface::fTrans
protected
G4double G4VTwistSurface::kCarTolerance
protected
const G4int G4VTwistSurface::sAreaMask = 0XF0000000
static

Definition at line 247 of file G4VTwistSurface.hh.

const G4int G4VTwistSurface::sAxis0 = 0x0000FF00
static
const G4int G4VTwistSurface::sAxis1 = 0x000000FF
static
const G4int G4VTwistSurface::sAxisMask = 0x0000FCFC
static

Definition at line 246 of file G4VTwistSurface.hh.

Referenced by GetBoundaryAxis(), and SetBoundary().

const G4int G4VTwistSurface::sAxisMax = 0x00000202
static
const G4int G4VTwistSurface::sAxisMin = 0x00000101
static
const G4int G4VTwistSurface::sAxisPhi = 0x00001414
static
const G4int G4VTwistSurface::sAxisRho = 0x00001010
static
const G4int G4VTwistSurface::sAxisX = 0x00000404
static

Definition at line 238 of file G4VTwistSurface.hh.

Referenced by G4TwistTrapFlatSide::GetAreaCode(), and GetBoundaryAxis().

const G4int G4VTwistSurface::sAxisY = 0x00000808
static

Definition at line 239 of file G4VTwistSurface.hh.

Referenced by G4TwistTrapFlatSide::GetAreaCode(), and GetBoundaryAxis().

const G4int G4VTwistSurface::sAxisZ = 0x00000C0C
static

Definition at line 240 of file G4VTwistSurface.hh.

Referenced by GetBoundaryAxis().

const G4int G4VTwistSurface::sBoundary = 0x20000000
static
const G4int G4VTwistSurface::sC0Max1Max = 0x40000202
static
const G4int G4VTwistSurface::sC0Max1Min = 0x40000201
static
const G4int G4VTwistSurface::sC0Min1Max = 0x40000102
static

Definition at line 235 of file G4VTwistSurface.hh.

Referenced by DebugPrint(), GetBoundaryLimit(), and SetCorner().

const G4int G4VTwistSurface::sC0Min1Min = 0x40000101
static

Definition at line 232 of file G4VTwistSurface.hh.

Referenced by DebugPrint(), GetBoundaryLimit(), and SetCorner().

const G4int G4VTwistSurface::sCorner = 0x40000000
static
const G4int G4VTwistSurface::sInside = 0x10000000
static
const G4int G4VTwistSurface::sOutside = 0x00000000
static
const G4int G4VTwistSurface::sSizeMask = 0x00000303
static

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