CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Fireworks/Vertices/src/TEveEllipsoid.cc

Go to the documentation of this file.
00001 #include "Fireworks/Vertices/interface/TEveEllipsoid.h"
00002 #include "TEveTrans.h"
00003 #include "TEveProjectionManager.h"
00004 #include "TMath.h"
00005 
00006 //______________________________________________________________________________
00007 TEveEllipsoid::TEveEllipsoid(const Text_t* n, const Text_t* t) :
00008    TEveShape(n, t)
00009 {
00010    // Constructor.
00011 }
00012 
00013 //______________________________________________________________________________
00014 void TEveEllipsoid::ComputeBBox()
00015 {
00016    // Compute bounding-box of the data.
00017 
00018    BBoxInit();
00019 
00020    Float_t a = TMath::Max(TMath::Max(TMath::Abs(fExtent3D[0]), TMath::Abs(fExtent3D[1])), TMath::Abs(fExtent3D[2]));
00021 
00022    fBBox[0] = -a +fPos[0];
00023    fBBox[1] =  a +fPos[0];
00024 
00025    fBBox[2] = -a +fPos[1];
00026    fBBox[3] =  a +fPos[1];
00027 
00028    fBBox[4] = -a +fPos[2];
00029    fBBox[5] =  a +fPos[2];
00030 }
00031 
00032 //______________________________________________________________________________
00033 TClass* TEveEllipsoid::ProjectedClass(const TEveProjection*) const
00034 {
00035    // Virtual from TEveProjectable, returns TEveEllipsoidProjected class.
00036 
00037    return TEveEllipsoidProjected::Class();
00038 }
00039 
00040 //==============================================================================
00041 // TEveEllipsoidProjected
00042 //==============================================================================
00043 
00044 //______________________________________________________________________________
00045 //
00046 // Projection of TEveEllipsoid.
00047 
00048 //______________________________________________________________________________
00049 TEveEllipsoidProjected::TEveEllipsoidProjected(const char* n, const char* t) :
00050    TEveShape(n, t)
00051 {
00052    // Constructor.
00053 }
00054 
00055 //______________________________________________________________________________
00056 TEveEllipsoidProjected::~TEveEllipsoidProjected()
00057 {
00058    // Destructor.
00059 }
00060 
00061 //______________________________________________________________________________
00062 void TEveEllipsoidProjected::ComputeBBox()
00063 {
00064    // Compute bounding-box, virtual from TAttBBox.
00065 
00066    BBoxInit();
00067    
00068 
00069    TEveEllipsoid    *e3d = dynamic_cast<TEveEllipsoid*>(fProjectable);
00070 
00071    //printf("project bbox  %p\n", (void*)e3d->GetBBox());
00072    if ( e3d ) {
00073       TEveProjection *proj = GetManager()->GetProjection();
00074       Float_t a = TMath::Max(TMath::Max(TMath::Abs(e3d->RefExtent3D()[0]), TMath::Abs(e3d->RefExtent3D()[1])), TMath::Abs(e3d->RefExtent3D()[2]));
00075       float* p = e3d->RefPos().Arr(); 
00076       float b[] = {-a + p[0], a + p[0], -a + p[1], a + p[1], -a + p[2], a + p[2] };
00077       TEveVector v;
00078       v.Set(b[0],b[2], b[4]); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00079       v.Set(b[1],b[2], b[4]); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00080       v.Set(b[0],b[3], b[4]); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00081       v.Set(b[1],b[3], b[4]); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00082       v.Set(b[0],b[2], b[5]); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00083       v.Set(b[1],b[2], b[5]); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00084       v.Set(b[0],b[3], b[5]); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00085       v.Set(b[1],b[3], b[5]); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00086 
00087       // for Z dimesion
00088       fBBox[4] -= a;
00089       fBBox[5] += a;
00090 
00091    }
00092    // printf("(%f, %f) (%f, %f) (%f, %f)\n",fBBox[0],fBBox[1],fBBox[2],fBBox[3],fBBox[4],fBBox[5] );
00093 }
00094 
00095 //______________________________________________________________________________
00096 void TEveEllipsoidProjected::SetDepthLocal(Float_t d)
00097 {
00098    // This is virtual method from base-class TEveProjected.
00099 
00100    SetDepthCommon(d, this, fBBox);
00101 }
00102 
00103 //______________________________________________________________________________
00104 void TEveEllipsoidProjected::SetProjection(TEveProjectionManager* mng, TEveProjectable* model)
00105 {
00106    // This is virtual method from base-class TEveProjected.
00107 
00108    TEveProjected::SetProjection(mng, model);
00109    CopyVizParams(dynamic_cast<TEveElement*>(model));
00110 }
00111 
00112 //______________________________________________________________________________
00113 void TEveEllipsoidProjected::UpdateProjection()
00114 {
00115    // Override from abstract function.
00116 }