//#####################################################################
// Copyright 2009, Avi Robinson-Mosher, Craig Schroeder.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class EDGE_INDEX
//#####################################################################
#ifndef __EDGE_INDEX__
#define __EDGE_INDEX__

#include <Core/Vectors/VECTOR.h>
namespace PhysBAM{

template<int d>
class EDGE_INDEX
{
    typedef VECTOR<int,d> IV;
public:
    EDGE_INDEX()
    {}

    EDGE_INDEX(int axis_input,const IV& index_input)
        :axis(axis_input),index(index_input)
    {}

    int axis;
    IV index;

    bool operator==(const EDGE_INDEX& fi) const
    {return axis==fi.axis && index==fi.index;}

    bool operator!=(const EDGE_INDEX& fi) const
    {return !(*this==fi);}

    IV First_Node_Index() const
    {return index;}

    IV Second_Node_Index() const
    {IV i(index);i(axis)++;return i;}

    template<class RW> void Read(UNTYPED_ISTREAM<RW>& input);
    template<class RW> void Write(UNTYPED_OSTREAM<RW>& output) const;
};
template<int d> struct HASH_REDUCE<EDGE_INDEX<d> >
{static int H(const EDGE_INDEX<d>& key){return int_hash(key.axis,HASH_REDUCE<VECTOR<int,d> >::H(key.index));}};
}
#endif
