211 G4bool IsParallel = false ;
212 G4bool IsConverged = false ;
255 G4bool tmpisvalid = false ;
257 std::vector<Intersection> xbuf ;
272 if ( std::fabs(p.
z()) <= L )
279 *(v.
y()*std::cos(phi) - v.
x()*std::sin(phi))))
289 xbuf.push_back(xbuftmp) ;
298 areacode[0], isvalid[0],
299 0, validate, &gp, &gv);
346 G4cout <<
"coef = " << c[0] <<
" " 359 for (
G4int i = 0 ; i<num ; i++ )
364 G4cout <<
"Solution " << i <<
" : " << srd[i] <<
G4endl ;
366 phi = std::fmod(srd[i] , pihalf) ;
378 xbuf.push_back(xbuftmp) ;
381 G4cout <<
"solution " << i <<
" = " << phi <<
" , " << u <<
G4endl ;
396 for (
size_t k = 0 ; k<xbuf.size() ; k++ )
399 G4cout <<
"Solution " << k <<
" : " 400 <<
"reconstructed phiR = " << xbuf[k].phi
401 <<
", uR = " << xbuf[k].u <<
G4endl ;
407 IsConverged = false ;
409 for (
G4int i = 1 ; i<maxint ; i++ )
412 surfacenormal =
NormAng(phi,u) ;
415 deltaX = ( tmpxx - xxonsurface ).mag() ;
416 theta = std::fabs(std::acos(v*surfacenormal) - pihalf) ;
428 G4cout <<
"Step i = " << i <<
", distance = " << tmpdist
429 <<
", " << deltaX <<
G4endl ;
437 G4cout <<
"approximated phi = " << phi <<
", u = " << u <<
G4endl ;
440 if ( deltaX <= factor*ctol ) { IsConverged = true ; break ; }
444 if ( std::fabs(tmpdist)<ctol ) { tmpdist = 0 ; }
447 G4cout <<
"refined solution " << phi <<
" , " << u <<
G4endl ;
461 if (tmpdist >= 0) tmpisvalid =
true;
469 if (tmpdist >= 0) { tmpisvalid =
true; }
474 G4Exception(
"G4TwistTrapAlphaSide::DistanceToSurface()",
476 "Feature NOT implemented !");
488 xbuf[k].distance = tmpdist ;
489 xbuf[k].areacode = tmpareacode ;
490 xbuf[k].isvalid = tmpisvalid ;
497 G4cout << G4endl <<
"list xbuf after sorting : " <<
G4endl ;
509 G4int nxxtmp = xbuf.size() ;
511 if ( nxxtmp<2 || IsParallel )
527 xbuf.push_back(xbuftmp) ;
542 xbuf.push_back(xbuftmp) ;
544 for (
size_t k = nxxtmp ; k<xbuf.size() ; k++ )
548 G4cout <<
"Solution " << k <<
" : " 549 <<
"reconstructed phiR = " << xbuf[k].phi
550 <<
", uR = " << xbuf[k].u <<
G4endl ;
556 IsConverged = false ;
558 for (
G4int i = 1 ; i<maxint ; i++ )
561 surfacenormal =
NormAng(phi,u) ;
563 deltaX = ( tmpxx - xxonsurface ).mag();
564 theta = std::fabs(std::acos(v*surfacenormal) - pihalf);
575 G4cout <<
"Step i = " << i <<
", distance = " << tmpdist
576 <<
", " << deltaX << G4endl
577 <<
"X = " << tmpxx <<
G4endl ;
584 G4cout <<
"approximated phi = " << phi <<
", u = " << u <<
G4endl ;
587 if ( deltaX <= factor*ctol ) { IsConverged = true ; break ; }
591 if ( std::fabs(tmpdist)<ctol ) { tmpdist = 0; }
594 G4cout <<
"refined solution " << phi <<
" , " << u <<
G4endl ;
608 if (tmpdist >= 0) { tmpisvalid =
true; }
616 if (tmpdist >= 0) { tmpisvalid =
true; }
621 G4Exception(
"G4TwistedBoxSide::DistanceToSurface()",
623 "Feature NOT implemented !");
635 xbuf[k].distance = tmpdist ;
636 xbuf[k].areacode = tmpareacode ;
637 xbuf[k].isvalid = tmpisvalid ;
650 G4cout << G4endl <<
"list xbuf after sorting : " <<
G4endl ;
656 for (
size_t i = 0 ; i<xbuf.size() ; i++ )
658 distance[i] = xbuf[i].distance;
660 areacode[i] = xbuf[i].areacode ;
661 isvalid[i] = xbuf[i].isvalid ;
664 isvalid[i], nxx, validate, &gp, &gv);
666 G4cout <<
"element Nr. " << i
667 <<
", local Intersection = " << xbuf[i].xx
668 <<
", distance = " << xbuf[i].distance
669 <<
", u = " << xbuf[i].u
670 <<
", phi = " << xbuf[i].phi
671 <<
", isvalid = " << xbuf[i].isvalid
679 G4cout << nxx <<
" possible physical solutions found" <<
G4endl ;
680 for (
G4int k= 0 ; k< nxx ; k++ )
682 G4cout <<
"global intersection Point found: " << gxx[k] <<
G4endl ;
void set(double x, double y, double z)
static const G4double kInfinity
void GetPhiUAtX(G4ThreeVector p, G4double &phi, G4double &u)
G4double GetDistance(G4int i) const
G4ThreeVector ComputeGlobalPoint(const G4ThreeVector &lp) const
G4int GetAreacode(G4int i) const
G4double DistanceToPlaneWithV(const G4ThreeVector &p, const G4ThreeVector &v, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
static const G4int sOutside
G4ThreeVector NormAng(G4double phi, G4double u)
G4GLOB_DLL std::ostream G4cout
G4bool IsValid(G4int i) const
void SetCurrentStatus(G4int i, G4ThreeVector &xx, G4double &dist, G4int &areacode, G4bool &isvalid, G4int nxx, EValidate validate, const G4ThreeVector *p, const G4ThreeVector *v=0)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual G4ThreeVector SurfacePoint(G4double phi, G4double u, G4bool isGlobal=false)
G4bool IsOutside(G4int areacode) const
static const G4double factor
G4ThreeVector GetXX(G4int i) const
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &gp) const
G4bool EqualIntersection(const Intersection &a, const Intersection &b)
virtual G4int GetAreaCode(const G4ThreeVector &xx, G4bool withTol=true)
G4ThreeVector ComputeLocalDirection(const G4ThreeVector &gp) const
G4bool IsInside(G4int areacode, G4bool testbitmode=false) const
G4bool DistanceSort(const Intersection &a, const Intersection &b)
G4int FindRoots(G4double *op, G4int degree, G4double *zeror, G4double *zeroi)
CurrentStatus fCurStatWithV
void ResetfDone(EValidate validate, const G4ThreeVector *p, const G4ThreeVector *v=0)