Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_gcode_viewer

This commit is contained in:
enricoturri1966 2020-05-29 12:29:24 +02:00
commit 71db69ef41
9 changed files with 1632 additions and 29 deletions

View File

@ -11,17 +11,6 @@ template BoundingBoxBase<Vec2d>::BoundingBoxBase(const std::vector<Vec2d> &point
template BoundingBox3Base<Vec3d>::BoundingBox3Base(const std::vector<Vec3d> &points);
BoundingBox::BoundingBox(const Lines &lines)
{
Points points;
points.reserve(lines.size());
for (const Line &line : lines) {
points.emplace_back(line.a);
points.emplace_back(line.b);
}
*this = BoundingBox(points);
}
void BoundingBox::polygon(Polygon* polygon) const
{
polygon->points.clear();

View File

@ -20,17 +20,19 @@ public:
min(pmin), max(pmax), defined(pmin(0) < pmax(0) && pmin(1) < pmax(1)) {}
BoundingBoxBase(const std::vector<PointClass>& points) : min(PointClass::Zero()), max(PointClass::Zero())
{
if (points.empty())
throw std::invalid_argument("Empty point set supplied to BoundingBoxBase constructor");
typename std::vector<PointClass>::const_iterator it = points.begin();
this->min = *it;
this->max = *it;
for (++ it; it != points.end(); ++ it) {
this->min = this->min.cwiseMin(*it);
this->max = this->max.cwiseMax(*it);
if (points.empty()) {
this->defined = false;
// throw std::invalid_argument("Empty point set supplied to BoundingBoxBase constructor");
} else {
typename std::vector<PointClass>::const_iterator it = points.begin();
this->min = *it;
this->max = *it;
for (++ it; it != points.end(); ++ it) {
this->min = this->min.cwiseMin(*it);
this->max = this->max.cwiseMax(*it);
}
this->defined = (this->min(0) < this->max(0)) && (this->min(1) < this->max(1));
}
this->defined = (this->min(0) < this->max(0)) && (this->min(1) < this->max(1));
}
void reset() { this->defined = false; this->min = PointClass::Zero(); this->max = PointClass::Zero(); }
void merge(const PointClass &point);
@ -143,7 +145,6 @@ public:
BoundingBox() : BoundingBoxBase<Point>() {}
BoundingBox(const Point &pmin, const Point &pmax) : BoundingBoxBase<Point>(pmin, pmax) {}
BoundingBox(const Points &points) : BoundingBoxBase<Point>(points) {}
BoundingBox(const Lines &lines);
friend BoundingBox get_extents_rotated(const Points &points, double angle);
};

View File

@ -10,6 +10,7 @@
// Serialization through the Cereal library
#include <cereal/access.hpp>
#define BOOST_VORONOI_USE_GMP 1
#include "boost/polygon/voronoi.hpp"
namespace ClipperLib {

View File

@ -125,4 +125,14 @@ Vec3d Linef3::intersect_plane(double z) const
return Vec3d(this->a(0) + v(0) * t, this->a(1) + v(1) * t, z);
}
BoundingBox get_extents(const Lines &lines)
{
BoundingBox bbox;
for (const Line &line : lines) {
bbox.merge(line.a);
bbox.merge(line.b);
}
return bbox;
}
}

View File

@ -103,6 +103,8 @@ public:
Vec3d b;
};
extern BoundingBox get_extents(const Lines &lines);
} // namespace Slic3r
// start Boost

View File

@ -6,6 +6,7 @@
#include <limits> // for numeric_limits
#include <assert.h>
#define BOOST_VORONOI_USE_GMP 1
#include "boost/polygon/voronoi.hpp"
using boost::polygon::voronoi_builder;
using boost::polygon::voronoi_diagram;

View File

@ -198,12 +198,20 @@ void GLGizmoCut::set_cut_z(double cut_z) const
void GLGizmoCut::perform_cut(const Selection& selection)
{
const auto instance_idx = selection.get_instance_idx();
const auto object_idx = selection.get_object_idx();
const int instance_idx = selection.get_instance_idx();
const int object_idx = selection.get_object_idx();
wxCHECK_RET(instance_idx >= 0 && object_idx >= 0, "GLGizmoCut: Invalid object selection");
wxGetApp().plater()->cut(object_idx, instance_idx, m_cut_z, m_keep_upper, m_keep_lower, m_rotate_lower);
// m_cut_z is the distance from the bed. Subtract possible SLA elevation.
const GLVolume* first_glvolume = selection.get_volume(*selection.get_volume_idxs().begin());
coordf_t object_cut_z = m_cut_z - first_glvolume->get_sla_shift_z();
if (object_cut_z > 0.)
wxGetApp().plater()->cut(object_idx, instance_idx, object_cut_z, m_keep_upper, m_keep_lower, m_rotate_lower);
else {
// the object is SLA-elevated and the plane is under it.
}
}
double GLGizmoCut::calc_projection(const Linef3& mouse_ray) const

View File

@ -12,10 +12,11 @@ add_executable(${_TEST_NAME}_tests
test_placeholder_parser.cpp
test_polygon.cpp
test_stl.cpp
test_meshsimplify.cpp
test_meshboolean.cpp
test_marchingsquares.cpp
test_timeutils.cpp
test_meshsimplify.cpp
test_meshboolean.cpp
test_marchingsquares.cpp
test_timeutils.cpp
test_voronoi.cpp
)
if (TARGET OpenVDB::openvdb)

File diff suppressed because it is too large Load Diff