wip on hollowing refactor

This commit is contained in:
tamasmeszaros 2021-05-25 18:23:01 +02:00
parent 1009f78862
commit f12187b53d
4 changed files with 21 additions and 21 deletions

View file

@ -21,11 +21,11 @@ namespace Slic3r {
class TriangleMeshDataAdapter {
public:
const TriangleMesh &mesh;
const indexed_triangle_set &its;
float voxel_scale;
size_t polygonCount() const { return mesh.its.indices.size(); }
size_t pointCount() const { return mesh.its.vertices.size(); }
size_t polygonCount() const { return its.indices.size(); }
size_t pointCount() const { return its.vertices.size(); }
size_t vertexCount(size_t) const { return 3; }
// 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.
void getIndexSpacePoint(size_t n, size_t v, openvdb::Vec3d& pos) const
{
auto vidx = size_t(mesh.its.indices[n](Eigen::Index(v)));
Slic3r::Vec3d p = mesh.its.vertices[vidx].cast<double>() * voxel_scale;
auto vidx = size_t(its.indices[n](Eigen::Index(v)));
Slic3r::Vec3d p = its.vertices[vidx].cast<double>() * voxel_scale;
pos = {p.x(), p.y(), p.z()};
}
TriangleMeshDataAdapter(const TriangleMesh &m, float voxel_sc = 1.f)
: mesh{m}, voxel_scale{voxel_sc} {};
TriangleMeshDataAdapter(const indexed_triangle_set &m, float voxel_sc = 1.f)
: its{m}, voxel_scale{voxel_sc} {};
};
// 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
// 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,
float voxel_scale,
float exteriorBandWidth,

View file

@ -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?)
// The resulting grid will contain the voxel_scale in its metadata under the
// "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 = {},
float voxel_scale = 1.f,
float voxel_scale = 1.f,
float exteriorBandWidth = 3.0f,
float interiorBandWidth = 3.0f,
int flags = 0);
@ -40,10 +40,10 @@ sla::Contour3D grid_to_contour3d(const openvdb::FloatGrid &grid,
double adaptivity,
bool relaxDisorientedTriangles = true);
TriangleMesh grid_to_mesh(const openvdb::FloatGrid &grid,
double isovalue = 0.0,
double adaptivity = 0.0,
bool relaxDisorientedTriangles = true);
indexed_triangle_set grid_to_mesh(const openvdb::FloatGrid &grid,
double isovalue = 0.0,
double adaptivity = 0.0,
bool relaxDisorientedTriangles = true);
openvdb::FloatGrid::Ptr redistance_grid(const openvdb::FloatGrid &grid,
double iso,

View file

@ -29,7 +29,7 @@ template<class S, class = FloatingOnly<S>>
inline void _scale(S s, Contour3D &m) { for (auto &p : m.points) p *= s; }
struct Interior {
TriangleMesh mesh;
indexed_triangle_set mesh;
openvdb::FloatGrid::Ptr gridptr;
mutable std::optional<openvdb::FloatGrid::ConstAccessor> accessor;
@ -53,12 +53,12 @@ void InteriorDeleter::operator()(Interior *p)
delete p;
}
TriangleMesh &get_mesh(Interior &interior)
indexed_triangle_set &get_mesh(Interior &interior)
{
return interior.mesh;
}
const TriangleMesh &get_mesh(const Interior &interior)
const indexed_triangle_set &get_mesh(const Interior &interior)
{
return interior.mesh;
}

View file

@ -27,8 +27,8 @@ struct Interior;
struct InteriorDeleter { void operator()(Interior *p); };
using InteriorPtr = std::unique_ptr<Interior, InteriorDeleter>;
TriangleMesh & get_mesh(Interior &interior);
const TriangleMesh &get_mesh(const Interior &interior);
indexed_triangle_set & get_mesh(Interior &interior);
const indexed_triangle_set &get_mesh(const Interior &interior);
struct DrainHole
{
@ -99,7 +99,7 @@ void cut_drainholes(std::vector<ExPolygons> & obj_slices,
const sla::DrainHoles & holes,
std::function<void(void)> thr);
}
}
} // namespace sla
} // namespace Slic3r
#endif // HOLLOWINGFILTER_H