mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 00:16:04 +08:00
Added test of objects outside plate in sequential printability test + various debugging.
This commit is contained in:
parent
757760b12f
commit
89758e9832
@ -177,7 +177,7 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
|||||||
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
|
||||||
|
|
||||||
std::map<int, int> flat_index_map;
|
std::map<int, int> flat_index_map;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < objects_to_print.size(); ++i)
|
for (unsigned int i = 0; i < objects_to_print.size(); ++i)
|
||||||
{
|
{
|
||||||
std::vector<Slic3r::Polygon> convex_level_polygons;
|
std::vector<Slic3r::Polygon> convex_level_polygons;
|
||||||
@ -210,8 +210,8 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
|||||||
scale_down_unreachable_polygons);
|
scale_down_unreachable_polygons);
|
||||||
|
|
||||||
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
unreachable_polygons.push_back(scale_down_unreachable_polygons);
|
||||||
polygons.push_back(scale_down_object_polygon);
|
polygons.push_back(scale_down_object_polygon);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& scheduled_plate: scheduled_plates)
|
for (const auto& scheduled_plate: scheduled_plates)
|
||||||
{
|
{
|
||||||
@ -228,6 +228,22 @@ bool check_ScheduledObjectsForSequentialPrintability(const SolverConfiguration
|
|||||||
{
|
{
|
||||||
const auto& flat_index = flat_index_map.find(scheduled_object.id)->second;
|
const auto& flat_index = flat_index_map.find(scheduled_object.id)->second;
|
||||||
|
|
||||||
|
assert(!objects_to_print[flat_index].pgns_at_height.empty());
|
||||||
|
|
||||||
|
if (!check_PolygonPositionWithinPlate(solver_configuration,
|
||||||
|
SEQ_SLICER_SCALE_FACTOR,
|
||||||
|
scheduled_object.x,
|
||||||
|
scheduled_object.y,
|
||||||
|
objects_to_print[flat_index].pgns_at_height[0].second))
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
{
|
||||||
|
printf("Object placed outside plate.\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
plate_polygons.push_back(polygons[flat_index]);
|
plate_polygons.push_back(polygons[flat_index]);
|
||||||
plate_unreachable_polygons.push_back(unreachable_polygons[flat_index]);
|
plate_unreachable_polygons.push_back(unreachable_polygons[flat_index]);
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ void prepare_ExtruderPolygons(const SolverConfiguration &solver
|
|||||||
bool extra_safety)
|
bool extra_safety)
|
||||||
{
|
{
|
||||||
for (unsigned int j = 0; j < object_to_print.pgns_at_height.size(); ++j)
|
for (unsigned int j = 0; j < object_to_print.pgns_at_height.size(); ++j)
|
||||||
{
|
{
|
||||||
coord_t height = object_to_print.pgns_at_height[j].first;
|
coord_t height = object_to_print.pgns_at_height[j].first;
|
||||||
|
|
||||||
if (!object_to_print.pgns_at_height[j].second.points.empty())
|
if (!object_to_print.pgns_at_height[j].second.points.empty())
|
||||||
@ -780,14 +780,14 @@ void prepare_UnreachableZonePolygons(const SolverConfiguration
|
|||||||
std::vector<Slic3r::Polygon> &unreachable_polygons)
|
std::vector<Slic3r::Polygon> &unreachable_polygons)
|
||||||
{
|
{
|
||||||
std::vector<std::vector<Slic3r::Polygon> > scaled_unreachable_polygons;
|
std::vector<std::vector<Slic3r::Polygon> > scaled_unreachable_polygons;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < extruder_convex_level_polygons.size(); ++i)
|
for (unsigned int i = 0; i < extruder_convex_level_polygons.size(); ++i)
|
||||||
{
|
{
|
||||||
std::vector<Slic3r::Polygon> scaled_level_unreachable_polygons;
|
std::vector<Slic3r::Polygon> scaled_level_unreachable_polygons;
|
||||||
extend_PolygonConvexUnreachableZone(solver_configuration,
|
extend_PolygonConvexUnreachableZone(solver_configuration,
|
||||||
polygon,
|
polygon,
|
||||||
extruder_convex_level_polygons[i],
|
extruder_convex_level_polygons[i],
|
||||||
scaled_level_unreachable_polygons);
|
scaled_level_unreachable_polygons);
|
||||||
scaled_unreachable_polygons.push_back(scaled_level_unreachable_polygons);
|
scaled_unreachable_polygons.push_back(scaled_level_unreachable_polygons);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -826,19 +826,18 @@ void prepare_UnreachableZonePolygons(const SolverConfiguration
|
|||||||
{
|
{
|
||||||
std::vector<std::vector<Slic3r::Polygon> > scaled_unreachable_polygons;
|
std::vector<std::vector<Slic3r::Polygon> > scaled_unreachable_polygons;
|
||||||
assert(extruder_convex_level_polygons.size() == convex_level_polygons.size());
|
assert(extruder_convex_level_polygons.size() == convex_level_polygons.size());
|
||||||
|
|
||||||
for (unsigned int i = 0; i < extruder_convex_level_polygons.size(); ++i)
|
for (unsigned int i = 0; i < extruder_convex_level_polygons.size(); ++i)
|
||||||
{
|
{
|
||||||
std::vector<Slic3r::Polygon> scaled_level_unreachable_polygons;
|
std::vector<Slic3r::Polygon> scaled_level_unreachable_polygons;
|
||||||
extend_PolygonConvexUnreachableZone(solver_configuration,
|
extend_PolygonConvexUnreachableZone(solver_configuration,
|
||||||
convex_level_polygons[i],
|
convex_level_polygons[i],
|
||||||
extruder_convex_level_polygons[i],
|
extruder_convex_level_polygons[i],
|
||||||
scaled_level_unreachable_polygons);
|
scaled_level_unreachable_polygons);
|
||||||
scaled_unreachable_polygons.push_back(scaled_level_unreachable_polygons);
|
scaled_unreachable_polygons.push_back(scaled_level_unreachable_polygons);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(extruder_box_level_polygons.size() == box_level_polygons.size());
|
assert(extruder_box_level_polygons.size() == box_level_polygons.size());
|
||||||
|
|
||||||
for (unsigned int i = 0; i < extruder_box_level_polygons.size(); ++i)
|
for (unsigned int i = 0; i < extruder_box_level_polygons.size(); ++i)
|
||||||
{
|
{
|
||||||
std::vector<Slic3r::Polygon> scaled_level_unreachable_polygons;
|
std::vector<Slic3r::Polygon> scaled_level_unreachable_polygons;
|
||||||
@ -884,6 +883,21 @@ bool check_PolygonSizeFitToPlate(const SolverConfiguration &solver_configuration
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool check_PolygonPositionWithinPlate(const SolverConfiguration &solver_configuration, coord_t x, coord_t y, const Slic3r::Polygon &polygon)
|
||||||
|
{
|
||||||
|
BoundingBox polygon_box = get_extents(polygon);
|
||||||
|
|
||||||
|
if (x + polygon_box.min.x() < 0 || x + polygon_box.max.x() > solver_configuration.x_plate_bounding_box_size)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (y + polygon_box.min.y() < 0 || y + polygon_box.max.y() > solver_configuration.y_plate_bounding_box_size)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool check_PolygonSizeFitToPlate(const SolverConfiguration &solver_configuration, coord_t scale_factor, const Slic3r::Polygon &polygon)
|
bool check_PolygonSizeFitToPlate(const SolverConfiguration &solver_configuration, coord_t scale_factor, const Slic3r::Polygon &polygon)
|
||||||
{
|
{
|
||||||
@ -905,6 +919,31 @@ bool check_PolygonSizeFitToPlate(const SolverConfiguration &solver_configuration
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool check_PolygonPositionWithinPlate(const SolverConfiguration &solver_configuration, coord_t scale_factor, coord_t x, coord_t y, const Slic3r::Polygon &polygon)
|
||||||
|
{
|
||||||
|
BoundingBox polygon_box = get_extents(polygon);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
{
|
||||||
|
printf("x: %d,%d\n", polygon_box.min.x() + x, polygon_box.max.x() + x);
|
||||||
|
printf("y: %d,%d\n", polygon_box.min.y() + y, polygon_box.max.y() + y);
|
||||||
|
printf("X: %d\n", solver_configuration.x_plate_bounding_box_size * scale_factor);
|
||||||
|
printf("Y: %d\n", solver_configuration.y_plate_bounding_box_size * scale_factor);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (x + polygon_box.min.x() < 0 || x + polygon_box.max.x() > solver_configuration.x_plate_bounding_box_size * scale_factor)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (y + polygon_box.min.y() < 0 || y + polygon_box.max.y() > solver_configuration.y_plate_bounding_box_size * scale_factor)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
/*----------------------------------------------------------------*/
|
||||||
|
|
||||||
bool check_PolygonConsumation(const std::vector<Slic3r::Polygon> &polygons, const std::vector<Slic3r::Polygon> &consumer_polygons)
|
bool check_PolygonConsumation(const std::vector<Slic3r::Polygon> &polygons, const std::vector<Slic3r::Polygon> &consumer_polygons)
|
||||||
|
@ -194,8 +194,10 @@ void prepare_UnreachableZonePolygons(const SolverConfiguration
|
|||||||
std::vector<Slic3r::Polygon> &unreachable_polygons);
|
std::vector<Slic3r::Polygon> &unreachable_polygons);
|
||||||
|
|
||||||
bool check_PolygonSizeFitToPlate(const SolverConfiguration &solver_configuration, const Slic3r::Polygon &polygon);
|
bool check_PolygonSizeFitToPlate(const SolverConfiguration &solver_configuration, const Slic3r::Polygon &polygon);
|
||||||
|
bool check_PolygonPositionWithinPlate(const SolverConfiguration &solver_configuration, coord_t x, coord_t y, const Slic3r::Polygon &polygon);
|
||||||
|
|
||||||
bool check_PolygonSizeFitToPlate(const SolverConfiguration &solver_configuration, coord_t scale_factor, const Slic3r::Polygon &polygon);
|
bool check_PolygonSizeFitToPlate(const SolverConfiguration &solver_configuration, coord_t scale_factor, const Slic3r::Polygon &polygon);
|
||||||
|
bool check_PolygonPositionWithinPlate(const SolverConfiguration &solver_configuration, coord_t scale_factor, coord_t x, coord_t y, const Slic3r::Polygon &polygon);
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
/*----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
/*================================================================*/
|
/*================================================================*/
|
||||||
|
|
||||||
|
#include <libslic3r/SVG.hpp>
|
||||||
#include <libslic3r/Geometry/ConvexHull.hpp>
|
#include <libslic3r/Geometry/ConvexHull.hpp>
|
||||||
|
|
||||||
#include "seq_defs.hpp"
|
#include "seq_defs.hpp"
|
||||||
@ -6238,6 +6239,147 @@ bool check_PointsOutsidePolygons(const std::vector<Rational>
|
|||||||
const std::vector<Slic3r::Polygon> &polygons,
|
const std::vector<Slic3r::Polygon> &polygons,
|
||||||
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
|
const std::vector<std::vector<Slic3r::Polygon> > &unreachable_polygons)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
{
|
||||||
|
printf("Levels U %d,%d\n", unreachable_polygons[0].size(), unreachable_polygons[1].size());
|
||||||
|
|
||||||
|
int c = 0;
|
||||||
|
string svg_filename = "collision_checking.svg";
|
||||||
|
SVG checking_svg(svg_filename);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
|
||||||
|
{
|
||||||
|
Polygon display_polygon = polygons[i];
|
||||||
|
|
||||||
|
for (unsigned int j = 0; j < display_polygon.points.size(); ++j)
|
||||||
|
{
|
||||||
|
display_polygon.points[j] = Point(SEQ_SVG_SCALE_FACTOR * (display_polygon.points[j].x() + dec_values_X[i].as_double()),
|
||||||
|
SEQ_SVG_SCALE_FACTOR * (display_polygon.points[j].y() + dec_values_Y[i].as_double()));
|
||||||
|
}
|
||||||
|
|
||||||
|
string color;
|
||||||
|
|
||||||
|
switch(c % 8)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
color = "green";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
color = "blue";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
color = "red";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
color = "grey";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
color = "cyan";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
color = "magenta";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
color = "yellow";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
{
|
||||||
|
color = "black";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
color = "indigo";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checking_svg.draw(display_polygon, color);
|
||||||
|
++c;
|
||||||
|
}
|
||||||
|
for (unsigned int i = 1; i < unreachable_polygons.size(); ++i)
|
||||||
|
{
|
||||||
|
for (unsigned int k = 0; k < unreachable_polygons[i].size(); ++k)
|
||||||
|
{
|
||||||
|
Polygon display_polygon = unreachable_polygons[i][k];
|
||||||
|
|
||||||
|
for (unsigned int j = 0; j < display_polygon.points.size(); ++j)
|
||||||
|
{
|
||||||
|
display_polygon.points[j] = Point(SEQ_SVG_SCALE_FACTOR * (display_polygon.points[j].x() + dec_values_X[i].as_double()),
|
||||||
|
SEQ_SVG_SCALE_FACTOR * (display_polygon.points[j].y() + dec_values_Y[i].as_double()));
|
||||||
|
}
|
||||||
|
|
||||||
|
string color;
|
||||||
|
|
||||||
|
switch(c % 8)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
color = "green";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
color = "blue";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
color = "red";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
color = "grey";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
color = "cyan";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
color = "magenta";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
color = "yellow";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
{
|
||||||
|
color = "black";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
color = "indigo";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checking_svg.draw(display_polygon, color);
|
||||||
|
++c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checking_svg.Close();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!polygons.empty())
|
if (!polygons.empty())
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
|
for (unsigned int i = 0; i < polygons.size() - 1; ++i)
|
||||||
@ -6354,7 +6496,7 @@ bool check_PointsOutsidePolygons(const std::vector<Rational>
|
|||||||
printf("X[i]: %.3f, Y[i]: %.3f, X[j]: %.3f, Y[j]: %.3f\n", dec_values_X[i].as_double(), dec_values_Y[i].as_double(), dec_values_X[j].as_double(), dec_values_Y[j].as_double());
|
printf("X[i]: %.3f, Y[i]: %.3f, X[j]: %.3f, Y[j]: %.3f\n", dec_values_X[i].as_double(), dec_values_Y[i].as_double(), dec_values_X[j].as_double(), dec_values_Y[j].as_double());
|
||||||
printf("Outside 2: %.3f\n", outside);
|
printf("Outside 2: %.3f\n", outside);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (outside > -EPSILON)
|
if (outside > -EPSILON)
|
||||||
{
|
{
|
||||||
|
@ -25,12 +25,12 @@ static Sequential::PrinterGeometry get_printer_geometry() {
|
|||||||
|
|
||||||
// Just hardcode MK4 geometry for now.
|
// Just hardcode MK4 geometry for now.
|
||||||
std::vector<ExtruderSlice> slices;
|
std::vector<ExtruderSlice> slices;
|
||||||
slices.push_back(ExtruderSlice{ 0, CONVEX, { { { -5000000, -5000000 }, { 5000000, -5000000 }, { 5000000, 5000000 }, { -5000000, 5000000 } } } });
|
slices.push_back(ExtruderSlice{ 0, CONVEX, { { { -5000000, -5000000 }, { 5000000, -5000000 }, { 5000000, 5000000 }, { -5000000, 5000000 } } } });
|
||||||
slices.push_back(ExtruderSlice{ 3000000, CONVEX, { { { -10000000, -21000000 }, { 37000000, -21000000 }, { 37000000, 44000000 }, { -10000000, 44000000 } },
|
slices.push_back(ExtruderSlice{ 3000000, CONVEX, { { { -10000000, -21000000 }, { 37000000, -21000000 }, { 37000000, 44000000 }, { -10000000, 44000000 } },
|
||||||
{ { -40000000, -45000000 }, { 38000000, -45000000 }, { 38000000, 20000000 }, { -40000000, 20000000 } } } });
|
{ { -40000000, -45000000 }, { 38000000, -45000000 }, { 38000000, 20000000 }, { -40000000, 20000000 } } } });
|
||||||
slices.push_back(ExtruderSlice{ 11000000, BOX, { { {-350000000, -23000000 }, {350000000, -23000000 }, {350000000, -35000000 }, {-350000000, -35000000 } } } });
|
slices.push_back(ExtruderSlice{ 11000000, BOX, { { {-350000000, -23000000 }, { 350000000, -23000000 }, { 350000000, -35000000 }, {-350000000, -35000000 } } } });
|
||||||
slices.push_back(ExtruderSlice{ 13000000, BOX, { { { -12000000, -350000000 }, { 9000000, -350000000 }, { 9000000, -39000000 }, { -12000000, -39000000 } },
|
slices.push_back(ExtruderSlice{ 13000000, BOX, { { { -13000000, -84000000 }, { 11000000, -84000000 }, { 11000000, -38000000 }, { -13000000, -38000000 } },
|
||||||
{ { -12000000, -250000000 }, {300000000, -250000000 }, {300000000, -82000000 }, { -12000000, -82000000} } } });
|
{ { 11000000, -300000000 }, { 300000000, -300000000 }, { 300000000, -84000000 }, { 11000000, -84000000 } } } });
|
||||||
|
|
||||||
|
|
||||||
// Geometry (simplified head model) for the MK3S printer
|
// Geometry (simplified head model) for the MK3S printer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user