13 using namespace ROOT::Experimental;
19 REveEllipsoid::REveEllipsoid(
const std::string &n ,
const std::string &t):
20 REveStraightLineSet(n, t)
29 void REveEllipsoid::DrawArch(
float phiStart,
float phiEnd,
float phiStep, REveVector& v0, REveVector& v1, REveVector& v2)
34 while (phi < phiEnd ) {
35 REveVector v = v0 + v1*((float)cos(phi)) + v2*((
float)sin(phi));
40 REveVector v = v0 + v1*((
float)cos(phiEnd)) + v2*((
float)sin(phiEnd));
47 void REveEllipsoid::SetPhiStep(
float ps)
55 void REveEllipsoid::SetBaseVectors(REveVector& v0, REveVector& v1, REveVector& v2)
65 void REveEllipsoid::Outline()
68 DrawArch(0, TMath::TwoPi(),fPhiStep, v0, fV0, fV1);
69 DrawArch(0, TMath::TwoPi(),fPhiStep, v0, fV0, fV2);
70 DrawArch(0, TMath::TwoPi(),fPhiStep, v0, fV1, fV2);
76 TClass* REveEllipsoid::ProjectedClass(
const REveProjection*)
const
78 return TClass::GetClass<REveEllipsoidProjected>();
85 Int_t REveEllipsoid::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
87 Int_t ret = REveStraightLineSet::WriteCoreJson(j, rnr_offset);
89 j[
"fSecondarySelect"] =
false;
101 REveEllipsoidProjected::REveEllipsoidProjected(
const std::string& ,
const std::string& ) :
102 REveStraightLineSetProjected()
109 REveEllipsoidProjected::~REveEllipsoidProjected()
116 void REveEllipsoidProjected::DrawArchProjected(
float phiStart,
float phiEnd,
float phiStep, REveVector& v0, REveVector& v1, REveVector& v2)
118 float phi = phiStart;
121 while (phi < phiEnd ) {
122 REveVector v = v0 + v1*((float)cos(phi)) + v2*((
float)sin(phi));
123 fArchPnts.push_back(f);
124 fArchPnts.push_back(v);
129 REveVector v = v0 + v1*((
float)cos(phiEnd)) + v2*((
float)sin(phiEnd));
130 fArchPnts.push_back(f);
131 fArchPnts.push_back(v);
137 float REveEllipsoidProjected::GetEllipseSurface (const REveVector& v1, const REveVector& v2)
139 REveEllipsoid& orig = *
dynamic_cast<REveEllipsoid*
>(fProjectable);
140 REveTrans * trans = orig.PtrMainTrans(kFALSE);
141 REveProjection& proj = * fManager->GetProjection();
145 TVector3 v0 = trans->GetPos();
146 REveVector p0(v0.x(), v0.y(), v0.z());
147 proj.ProjectPointfv(&trans0, p0, p0, fDepth);
151 proj.ProjectPointfv(trans,v1, p1, fDepth);
155 proj.ProjectPointfv(trans, v2, p2, fDepth);
157 return (p1-p0).Mag2()+ (p2-p0).Mag2();
163 void REveEllipsoidProjected::OutlineProjected()
165 REveEllipsoid& orig = *
dynamic_cast<REveEllipsoid*
>(fProjectable);
169 REveVector v1 = orig.fV0;
170 REveVector v2 = orig.fV1;
171 float d = GetEllipseSurface(v1, v2);
179 REveVector v1 = orig.fV1;
180 REveVector v2 = orig.fV2;
181 float d = GetEllipseSurface(v1, v2);
189 REveVector v1 = orig.fV0;
190 REveVector v2 = orig.fV2;
191 float d = GetEllipseSurface(v1, v2);
199 printf(
"REveEllipsoidProjected::OutlineProjected, printing axes %s\n", GetCName());
205 DrawArchProjected(0, TMath::TwoPi(), orig.fPhiStep, p0, fMV0, fMV1);
211 void REveEllipsoidProjected::BuildRenderData()
213 REveStraightLineSetProjected::BuildRenderData();
221 void REveEllipsoidProjected::SetProjection(REveProjectionManager* mng, REveProjectable* model)
223 REveProjected::SetProjection(mng, model);
224 CopyVizParams(dynamic_cast<REveElement*>(model));
231 void REveEllipsoidProjected::UpdateProjection()
234 REveProjection& proj = * fManager->GetProjection();
235 REveEllipsoid& orig = *
dynamic_cast<REveEllipsoid*
>(fProjectable);
237 REveTrans *trans = orig.PtrMainTrans(kFALSE);
240 Int_t num_lines = (int)fArchPnts.size();
241 if (proj.HasSeveralSubSpaces())
242 num_lines += TMath::Max(1, num_lines/10);
243 fLinePlex.Reset(
sizeof(Line_t), num_lines);
245 for (
size_t i = 0; i <fArchPnts.size(); i+=2 )
247 proj.ProjectPointfv(trans, fArchPnts[i], p1, fDepth);
248 proj.ProjectPointfv(trans, fArchPnts[i+1], p2, fDepth);
250 if (proj.AcceptSegment(p1, p2, 0.1f))
256 REveVector bp1(fArchPnts[i]), bp2(fArchPnts[i+1]);
258 trans->MultiplyIP(bp1);
259 trans->MultiplyIP(bp2);
261 proj.BisectBreakPoint(bp1, bp2, kTRUE, fDepth);
267 if (proj.HasSeveralSubSpaces())
271 fMarkerPlex.Reset(
sizeof(Marker_t), orig.GetMarkerPlex().Size());
272 REveChunkManager::iterator mi(orig.GetMarkerPlex());
276 Marker_t &m = * (Marker_t*) mi();
278 proj.ProjectPointfv(trans, m.fV, pp, fDepth);
279 AddMarker(pp, m.fLineId);
286 Int_t REveEllipsoidProjected::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
288 Int_t ret = REveStraightLineSet::WriteCoreJson(j, rnr_offset);
290 j[
"fSecondarySelect"] =
false;