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

This commit is contained in:
Enrico Turri 2019-10-24 08:46:58 +02:00
commit 540253f676
3 changed files with 26 additions and 22 deletions

View File

@ -283,7 +283,14 @@ endfunction()
if(TARGET Boost::system) if(TARGET Boost::system)
message(STATUS "Boost::boost exists") message(STATUS "Boost::boost exists")
target_link_libraries(boost_headeronly INTERFACE Boost::boost) target_link_libraries(boost_headeronly INTERFACE Boost::boost)
list(TRANSFORM _boost_components PREPEND Boost:: OUTPUT_VARIABLE _boost_targets)
# Only from cmake 3.12
# list(TRANSFORM _boost_components PREPEND Boost:: OUTPUT_VARIABLE _boost_targets)
set(_boost_targets "")
foreach(comp ${_boost_components})
list(APPEND _boost_targets "Boost::${comp}")
endforeach()
target_link_libraries(boost_libs INTERFACE target_link_libraries(boost_libs INTERFACE
boost_headeronly # includes the custom compile definitions as well boost_headeronly # includes the custom compile definitions as well
${_boost_targets} ${_boost_targets}

View File

@ -663,7 +663,6 @@ namespace Voronoi { namespace Internal {
typedef boost::polygon::point_data<coordinate_type> point_type; typedef boost::polygon::point_data<coordinate_type> point_type;
typedef boost::polygon::segment_data<coordinate_type> segment_type; typedef boost::polygon::segment_data<coordinate_type> segment_type;
typedef boost::polygon::rectangle_data<coordinate_type> rect_type; typedef boost::polygon::rectangle_data<coordinate_type> rect_type;
// typedef voronoi_builder<int> VB;
typedef boost::polygon::voronoi_diagram<coordinate_type> VD; typedef boost::polygon::voronoi_diagram<coordinate_type> VD;
typedef VD::cell_type cell_type; typedef VD::cell_type cell_type;
typedef VD::cell_type::source_index_type source_index_type; typedef VD::cell_type::source_index_type source_index_type;
@ -710,15 +709,15 @@ namespace Voronoi { namespace Internal {
if (cell1.contains_point() && cell2.contains_point()) { if (cell1.contains_point() && cell2.contains_point()) {
point_type p1 = retrieve_point(segments, cell1); point_type p1 = retrieve_point(segments, cell1);
point_type p2 = retrieve_point(segments, cell2); point_type p2 = retrieve_point(segments, cell2);
origin.x((p1(0) + p2(0)) * 0.5); origin.x((p1.x() + p2.x()) * 0.5);
origin.y((p1(1) + p2(1)) * 0.5); origin.y((p1.y() + p2.y()) * 0.5);
direction.x(p1(1) - p2(1)); direction.x(p1.y() - p2.y());
direction.y(p2(0) - p1(0)); direction.y(p2.x() - p1.x());
} else { } else {
origin = cell1.contains_segment() ? retrieve_point(segments, cell2) : retrieve_point(segments, cell1); origin = cell1.contains_segment() ? retrieve_point(segments, cell2) : retrieve_point(segments, cell1);
segment_type segment = cell1.contains_segment() ? segments[cell1.source_index()] : segments[cell2.source_index()]; segment_type segment = cell1.contains_segment() ? segments[cell1.source_index()] : segments[cell2.source_index()];
coordinate_type dx = high(segment)(0) - low(segment)(0); coordinate_type dx = high(segment).x() - low(segment).x();
coordinate_type dy = high(segment)(1) - low(segment)(1); coordinate_type dy = high(segment).y() - low(segment).y();
if ((low(segment) == origin) ^ cell1.contains_point()) { if ((low(segment) == origin) ^ cell1.contains_point()) {
direction.x(dy); direction.x(dy);
direction.y(-dx); direction.y(-dx);
@ -727,19 +726,19 @@ namespace Voronoi { namespace Internal {
direction.y(dx); direction.y(dx);
} }
} }
coordinate_type koef = bbox_max_size / (std::max)(fabs(direction(0)), fabs(direction(1))); coordinate_type koef = bbox_max_size / (std::max)(fabs(direction.x()), fabs(direction.y()));
if (edge.vertex0() == NULL) { if (edge.vertex0() == NULL) {
clipped_edge->push_back(point_type( clipped_edge->push_back(point_type(
origin(0) - direction(0) * koef, origin.x() - direction.x() * koef,
origin(1) - direction(1) * koef)); origin.y() - direction.y() * koef));
} else { } else {
clipped_edge->push_back( clipped_edge->push_back(
point_type(edge.vertex0()->x(), edge.vertex0()->y())); point_type(edge.vertex0()->x(), edge.vertex0()->y()));
} }
if (edge.vertex1() == NULL) { if (edge.vertex1() == NULL) {
clipped_edge->push_back(point_type( clipped_edge->push_back(point_type(
origin(0) + direction(0) * koef, origin.x() + direction.x() * koef,
origin(1) + direction(1) * koef)); origin.y() + direction.y() * koef));
} else { } else {
clipped_edge->push_back( clipped_edge->push_back(
point_type(edge.vertex1()->x(), edge.vertex1()->y())); point_type(edge.vertex1()->x(), edge.vertex1()->y()));
@ -759,7 +758,7 @@ namespace Voronoi { namespace Internal {
} /* namespace Internal */ } // namespace Voronoi } /* namespace Internal */ } // namespace Voronoi
static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ voronoi_diagram<double> &vd, const ThickPolylines *polylines, const char *path) static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ boost::polygon::voronoi_diagram<double> &vd, const ThickPolylines *polylines, const char *path)
{ {
const double scale = 0.2; const double scale = 0.2;
const std::string inputSegmentPointColor = "lightseagreen"; const std::string inputSegmentPointColor = "lightseagreen";
@ -803,7 +802,7 @@ static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ voronoi_d
Voronoi::Internal::point_type(double(it->b(0)), double(it->b(1))))); Voronoi::Internal::point_type(double(it->b(0)), double(it->b(1)))));
// Color exterior edges. // Color exterior edges.
for (voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it) for (boost::polygon::voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it)
if (!it->is_finite()) if (!it->is_finite())
Voronoi::Internal::color_exterior(&(*it)); Voronoi::Internal::color_exterior(&(*it));
@ -818,11 +817,11 @@ static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ voronoi_d
#if 1 #if 1
// Draw voronoi vertices. // Draw voronoi vertices.
for (voronoi_diagram<double>::const_vertex_iterator it = vd.vertices().begin(); it != vd.vertices().end(); ++it) for (boost::polygon::voronoi_diagram<double>::const_vertex_iterator it = vd.vertices().begin(); it != vd.vertices().end(); ++it)
if (! internalEdgesOnly || it->color() != Voronoi::Internal::EXTERNAL_COLOR) if (! internalEdgesOnly || it->color() != Voronoi::Internal::EXTERNAL_COLOR)
svg.draw(Point(coord_t((*it)(0)), coord_t((*it)(1))), voronoiPointColor, voronoiPointRadius); svg.draw(Point(coord_t(it->x()), coord_t(it->y())), voronoiPointColor, voronoiPointRadius);
for (voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it) { for (boost::polygon::voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it) {
if (primaryEdgesOnly && !it->is_primary()) if (primaryEdgesOnly && !it->is_primary())
continue; continue;
if (internalEdgesOnly && (it->color() == Voronoi::Internal::EXTERNAL_COLOR)) if (internalEdgesOnly && (it->color() == Voronoi::Internal::EXTERNAL_COLOR))
@ -845,7 +844,7 @@ static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ voronoi_d
color = voronoiLineColorSecondary; color = voronoiLineColorSecondary;
} }
for (std::size_t i = 0; i + 1 < samples.size(); ++i) for (std::size_t i = 0; i + 1 < samples.size(); ++i)
svg.draw(Line(Point(coord_t(samples[i](0)), coord_t(samples[i](1))), Point(coord_t(samples[i+1](0)), coord_t(samples[i+1](1)))), color, voronoiLineWidth); svg.draw(Line(Point(coord_t(samples[i].x()), coord_t(samples[i].y())), Point(coord_t(samples[i+1].x()), coord_t(samples[i+1].y()))), color, voronoiLineWidth);
} }
#endif #endif

View File

@ -11,8 +11,6 @@
#include <cereal/access.hpp> #include <cereal/access.hpp>
#include "boost/polygon/voronoi.hpp" #include "boost/polygon/voronoi.hpp"
using boost::polygon::voronoi_builder;
using boost::polygon::voronoi_diagram;
namespace ClipperLib { namespace ClipperLib {
class PolyNode; class PolyNode;
@ -192,7 +190,7 @@ class MedialAxis {
void build(Polylines* polylines); void build(Polylines* polylines);
private: private:
class VD : public voronoi_diagram<double> { class VD : public boost::polygon::voronoi_diagram<double> {
public: public:
typedef double coord_type; typedef double coord_type;
typedef boost::polygon::point_data<coordinate_type> point_type; typedef boost::polygon::point_data<coordinate_type> point_type;