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());
LA_CORE_API spdlog::logger & logger()
Retrieves the current logger.
Definition Logger.cpp:40
@ Scalar
Mesh attribute must have exactly 1 channel.
Definition AttributeFwd.h:56
SurfaceMesh< ToScalar, ToIndex > cast(const SurfaceMesh< FromScalar, FromIndex > &source_mesh, const AttributeFilter &convertible_attributes={}, std::vector< std::string > *converted_attributes_names=nullptr)
Cast a mesh to a mesh of different scalar and/or index type.
Main namespace for Lagrange.