47#include "MR_rect_tree.hpp"
48#include "MR_cell_cplx.hpp"
49#include "MR_rt_to_cc.hpp"
52typedef mjr::tree15b2d5rT tt_t;
53typedef mjr::MRccT5 cc_t;
54typedef mjr::MR_rt_to_cc<tt_t, cc_t> tc_t;
57tt_t::rrpt_t damp_cos_wave(tt_t::drpt_t xvec) {
61 double m = std::exp(-d/4);
62 double s = std::sqrt(d);
63 double z = m*cos(4*s);
64 double dx = -(cos((4 * s)) * s + 4 * sin( (4 * s))) * x * exp(-x * x / 2 - y * y / 2);
65 double dy = -(cos((4 * s)) * s + 4 * sin( (4 * s))) * y * exp(-x * x / 2 - y * y / 2);
66 double dd = -m*(cos(4*s)*s+8*sin(4*s));
76 double nm = std::sqrt(1+dx*dx+dy*dy);
77 return {z, -dx/nm, -dy/nm, 1/nm, dd};
81double circle_sdf(
double r, tt_t::drpt_t xvec) {
90 tt_t tree({-2.1, -2.1},
95 tree.refine_grid(2, damp_cos_wave);
108 tree.refine_leaves_recursive_cell_pred(6, damp_cos_wave, [&tree](tt_t::diti_t i) {
return tree.cell_cross_range_level(i, 4, 0.0); });
111 tree.balance_tree(1, damp_cos_wave);
115 tc_t::construct_geometry_fans(ccplx,
118 {{tc_t::val_src_spc_t::FDOMAIN, 0},
119 {tc_t::val_src_spc_t::FDOMAIN, 1},
120 {tc_t::val_src_spc_t::FRANGE, 0}});
124 ccplx.set_data_name_to_data_idx_lst({{
"x", {0}},
128 {
"NORMALS", {3,4,5}}});
132 ccplx.write_legacy_vtk(
"surface_with_normals.vtk",
"surface_with_normals");
133 ccplx.write_xml_vtk(
"surface_with_normals.vtu",
"surface_with_normals");
134 ccplx.write_ply(
"surface_with_normals.ply",
"surface_with_normals");