#include
#include "math/math_defs.hpp"
namespace internal
{
#define def_subface_func_list(func_name) \
static constexpr std::array(surface_type::max_count)> func_name##_func_list = { \
&plane_function_impl::func_name, \
&sphere_function_impl::func_name, \
&cylinder_function_impl::func_name, \
nullptr}
def_subface_func_list(eval_sdf);
def_subface_func_list(eval_sdf_grad);
def_subface_func_list(map_param_to_point);
def_subface_func_list(map_point_to_param);
def_subface_func_list(eval_du_constraint);
def_subface_func_list(eval_dv_constraint);
def_subface_func_list(eval_intersection);
#undef def_subface_func_list
#define def_export_get_function_ptr_impl(func_name) \
PE_API func_name##_ptr_t get_##func_name##_ptr(surface_type type) \
{ \
return func_name##_func_list[static_cast>(type)]; \
}
def_export_get_function_ptr_impl(eval_sdf);
def_export_get_function_ptr_impl(eval_sdf_grad);
def_export_get_function_ptr_impl(map_param_to_point);
def_export_get_function_ptr_impl(map_point_to_param);
def_export_get_function_ptr_impl(eval_du_constraint);
def_export_get_function_ptr_impl(eval_dv_constraint);
def_export_get_function_ptr_impl(eval_intersection);
#undef def_export_get_function_ptr_impl
PE_API double get_cycle(surface_type type)
{
switch (type) {
case surface_type::sphere: return two_pi;
case surface_type::cylinder: return two_pi;
case surface_type::cone: return sqrt_2 * pi;
default: return std::numeric_limits::infinity();
}
}
} // namespace internal