/////////////////////////////////////////////////////////////////////
// CLOTH
// Eugene Hsu, MATH 466
// Cloth object definition
/////////////////////////////////////////////////////////////////////

#ifndef CLOTH_H
#define CLOTH_H

#include "particlesys.h"
#include "odesolver.h"
#include "rcpointer.h"

class Cloth
{
public:
    // Make a 1x1 size cloth on a uniform nXn grid
    Cloth(
        int n, 
        double structk, 
        double sheark, 
        double flexk,
        double grav,
        double visc,
        const RcPointer<OdeSolver2> &solver);

    void fix(int i, int j);
    void unfix(int i, int j);
	bool isFixed(int i, int j) const;

    void setPos(int i, int j, const Vec3d &v);
    Vec3d getPos(int i, int j) const;
    
    void draw(bool shade=false) const;
    
    void step(double h, double max_allowed_displacement = 0.0);

	int getSize() const { return _n; }

    double max_displacement();
    
private:
    int _n;
    RcPointer<ParticleSys> _ps;
    
};

#endif

