Logo ROOT  
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 
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 }
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TAttBBox::BBoxClear
void BBoxClear()
Remove BBox information.
Definition: TAttBBox.cxx:54
Float_t
float Float_t
Definition: RtypesCore.h:57
TAttBBox::BBoxZero
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
x
Double_t x[n]
Definition: legend1.C:17
TAttBBox::AssertBBoxExtents
void AssertBBoxExtents(Float_t epsilon=0.005)
Assert extents of all sides of the bounding-box are at least epsilon.
Definition: TAttBBox.cxx:62
b
#define b(i)
Definition: RSha256.hxx:100
TAttBBox::fBBox
Float_t * fBBox
Definition: TAttBBox.h:20
TAttBBox
Helper for management of bounding-box information.
Definition: TAttBBox.h:18
TAttBBox.h
epsilon
REAL epsilon
Definition: triangle.c:617
TAttBBox::BBoxInit
void BBoxInit(Float_t infinity=1e6)
Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
Definition: TAttBBox.cxx:29
y
Double_t y[n]
Definition: legend1.C:17
TAttBBox::SetupBBoxCube
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
int