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