//#####################################################################
// Copyright 2004, Eran Guendelman.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class QT_SPLIT_OBJECT
//##################################################################### 
#ifndef __QT_SPLIT_OBJECT__
#define __QT_SPLIT_OBJECT__

#include <Core/Geometry_Particles/GEOMETRY_PARTICLES.h>
#include <Core/Meshes/MESHES_FORWARD.h>
#include <Core/Viewer/VIEWER_OPTIONS.h>
#include "QT_COMPONENT.h"
#include <memory>

namespace PhysBAM
{
template<class OBJ> class QT_OBJECT;

template<class TV,class TYPE>
class QT_SPLIT_OBJECT:public QT_COMPONENT
{
public:
    typedef typename TV::SCALAR T;
    typedef typename TYPE::MESH MESH;
    typedef MESH_OPTIONS<TYPE::dimension> OPT;
protected:
private:
    std::shared_ptr<QT_OBJECT<TYPE>> obj;
    std::shared_ptr<QT_OBJECT<MESH>> mesh_obj;
    std::shared_ptr<QT_OBJECT<GEOMETRY_PARTICLES<TV>>> particle_obj;
    TYPE* ptr=nullptr;
    bool split=false;
    
public:
    bool valid=false;

    QT_SPLIT_OBJECT(QT_WORLD& world,const std::string& name,const std::string& file);
    QT_SPLIT_OBJECT(QT_WORLD& world,const std::string& name,const std::string& mesh_file,const std::string& part_file);
    virtual ~QT_SPLIT_OBJECT();

    void Read() override;
    void Invalidate(bool invalidate_common) override;
    RANGE<FV> Bounding_Box() override;

    const TYPE& Obj() const {return *ptr;}
    TYPE& Obj() {return *ptr;}
};
}

#endif
