TAttBBox.cxx

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TAttBBox.cxx 20877 2007-11-19 11:17:07Z rdm $
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 
00013 #include "TAttBBox.h"
00014 
00015 
00016 //______________________________________________________________________
00017 // TAttBBox
00018 //
00019 // Helper for management of bounding-box information.
00020 // Optionally used by classes that use direct OpenGL rendering
00021 // via <Class>GL class.
00022 
00023 ClassImp(TAttBBox)
00024 
00025 //______________________________________________________________________________
00026 void TAttBBox::BBoxInit(Float_t infinity)
00027 {
00028    // Allocate and prepare for incremental filling.
00029 
00030    if (fBBox == 0) fBBox = new Float_t[6];
00031 
00032    fBBox[0] =  infinity;   fBBox[1] = -infinity;
00033    fBBox[2] =  infinity;   fBBox[3] = -infinity;
00034    fBBox[4] =  infinity;   fBBox[5] = -infinity;
00035 }
00036 
00037 //______________________________________________________________________________
00038 void TAttBBox::BBoxZero(Float_t epsilon, Float_t x, Float_t y, Float_t z)
00039 {
00040    // Create cube of volume (2*epsiolon)^3 at (x,y,z).
00041    // epsilon iz zero by default.
00042 
00043    if (fBBox == 0) fBBox = new Float_t[6];
00044 
00045    fBBox[0] = x - epsilon;   fBBox[1] = x + epsilon;
00046    fBBox[2] = y - epsilon;   fBBox[3] = y + epsilon;
00047    fBBox[4] = z - epsilon;   fBBox[5] = z + epsilon;
00048 }
00049 
00050 //______________________________________________________________________________
00051 void TAttBBox::BBoxClear()
00052 {
00053    // Remove BBox information.
00054 
00055    delete [] fBBox; fBBox = 0;
00056 }
00057 
00058 //______________________________________________________________________________
00059 void TAttBBox::AssertBBoxExtents(Float_t epsilon)
00060 {
00061    // Assert extents of all sides of the bounding-box are at least epsilon.
00062 
00063    for (Int_t i=0; i<6; i+=2) {
00064       if (fBBox[i+1] - fBBox[i] < epsilon) {
00065          Float_t b  = 0.5*(fBBox[i] + fBBox[i+1]);
00066          fBBox[i]   = b - 0.5*epsilon;
00067          fBBox[i+1] = b + 0.5*epsilon;
00068       }
00069    } 
00070 }

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