Logo ROOT   6.10/09
Reference Guide
TAttBBox.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Matevz Tadel 7/4/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, 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 
13 #include "TAttBBox.h"
14 
15 /** \class TAttBBox
16 \ingroup Base
17 \ingroup GraphicsAtt
18 
19 Helper for management of bounding-box information.
20 Optionally used by classes that use direct OpenGL rendering
21 via `<Class>GL class`.
22 */
23 
25 
26 ////////////////////////////////////////////////////////////////////////////////
27 /// Allocate and prepare for incremental filling.
28 
29 void TAttBBox::BBoxInit(Float_t infinity)
30 {
31  if (fBBox == 0) fBBox = new Float_t[6];
32 
33  fBBox[0] = infinity; fBBox[1] = -infinity;
34  fBBox[2] = infinity; fBBox[3] = -infinity;
35  fBBox[4] = infinity; fBBox[5] = -infinity;
36 }
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Create cube of volume (2*epsilon)^3 at (x,y,z).
40 /// epsilon is zero by default.
41 
43 {
44  if (fBBox == 0) fBBox = new Float_t[6];
45 
46  fBBox[0] = x - epsilon; fBBox[1] = x + epsilon;
47  fBBox[2] = y - epsilon; fBBox[3] = y + epsilon;
48  fBBox[4] = z - epsilon; fBBox[5] = z + epsilon;
49 }
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// Remove BBox information.
53 
55 {
56  delete [] fBBox; fBBox = 0;
57 }
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 /// Assert extents of all sides of the bounding-box are at least epsilon.
61 
63 {
64  for (Int_t i=0; i<6; i+=2) {
65  if (fBBox[i+1] - fBBox[i] < epsilon) {
66  Float_t b = 0.5*(fBBox[i] + fBBox[i+1]);
67  fBBox[i] = b - 0.5*epsilon;
68  fBBox[i+1] = b + 0.5*epsilon;
69  }
70  }
71 }
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 /// Setup bounding box as cube with given extent and center position.
75 
77 {
78  BBoxZero(extent, x, y, z);
79 }
float Float_t
Definition: RtypesCore.h:53
int Int_t
Definition: RtypesCore.h:41
Float_t * fBBox
Definition: TAttBBox.h:20
Double_t x[n]
Definition: legend1.C:17
void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0)
Create cube of volume (2*epsilon)^3 at (x,y,z).
Definition: TAttBBox.cxx:42
void BBoxClear()
Remove BBox information.
Definition: TAttBBox.cxx:54
void SetupBBoxCube(Float_t extent, Float_t x, Float_t y, Float_t z)
Setup bounding box as cube with given extent and center position.
Definition: TAttBBox.cxx:76
REAL epsilon
Definition: triangle.c:617
#define ClassImp(name)
Definition: Rtypes.h:336
Double_t y[n]
Definition: legend1.C:17
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
typedef void((*Func_t)())
Helper for management of bounding-box information.
Definition: TAttBBox.h:17
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
void AssertBBoxExtents(Float_t epsilon=0.005)
Assert extents of all sides of the bounding-box are at least epsilon.
Definition: TAttBBox.cxx:62