mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-12 04:11:50 +08:00
wip on hollowing refactor
This commit is contained in:
parent
1009f78862
commit
f12187b53d
@ -21,11 +21,11 @@ namespace Slic3r {
|
|||||||
|
|
||||||
class TriangleMeshDataAdapter {
|
class TriangleMeshDataAdapter {
|
||||||
public:
|
public:
|
||||||
const TriangleMesh &mesh;
|
const indexed_triangle_set &its;
|
||||||
float voxel_scale;
|
float voxel_scale;
|
||||||
|
|
||||||
size_t polygonCount() const { return mesh.its.indices.size(); }
|
size_t polygonCount() const { return its.indices.size(); }
|
||||||
size_t pointCount() const { return mesh.its.vertices.size(); }
|
size_t pointCount() const { return its.vertices.size(); }
|
||||||
size_t vertexCount(size_t) const { return 3; }
|
size_t vertexCount(size_t) const { return 3; }
|
||||||
|
|
||||||
// Return position pos in local grid index space for polygon n and vertex v
|
// Return position pos in local grid index space for polygon n and vertex v
|
||||||
@ -33,19 +33,19 @@ public:
|
|||||||
// And the voxel count per unit volume can be affected this way.
|
// And the voxel count per unit volume can be affected this way.
|
||||||
void getIndexSpacePoint(size_t n, size_t v, openvdb::Vec3d& pos) const
|
void getIndexSpacePoint(size_t n, size_t v, openvdb::Vec3d& pos) const
|
||||||
{
|
{
|
||||||
auto vidx = size_t(mesh.its.indices[n](Eigen::Index(v)));
|
auto vidx = size_t(its.indices[n](Eigen::Index(v)));
|
||||||
Slic3r::Vec3d p = mesh.its.vertices[vidx].cast<double>() * voxel_scale;
|
Slic3r::Vec3d p = its.vertices[vidx].cast<double>() * voxel_scale;
|
||||||
pos = {p.x(), p.y(), p.z()};
|
pos = {p.x(), p.y(), p.z()};
|
||||||
}
|
}
|
||||||
|
|
||||||
TriangleMeshDataAdapter(const TriangleMesh &m, float voxel_sc = 1.f)
|
TriangleMeshDataAdapter(const indexed_triangle_set &m, float voxel_sc = 1.f)
|
||||||
: mesh{m}, voxel_scale{voxel_sc} {};
|
: its{m}, voxel_scale{voxel_sc} {};
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Do I need to call initialize? Seems to work without it as well but the
|
// TODO: Do I need to call initialize? Seems to work without it as well but the
|
||||||
// docs say it should be called ones. It does a mutex lock-unlock sequence all
|
// docs say it should be called ones. It does a mutex lock-unlock sequence all
|
||||||
// even if was called previously.
|
// even if was called previously.
|
||||||
openvdb::FloatGrid::Ptr mesh_to_grid(const TriangleMesh & mesh,
|
openvdb::FloatGrid::Ptr mesh_to_grid(const indexed_triangle_set & mesh,
|
||||||
const openvdb::math::Transform &tr,
|
const openvdb::math::Transform &tr,
|
||||||
float voxel_scale,
|
float voxel_scale,
|
||||||
float exteriorBandWidth,
|
float exteriorBandWidth,
|
||||||
|
@ -28,9 +28,9 @@ inline Vec4i to_vec4i(const openvdb::Vec4I &v) { return Vec4i{int(v[0]), int(v[1
|
|||||||
// achievable through the Transform parameter. (TODO: or is it?)
|
// achievable through the Transform parameter. (TODO: or is it?)
|
||||||
// The resulting grid will contain the voxel_scale in its metadata under the
|
// The resulting grid will contain the voxel_scale in its metadata under the
|
||||||
// "voxel_scale" key to be used in grid_to_mesh function.
|
// "voxel_scale" key to be used in grid_to_mesh function.
|
||||||
openvdb::FloatGrid::Ptr mesh_to_grid(const TriangleMesh & mesh,
|
openvdb::FloatGrid::Ptr mesh_to_grid(const indexed_triangle_set & mesh,
|
||||||
const openvdb::math::Transform &tr = {},
|
const openvdb::math::Transform &tr = {},
|
||||||
float voxel_scale = 1.f,
|
float voxel_scale = 1.f,
|
||||||
float exteriorBandWidth = 3.0f,
|
float exteriorBandWidth = 3.0f,
|
||||||
float interiorBandWidth = 3.0f,
|
float interiorBandWidth = 3.0f,
|
||||||
int flags = 0);
|
int flags = 0);
|
||||||
@ -40,10 +40,10 @@ sla::Contour3D grid_to_contour3d(const openvdb::FloatGrid &grid,
|
|||||||
double adaptivity,
|
double adaptivity,
|
||||||
bool relaxDisorientedTriangles = true);
|
bool relaxDisorientedTriangles = true);
|
||||||
|
|
||||||
TriangleMesh grid_to_mesh(const openvdb::FloatGrid &grid,
|
indexed_triangle_set grid_to_mesh(const openvdb::FloatGrid &grid,
|
||||||
double isovalue = 0.0,
|
double isovalue = 0.0,
|
||||||
double adaptivity = 0.0,
|
double adaptivity = 0.0,
|
||||||
bool relaxDisorientedTriangles = true);
|
bool relaxDisorientedTriangles = true);
|
||||||
|
|
||||||
openvdb::FloatGrid::Ptr redistance_grid(const openvdb::FloatGrid &grid,
|
openvdb::FloatGrid::Ptr redistance_grid(const openvdb::FloatGrid &grid,
|
||||||
double iso,
|
double iso,
|
||||||
|
@ -29,7 +29,7 @@ template<class S, class = FloatingOnly<S>>
|
|||||||
inline void _scale(S s, Contour3D &m) { for (auto &p : m.points) p *= s; }
|
inline void _scale(S s, Contour3D &m) { for (auto &p : m.points) p *= s; }
|
||||||
|
|
||||||
struct Interior {
|
struct Interior {
|
||||||
TriangleMesh mesh;
|
indexed_triangle_set mesh;
|
||||||
openvdb::FloatGrid::Ptr gridptr;
|
openvdb::FloatGrid::Ptr gridptr;
|
||||||
mutable std::optional<openvdb::FloatGrid::ConstAccessor> accessor;
|
mutable std::optional<openvdb::FloatGrid::ConstAccessor> accessor;
|
||||||
|
|
||||||
@ -53,12 +53,12 @@ void InteriorDeleter::operator()(Interior *p)
|
|||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
|
|
||||||
TriangleMesh &get_mesh(Interior &interior)
|
indexed_triangle_set &get_mesh(Interior &interior)
|
||||||
{
|
{
|
||||||
return interior.mesh;
|
return interior.mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TriangleMesh &get_mesh(const Interior &interior)
|
const indexed_triangle_set &get_mesh(const Interior &interior)
|
||||||
{
|
{
|
||||||
return interior.mesh;
|
return interior.mesh;
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ struct Interior;
|
|||||||
struct InteriorDeleter { void operator()(Interior *p); };
|
struct InteriorDeleter { void operator()(Interior *p); };
|
||||||
using InteriorPtr = std::unique_ptr<Interior, InteriorDeleter>;
|
using InteriorPtr = std::unique_ptr<Interior, InteriorDeleter>;
|
||||||
|
|
||||||
TriangleMesh & get_mesh(Interior &interior);
|
indexed_triangle_set & get_mesh(Interior &interior);
|
||||||
const TriangleMesh &get_mesh(const Interior &interior);
|
const indexed_triangle_set &get_mesh(const Interior &interior);
|
||||||
|
|
||||||
struct DrainHole
|
struct DrainHole
|
||||||
{
|
{
|
||||||
@ -99,7 +99,7 @@ void cut_drainholes(std::vector<ExPolygons> & obj_slices,
|
|||||||
const sla::DrainHoles & holes,
|
const sla::DrainHoles & holes,
|
||||||
std::function<void(void)> thr);
|
std::function<void(void)> thr);
|
||||||
|
|
||||||
}
|
} // namespace sla
|
||||||
}
|
} // namespace Slic3r
|
||||||
|
|
||||||
#endif // HOLLOWINGFILTER_H
|
#endif // HOLLOWINGFILTER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user