WIP fixing trafos

This commit is contained in:
tamasmeszaros 2023-01-17 11:23:18 +01:00
parent 0fa9bcc63b
commit 9ee71ddd92
5 changed files with 29 additions and 14 deletions

View file

@ -3,7 +3,11 @@
#include <libslic3r/Point.hpp>
namespace Slic3r { namespace sla {
namespace Slic3r {
class ModelObject;
namespace sla {
// An enum to keep track of where the current points on the ModelObject came from.
enum class PointsStatus {
@ -62,6 +66,9 @@ struct SupportPoint
using SupportPoints = std::vector<SupportPoint>;
SupportPoints transformed_support_points(const ModelObject &mo,
const Transform3d &trafo);
}} // namespace Slic3r::sla
#endif // SUPPORTPOINT_HPP

View file

@ -661,5 +661,17 @@ void SupportPointGenerator::output_expolygons(const ExPolygons& expolys, const s
}
#endif
SupportPoints transformed_support_points(const ModelObject &mo,
const Transform3d &trafo)
{
auto spts = mo.sla_support_points;
Transform3f tr = trafo.cast<float>();
for (sla::SupportPoint& suppt : spts) {
suppt.pos = tr * suppt.pos;
}
return spts;
}
} // namespace sla
} // namespace Slic3r

View file

@ -1051,20 +1051,16 @@ SLAPrintObject::get_parts_to_slice(SLAPrintObjectStep untilstep) const
sla::SupportPoints SLAPrintObject::transformed_support_points() const
{
assert(m_model_object != nullptr);
auto spts = m_model_object->sla_support_points;
const Transform3d& vol_trafo = m_model_object->volumes.front()->get_transformation().get_matrix();
const Transform3f& tr = (trafo() * vol_trafo).cast<float>();
for (sla::SupportPoint& suppt : spts) {
suppt.pos = tr * suppt.pos;
}
return spts;
assert(model_object());
return sla::transformed_support_points(*model_object(), trafo());
}
sla::DrainHoles SLAPrintObject::transformed_drainhole_points() const
{
return sla::transformed_drainhole_points(*this->model_object(), trafo());
assert(model_object());
return sla::transformed_drainhole_points(*model_object(), trafo());
}
DynamicConfig SLAPrintStatistics::config() const

View file

@ -123,7 +123,7 @@ void GLGizmoHollow::render_points(const Selection& selection)
return;
double shift_z = m_c->selection_info()->print_object()->get_current_elevation();
Transform3d trafo(inst->get_transformation().get_matrix() * inst->get_object()->volumes.front()->get_matrix());
Transform3d trafo(inst->get_transformation().get_matrix());
trafo.translation()(2) += shift_z;
const Geometry::Transformation transformation{trafo};

View file

@ -153,7 +153,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection)
return;
double shift_z = m_c->selection_info()->print_object()->get_current_elevation();
Transform3d trafo(inst->get_transformation().get_matrix() * inst->get_object()->volumes.front()->get_matrix());
Transform3d trafo = inst->get_transformation().get_matrix();
trafo.translation()(2) += shift_z;
const Geometry::Transformation transformation{trafo};
@ -1084,7 +1084,7 @@ void GLGizmoSlaSupports::get_data_from_backend()
if (po->model_object()->id() == mo->id()) {
m_normal_cache.clear();
const std::vector<sla::SupportPoint>& points = po->get_support_points();
auto mat = (po->trafo() * po->model_object()->volumes.front()->get_transformation().get_matrix()).inverse().cast<float>();
auto mat = po->trafo().inverse().cast<float>();
for (unsigned int i=0; i<points.size();++i)
m_normal_cache.emplace_back(sla::SupportPoint(mat * points[i].pos, points[i].head_front_radius, points[i].is_new_island));