#ifndef ROOT_TGeoVoxelFinder
#define ROOT_TGeoVoxelFinder
#ifndef ROOT_TObject
#include "TObject.h"
#endif
class TGeoVolume;
class TGeoVoxelFinder : public TObject
{
public:
enum EVoxelsType {
kGeoInvalidVoxels = BIT(15),
kGeoRebuildVoxels = BIT(16)
};
protected:
TGeoVolume *fVolume;
Int_t fNcandidates;
Int_t fCurrentVoxel;
Int_t fIbx;
Int_t fIby;
Int_t fIbz;
Int_t fNboxes;
Int_t fNox;
Int_t fNoy;
Int_t fNoz;
Int_t fNex;
Int_t fNey;
Int_t fNez;
Int_t fNx;
Int_t fNy;
Int_t fNz;
Int_t fPriority[3];
Int_t fSlices[3];
Int_t fInc[3];
Double_t fInvdir[3];
Double_t fLimits[3];
Double_t *fBoxes;
Double_t *fXb;
Double_t *fYb;
Double_t *fZb;
Int_t *fOBx;
Int_t *fOBy;
Int_t *fOBz;
Int_t *fOEx;
Int_t *fOEy;
Int_t *fOEz;
Int_t *fExtraX;
Int_t *fExtraY;
Int_t *fExtraZ;
Int_t *fNsliceX;
Int_t *fNsliceY;
Int_t *fNsliceZ;
UChar_t *fIndcX;
UChar_t *fIndcY;
UChar_t *fIndcZ;
Int_t *fCheckList;
UChar_t *fBits1;
TGeoVoxelFinder(const TGeoVoxelFinder&);
TGeoVoxelFinder& operator=(const TGeoVoxelFinder&);
void BuildVoxelLimits();
Int_t *GetExtraX(Int_t islice, Bool_t left, Int_t &nextra) const;
Int_t *GetExtraY(Int_t islice, Bool_t left, Int_t &nextra) const;
Int_t *GetExtraZ(Int_t islice, Bool_t left, Int_t &nextra) const;
Bool_t GetIndices(Double_t *point);
Int_t GetPriority(Int_t iaxis) const {return fPriority[iaxis];}
Int_t GetNcandidates() const {return fNcandidates;}
Int_t *GetValidExtra(Int_t *list, Int_t &ncheck);
Int_t *GetValidExtra(Int_t n1, UChar_t *array1, Int_t *list, Int_t &ncheck);
Int_t *GetValidExtra(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2, Int_t *list, Int_t &ncheck);
Int_t *GetVoxelCandidates(Int_t i, Int_t j, Int_t k, Int_t &ncheck);
Bool_t Intersect(Int_t n1, UChar_t *array1, Int_t &nf, Int_t *result);
Bool_t Intersect(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2,
Int_t &nf, Int_t *result);
Bool_t Intersect(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2,
Int_t n3, UChar_t *array3, Int_t &nf, Int_t *result);
Bool_t IntersectAndStore(Int_t n1, UChar_t *array1);
Bool_t IntersectAndStore(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2);
Bool_t IntersectAndStore(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2,
Int_t n3, UChar_t *array3);
void SortAll(Option_t *option="");
Bool_t Union(Int_t n1, UChar_t *array1);
Bool_t Union(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2);
Bool_t Union(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2,
Int_t n3, UChar_t *array3);
public :
TGeoVoxelFinder();
TGeoVoxelFinder(TGeoVolume *vol);
virtual ~TGeoVoxelFinder();
virtual void CreateCheckList();
void DaughterToMother(Int_t id, Double_t *local, Double_t *master) const;
virtual Double_t Efficiency();
virtual Int_t *GetCheckList(Double_t *point, Int_t &nelem);
Int_t *GetCheckList(Int_t &nelem) const {nelem=fNcandidates; return fCheckList;}
virtual Int_t *GetNextCandidates(Double_t *point, Int_t &ncheck);
virtual void FindOverlaps(Int_t inode) const;
Bool_t IsInvalid() const {return TObject::TestBit(kGeoInvalidVoxels);}
Bool_t NeedRebuild() const {return TObject::TestBit(kGeoRebuildVoxels);}
Double_t *GetBoxes() const {return fBoxes;}
Bool_t IsSafeVoxel(Double_t *point, Int_t inode, Double_t minsafe) const;
virtual void Print(Option_t *option="") const;
void PrintVoxelLimits(Double_t *point) const;
void SetInvalid(Bool_t flag=kTRUE) {TObject::SetBit(kGeoInvalidVoxels, flag);}
void SetNeedRebuild(Bool_t flag=kTRUE) {TObject::SetBit(kGeoRebuildVoxels, flag);}
virtual Int_t *GetNextVoxel(Double_t *point, Double_t *dir, Int_t &ncheck);
virtual void SortCrossedVoxels(Double_t *point, Double_t *dir);
virtual void Voxelize(Option_t *option="");
ClassDef(TGeoVoxelFinder, 3)
};
#endif