//#####################################################################
// Copyright 2004-2008, Ron Fedkiw, Unnur Gretarsdottir, Geoffrey Irving, Nipun Kwatra, Andrew Selle.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class TRIANGLE_BENDING_SPRINGS
//#####################################################################
#ifndef __TRIANGLE_BENDING_SPRINGS__
#define __TRIANGLE_BENDING_SPRINGS__

#include <Core/Meshes/MESHES_FORWARD.h>
#include <Core/Meshes/SEGMENT_MESH.h>
#include <Deformables/Forces/LINEAR_SPRINGS.h>
namespace PhysBAM{

template<class T>
class TRIANGLE_BENDING_SPRINGS:public LINEAR_SPRINGS<VECTOR<T,3> >
{
    typedef VECTOR<T,3> TV;
public:
    typedef LINEAR_SPRINGS<TV> BASE;
    using LINEAR_SPRINGS<TV>::Set_Stiffness;using LINEAR_SPRINGS<TV>::Set_Damping;using LINEAR_SPRINGS<TV>::segment_mesh;

    SEGMENT_MESH bending_segment_mesh;

    TRIANGLE_BENDING_SPRINGS(DEFORMABLE_PARTICLES<TV>& particles,TRIANGLE_MESH& triangle_mesh);

    virtual ~TRIANGLE_BENDING_SPRINGS();

//#####################################################################
    void Initialize(TRIANGLE_MESH& triangle_mesh);
//#####################################################################
};

template<class T> TRIANGLE_BENDING_SPRINGS<T>*
Create_Bending_Springs(DEFORMABLE_PARTICLES<VECTOR<T,3> >& particles,TRIANGLE_MESH& triangle_mesh,const T stiffness=2/(1+sqrt((T)2)),
    const T overdamping_fraction=2,const bool limit_time_step_by_strain_rate=true,const T max_strain_per_time_step=.1,const bool use_rest_state_for_strain_rate=true,
    const T restlength_enlargement_fraction=0,const bool verbose=true);

template<class T> TRIANGLE_BENDING_SPRINGS<T>*
Create_Bending_Springs(TRIANGULATED_SURFACE<T>& triangulated_surface,
    const T stiffness=2/(1+sqrt((T)2)),const T overdamping_fraction=2,const bool limit_time_step_by_strain_rate=true,const T max_strain_per_time_step=.1,
    const bool use_rest_state_for_strain_rate=true,const T restlength_enlargement_fraction=0,const bool verbose=true);

}
#endif
