Revisited all test modules for sequential printing library.

This commit is contained in:
surynek 2025-02-18 16:38:48 +01:00 committed by Lukas Matena
parent eac29863ed
commit f37de58c57
10 changed files with 1336 additions and 686 deletions

View File

@ -18,8 +18,7 @@ target_link_libraries(sequential_decimator PRIVATE libseqarrange)
if (SLIC3R_BUILD_TESTS)
find_package(Catch2 3.8 REQUIRED)
add_executable(libseqarrange_tests test/prusaparts.cpp test/seq_test_polygon.cpp)
# test/seq_test_sequential.cpp test/seq_test_preprocess.cpp test/seq_test_interface.cpp
add_executable(libseqarrange_tests test/prusaparts.cpp test/seq_test_polygon.cpp test/seq_test_sequential.cpp test/seq_test_preprocess.cpp test/seq_test_interface.cpp)
target_include_directories(libseqarrange_tests PRIVATE src )
target_link_libraries(libseqarrange_tests PRIVATE Catch2::Catch2WithMain libseqarrange)

View File

@ -11006,12 +11006,12 @@ bool optimize_SubglobalSequentialPolygonNonoverlappingBinaryCentered(const Solve
if (!optimized)
{
if (curr_polygon <= 0)
{
{
return false;
}
else
{
if (curr_polygon + solver_configuration.object_group_size < polygons.size())
if (curr_polygon + solver_configuration.object_group_size < polygons.size())
{
curr_polygon += solver_configuration.object_group_size;

View File

@ -1,6 +1,6 @@
/*================================================================*/
/*
* Author: Pavel Surynek, 2023 - 2024
* Author: Pavel Surynek, 2023 - 2025
* Company: Prusa Research
*
* File: seq_test_interface.cpp
@ -40,8 +40,8 @@ using namespace Sequential;
/*----------------------------------------------------------------*/
const int SEQ_PRUSA_MK3S_X_SIZE = 2500;
const int SEQ_PRUSA_MK3S_Y_SIZE = 2100;
const coord_t SEQ_PRUSA_MK3S_X_SIZE = 250000000;
const coord_t SEQ_PRUSA_MK3S_Y_SIZE = 210000000;
/*----------------------------------------------------------------*/
@ -502,25 +502,43 @@ void save_import_data(const std::string &filename,
/*----------------------------------------------------------------*/
TEST_CASE("Interface test 1", "[Sequential Arrangement Interface]")
{
//void interface_test_1(void)
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing interface 1 ...\n");
INFO("Testing interface 1 ...");
#ifdef DEBUG
start = clock();
#endif
SolverConfiguration solver_configuration;
solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_HIGH;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
printf("Loading objects ...\n");
#ifdef DEBUG
{
printf("Loading objects ...\n");
}
#endif
std::vector<ObjectToPrint> objects_to_print = load_exported_data_from_text(arrange_data_export_text);
REQUIRE(objects_to_print.size() > 0);
printf("Loading objects ... finished\n");
#ifdef DEBUG
{
printf("Loading objects ... finished\n");
}
#endif
std::vector<ScheduledPlate> scheduled_plates;
printf("Scheduling objects for sequential print ...\n");
#ifdef DEBUG
{
printf("Scheduling objects for sequential print ...\n");
}
#endif
int result = schedule_ObjectsForSequentialPrint(solver_configuration,
objects_to_print,
@ -529,19 +547,35 @@ TEST_CASE("Interface test 1", "[Sequential Arrangement Interface]")
REQUIRE(result == 0);
if (result == 0)
{
printf("Object scheduling for sequential print SUCCESSFUL !\n");
#ifdef DEBUG
{
printf("Object scheduling for sequential print SUCCESSFUL !\n");
}
#endif
printf("Number of plates: %ld\n", scheduled_plates.size());
#ifdef DEBUG
{
printf("Number of plates: %ld\n", scheduled_plates.size());
}
#endif
REQUIRE(scheduled_plates.size() > 0);
for (unsigned int plate = 0; plate < scheduled_plates.size(); ++plate)
{
printf(" Number of objects on plate: %ld\n", scheduled_plates[plate].scheduled_objects.size());
#ifdef DEBUG
{
printf(" Number of objects on plate: %ld\n", scheduled_plates[plate].scheduled_objects.size());
}
#endif
REQUIRE(scheduled_plates[plate].scheduled_objects.size() > 0);
for (const auto& scheduled_object: scheduled_plates[plate].scheduled_objects)
{
cout << " ID: " << scheduled_object.id << " X: " << scheduled_object.x << " Y: " << scheduled_object.y << endl;
#ifdef DEBUG
{
cout << " ID: " << scheduled_object.id << " X: " << scheduled_object.x << " Y: " << scheduled_object.y << endl;
}
#endif
REQUIRE(scheduled_object.x >= solver_configuration.plate_bounding_box.min.x() * SEQ_SLICER_SCALE_FACTOR);
REQUIRE(scheduled_object.x <= solver_configuration.plate_bounding_box.max.x() * SEQ_SLICER_SCALE_FACTOR);
REQUIRE(scheduled_object.y >= solver_configuration.plate_bounding_box.min.y() * SEQ_SLICER_SCALE_FACTOR);
@ -551,39 +585,66 @@ TEST_CASE("Interface test 1", "[Sequential Arrangement Interface]")
}
else
{
printf("Something went WRONG during sequential scheduling (code: %d)\n", result);
#ifdef DEBUG
{
printf("Something went WRONG during sequential scheduling (code: %d)\n", result);
}
#endif
}
#ifdef DEBUG
finish = clock();
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing interface 1 ... finished\n");
#endif
#ifdef DEBUG
{
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
INFO("Testing interface 1 ... finished");
}
TEST_CASE("Interface test 2", "[Sequential Arrangement Interface]")
{
//void interface_test_2(void)
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing interface 2 ...\n");
INFO("Testing interface 2 ...");
#ifdef DEBUG
start = clock();
#endif
SolverConfiguration solver_configuration;
solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_HIGH;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
printf("Loading objects ...\n");
#ifdef DEBUG
{
printf("Loading objects ...\n");
}
#endif
std::vector<ObjectToPrint> objects_to_print = load_exported_data_from_text(arrange_data_export_text);
std::vector<std::vector<Slic3r::Polygon> > convex_unreachable_zones;
std::vector<std::vector<Slic3r::Polygon> > box_unreachable_zones;
printf("Preparing extruder unreachable zones ...\n");
#ifdef DEBUG
{
printf("Preparing extruder unreachable zones ...\n");
}
#endif
setup_ExtruderUnreachableZones(solver_configuration, convex_unreachable_zones, box_unreachable_zones);
std::vector<ScheduledPlate> scheduled_plates;
printf("Scheduling objects for sequential print ...\n");
#ifdef DEBUG
{
printf("Scheduling objects for sequential print ...\n");
}
#endif
int result = schedule_ObjectsForSequentialPrint(solver_configuration,
objects_to_print,
@ -594,20 +655,30 @@ TEST_CASE("Interface test 2", "[Sequential Arrangement Interface]")
REQUIRE(result == 0);
if (result == 0)
{
printf("Object scheduling for sequential print SUCCESSFUL !\n");
printf("Number of plates: %ld\n", scheduled_plates.size());
#ifdef DEBUG
{
printf("Object scheduling for sequential print SUCCESSFUL !\n");
printf("Number of plates: %ld\n", scheduled_plates.size());
}
#endif
REQUIRE(scheduled_plates.size() > 0);
for (unsigned int plate = 0; plate < scheduled_plates.size(); ++plate)
{
printf(" Number of objects on plate: %ld\n", scheduled_plates[plate].scheduled_objects.size());
#ifdef DEBUG
{
printf(" Number of objects on plate: %ld\n", scheduled_plates[plate].scheduled_objects.size());
}
#endif
REQUIRE(scheduled_plates[plate].scheduled_objects.size() > 0);
for (const auto& scheduled_object: scheduled_plates[plate].scheduled_objects)
{
cout << " ID: " << scheduled_object.id << " X: " << scheduled_object.x << " Y: " << scheduled_object.y << endl;
#ifdef DEBUG
{
cout << " ID: " << scheduled_object.id << " X: " << scheduled_object.x << " Y: " << scheduled_object.y << endl;
}
#endif
REQUIRE(scheduled_object.x >= solver_configuration.plate_bounding_box.min.x() * SEQ_SLICER_SCALE_FACTOR);
REQUIRE(scheduled_object.x <= solver_configuration.plate_bounding_box.max.x() * SEQ_SLICER_SCALE_FACTOR);
REQUIRE(scheduled_object.y >= solver_configuration.plate_bounding_box.min.y() * SEQ_SLICER_SCALE_FACTOR);
@ -617,119 +688,224 @@ TEST_CASE("Interface test 2", "[Sequential Arrangement Interface]")
}
else
{
printf("Something went WRONG during sequential scheduling (code: %d)\n", result);
#ifdef DEBUG
{
printf("Something went WRONG during sequential scheduling (code: %d)\n", result);
}
#endif
}
#ifdef DEBUG
finish = clock();
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing interface 2 ... finished\n");
#endif
#ifdef DEBUG
{
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
INFO("Testing interface 2 ... finished");
}
TEST_CASE("Interface test 3", "[Sequential Arrangement Interface]")
{
//void interface_test_3(void)
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing interface 3 ...\n");
INFO("Testing interface 3 ...");
#ifdef DEBUG
start = clock();
#endif
PrinterGeometry printer_geometry;
PrinterGeometry printer_geometry =
{
{ {0, 0}, {250000000, 0}, {250000000, 210000000}, {0, 210000000} },
{ 0, 3000000, 22000000},
{ 11000000, 13000000 },
{
{0, { { {-500000, -500000}, {500000, -500000}, {500000, 500000}, {-500000, 500000} } } },
{3000000, { { {-9000000, -17000000}, {40000000, -17000000}, {40000000, 44000000}, {-9000000, 44000000} },
{ {-36000000, -44000000}, {40000000, -44000000}, {40000000, -13000000}, {-36000000, -13000000} } } },
{22000000, { { {-41000000, -45000000}, {16000000, -45000000}, {16000000, 22000000}, {-41000000, 22000000} },
{ {11000000, -45000000}, {39000000, -45000000}, {39000000, 45000000}, {11000000 , 45000000} } } },
{11000000, { { {-300000000, -4000000}, {300000000, -4000000}, {300000000, -14000000}, {-300000000, -14000000} } } },
{13000000, { { {-13000000, -84000000}, {11000000, -84000000}, {11000000, -38000000}, {-13000000, -38000000} },
{ {11000000, -300000000}, {300000000, -300000000}, {300000000, -84000000}, {11000000, -84000000} } } }
}
};
/*
int result = load_printer_geometry_from_text(printer_geometry_mk4_text, printer_geometry);
REQUIRE(result == 0);
if (result != 0)
{
printf("Printer geometry load error.\n");
#ifdef DEBUG
{
printf("Printer geometry load error.\n");
}
#endif
return;
}
*/
REQUIRE(printer_geometry.plate.points.size() == 4);
for (const auto& convex_height: printer_geometry.convex_heights)
#ifdef DEBUG
{
cout << "convex_height:" << convex_height << endl;
}
for (const auto& box_height: printer_geometry.box_heights)
{
cout << "box_height:" << box_height << endl;
}
printf("extruder slices:\n");
REQUIRE(printer_geometry.extruder_slices.size() > 0);
for (std::map<coord_t, std::vector<Polygon> >::const_iterator extruder_slice = printer_geometry.extruder_slices.begin(); extruder_slice != printer_geometry.extruder_slices.end(); ++extruder_slice)
{
for (const auto &polygon: extruder_slice->second)
for (const auto& convex_height: printer_geometry.convex_heights)
{
printf(" polygon height: %d\n", extruder_slice->first);
for (const auto &point: polygon.points)
{
cout << " " << point.x() << " " << point.y() << endl;
}
cout << "convex_height:" << convex_height << endl;
}
}
#endif
#ifdef DEBUG
{
for (const auto& box_height: printer_geometry.box_heights)
{
cout << "box_height:" << box_height << endl;
}
}
#endif
#ifdef DEBUG
{
printf("extruder slices:\n");
}
#endif
REQUIRE(printer_geometry.extruder_slices.size() > 0);
#ifdef DEBUG
{
for (std::map<coord_t, std::vector<Polygon> >::const_iterator extruder_slice = printer_geometry.extruder_slices.begin(); extruder_slice != printer_geometry.extruder_slices.end(); ++extruder_slice)
{
for (const auto &polygon: extruder_slice->second)
{
printf(" polygon height: %d\n", extruder_slice->first);
for (const auto &point: polygon.points)
{
cout << " " << point.x() << " " << point.y() << endl;
}
}
}
}
#endif
#ifdef DEBUG
finish = clock();
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing interface 3 ... finished\n");
{
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
INFO("Testing interface 3 ... finished");
}
TEST_CASE("Interface test 4", "[Sequential Arrangement Interface]")
//void interface_test_4(void)
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing interface 4 ...\n");
INFO("Testing interface 4 ...");
#ifdef DEBUG
start = clock();
#endif
SolverConfiguration solver_configuration;
solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_HIGH;
solver_configuration.object_group_size = 4;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
printf("Loading objects ...\n");
#ifdef DEBUG
{
printf("Loading objects ...\n");
}
#endif
std::vector<ObjectToPrint> objects_to_print = load_exported_data_from_text(arrange_data_export_text);
printf("Loading objects ... finished\n");
#ifdef DEBUG
{
printf("Loading objects ... finished\n");
}
#endif
PrinterGeometry printer_geometry;
printf("Loading printer geometry ...\n");
#ifdef DEBUG
{
printf("Loading printer geometry ...\n");
}
#endif
int result = load_printer_geometry_from_text(printer_geometry_mk4_compatibility_text, printer_geometry);
REQUIRE(result == 0);
if (result != 0)
{
printf("Cannot load printer geometry (code: %d).\n", result);
#ifdef DEBUG
{
printf("Cannot load printer geometry (code: %d).\n", result);
}
#endif
return;
}
solver_configuration.setup(printer_geometry);
printf("Loading printer geometry ... finished\n");
#ifdef DEBUG
{
printf("Loading printer geometry ... finished\n");
}
#endif
std::vector<ScheduledPlate> scheduled_plates;
printf("Scheduling objects for sequential print ...\n");
#ifdef DEBUG
{
printf("Scheduling objects for sequential print ...\n");
}
#endif
scheduled_plates = schedule_ObjectsForSequentialPrint(solver_configuration,
printer_geometry,
objects_to_print);
printf("Object scheduling for sequential print SUCCESSFUL !\n");
printf("Number of plates: %ld\n", scheduled_plates.size());
#ifdef DEBUG
{
printf("Object scheduling for sequential print SUCCESSFUL !\n");
}
#endif
#ifdef DEBUG
{
printf("Number of plates: %ld\n", scheduled_plates.size());
}
#endif
REQUIRE(scheduled_plates.size() > 0);
for (unsigned int plate = 0; plate < scheduled_plates.size(); ++plate)
{
printf(" Number of objects on plate: %ld\n", scheduled_plates[plate].scheduled_objects.size());
#ifdef DEBUG
{
printf(" Number of objects on plate: %ld\n", scheduled_plates[plate].scheduled_objects.size());
}
#endif
REQUIRE(scheduled_plates[plate].scheduled_objects.size() > 0);
for (const auto& scheduled_object: scheduled_plates[plate].scheduled_objects)
{
cout << " ID: " << scheduled_object.id << " X: " << scheduled_object.x << " Y: " << scheduled_object.y << endl;
#ifdef DEBUG
{
cout << " ID: " << scheduled_object.id << " X: " << scheduled_object.x << " Y: " << scheduled_object.y << endl;
}
#endif
BoundingBox plate_box = get_extents(printer_geometry.plate);
@ -739,68 +915,122 @@ TEST_CASE("Interface test 4", "[Sequential Arrangement Interface]")
REQUIRE(scheduled_object.y <= plate_box.max.y());
}
}
#ifdef DEBUG
finish = clock();
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing interface 4 ... finished\n");
#endif
#ifdef DEBUG
{
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
INFO("Testing interface 4 ... finished");
}
TEST_CASE("Interface test 5", "[Sequential Arrangement Interface]")
//void interface_test_5(void)
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing interface 5 ...\n");
INFO("Testing interface 5 ...");
#ifdef DEBUG
start = clock();
#endif
SolverConfiguration solver_configuration;
solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_LOW;
solver_configuration.object_group_size = 4;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
printf("Loading objects ...\n");
#ifdef DEBUG
{
printf("Loading objects ...\n");
}
#endif
std::vector<ObjectToPrint> objects_to_print = load_exported_data_from_text(arrange_data_export_text);
printf("Loading objects ... finished\n");
#ifdef DEBUG
{
printf("Loading objects ... finished\n");
}
#endif
PrinterGeometry printer_geometry;
printf("Loading printer geometry ...\n");
#ifdef DEBUG
{
printf("Loading printer geometry ...\n");
}
#endif
int result = load_printer_geometry_from_text(printer_geometry_mk4_compatibility_text, printer_geometry);
REQUIRE(result == 0);
if (result != 0)
{
printf("Cannot load printer geometry (code: %d).\n", result);
#ifdef DEBUG
{
printf("Cannot load printer geometry (code: %d).\n", result);
}
#endif
return;
}
solver_configuration.setup(printer_geometry);
printf("Loading printer geometry ... finished\n");
#ifdef DEBUG
{
printf("Loading printer geometry ... finished\n");
}
#endif
std::vector<ScheduledPlate> scheduled_plates;
printf("Scheduling objects for sequential print ...\n");
#ifdef DEBUG
{
printf("Scheduling objects for sequential print ...\n");
}
#endif
scheduled_plates = schedule_ObjectsForSequentialPrint(solver_configuration,
printer_geometry,
objects_to_print,
[](int progress) { printf("Progress: %d\n", progress);
REQUIRE(progress >= 0);
[](int progress) {
#ifdef DEBUG
{ printf("Progress: %d\n", progress); }
#endif
REQUIRE(progress >= 0);
REQUIRE(progress <= 100); });
printf("Object scheduling for sequential print SUCCESSFUL !\n");
printf("Number of plates: %ld\n", scheduled_plates.size());
#ifdef DEBUG
{
printf("Object scheduling for sequential print SUCCESSFUL !\n");
}
#endif
#ifdef DEBUG
{
printf("Number of plates: %ld\n", scheduled_plates.size());
}
#endif
REQUIRE(scheduled_plates.size() > 0);
for (unsigned int plate = 0; plate < scheduled_plates.size(); ++plate)
{
printf(" Number of objects on plate: %ld\n", scheduled_plates[plate].scheduled_objects.size());
#ifdef DEBUG
{
printf("Number of objects on plate: %ld\n", scheduled_plates[plate].scheduled_objects.size());
}
#endif
REQUIRE(scheduled_plates[plate].scheduled_objects.size() > 0);
for (const auto& scheduled_object: scheduled_plates[plate].scheduled_objects)
{
cout << " ID: " << scheduled_object.id << " X: " << scheduled_object.x << " Y: " << scheduled_object.y << endl;
#ifdef DEBUG
{
cout << " ID: " << scheduled_object.id << " X: " << scheduled_object.x << " Y: " << scheduled_object.y << endl;
}
#endif
BoundingBox plate_box = get_extents(printer_geometry.plate);
@ -811,46 +1041,81 @@ TEST_CASE("Interface test 5", "[Sequential Arrangement Interface]")
}
}
#ifdef DEBUG
finish = clock();
printf("Solving time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
{
printf("Solving time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
start = clock();
#endif
start = clock();
printf("Checking sequential printability ...\n");
#ifdef DEBUG
{
printf("Checking sequential printability ...\n");
}
#endif
bool printable = check_ScheduledObjectsForSequentialPrintability(solver_configuration,
printer_geometry,
objects_to_print,
scheduled_plates);
printf(" Scheduled/arranged objects are sequentially printable: %s\n", (printable ? "YES" : "NO"));
scheduled_plates);
#ifdef DEBUG
{
printf(" Scheduled/arranged objects are sequentially printable: %s\n", (printable ? "YES" : "NO"));
}
#endif
REQUIRE(printable);
printf("Checking sequential printability ... finished\n");
#ifdef DEBUG
{
printf("Checking sequential printability ... finished\n");
}
#endif
finish = clock();
printf("Checking time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
#ifdef DEBUG
finish = clock();
{
printf("Checking time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
printf("Testing interface 5 ... finished\n");
INFO("Testing interface 5 ... finished");
}
TEST_CASE("Interface test 6", "[Sequential Arrangement Interface]")
//void interface_test_6(void)
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing interface 6 ...\n");
INFO("Testing interface 6 ...");
#ifdef DEBUG
start = clock();
#endif
SolverConfiguration solver_configuration;
solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_LOW;
solver_configuration.object_group_size = 4;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
printf("Loading objects ...\n");
#ifdef DEBUG
{
printf("Loading objects ...\n");
}
#endif
std::vector<ObjectToPrint> objects_to_print = load_exported_data_from_text(arrange_data_export_text);
REQUIRE(objects_to_print.size() > 0);
printf("Loading objects ... finished\n");
REQUIRE(objects_to_print.size() > 0);
#ifdef DEBUG
{
printf("Loading objects ... finished\n");
}
#endif
for (auto& object_to_print: objects_to_print)
{
@ -859,41 +1124,77 @@ TEST_CASE("Interface test 6", "[Sequential Arrangement Interface]")
PrinterGeometry printer_geometry;
printf("Loading printer geometry ...\n");
#ifdef DEBUG
{
printf("Loading printer geometry ...\n");
}
#endif
int result = load_printer_geometry_from_text(printer_geometry_mk4_compatibility_text, printer_geometry);
REQUIRE(result == 0);
if (result != 0)
{
printf("Cannot load printer geometry (code: %d).\n", result);
#ifdef DEBUG
{
printf("Cannot load printer geometry (code: %d).\n", result);
}
#endif
return;
}
solver_configuration.setup(printer_geometry);
printf("Loading printer geometry ... finished\n");
#ifdef DEBUG
{
printf("Loading printer geometry ... finished\n");
}
#endif
std::vector<ScheduledPlate> scheduled_plates;
printf("Scheduling objects for sequential print ...\n");
#ifdef DEBUG
{
printf("Scheduling objects for sequential print ...\n");
}
#endif
scheduled_plates = schedule_ObjectsForSequentialPrint(solver_configuration,
printer_geometry,
objects_to_print,
[](int progress) { printf("Progress: %d\n", progress);
[](int progress) {
#ifdef DEBUG
{ printf("Progress: %d\n", progress); }
#endif
REQUIRE(progress >= 0);
REQUIRE(progress <= 100); });
printf("Object scheduling for sequential print SUCCESSFUL !\n");
printf("Number of plates: %ld\n", scheduled_plates.size());
#ifdef DEBUG
{
printf("Object scheduling for sequential print SUCCESSFUL !\n");
}
#endif
#ifdef DEBUG
{
printf("Number of plates: %ld\n", scheduled_plates.size());
}
#endif
REQUIRE(scheduled_plates.size() > 0);
for (unsigned int plate = 0; plate < scheduled_plates.size(); ++plate)
{
printf(" Number of objects on plate: %ld\n", scheduled_plates[plate].scheduled_objects.size());
#ifdef DEBUG
{
printf(" Number of objects on plate: %ld\n", scheduled_plates[plate].scheduled_objects.size());
}
#endif
REQUIRE(scheduled_plates[plate].scheduled_objects.size() > 0);
for (const auto& scheduled_object: scheduled_plates[plate].scheduled_objects)
{
cout << " ID: " << scheduled_object.id << " X: " << scheduled_object.x << " Y: " << scheduled_object.y << endl;
#ifdef DEBUG
{
cout << " ID: " << scheduled_object.id << " X: " << scheduled_object.x << " Y: " << scheduled_object.y << endl;
}
#endif
BoundingBox plate_box = get_extents(printer_geometry.plate);
REQUIRE(scheduled_object.x >= plate_box.min.x());
@ -903,27 +1204,46 @@ TEST_CASE("Interface test 6", "[Sequential Arrangement Interface]")
}
}
#ifdef DEBUG
finish = clock();
printf("Solving time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
{
printf("Solving time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
start = clock();
#endif
start = clock();
printf("Checking sequential printability ...\n");
#ifdef DEBUG
{
printf("Checking sequential printability ...\n");
}
#endif
bool printable = check_ScheduledObjectsForSequentialPrintability(solver_configuration,
printer_geometry,
objects_to_print,
scheduled_plates);
printf(" Scheduled/arranged objects are sequentially printable: %s\n", (printable ? "YES" : "NO"));
#ifdef DEBUG
{
printf(" Scheduled/arranged objects are sequentially printable: %s\n", (printable ? "YES" : "NO"));
}
#endif
REQUIRE(printable);
printf("Checking sequential printability ... finished\n");
#ifdef DEBUG
{
printf("Checking sequential printability ... finished\n");
}
finish = clock();
#endif
finish = clock();
printf("Checking time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
#ifdef DEBUG
{
printf("Checking time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
printf("Testing interface 6 ... finished\n");
INFO("Testing interface 6 ... finished");
}

View File

@ -1,6 +1,6 @@
/*================================================================*/
/*
* Author: Pavel Surynek, 2023 - 2024
* Author: Pavel Surynek, 2023 - 2025
* Company: Prusa Research
*
* File: seq_test_interface.hpp

View File

@ -1,6 +1,6 @@
/*================================================================*/
/*
* Author: Pavel Surynek, 2023 - 2024
* Author: Pavel Surynek, 2023 - 2025
* Company: Prusa Research
*
* File: seq_test_polygon.cpp
@ -878,8 +878,6 @@ void polygon_test_6(void)
z3::expr deco_1 = expr(z_context.real_const("deco_1"));
z3::expr lino_1 = (valo_1 * deco_1 == 0);
printf("value: %.3f\n", value);
cout << float(z_model[i]) << "\n";
@ -1139,7 +1137,7 @@ TEST_CASE("Polygon test 7", "[Polygon]")
double value = X_positions[i].as_double();
printf("Orig X: %.3f\n", value);
value = Y_positi ons[i].as_double();
value = Y_positions[i].as_double();
printf("Orig Y: %.3f\n", value);
}
}
@ -1446,37 +1444,7 @@ void polygon_test_8(void)
else
{
break;
}
#ifdef DEBUG
{
cout << float(z_model[i]) << "\n";
switch (z_model.get_const_interp(z_model[i]).bool_value())
{
case Z3_L_FALSE:
{
printf(" value: FALSE\n");
break;
}
case Z3_L_TRUE:
{
printf(" value: TRUE\n");
break;
}
case Z3_L_UNDEF:
{
printf(" value: UNDEF\n");
break;
}
default:
{
break;
}
}
}
#endif
}
}
#ifdef DEBUG
finish = clock();
@ -1499,7 +1467,8 @@ void polygon_test_8(void)
printf("Orig X: %.3f\n", value);
value = Y_positions[i].as_double();
printf("Orig Y: %.3f\n", value);
printf("Orig Y: %.3f\n", value);
}
}
#endif
@ -1508,7 +1477,7 @@ void polygon_test_8(void)
Polygon display_polygon_1 = scale_UP(polygon_1, poly_1_pos_x, poly_1_pos_y);
Polygon display_polygon_2 = scale_UP(polygon_2, poly_2_pos_x, poly_2_pos_y);
Polygon display_polygon_3 = scale_UP(polygon_3, poly_3_pos_x, poly_3_pos_y);
preview_svg.draw(display_polygon_1, "green");
preview_svg.draw(display_polygon_2, "blue");
preview_svg.draw(display_polygon_3, "red");
@ -1777,35 +1746,6 @@ TEST_CASE("Polygon test 9", "[Polygon]")
{
break;
}
#ifdef DEBUG
{
cout << float(z_model[i]) << "\n";
switch (z_model.get_const_interp(z_model[i]).bool_value())
{
case Z3_L_FALSE:
{
printf(" value: FALSE\n");
break;
}
case Z3_L_TRUE:
{
printf(" value: TRUE\n");
break;
}
case Z3_L_UNDEF:
{
printf(" value: UNDEF\n");
break;
}
default:
{
break;
}
}
}
#endif
}
#ifdef DEBUG
finish = clock();
@ -2088,35 +2028,6 @@ void polygon_test_10(void)
{
break;
}
#ifdef DEBUG
{
cout << float(z_model[i]) << "\n";
switch (z_model.get_const_interp(z_model[i]).bool_value())
{
case Z3_L_FALSE:
{
printf(" value: FALSE\n");
break;
}
case Z3_L_TRUE:
{
printf(" value: TRUE\n");
break;
}
case Z3_L_UNDEF:
{
printf(" value: UNDEF\n");
break;
}
default:
{
break;
}
}
}
#endif
}
#ifdef DEBUG
finish = clock();
@ -2558,35 +2469,6 @@ TEST_CASE("Polygon test 11", "[Polygon]")
{
break;
}
#ifdef DEBUG
{
cout << float(z_model[i]) << "\n";
switch (z_model.get_const_interp(z_model[i]).bool_value())
{
case Z3_L_FALSE:
{
printf(" value: FALSE\n");
break;
}
case Z3_L_TRUE:
{
printf(" value: TRUE\n");
break;
}
case Z3_L_UNDEF:
{
printf(" value: UNDEF\n");
break;
}
default:
{
break;
}
}
}
#endif
}
#ifdef DEBUG
finish = clock();

View File

@ -1,6 +1,6 @@
/*================================================================*/
/*
* Author: Pavel Surynek, 2023 - 2024
* Author: Pavel Surynek, 2023 - 2025
* Company: Prusa Research
*
* File: seq_test_polygon.hpp

View File

@ -1,6 +1,6 @@
/*================================================================*/
/*
* Author: Pavel Surynek, 2023 - 2024
* Author: Pavel Surynek, 2023 - 2025
* Company: Prusa Research
*
* File: seq_test_preprocess.cpp
@ -50,13 +50,12 @@ using namespace Sequential;
/*----------------------------------------------------------------*/
const int SEQ_PRUSA_MK3S_X_SIZE = 2500;
const int SEQ_PRUSA_MK3S_Y_SIZE = 2100;
const coord_t SEQ_PRUSA_MK3S_X_SIZE = 250000000;
const coord_t SEQ_PRUSA_MK3S_Y_SIZE = 210000000;
/*----------------------------------------------------------------*/
/*
static Polygon scale_UP(const Polygon &polygon)
{
Polygon poly = polygon;
@ -68,7 +67,7 @@ static Polygon scale_UP(const Polygon &polygon)
return poly;
}
*/
static Polygon scale_UP(const Polygon &polygon, double x_pos, double y_pos)
{
@ -88,14 +87,17 @@ std::vector<Polygon> test_polygons;
TEST_CASE("Preprocessing test 1", "[Sequential Arrangement Preprocessing]")
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing preprocessing 1 ...\n");
INFO("Testing preprocessing 1 ...");
SolverConfiguration solver_configuration;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
#ifdef DEBUG
start = clock();
#endif
for (unsigned int i = 0; i < PRUSA_PART_POLYGONS.size(); ++i)
{
Polygon scale_down_polygon;
@ -110,29 +112,40 @@ TEST_CASE("Preprocessing test 1", "[Sequential Arrangement Preprocessing]")
Polygon display_polygon = scale_UP(test_polygons[i], 1000, 1000);
preview_svg.draw(display_polygon, "blue");
preview_svg.Close();
}
}
#ifdef DEBUG
finish = clock();
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing preprocessing 1 ... finished\n");
#endif
#ifdef DEBUG
{
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
INFO("Testing preprocessing 1 ... finished");
}
TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
{
//TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
void preprocessing_test_2(void)
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing preprocess 2 ...\n");
INFO("Testing preprocess 2 ...");
#ifdef DEBUG
start = clock();
#endif
SolverConfiguration solver_configuration;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
vector<Polygon> polygons;
vector<Polygon> unreachable_polygons;
for (unsigned int i = 0; i < PRUSA_PART_POLYGONS.size(); ++i)
for (unsigned int i = 0; i < 8 /*PRUSA_PART_POLYGONS.size()*/; ++i)
{
Polygon scale_down_polygon;
scaleDown_PolygonForSequentialSolver(PRUSA_PART_POLYGONS[i], scale_down_polygon);
@ -169,21 +182,29 @@ TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
decided_polygons,
remaining_polygons);
printf("----> Optimization finished <----\n");
#ifdef DEBUG
{
printf("----> Optimization finished <----\n");
}
#endif
REQUIRE(optimized);
if (optimized)
{
printf("Polygon positions:\n");
for (unsigned int i = 0; i < decided_polygons.size(); ++i)
#ifdef DEBUG
{
printf(" [%d] %.3f, %.3f (%.3f)\n", decided_polygons[i], poly_positions_X[decided_polygons[i]].as_double(), poly_positions_Y[decided_polygons[i]].as_double(), times_T[decided_polygons[i]].as_double());
}
printf("Remaining polygons: %ld\n", remaining_polygons.size());
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
{
printf(" %d\n", remaining_polygons[i]);
printf("Polygon positions:\n");
for (unsigned int i = 0; i < decided_polygons.size(); ++i)
{
printf(" [%d] %.3f, %.3f (%.3f)\n", decided_polygons[i], poly_positions_X[decided_polygons[i]].as_double(), poly_positions_Y[decided_polygons[i]].as_double(), times_T[decided_polygons[i]].as_double());
}
printf("Remaining polygons: %ld\n", remaining_polygons.size());
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
{
printf(" %d\n", remaining_polygons[i]);
}
}
#endif
SVG preview_svg("preprocess_test_2.svg");
@ -194,29 +215,26 @@ TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
#ifdef DEBUG
{
printf("----> %.3f,%.3f\n", poly_positions_X[decided_polygons[i]].as_double(), poly_positions_Y[decided_polygons[i]].as_double());
for (int k = 0; k < polygons[decided_polygons[i]].points.size(); ++k)
for (unsigned int k = 0; k < polygons[decided_polygons[i]].points.size(); ++k)
{
printf(" xy: %d, %d\n", polygons[decided_polygons[i]].points[k].x(), polygons[decided_polygons[i]].points[k].y());
}
}
#endif
for (unsigned int j = 0; j < unreachable_polygons[decided_polygons[i]].size(); ++j)
#ifdef DEBUG
{
#ifdef DEBUG
for (unsigned int k = 0; k < unreachable_polygons[decided_polygons[i]].points.size(); ++k)
{
for (int k = 0; k < unreachable_polygons[decided_polygons[i]][j].points.size(); ++k)
{
printf(" Pxy: %d, %d\n", unreachable_polygons[decided_polygons[i]][j].points[k].x(), unreachable_polygons[decided_polygons[i]][j].points[k].y());
}
printf(" Pxy: %d, %d\n", unreachable_polygons[decided_polygons[i]].points[k].x(), unreachable_polygons[decided_polygons[i]].points[k].y());
}
#endif
Polygon display_unreachable_polygon = scale_UP(unreachable_polygons[decided_polygons[i]],
poly_positions_X[decided_polygons[i]].as_double(),
poly_positions_Y[decided_polygons[i]].as_double());
preview_svg.draw(display_unreachable_polygon, "lightgrey");
}
#endif
Polygon display_unreachable_polygon = scale_UP(unreachable_polygons[decided_polygons[i]],
poly_positions_X[decided_polygons[i]].as_double(),
poly_positions_Y[decided_polygons[i]].as_double());
preview_svg.draw(display_unreachable_polygon, "lightgrey");
}
}
@ -303,19 +321,33 @@ TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
}
else
{
printf("Polygon optimization FAILED.\n");
}
#ifdef DEBUG
{
printf("Polygon optimization FAILED.\n");
}
#endif
}
#ifdef DEBUG
finish = clock();
#endif
printf("Intermediate time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
#ifdef DEBUG
{
printf("Intermediate time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
vector<Polygon> next_polygons;
vector<Polygon> next_unreachable_polygons;
for (unsigned int i = 0; i < polygon_index_map.size(); ++i)
#ifdef DEBUG
{
printf(" %d\n", polygon_index_map[i]);
for (unsigned int i = 0; i < polygon_index_map.size(); ++i)
{
printf(" %d\n", polygon_index_map[i]);
}
}
#endif
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
{
next_polygons.push_back(polygons[remaining_polygons[i]]);
@ -336,23 +368,33 @@ TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
}
while (!remaining_polygons.empty());
#ifdef DEBUG
finish = clock();
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing preprocess 2 ... finished\n");
#endif
#ifdef DEBUG
{
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
INFO("Testing preprocess 2 ... finished");
}
TEST_CASE("Preprocessing test 3", "[Sequential Arrangement Preprocessing]")
{
#ifdef DEBUG
clock_t start, finish;
#endif
SolverConfiguration solver_configuration;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
printf("Testing preprocessing 3 ...\n");
INFO("Testing preprocessing 3 ...");
#ifdef DEBUG
start = clock();
#endif
std::vector<Slic3r::Polygon> nozzle_unreachable_polygons;
std::vector<Slic3r::Polygon> extruder_unreachable_polygons;
@ -585,28 +627,38 @@ TEST_CASE("Preprocessing test 3", "[Sequential Arrangement Preprocessing]")
preview_svg.Close();
}
}
#ifdef DEBUG
finish = clock();
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing preprocess 3 ... finished\n");
#endif
#ifdef DEBUG
{
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
INFO("Testing preprocess 3 ... finished");
}
TEST_CASE("Preprocessing test 4", "[Sequential Arrangement Preprocessing]")
{
//TEST_CASE("Preprocessing test 4", "[Sequential Arrangement Preprocessing]")
void preprocessing_test_4(void)
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing preprocess 4 ...\n");
INFO("Testing preprocess 4 ...");
#ifdef DEBUG
start = clock();
#endif
SolverConfiguration solver_configuration;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
std::vector<Slic3r::Polygon> polygons;
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
for (int i = 0; i < 12; ++i)
{
Polygon scale_down_polygon;
@ -658,21 +710,29 @@ TEST_CASE("Preprocessing test 4", "[Sequential Arrangement Preprocessing]")
decided_polygons,
remaining_polygons);
printf("----> Optimization finished <----\n");
#ifdef DEBUG
{
printf("----> Optimization finished <----\n");
}
#endif
REQUIRE(optimized);
if (optimized)
{
printf("Polygon positions:\n");
for (unsigned int i = 0; i < decided_polygons.size(); ++i)
#ifdef DEBUG
{
printf(" [%d] %.3f, %.3f (%.3f)\n", decided_polygons[i], poly_positions_X[decided_polygons[i]].as_double(), poly_positions_Y[decided_polygons[i]].as_double(), times_T[decided_polygons[i]].as_double());
}
printf("Remaining polygons: %ld\n", remaining_polygons.size());
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
{
printf(" %d\n", remaining_polygons[i]);
printf("Polygon positions:\n");
for (unsigned int i = 0; i < decided_polygons.size(); ++i)
{
printf(" [%d] %.3f, %.3f (%.3f)\n", decided_polygons[i], poly_positions_X[decided_polygons[i]].as_double(), poly_positions_Y[decided_polygons[i]].as_double(), times_T[decided_polygons[i]].as_double());
}
printf("Remaining polygons: %ld\n", remaining_polygons.size());
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
{
printf(" %d\n", remaining_polygons[i]);
}
}
#endif
SVG preview_svg("preprocess_test_4.svg");
@ -682,27 +742,29 @@ TEST_CASE("Preprocessing test 4", "[Sequential Arrangement Preprocessing]")
{
#ifdef DEBUG
{
printf("----> %.3f,%.3f\n", poly_positions_X[decided_polygons[i]].as_double(), poly_positions_Y[decided_polygons[i]].as_double());
for (int k = 0; k < polygons[decided_polygons[i]].points.size(); ++k)
{
printf(" xy: %d, %d\n", polygons[decided_polygons[i]].points[k].x(), polygons[decided_polygons[i]].points[k].y());
printf("----> %.3f,%.3f\n", poly_positions_X[decided_polygons[i]].as_double(), poly_positions_Y[decided_polygons[i]].as_double());
for (unsigned int k = 0; k < polygons[decided_polygons[i]].points.size(); ++k)
{
printf(" xy: %d, %d\n", polygons[decided_polygons[i]].points[k].x(), polygons[decided_polygons[i]].points[k].y());
}
}
}
#endif
for (unsigned int j = 0; j < unreachable_polygons[decided_polygons[i]].size(); ++j)
{
#ifdef DEBUG
{
for (int k = 0; k < unreachable_polygons[decided_polygons[i]][j].points.size(); ++k)
{
printf(" Pxy: %d, %d\n", unreachable_polygons[decided_polygons[i]][j].points[k].x(), unreachable_polygons[decided_polygons[i]][j].points[k].y());
for (unsigned int k = 0; k < unreachable_polygons[decided_polygons[i]][j].points.size(); ++k)
{
printf(" Pxy: %d, %d\n", unreachable_polygons[decided_polygons[i]][j].points[k].x(), unreachable_polygons[decided_polygons[i]][j].points[k].y());
}
}
#endif
Polygon display_unreachable_polygon = scale_UP(unreachable_polygons[decided_polygons[i]][j],
poly_positions_X[decided_polygons[i]].as_double(),
poly_positions_Y[decided_polygons[i]].as_double());
preview_svg.draw(display_unreachable_polygon, "lightgrey");
poly_positions_X[decided_polygons[i]].as_double(),
poly_positions_Y[decided_polygons[i]].as_double());
preview_svg.draw(display_unreachable_polygon, "lightgrey");
}
}
}
@ -712,7 +774,6 @@ TEST_CASE("Preprocessing test 4", "[Sequential Arrangement Preprocessing]")
Polygon display_polygon = scale_UP(polygons[decided_polygons[i]],
poly_positions_X[decided_polygons[i]].as_double(),
poly_positions_Y[decided_polygons[i]].as_double());
string color;
switch(i)
@ -785,23 +846,37 @@ TEST_CASE("Preprocessing test 4", "[Sequential Arrangement Preprocessing]")
preview_svg.draw(display_polygon, color);
}
preview_svg.Close();
}
else
{
printf("Polygon optimization FAILED.\n");
#ifdef DEBUG
{
printf("Polygon optimization FAILED.\n");
}
#endif
}
finish = clock();
printf("Intermediate time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
#ifdef DEBUG
finish = clock();
#endif
#ifdef DEBUG
{
printf("Intermediate time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
vector<Polygon> next_polygons;
vector<vector<Polygon> > next_unreachable_polygons;
for (unsigned int i = 0; i < polygon_index_map.size(); ++i)
#ifdef DEBUG
{
printf(" %d\n", polygon_index_map[i]);
for (unsigned int i = 0; i < polygon_index_map.size(); ++i)
{
printf(" %d\n", polygon_index_map[i]);
}
}
#endif
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
{
next_polygons.push_back(polygons[remaining_polygons[i]]);
@ -822,23 +897,33 @@ TEST_CASE("Preprocessing test 4", "[Sequential Arrangement Preprocessing]")
}
while (!remaining_polygons.empty());
#ifdef DEBUG
finish = clock();
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing preprocess 4 ... finished\n");
#endif
#ifdef DEBUG
{
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
INFO("Testing preprocess 4 ... finished");
}
TEST_CASE("Preprocessing test 5", "[Sequential Arrangement Preprocessing]")
{
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing preprocess 5 ...\n");
INFO("Testing preprocess 5 ...");
#ifdef DEBUG
start = clock();
#endif
SolverConfiguration solver_configuration;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
std::vector<Slic3r::Polygon> polygons;
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
@ -878,27 +963,38 @@ TEST_CASE("Preprocessing test 5", "[Sequential Arrangement Preprocessing]")
preview_svg.Close();
}
#ifdef DEBUG
finish = clock();
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing preprocess 5 ... finished\n");
#endif
#ifdef DEBUG
{
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
INFO("Testing preprocess 5 ... finished");
}
TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
{
//TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
void preprocessing_test_6(void)
{
#ifdef DEBUG
clock_t start, finish;
#endif
printf("Testing preprocess 6 ...\n");
INFO("Testing preprocess 6 ...");
#ifdef DEBUG
start = clock();
#endif
SolverConfiguration solver_configuration;
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE});
solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE / SEQ_SLICER_SCALE_FACTOR, SEQ_PRUSA_MK3S_Y_SIZE / SEQ_SLICER_SCALE_FACTOR});
std::vector<Slic3r::Polygon> polygons;
std::vector<std::vector<Slic3r::Polygon> > unreachable_polygons;
for (unsigned int i = 0; i < PRUSA_PART_POLYGONS.size(); ++i)
for (unsigned int i = 0; i < 12 /*PRUSA_PART_POLYGONS.size()*/; ++i)
{
Polygon decimated_polygon;
decimate_PolygonForSequentialSolver(solver_configuration,
@ -955,21 +1051,29 @@ TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
decided_polygons,
remaining_polygons);
printf("----> Optimization finished <----\n");
#ifdef DEBUG
{
printf("----> Optimization finished <----\n");
}
#endif
REQUIRE(optimized);
if (optimized)
{
printf("Polygon positions:\n");
for (unsigned int i = 0; i < decided_polygons.size(); ++i)
#ifdef DEBUG
{
printf(" [%d] %.3f, %.3f (%.3f)\n", decided_polygons[i], poly_positions_X[decided_polygons[i]].as_double(), poly_positions_Y[decided_polygons[i]].as_double(), times_T[decided_polygons[i]].as_double());
}
printf("Remaining polygons: %ld\n", remaining_polygons.size());
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
{
printf(" %d\n", remaining_polygons[i]);
printf("Polygon positions:\n");
for (unsigned int i = 0; i < decided_polygons.size(); ++i)
{
printf(" [%d] %.3f, %.3f (%.3f)\n", decided_polygons[i], poly_positions_X[decided_polygons[i]].as_double(), poly_positions_Y[decided_polygons[i]].as_double(), times_T[decided_polygons[i]].as_double());
}
printf("Remaining polygons: %ld\n", remaining_polygons.size());
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
{
printf(" %d\n", remaining_polygons[i]);
}
}
#endif
SVG preview_svg("preprocess_test_6.svg");
@ -980,7 +1084,7 @@ TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
#ifdef DEBUG
{
printf("----> %.3f,%.3f\n", poly_positions_X[decided_polygons[i]].as_double(), poly_positions_Y[decided_polygons[i]].as_double());
for (int k = 0; k < polygons[decided_polygons[i]].points.size(); ++k)
for (unsigned int k = 0; k < polygons[decided_polygons[i]].points.size(); ++k)
{
printf(" xy: %d, %d\n", polygons[decided_polygons[i]].points[k].x(), polygons[decided_polygons[i]].points[k].y());
}
@ -990,7 +1094,7 @@ TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
{
#ifdef DEBUG
{
for (int k = 0; k < unreachable_polygons[decided_polygons[i]][j].points.size(); ++k)
for (unsigned int k = 0; k < unreachable_polygons[decided_polygons[i]][j].points.size(); ++k)
{
printf(" Pxy: %d, %d\n", unreachable_polygons[decided_polygons[i]][j].points[k].x(), unreachable_polygons[decided_polygons[i]][j].points[k].y());
}
@ -1087,18 +1191,33 @@ TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
}
else
{
printf("Polygon optimization FAILED.\n");
#ifdef DEBUG
{
printf("Polygon optimization FAILED.\n");
}
#endif
}
finish = clock();
printf("Intermediate time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
#ifdef DEBUG
finish = clock();
#endif
#ifdef DEBUG
{
printf("Intermediate time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
vector<Polygon> next_polygons;
vector<vector<Polygon> > next_unreachable_polygons;
for (unsigned int i = 0; i < polygon_index_map.size(); ++i)
#ifdef DEBUG
{
printf(" %d\n", polygon_index_map[i]);
for (unsigned int i = 0; i < polygon_index_map.size(); ++i)
{
printf(" %d\n", polygon_index_map[i]);
}
}
#endif
for (unsigned int i = 0; i < remaining_polygons.size(); ++i)
{
next_polygons.push_back(polygons[remaining_polygons[i]]);
@ -1119,10 +1238,16 @@ TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
}
while (!remaining_polygons.empty());
#ifdef DEBUG
finish = clock();
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
printf("Testing preprocess 6 ... finished\n");
#endif
#ifdef DEBUG
{
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
}
#endif
INFO("Testing preprocess 6 ... finished");
}

View File

@ -1,6 +1,6 @@
/*================================================================*/
/*
* Author: Pavel Surynek, 2023 - 2024
* Author: Pavel Surynek, 2023 - 2025
* Company: Prusa Research
*
* File: seq_test_preprocess.hpp

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/*================================================================*/
/*
* Author: Pavel Surynek, 2023 - 2024
* Author: Pavel Surynek, 2023 - 2025
* Company: Prusa Research
*
* File: seq_test_sequential.hpp