extract explicit mesh with topology information from implicit surfaces with boolean operations, and do surface/volume integrating on them.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

48 lines
2.1 KiB

#include <base/subface.hpp>
#include "math/math_defs.hpp"
namespace internal
{
#define def_subface_func_list(func_name) \
static constexpr std::array<func_name##_ptr_t, static_cast<uint8_t>(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<std::underlying_type_t<surface_type>>(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<double>::infinity();
}
}
} // namespace internal