14#include <lagrange/Logger.h>
16#include <openvdb/openvdb.h>
17#include <openvdb/tools/VolumeToSpheres.h>
35template <
typename Gr
idType,
typename Derived>
36void fill_with_spheres(
38 Eigen::PlainObjectBase<Derived>& spheres,
40 bool overlapping =
false)
42 openvdb::initialize();
44 using Scalar =
typename Derived::Scalar;
45 using RowVector4s = Eigen::Matrix<float, 1, 4>;
47 if (max_spheres <= 0) {
48 logger().warn(
"Max spheres needs to be >= 1.");
52 const openvdb::Vec2i sphere_count(1, max_spheres);
54 std::vector<openvdb::Vec4s> points;
55 openvdb::tools::fillWithSpheres(grid, points, sphere_count, overlapping);
57 spheres.resize(points.size(), 4);
59 for (
size_t i = 0; i < points.size(); ++i) {
60 const RowVector4s p(points[i].x(), points[i].y(), points[i].z(), points[i].w());
61 spheres.row(i) << p.template cast<Scalar>();
LA_CORE_API spdlog::logger & logger()
Retrieves the current logger.
Definition: Logger.cpp:40
Main namespace for Lagrange.
Definition: AABBIGL.h:30