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.
46 lines
1.4 KiB
46 lines
1.4 KiB
1 year ago
|
#pragma once
|
||
|
|
||
|
#include "assert.hpp"
|
||
|
#include "discretization_helpers.hpp"
|
||
|
#include "FillInterior_fwd.hpp"
|
||
|
|
||
|
namespace meshless {
|
||
|
template<typename contains_func>
|
||
|
void fillInteriorWithDensity(const OccShape& shape, DomainDiscretization<Eigen::Vector3d>& domain, const std::function<double(Eigen::Vector3d)>& 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<double, 3>::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";
|
||
|
}
|
||
|
|
||
|
};
|