Skip to content
Snippets Groups Projects
Commit ddf7fbef authored by Matevz Tadel's avatar Matevz Tadel
Browse files

Generalize TEveProjection::BisectBreakPoint() and use it from

TEveTrackProjected and TEveStraightLineSetProjected.

The old argument signature is still supported but prints a warning that it is
obsolete.


git-svn-id: http://root.cern.ch/svn/root/trunk@39679 27541ba8-7e3a-0410-8455-c3a389f83636
parent 09598724
No related branches found
No related tags found
No related merge requests found
......@@ -132,7 +132,8 @@ public:
virtual Bool_t AcceptSegment(TEveVector&, TEveVector&, Float_t /*tolerance*/) const { return kTRUE; }
virtual Int_t SubSpaceId(const TEveVector&) const { return 0; }
virtual Bool_t IsOnSubSpaceBoundrary(const TEveVector&) const { return kFALSE; }
virtual void BisectBreakPoint(TEveVector& vL, TEveVector& vR, Float_t eps_sqr=1e-10f);
virtual void BisectBreakPoint(TEveVector& vL, TEveVector& vR, Float_t eps_sqr);
virtual void BisectBreakPoint(TEveVector& vL, TEveVector& vR, Bool_t project_result=kFALSE, Float_t depth=0);
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector& vec);
// utils to draw axis
......
......@@ -26,7 +26,6 @@ private:
TEveTrackProjected& operator=(const TEveTrackProjected&); // Not implemented
Int_t GetBreakPointIdx(Int_t start);
void GetBreakPoint(TEveVector& vL, TEveVector& vR);
TEveVector* fOrigPnts; // original track points
......
......@@ -332,15 +332,37 @@ void TEveProjection::SetPastFixZFac(Float_t x)
}
//______________________________________________________________________________
void TEveProjection::BisectBreakPoint(TEveVector& vL, TEveVector& vR, Float_t eps_sqr)
void TEveProjection::BisectBreakPoint(TEveVector& vL, TEveVector& vR, Float_t /*eps_sqr*/)
{
// Find break-point on both sides of the discontinuity.
// They still need to be projected.
// They still need to be projected after the call.
// This is an obsolete version of the method that required manual
// specification of precision -- this lead to (infrequent) infinite loops.
static Bool_t warnedp = kFALSE;
if (!warnedp)
{
Warning("BisectBreakPoint", "call with eps_sqr argument is obsolete - please use the new signature.");
warnedp = kTRUE;
}
BisectBreakPoint(vL, vR, kFALSE);
}
//______________________________________________________________________________
void TEveProjection::BisectBreakPoint(TEveVector& vL, TEveVector& vR,
Bool_t project_result, Float_t depth)
{
// Find break-point on both sides of the discontinuity.
// If project_result is true, the resulting break points will be projected
// with given depth value.
TEveVector vM, vLP, vMP;
while ((vL-vR).Mag2() > eps_sqr)
Int_t n_loops = TMath::CeilNint(TMath::Log2(1e12 * (vL-vR).Mag2() / (0.5f*(vL+vR)).Mag2()) / 2);
while (--n_loops >= 0)
{
vM.Mult(vL+vR, 0.5f);
vM.Mult(vL + vR, 0.5f);
vLP.Set(vL); ProjectPoint(vLP.fX, vLP.fY, vLP.fZ, 0);
vMP.Set(vM); ProjectPoint(vMP.fX, vMP.fY, vMP.fZ, 0);
......@@ -348,13 +370,23 @@ void TEveProjection::BisectBreakPoint(TEveVector& vL, TEveVector& vR, Float_t ep
{
vL.Set(vM);
vR.Set(vM);
return;
break;
}
if (AcceptSegment(vLP, vMP, 0.0f))
{
vL.Set(vM);
}
else
{
vR.Set(vM);
}
}
if (project_result)
{
ProjectVector(vL, depth);
ProjectVector(vR, depth);
}
}
......
......@@ -306,9 +306,7 @@ void TEveStraightLineSetProjected::UpdateProjection()
trans->MultiplyIP(bp1);
trans->MultiplyIP(bp2);
}
proj.BisectBreakPoint(bp1, bp2, 1e-10f);
proj.ProjectVector(bp1, fDepth);
proj.ProjectVector(bp2, fDepth);
proj.BisectBreakPoint(bp1, bp2, kTRUE, fDepth);
AddLine(p1, bp1)->fId = l->fId;
AddLine(bp2, p2)->fId = l->fId;
......
......@@ -78,35 +78,6 @@ void TEveTrackProjected::UpdateProjection()
MakeTrack(kFALSE); // TEveProjectionManager makes recursive calls
}
//______________________________________________________________________________
void TEveTrackProjected::GetBreakPoint(TEveVector& vL, TEveVector& vR)
{
// With bisection calculate break-point vertices.
// Returns projected coordinates.
TEveProjection *projection = fManager->GetProjection();
TEveVector vM, vLP, vMP;
Int_t n_loops = TMath::CeilNint(TMath::Log2(1e12 * (vL-vR).Mag2() / (0.5f*(vL+vR)).Mag2()) / 2);
while (--n_loops >= 0)
{
vM.Mult(vL+vR, 0.5f);
vLP.Set(vL); projection->ProjectPoint(vLP.fX, vLP.fY, vLP.fZ, 0);
vMP.Set(vM); projection->ProjectPoint(vMP.fX, vMP.fY, vMP.fZ, 0);
if (projection->AcceptSegment(vLP, vMP, 0.0f))
{
vL.Set(vM);
}
else
{
vR.Set(vM);
}
}
projection->ProjectVector(vL, fDepth);
projection->ProjectVector(vR, fDepth);
}
//______________________________________________________________________________
Int_t TEveTrackProjected::GetBreakPointIdx(Int_t start)
{
......@@ -197,7 +168,7 @@ void TEveTrackProjected::MakeTrack(Bool_t recurse)
TEveVector vL = fOrigPnts[bR];
TEveVector vR = fOrigPnts[bR + 1];
GetBreakPoint(vL, vR);
projection->BisectBreakPoint(vL, vR, kTRUE, fDepth);
vvec.push_back(vL);
fBreakPoints.push_back((Int_t)vvec.size());
vvec.push_back(vR);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment