Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:35

0001 #include "Fireworks/Vertices/interface/TEveEllipsoid.h"
0002 #include "TEveTrans.h"
0003 #include "TEveProjectionManager.h"
0004 #include "TMath.h"
0005 
0006 //______________________________________________________________________________
0007 TEveEllipsoid::TEveEllipsoid(const Text_t* n, const Text_t* t) : TEveShape(n, t) {
0008   // Constructor.
0009 }
0010 
0011 //______________________________________________________________________________
0012 void TEveEllipsoid::ComputeBBox() {
0013   // Compute bounding-box of the data.
0014 
0015   BBoxInit();
0016 
0017   Float_t a = TMath::Max(TMath::Max(TMath::Abs(fExtent3D[0]), TMath::Abs(fExtent3D[1])), TMath::Abs(fExtent3D[2]));
0018 
0019   fBBox[0] = -a + fPos[0];
0020   fBBox[1] = a + fPos[0];
0021 
0022   fBBox[2] = -a + fPos[1];
0023   fBBox[3] = a + fPos[1];
0024 
0025   fBBox[4] = -a + fPos[2];
0026   fBBox[5] = a + fPos[2];
0027 }
0028 
0029 //______________________________________________________________________________
0030 TClass* TEveEllipsoid::ProjectedClass(const TEveProjection*) const {
0031   // Virtual from TEveProjectable, returns TEveEllipsoidProjected class.
0032 
0033   return TEveEllipsoidProjected::Class();
0034 }
0035 
0036 //==============================================================================
0037 // TEveEllipsoidProjected
0038 //==============================================================================
0039 
0040 //______________________________________________________________________________
0041 //
0042 // Projection of TEveEllipsoid.
0043 
0044 //______________________________________________________________________________
0045 TEveEllipsoidProjected::TEveEllipsoidProjected(const char* n, const char* t) : TEveShape(n, t) {
0046   // Constructor.
0047 }
0048 
0049 //______________________________________________________________________________
0050 TEveEllipsoidProjected::~TEveEllipsoidProjected() {
0051   // Destructor.
0052 }
0053 
0054 //______________________________________________________________________________
0055 void TEveEllipsoidProjected::ComputeBBox() {
0056   // Compute bounding-box, virtual from TAttBBox.
0057 
0058   BBoxInit();
0059 
0060   TEveEllipsoid* e3d = dynamic_cast<TEveEllipsoid*>(fProjectable);
0061 
0062   //printf("project bbox  %p\n", (void*)e3d->GetBBox());
0063   if (e3d) {
0064     TEveProjection* proj = GetManager()->GetProjection();
0065     Float_t a = TMath::Max(TMath::Max(TMath::Abs(e3d->RefExtent3D()[0]), TMath::Abs(e3d->RefExtent3D()[1])),
0066                            TMath::Abs(e3d->RefExtent3D()[2]));
0067     float* p = e3d->RefPos().Arr();
0068     float b[] = {-a + p[0], a + p[0], -a + p[1], a + p[1], -a + p[2], a + p[2]};
0069     TEveVector v;
0070     v.Set(b[0], b[2], b[4]);
0071     proj->ProjectVector(v, fDepth);
0072     BBoxCheckPoint(v);
0073     v.Set(b[1], b[2], b[4]);
0074     proj->ProjectVector(v, fDepth);
0075     BBoxCheckPoint(v);
0076     v.Set(b[0], b[3], b[4]);
0077     proj->ProjectVector(v, fDepth);
0078     BBoxCheckPoint(v);
0079     v.Set(b[1], b[3], b[4]);
0080     proj->ProjectVector(v, fDepth);
0081     BBoxCheckPoint(v);
0082     v.Set(b[0], b[2], b[5]);
0083     proj->ProjectVector(v, fDepth);
0084     BBoxCheckPoint(v);
0085     v.Set(b[1], b[2], b[5]);
0086     proj->ProjectVector(v, fDepth);
0087     BBoxCheckPoint(v);
0088     v.Set(b[0], b[3], b[5]);
0089     proj->ProjectVector(v, fDepth);
0090     BBoxCheckPoint(v);
0091     v.Set(b[1], b[3], b[5]);
0092     proj->ProjectVector(v, fDepth);
0093     BBoxCheckPoint(v);
0094 
0095     // for Z dimesion
0096     fBBox[4] -= a;
0097     fBBox[5] += a;
0098   }
0099   // printf("(%f, %f) (%f, %f) (%f, %f)\n",fBBox[0],fBBox[1],fBBox[2],fBBox[3],fBBox[4],fBBox[5] );
0100 }
0101 
0102 //______________________________________________________________________________
0103 void TEveEllipsoidProjected::SetDepthLocal(Float_t d) {
0104   // This is virtual method from base-class TEveProjected.
0105 
0106   SetDepthCommon(d, this, fBBox);
0107 }
0108 
0109 //______________________________________________________________________________
0110 void TEveEllipsoidProjected::SetProjection(TEveProjectionManager* mng, TEveProjectable* model) {
0111   // This is virtual method from base-class TEveProjected.
0112 
0113   TEveProjected::SetProjection(mng, model);
0114   CopyVizParams(dynamic_cast<TEveElement*>(model));
0115 }
0116 
0117 //______________________________________________________________________________
0118 void TEveEllipsoidProjected::UpdateProjection() {
0119   // Override from abstract function.
0120 }