00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TEveBox.h"
00013 #include "TEveProjectionManager.h"
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 ClassImp(TEveBox);
00032
00033
00034 TEveBox::TEveBox(const char* n, const char* t) :
00035 TEveShape(n, t)
00036 {
00037
00038 }
00039
00040
00041 TEveBox::~TEveBox()
00042 {
00043
00044 }
00045
00046
00047 void TEveBox::SetVertex(Int_t i, Float_t x, Float_t y, Float_t z)
00048 {
00049
00050
00051 fVertices[i][0] = x;
00052 fVertices[i][1] = y;
00053 fVertices[i][2] = z;
00054 ResetBBox();
00055 }
00056
00057
00058 void TEveBox::SetVertex(Int_t i, const Float_t* v)
00059 {
00060
00061
00062 fVertices[i][0] = v[0];
00063 fVertices[i][1] = v[1];
00064 fVertices[i][2] = v[2];
00065 ResetBBox();
00066 }
00067
00068
00069 void TEveBox::SetVertices(const Float_t* vs)
00070 {
00071
00072
00073 memcpy(fVertices, vs, sizeof(fVertices));
00074 ResetBBox();
00075 }
00076
00077
00078
00079
00080 void TEveBox::ComputeBBox()
00081 {
00082
00083
00084 TEveShape::CheckAndFixBoxOrientationFv(fVertices);
00085
00086 BBoxInit();
00087 for (Int_t i=0; i<8; ++i)
00088 {
00089 BBoxCheckPoint(fVertices[i]);
00090 }
00091 }
00092
00093
00094 TClass* TEveBox::ProjectedClass(const TEveProjection*) const
00095 {
00096
00097
00098 return TEveBoxProjected::Class();
00099 }
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 ClassImp(TEveBoxProjected);
00111
00112 Bool_t TEveBoxProjected::fgDebugCornerPoints = kFALSE;
00113
00114
00115 TEveBoxProjected::TEveBoxProjected(const char* n, const char* t) :
00116 TEveShape(n, t),
00117 fBreakIdx(0)
00118 {
00119
00120 }
00121
00122
00123 TEveBoxProjected::~TEveBoxProjected()
00124 {
00125
00126 }
00127
00128
00129 void TEveBoxProjected::ComputeBBox()
00130 {
00131
00132
00133 BBoxInit();
00134 for (vVector2_i i = fPoints.begin(); i != fPoints.end(); ++i)
00135 {
00136 BBoxCheckPoint(i->fX, i->fY, fDepth);
00137 }
00138 }
00139
00140
00141 void TEveBoxProjected::SetDepthLocal(Float_t d)
00142 {
00143
00144
00145 SetDepthCommon(d, this, fBBox);
00146 }
00147
00148
00149 void TEveBoxProjected::SetProjection(TEveProjectionManager* mng, TEveProjectable* model)
00150 {
00151
00152
00153 TEveProjected::SetProjection(mng, model);
00154 CopyVizParams(dynamic_cast<TEveElement*>(model));
00155 }
00156
00157
00158 void TEveBoxProjected::UpdateProjection()
00159 {
00160
00161
00162
00163
00164
00165
00166 TEveBox *box = dynamic_cast<TEveBox*>(fProjectable);
00167
00168 fDebugPoints.clear();
00169
00170
00171 vVector2_t pp[2];
00172 {
00173 TEveProjection *projection = fManager->GetProjection();
00174 TEveTrans *trans = box->PtrMainTrans(kFALSE);
00175
00176 TEveVector pbuf;
00177 for (Int_t i = 0; i < 8; ++i)
00178 {
00179 projection->ProjectPointfv(trans, box->GetVertex(i), pbuf, fDepth);
00180 vVector2_t& ppv = pp[projection->SubSpaceId(pbuf)];
00181
00182 TEveVector2 p(pbuf);
00183 Bool_t overlap = kFALSE;
00184 for (vVector2_i j = ppv.begin(); j != ppv.end(); ++j)
00185 {
00186 if (p.SquareDistance(*j) < TEveProjection::fgEpsSqr)
00187 {
00188 overlap = kTRUE;
00189 break;
00190 }
00191 }
00192 if (! overlap)
00193 {
00194 ppv.push_back(p);
00195 if (fgDebugCornerPoints)
00196 fDebugPoints.push_back(p);
00197 }
00198 }
00199 }
00200
00201 fPoints.clear();
00202 fBreakIdx = 0;
00203
00204 if ( ! pp[0].empty())
00205 {
00206 FindConvexHull(pp[0], fPoints, this);
00207 }
00208 if ( ! pp[1].empty())
00209 {
00210 fBreakIdx = fPoints.size();
00211 FindConvexHull(pp[1], fPoints, this);
00212 }
00213 }
00214
00215
00216 Bool_t TEveBoxProjected::GetDebugCornerPoints()
00217 {
00218
00219
00220 return fgDebugCornerPoints;
00221 }
00222
00223
00224 void TEveBoxProjected::SetDebugCornerPoints(Bool_t d)
00225 {
00226
00227
00228
00229
00230 fgDebugCornerPoints = d;
00231 }