#pragma once #include "assert.hpp" #include "discretization_helpers.hpp" #include "FillInterior_fwd.hpp" namespace meshless { template void fillInteriorWithDensity(const OccShape& shape, DomainDiscretization& domain, const std::function& h, KDTreeMutable& search, contains_func& containsFunc, int type) { if(type == 0) type = 1; std::mt19937 gen(shape.seed_); std::cout << "Filling the domain interior...\n"; int curNode = 0; int endNode = domain.size(); search.insert(domain.positions()); while((curNode < endNode) && (endNode < shape.max_points_interior)) { std::cout << "CurNode/EndNode: " << curNode << "/" << endNode << '\n'; auto p = domain.pos(curNode); double r = h(p); assert_msg(r > 0, "Nodal spacing radius should be > 0, got %g.", r); auto candidates = SphereDiscretization::construct(r, shape.n_samples, gen); for(const auto& f : candidates) { auto node = p + f; if(!containsFunc(node))continue; if(search.existsPointInSphere(node, r * shape.zeta)) { continue; } domain.addInternalNode(node, type); search.insert(node); endNode++; } curNode++; } if(endNode >= shape.max_points_interior) { std::cerr << "Maximum number of points reached, fill may be incomplete." << std::endl; } std::cout << "Filling the domain interior done!\n"; } };