TAttBBox.h

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TAttBBox.h 26606 2008-12-02 20:36:09Z pcanal $
00002 // Author: Matevz Tadel  7/4/2006
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TAttBBox
00013 #define ROOT_TAttBBox
00014 
00015 #ifndef ROOT_Rtypes
00016 #include "Rtypes.h"
00017 #endif
00018 
00019 class TAttBBox
00020 {
00021 protected:
00022    Float_t*  fBBox;   //! Dynamic Float_t[6] X(min,max), Y(min,max), Z(min,max)
00023 
00024    void BBoxInit(Float_t infinity=1e6);
00025    void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0);
00026    void BBoxClear();
00027 
00028    void BBoxCheckPoint(Float_t x, Float_t y, Float_t z);
00029    void BBoxCheckPoint(const Float_t* p);
00030 
00031    void AssertBBoxExtents(Float_t epsilon=0.005);
00032 
00033    TAttBBox(const TAttBBox& tab) : fBBox(0) {
00034       BBoxInit(); if(tab.fBBox) for(Int_t i=0; i<6; i++) fBBox[i]=tab.fBBox[i];
00035    }
00036    
00037 public:
00038    TAttBBox(): fBBox(0) { }
00039    virtual ~TAttBBox() { BBoxClear(); }
00040 
00041    TAttBBox& operator=(const TAttBBox& tab) 
00042      {if(this!=&tab) {BBoxInit(); if(tab.fBBox) for(Int_t i=0; i<6; i++) fBBox[i]=tab.fBBox[i];}
00043      return *this;}
00044 
00045    Bool_t   GetBBoxOK() const { return fBBox != 0; }
00046    Float_t* GetBBox()         { return fBBox; }
00047    Float_t* AssertBBox()      { if(fBBox == 0) ComputeBBox(); return fBBox; }
00048    void     ResetBBox()       { if(fBBox != 0) BBoxClear(); }
00049 
00050    virtual void ComputeBBox() = 0;
00051 
00052    ClassDef(TAttBBox,1); // Helper for management of bounding-box information
00053 };
00054 
00055 
00056 // Inline methods:
00057 
00058 inline void TAttBBox::BBoxCheckPoint(Float_t x, Float_t y, Float_t z)
00059 {
00060    if(x < fBBox[0]) fBBox[0] = x;   if(x > fBBox[1]) fBBox[1] = x;
00061    if(y < fBBox[2]) fBBox[2] = y;   if(y > fBBox[3]) fBBox[3] = y;
00062    if(z < fBBox[4]) fBBox[4] = z;   if(z > fBBox[5]) fBBox[5] = z;
00063 }
00064 
00065 inline void TAttBBox::BBoxCheckPoint(const Float_t* p)
00066 {
00067    BBoxCheckPoint(p[0], p[1], p[2]);
00068 }
00069 
00070 #endif

Generated on Tue Jul 5 14:10:21 2011 for ROOT_528-00b_version by  doxygen 1.5.1