Reproject support and hole points after a reload from disk op.

This commit is contained in:
tamasmeszaros 2020-05-12 15:52:33 +02:00
parent 54925a191e
commit f7a43f9757
3 changed files with 41 additions and 0 deletions

View File

@ -232,6 +232,7 @@ add_library(libslic3r STATIC
SLA/Contour3D.cpp SLA/Contour3D.cpp
SLA/EigenMesh3D.hpp SLA/EigenMesh3D.hpp
SLA/Clustering.hpp SLA/Clustering.hpp
SLA/ReprojectPointsOnMesh.hpp
) )
if (SLIC3R_STATIC) if (SLIC3R_STATIC)

View File

@ -0,0 +1,28 @@
#ifndef REPROJECTPOINTSONMESH_HPP
#define REPROJECTPOINTSONMESH_HPP
#include "libslic3r/Point.hpp"
#include "SupportPoint.hpp"
#include "Hollowing.hpp"
#include "EigenMesh3D.hpp"
#include <tbb/parallel_for.h>
namespace Slic3r { namespace sla {
template<class Pt> Vec3d pos(const Pt &p) { return p.pos.template cast<double>(); }
template<class Pt> void pos(Pt &p, const Vec3d &pp) { p.pos = pp.cast<float>(); }
template<class PointType>
void reproject_support_points(const EigenMesh3D &mesh, std::vector<PointType> &pts)
{
tbb::parallel_for(size_t(0), pts.size(), [&mesh, &pts](size_t idx) {
int junk;
Vec3d new_pos;
mesh.squared_distance(pos(pts[idx]), junk, new_pos);
pos(pts[idx], new_pos);
});
}
}}
#endif // REPROJECTPOINTSONMESH_HPP

View File

@ -38,6 +38,7 @@
#include "libslic3r/Model.hpp" #include "libslic3r/Model.hpp"
#include "libslic3r/SLA/Hollowing.hpp" #include "libslic3r/SLA/Hollowing.hpp"
#include "libslic3r/SLA/SupportPoint.hpp" #include "libslic3r/SLA/SupportPoint.hpp"
#include "libslic3r/SLA/ReprojectPointsOnMesh.hpp"
#include "libslic3r/Polygon.hpp" #include "libslic3r/Polygon.hpp"
#include "libslic3r/Print.hpp" #include "libslic3r/Print.hpp"
#include "libslic3r/PrintConfig.hpp" #include "libslic3r/PrintConfig.hpp"
@ -3122,6 +3123,17 @@ void Plater::priv::reload_from_disk()
std::swap(old_model_object->volumes[sel_v.volume_idx], old_model_object->volumes.back()); std::swap(old_model_object->volumes[sel_v.volume_idx], old_model_object->volumes.back());
old_model_object->delete_volume(old_model_object->volumes.size() - 1); old_model_object->delete_volume(old_model_object->volumes.size() - 1);
old_model_object->ensure_on_bed(); old_model_object->ensure_on_bed();
std::unique_ptr<sla::EigenMesh3D> emesh;
if (!old_model_object->sla_support_points.empty()) {
emesh = std::make_unique<sla::EigenMesh3D>(old_model_object->raw_mesh());
sla::reproject_support_points(*emesh, old_model_object->sla_support_points);
}
if (!old_model_object->sla_drain_holes.empty()) {
if (!emesh) emesh = std::make_unique<sla::EigenMesh3D>(old_model_object->raw_mesh());
sla::reproject_support_points(*emesh, old_model_object->sla_drain_holes);
}
} }
} }
} }