ROOT  6.06/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 Helper for management of bounding-box information.
17 Optionally used by classes that use direct OpenGL rendering
18 via `<Class>GL class`.
19 */
20 
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 /// Allocate and prepare for incremental filling.
25 
26 void TAttBBox::BBoxInit(Float_t infinity)
27 {
28  if (fBBox == 0) fBBox = new Float_t[6];
29 
30  fBBox[0] = infinity; fBBox[1] = -infinity;
31  fBBox[2] = infinity; fBBox[3] = -infinity;
32  fBBox[4] = infinity; fBBox[5] = -infinity;
33 }
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /// Create cube of volume (2*epsilon)^3 at (x,y,z).
37 /// epsilon is zero by default.
38 
40 {
41  if (fBBox == 0) fBBox = new Float_t[6];
42 
43  fBBox[0] = x - epsilon; fBBox[1] = x + epsilon;
44  fBBox[2] = y - epsilon; fBBox[3] = y + epsilon;
45  fBBox[4] = z - epsilon; fBBox[5] = z + epsilon;
46 }
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 /// Remove BBox information.
50 
52 {
53  delete [] fBBox; fBBox = 0;
54 }
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Assert extents of all sides of the bounding-box are at least epsilon.
58 
60 {
61  for (Int_t i=0; i<6; i+=2) {
62  if (fBBox[i+1] - fBBox[i] < epsilon) {
63  Float_t b = 0.5*(fBBox[i] + fBBox[i+1]);
64  fBBox[i] = b - 0.5*epsilon;
65  fBBox[i+1] = b + 0.5*epsilon;
66  }
67  }
68 }
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// Setup bounding box as cube with given extent and center position.
72 
74 {
75  BBoxZero(extent, x, y, z);
76 }
float Float_t
Definition: RtypesCore.h:53
int Int_t
Definition: RtypesCore.h:41
Float_t * fBBox
Definition: TAttBBox.h:22
Double_t x[n]
Definition: legend1.C:17
ClassImp(TAttBBox) void TAttBBox
Allocate and prepare for incremental filling.
Definition: TAttBBox.cxx:21
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:39
const Double_t infinity
Definition: CsgOps.cxx:85
void BBoxClear()
Remove BBox information.
Definition: TAttBBox.cxx:51
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:73
REAL epsilon
Definition: triangle.c:617
Double_t y[n]
Definition: legend1.C:17
typedef void((*Func_t)())
Helper for management of bounding-box information.
Definition: TAttBBox.h:19
void AssertBBoxExtents(Float_t epsilon=0.005)
Assert extents of all sides of the bounding-box are at least epsilon.
Definition: TAttBBox.cxx:59