2019-11-01 14:31:26 +00:00
|
|
|
#ifndef OPENVDBUTILS_HPP
|
|
|
|
#define OPENVDBUTILS_HPP
|
2019-10-31 13:36:33 +00:00
|
|
|
|
|
|
|
#include <libslic3r/TriangleMesh.hpp>
|
2021-02-10 17:04:16 +00:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
// Suppress warning C4146 in include/gmp.h(2177,31): unary minus operator applied to unsigned type, result still unsigned
|
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable : 4146)
|
|
|
|
#endif // _MSC_VER
|
2019-10-31 13:36:33 +00:00
|
|
|
#include <openvdb/openvdb.h>
|
2021-02-10 17:04:16 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif // _MSC_VER
|
2019-10-31 13:36:33 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2019-11-08 15:51:43 +00:00
|
|
|
inline Vec3f to_vec3f(const openvdb::Vec3s &v) { return Vec3f{v.x(), v.y(), v.z()}; }
|
|
|
|
inline Vec3d to_vec3d(const openvdb::Vec3s &v) { return to_vec3f(v).cast<double>(); }
|
|
|
|
inline Vec3i to_vec3i(const openvdb::Vec3I &v) { return Vec3i{int(v[0]), int(v[1]), int(v[2])}; }
|
|
|
|
|
2020-12-17 12:38:09 +00:00
|
|
|
// Here voxel_scale defines the scaling of voxels which affects the voxel count.
|
|
|
|
// 1.0 value means a voxel for every unit cube. 2 means the model is scaled to
|
|
|
|
// be 2x larger and the voxel count is increased by the increment in the scaled
|
|
|
|
// volume, thus 4 times. This kind a sampling accuracy selection is not
|
|
|
|
// achievable through the Transform parameter. (TODO: or is it?)
|
|
|
|
// The resulting grid will contain the voxel_scale in its metadata under the
|
|
|
|
// "voxel_scale" key to be used in grid_to_mesh function.
|
2021-05-25 16:23:01 +00:00
|
|
|
openvdb::FloatGrid::Ptr mesh_to_grid(const indexed_triangle_set & mesh,
|
2019-11-05 13:48:00 +00:00
|
|
|
const openvdb::math::Transform &tr = {},
|
2021-05-25 16:23:01 +00:00
|
|
|
float voxel_scale = 1.f,
|
2019-11-05 08:43:42 +00:00
|
|
|
float exteriorBandWidth = 3.0f,
|
2022-05-27 10:25:32 +00:00
|
|
|
float interiorBandWidth = 3.0f);
|
2019-10-31 13:36:33 +00:00
|
|
|
|
2021-05-25 16:23:01 +00:00
|
|
|
indexed_triangle_set grid_to_mesh(const openvdb::FloatGrid &grid,
|
|
|
|
double isovalue = 0.0,
|
|
|
|
double adaptivity = 0.0,
|
|
|
|
bool relaxDisorientedTriangles = true);
|
2019-11-06 12:38:43 +00:00
|
|
|
|
2022-05-27 10:25:32 +00:00
|
|
|
openvdb::FloatGrid::Ptr redistance_grid(const openvdb::FloatGrid &grid,
|
|
|
|
double iso);
|
|
|
|
|
2019-11-08 15:51:43 +00:00
|
|
|
openvdb::FloatGrid::Ptr redistance_grid(const openvdb::FloatGrid &grid,
|
|
|
|
double iso,
|
2022-05-27 10:25:32 +00:00
|
|
|
double ext_range,
|
|
|
|
double int_range);
|
2019-10-31 13:36:33 +00:00
|
|
|
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
2019-11-01 14:31:26 +00:00
|
|
|
#endif // OPENVDBUTILS_HPP
|