//#####################################################################
// Copyright 2005-2021, Geoffrey Irving, Michael Lentine, Craig Schroeder, Andrew Selle, Tamar Shinar.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class FACE_LOOKUP_UNIFORM
//#####################################################################
#ifndef __FACE_LOOKUP_UNIFORM__
#define __FACE_LOOKUP_UNIFORM__

#include <Core/Utilities/TYPE_UTILITIES.h>

namespace PhysBAM{
TEST_FOR_MEMBER(Starting_Point_Face);
template<class T_FACE_ARRAY,class IV> decltype(auto)
Starting_Point_Face(const T_FACE_ARRAY& f,const int axis,const IV& face)
{
    constexpr bool has=HAS_MEMBER(T_FACE_ARRAY,Starting_Point_Face);
    if constexpr(has) return f.Starting_Point_Face(axis,face);
    else return f;
}

TEST_FOR_MEMBER(Starting_Point_Cell);
template<class T_FACE_ARRAY,class IV> decltype(auto)
Starting_Point_Cell(const T_FACE_ARRAY& f,const IV& cell)
{
    constexpr bool has=HAS_MEMBER(T_FACE_ARRAY,Starting_Point_Cell);
    if constexpr(has) return f.Starting_Point_Cell(cell);
    else return f;
}

TEST_FOR_MEMBER(Region);
template<class T_FACE_ARRAY> decltype(auto)
Region(const T_FACE_ARRAY& f,const int region)
{
    constexpr bool has=HAS_MEMBER(T_FACE_ARRAY,Region);
    if constexpr(has) return f.Region(region);
    else return f;
}

TEST_FOR_MEMBER(Set_Reference_Point);
template<class T_FACE_ARRAY,class TV> void
Set_Reference_Point(const T_FACE_ARRAY& f,const TV& reference_point)
{
    constexpr bool has=HAS_MEMBER(T_FACE_ARRAY,Set_Reference_Point);
    if constexpr(has) f.Set_Reference_Point(reference_point);
}

TEST_FOR_MEMBER(Clear_Reference_Point);
template<class T_FACE_ARRAY> void
Clear_Reference_Point(const T_FACE_ARRAY& f)
{
    constexpr bool has=HAS_MEMBER(T_FACE_ARRAY,Clear_Reference_Point);
    if constexpr(has) f.Clear_Reference_Point();
}

}
#endif
