Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveBox.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Author: Matevz Tadel, 2010
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TEveBox.h"
14
15/** \class TEveBox
16\ingroup TEve
173D box with arbitrary vertices (cuboid).
18Vertices 0-3 specify the "bottom" rectangle in clockwise direction and
19vertices 4-7 the "top" rectangle so that 4 is above 0, 5 above 1 and so on.
20
21If vertices are provided some local coordinates the transformation matrix
22of the element should also be set (but then the memory usage is increased
23by the size of the TEveTrans object).
24
25Currently only supports 3D -> 2D projections.
26*/
27
28
29////////////////////////////////////////////////////////////////////////////////
30/// Constructor.
31
32TEveBox::TEveBox(const char* n, const char* t) :
33 TEveShape(n, t)
34{
35}
36
37////////////////////////////////////////////////////////////////////////////////
38/// Destructor.
39
43
44////////////////////////////////////////////////////////////////////////////////
45/// Set vertex 'i'.
46
48{
49 fVertices[i][0] = x;
50 fVertices[i][1] = y;
51 fVertices[i][2] = z;
52 ResetBBox();
53}
54
55////////////////////////////////////////////////////////////////////////////////
56/// Set vertex 'i'.
57
59{
60 fVertices[i][0] = v[0];
61 fVertices[i][1] = v[1];
62 fVertices[i][2] = v[2];
63 ResetBBox();
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// Set vertices.
68
70{
71 memcpy(fVertices, vs, sizeof(fVertices));
72 ResetBBox();
73}
74
75
76////////////////////////////////////////////////////////////////////////////////
77/// Compute bounding-box of the data.
78
80{
82
83 BBoxInit();
84 for (Int_t i=0; i<8; ++i)
85 {
87 }
88}
89
90////////////////////////////////////////////////////////////////////////////////
91/// Virtual from TEveProjectable, return TEveBoxProjected class.
92
97
98
99/** \class TEveBoxProjected
100\ingroup TEve
101Projection of TEveBox.
102*/
103
104
106
107////////////////////////////////////////////////////////////////////////////////
108/// Constructor.
109
110TEveBoxProjected::TEveBoxProjected(const char* n, const char* t) :
111 TEveShape(n, t),
112 fBreakIdx(0)
113{
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// Destructor.
118
122
123////////////////////////////////////////////////////////////////////////////////
124/// Compute bounding-box, virtual from TAttBBox.
125
127{
128 BBoxInit();
129 for (vVector2_i i = fPoints.begin(); i != fPoints.end(); ++i)
130 {
131 BBoxCheckPoint(i->fX, i->fY, fDepth);
132 }
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// This is virtual method from base-class TEveProjected.
137
142
143////////////////////////////////////////////////////////////////////////////////
144/// This is virtual method from base-class TEveProjected.
145
151
152////////////////////////////////////////////////////////////////////////////////
153/// Re-project the box. Projects all points and finds 2D convex-hull.
154///
155/// The only issue is with making sure that initial conditions for
156/// hull-search are reasonable -- that is, there are no overlaps with the
157/// first point.
158
160{
161 TEveBox *box = dynamic_cast<TEveBox*>(fProjectable);
162
163 fDebugPoints.clear();
164
165 // Project points in global CS, remove overlaps.
166 vVector2_t pp[2];
167 {
169 TEveTrans *trans = box->PtrMainTrans(kFALSE);
170
172 for (Int_t i = 0; i < 8; ++i)
173 {
174 projection->ProjectPointfv(trans, box->GetVertex(i), pbuf, fDepth);
175 vVector2_t& ppv = pp[projection->SubSpaceId(pbuf)];
176
179 for (vVector2_i j = ppv.begin(); j != ppv.end(); ++j)
180 {
181 if (p.SquareDistance(*j) < TEveProjection::fgEpsSqr)
182 {
183 overlap = kTRUE;
184 break;
185 }
186 }
187 if (! overlap)
188 {
189 ppv.push_back(p);
191 fDebugPoints.push_back(p);
192 }
193 }
194 }
195
196 fPoints.clear();
197 fBreakIdx = 0;
198
199 if ( ! pp[0].empty())
200 {
201 FindConvexHull(pp[0], fPoints, this);
202 }
203 if ( ! pp[1].empty())
204 {
205 fBreakIdx = fPoints.size();
206 FindConvexHull(pp[1], fPoints, this);
207 }
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Get state of fgDebugCornerPoints static.
212
217
218////////////////////////////////////////////////////////////////////////////////
219/// Set state of fgDebugCornerPoints static.
220/// When this is true, points will be drawn at the corners of
221/// computed convex hull.
222
#define d(i)
Definition RSha256.hxx:102
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
const_iterator begin() const
const_iterator end() const
void BBoxCheckPoint(Float_t x, Float_t y, Float_t z)
Definition TAttBBox.h:69
void ResetBBox()
Definition TAttBBox.h:57
void BBoxInit(Float_t infinity=1e6)
Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
Definition TAttBBox.cxx:28
Float_t * fBBox
Definition TAttBBox.h:20
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static Bool_t GetDebugCornerPoints()
Get state of fgDebugCornerPoints static.
Definition TEveBox.cxx:213
static void SetDebugCornerPoints(Bool_t d)
Set state of fgDebugCornerPoints static.
Definition TEveBox.cxx:223
void ComputeBBox() override
Compute bounding-box, virtual from TAttBBox.
Definition TEveBox.cxx:126
static Bool_t fgDebugCornerPoints
Definition TEveBox.h:72
Int_t fBreakIdx
Definition TEveBox.h:67
void SetDepthLocal(Float_t d) override
This is virtual method from base-class TEveProjected.
Definition TEveBox.cxx:138
TEveBoxProjected(const TEveBoxProjected &)
void UpdateProjection() override
Re-project the box.
Definition TEveBox.cxx:159
vVector2_t fDebugPoints
Definition TEveBox.h:68
vVector2_t fPoints
Definition TEveBox.h:66
~TEveBoxProjected() override
Destructor.
Definition TEveBox.cxx:119
static TClass * Class()
void SetProjection(TEveProjectionManager *mng, TEveProjectable *model) override
This is virtual method from base-class TEveProjected.
Definition TEveBox.cxx:146
3D box with arbitrary vertices (cuboid).
Definition TEveBox.h:22
~TEveBox() override
Destructor.
Definition TEveBox.cxx:40
TEveBox(const TEveBox &)
TClass * ProjectedClass(const TEveProjection *p) const override
Virtual from TEveProjectable, return TEveBoxProjected class.
Definition TEveBox.cxx:93
void SetVertices(const Float_t *vs)
Set vertices.
Definition TEveBox.cxx:69
void ComputeBBox() override
Compute bounding-box of the data.
Definition TEveBox.cxx:79
void SetVertex(Int_t i, Float_t x, Float_t y, Float_t z)
Set vertex 'i'.
Definition TEveBox.cxx:47
Float_t fVertices[8][3]
Definition TEveBox.h:30
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition TEveElement.h:36
Abstract base-class for non-linear projectable objects.
TEveProjectable * fProjectable
TEveProjectionManager * fManager
virtual void SetProjection(TEveProjectionManager *mng, TEveProjectable *model)
Sets projection manager and reference in the projectable object.
void SetDepthCommon(Float_t d, TEveElement *el, Float_t *bbox)
Utility function to update the z-values of the bounding-box.
Manager class for steering of projections and managing projected objects.
TEveProjection * GetProjection()
Base-class for non-linear projections.
static Float_t fgEpsSqr
Abstract base-class for 2D/3D shapes.
Definition TEveShape.h:26
std::vector< TEveVector2 >::iterator vVector2_i
Definition TEveShape.h:35
static void CheckAndFixBoxOrientationFv(Float_t box[8][3])
Make sure box orientation is consistent with standard arrangement.
std::vector< TEveVector2 > vVector2_t
Definition TEveShape.h:34
void CopyVizParams(const TEveElement *el) override
Copy visualization parameters from element el.
Definition TEveShape.cxx:69
static Int_t FindConvexHull(const vVector2_t &pin, vVector2_t &pout, TEveElement *caller=nullptr)
Determines the convex-hull of points in pin.
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition TEveTrans.h:27
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16