Logo ROOT   6.08/07
Reference Guide
TAttBBox.h
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 #ifndef ROOT_TAttBBox
13 #define ROOT_TAttBBox
14 
15 #ifndef ROOT_Rtypes
16 #include "Rtypes.h"
17 #endif
18 
19 class TAttBBox
20 {
21 protected:
22  Float_t* fBBox; //! Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
23 
24  void BBoxInit(Float_t infinity=1e6);
25  void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0);
26  void BBoxClear();
27 
29  void BBoxCheckPoint(const Float_t* p);
30 
31  void AssertBBoxExtents(Float_t epsilon=0.005);
32 
33  TAttBBox(const TAttBBox& tab) : fBBox(0) {
34  BBoxInit(); if(tab.fBBox) for(Int_t i=0; i<6; i++) fBBox[i]=tab.fBBox[i];
35  }
36 
37 public:
38  TAttBBox(): fBBox(0) { }
39  virtual ~TAttBBox() { BBoxClear(); }
40 
42  {if(this!=&tab) {BBoxInit(); if(tab.fBBox) for(Int_t i=0; i<6; i++) fBBox[i]=tab.fBBox[i];}
43  return *this;}
44 
45  Bool_t GetBBoxOK() const { return fBBox != 0; }
46  Float_t* GetBBox() { return fBBox; }
47  Float_t* AssertBBox() { if(fBBox == 0) ComputeBBox(); return fBBox; }
48  void ResetBBox() { if(fBBox != 0) BBoxClear(); }
49 
50  void SetupBBoxCube(Float_t extent, Float_t x, Float_t y, Float_t z);
51 
52  virtual void ComputeBBox() = 0;
53 
54  ClassDef(TAttBBox,1); // Helper for management of bounding-box information
55 };
56 
57 
58 // Inline methods:
59 
61 {
62  if(x < fBBox[0]) fBBox[0] = x;
63  if(x > fBBox[1]) fBBox[1] = x;
64  if(y < fBBox[2]) fBBox[2] = y;
65  if(y > fBBox[3]) fBBox[3] = y;
66  if(z < fBBox[4]) fBBox[4] = z;
67  if(z > fBBox[5]) fBBox[5] = z;
68 }
69 
70 inline void TAttBBox::BBoxCheckPoint(const Float_t* p)
71 {
72  BBoxCheckPoint(p[0], p[1], p[2]);
73 }
74 
75 #endif
TAttBBox & operator=(const TAttBBox &tab)
Definition: TAttBBox.h:41
float Float_t
Definition: RtypesCore.h:53
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Float_t * fBBox
Definition: TAttBBox.h:22
Bool_t GetBBoxOK() const
Definition: TAttBBox.h:45
void BBoxCheckPoint(Float_t x, Float_t y, Float_t z)
Definition: TAttBBox.h:60
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void ComputeBBox()=0
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 ResetBBox()
Definition: TAttBBox.h:48
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
virtual ~TAttBBox()
Definition: TAttBBox.h:39
Float_t * GetBBox()
Definition: TAttBBox.h:46
TAttBBox(const TAttBBox &tab)
Definition: TAttBBox.h:33
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
Float_t * AssertBBox()
Definition: TAttBBox.h:47
Helper for management of bounding-box information.
Definition: TAttBBox.h:19
void BBoxInit(Float_t infinity=1e6)
Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
Definition: TAttBBox.cxx:29
void AssertBBoxExtents(Float_t epsilon=0.005)
Assert extents of all sides of the bounding-box are at least epsilon.
Definition: TAttBBox.cxx:62
TAttBBox()
Definition: TAttBBox.h:38