//#####################################################################
// Copyright 2005-2006, Eran Guendelman, Geoffrey Irving, Jonathan Su.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class PARTICLE_HIERARCHY
//#####################################################################
#ifndef __PARTICLE_HIERARCHY__
#define __PARTICLE_HIERARCHY__

#include <Core/Spatial_Acceleration/BOX_HIERARCHY.h>
#include <Core/Spatial_Acceleration/SPATIAL_ACCELERATION_FORWARD.h>
namespace PhysBAM{

template<class TV,class T_ARRAY>
class PARTICLE_HIERARCHY:public BOX_HIERARCHY<TV>
{
private:
    typedef typename TV::SCALAR T;
public:
    typedef BOX_HIERARCHY<TV> BASE;
    using BASE::Compute;

    const T_ARRAY& X;

    PARTICLE_HIERARCHY(const T_ARRAY& X_input,const bool update_boxes=true)
        :X(X_input)
    {
        Compute(true);
    }
    ~PARTICLE_HIERARCHY() = default;

    void Compute(bool update_boxes)
    {
        ARRAY<RANGE<TV> > boxes(X.Size());
        for(int i=0;i<X.Size();i++)
            boxes(i)=RANGE<TV>(X(i));
        Compute(boxes,update_boxes);
    }
//#####################################################################
};
}
#endif
