14#include <lagrange/Logger.h>
17#include <lagrange/utils/warnoff.h>
18#include <openvdb/openvdb.h>
19#include <openvdb/tools/VolumeToSpheres.h>
20#include <lagrange/utils/warnon.h>
39template <
typename Gr
idType,
typename Derived>
40void fill_with_spheres(
42 Eigen::PlainObjectBase<Derived>& spheres,
44 bool overlapping =
false)
46 openvdb::initialize();
48 using Scalar =
typename Derived::Scalar;
49 using RowVector4s = Eigen::Matrix<float, 1, 4>;
51 if (max_spheres <= 0) {
52 logger().warn(
"Max spheres needs to be >= 1.");
56 const openvdb::Vec2i sphere_count(1, max_spheres);
58 std::vector<openvdb::Vec4s> points;
59 openvdb::tools::fillWithSpheres(grid, points, sphere_count, overlapping);
61 spheres.resize(points.size(), 4);
63 for (
size_t i = 0; i < points.size(); ++i) {
64 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.