1 #include "TKDInterpolator.h"
2 #include "TKDNodeInfo.h"
5 #include "TClonesArray.h"
7 ClassImp(TKDInterpolator)
11 //_________________________________________________________________
12 TKDInterpolator::TKDInterpolator() :
15 // Default constructor. To be used with care since in this case building
16 // of data structure is completly left to the user responsability.
19 //_________________________________________________________________
20 TKDInterpolator::TKDInterpolator(Int_t ndim, Int_t npoints) :
21 TKDInterpolatorBase(ndim)
23 // Wrapper constructor for the TKDTree.
25 if(npoints) TKDInterpolatorBase::Build(npoints);
29 //_________________________________________________________________
30 TKDInterpolator::~TKDInterpolator()
34 //_________________________________________________________________
35 void TKDInterpolator::AddNode(const TKDNodeInfo &node)
38 Warning("TKDInterpolator::SetNode()", "Node array not defined.");
42 Int_t n(GetNTNodes());
43 new((*fNodes)[n++]) TKDNodeInfo(node);
46 //_________________________________________________________________
47 Bool_t TKDInterpolator::Build(Int_t npoints, Int_t ndim)
50 return TKDInterpolatorBase::Build(npoints);
53 //_________________________________________________________________
54 Int_t TKDInterpolator::GetNodeIndex(const Float_t *p)
56 // printf("TKDInterpolator::GetNodeIndex() ...\n");
57 // printf("Looking for p[");
58 // for(int i=0; i<fNSize; i++) printf("%f ", p[i]);
61 for(Int_t i=GetNTNodes(); i--;)
62 if(((TKDNodeInfo*)(*fNodes)[i])->Has(p)) return i;
65 for(int i=0; i<fNSize; i++) printf("%f ", p[i]);
66 printf("] outside range.\n");
71 //_________________________________________________________________
72 Bool_t TKDInterpolator::SetNode(Int_t inode, const TKDNodeInfo &ref)
75 Warning("TKDInterpolator::SetNode()", "Node array not defined.");
78 if(inode >= GetNTNodes()){
79 Warning("TKDInterpolator::SetNode()", "Node array defined up to %d.", GetNTNodes());
82 TKDNodeInfo *node = (TKDNodeInfo*)(*fNodes)[inode];