mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 20:10:37 +08:00
Revisited all test modules for sequential printing library.
This commit is contained in:
parent
eac29863ed
commit
f37de58c57
@ -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)
|
||||
|
||||
|
@ -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});
|
||||
|
||||
#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);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Loading objects ... finished\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<ScheduledPlate> scheduled_plates;
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Scheduling objects for sequential print ...\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
int result = schedule_ObjectsForSequentialPrint(solver_configuration,
|
||||
objects_to_print,
|
||||
@ -528,20 +546,36 @@ TEST_CASE("Interface test 1", "[Sequential Arrangement Interface]")
|
||||
|
||||
REQUIRE(result == 0);
|
||||
if (result == 0)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#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);
|
||||
@ -550,40 +584,67 @@ TEST_CASE("Interface test 1", "[Sequential Arrangement Interface]")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Something went WRONG during sequential scheduling (code: %d)\n", result);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
finish = clock();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
printf("Testing interface 1 ... finished\n");
|
||||
}
|
||||
#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});
|
||||
|
||||
#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;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Preparing extruder unreachable zones ...\n");
|
||||
}
|
||||
#endif
|
||||
setup_ExtruderUnreachableZones(solver_configuration, convex_unreachable_zones, box_unreachable_zones);
|
||||
|
||||
std::vector<ScheduledPlate> scheduled_plates;
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Scheduling objects for sequential print ...\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
int result = schedule_ObjectsForSequentialPrint(solver_configuration,
|
||||
objects_to_print,
|
||||
@ -593,21 +654,31 @@ TEST_CASE("Interface test 2", "[Sequential Arrangement Interface]")
|
||||
|
||||
REQUIRE(result == 0);
|
||||
if (result == 0)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#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);
|
||||
@ -616,49 +687,102 @@ TEST_CASE("Interface test 2", "[Sequential Arrangement Interface]")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Something went WRONG during sequential scheduling (code: %d)\n", result);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
finish = clock();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
printf("Testing interface 2 ... finished\n");
|
||||
}
|
||||
#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)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Printer geometry load error.\n");
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
REQUIRE(printer_geometry.plate.points.size() == 4);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
for (const auto& convex_height: printer_geometry.convex_heights)
|
||||
{
|
||||
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)
|
||||
@ -672,64 +796,116 @@ TEST_CASE("Interface test 3", "[Sequential Arrangement Interface]")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
finish = clock();
|
||||
|
||||
{
|
||||
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
printf("Testing interface 3 ... finished\n");
|
||||
}
|
||||
#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});
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Loading objects ...\n");
|
||||
}
|
||||
#endif
|
||||
std::vector<ObjectToPrint> objects_to_print = load_exported_data_from_text(arrange_data_export_text);
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Loading objects ... finished\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
PrinterGeometry printer_geometry;
|
||||
|
||||
#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)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Cannot load printer geometry (code: %d).\n", result);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
solver_configuration.setup(printer_geometry);
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Loading printer geometry ... finished\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<ScheduledPlate> scheduled_plates;
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Scheduling objects for sequential print ...\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
scheduled_plates = schedule_ObjectsForSequentialPrint(solver_configuration,
|
||||
printer_geometry,
|
||||
objects_to_print);
|
||||
|
||||
#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)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#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);
|
||||
|
||||
@ -740,67 +916,121 @@ TEST_CASE("Interface test 4", "[Sequential Arrangement Interface]")
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
finish = clock();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
printf("Testing interface 4 ... finished\n");
|
||||
}
|
||||
#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});
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Loading objects ...\n");
|
||||
}
|
||||
#endif
|
||||
std::vector<ObjectToPrint> objects_to_print = load_exported_data_from_text(arrange_data_export_text);
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Loading objects ... finished\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
PrinterGeometry printer_geometry;
|
||||
|
||||
#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)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Cannot load printer geometry (code: %d).\n", result);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
solver_configuration.setup(printer_geometry);
|
||||
#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); });
|
||||
|
||||
#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)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#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);
|
||||
|
||||
}
|
||||
start = clock();
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Checking sequential printability ...\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
bool printable = check_ScheduledObjectsForSequentialPrintability(solver_configuration,
|
||||
printer_geometry,
|
||||
objects_to_print,
|
||||
scheduled_plates);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf(" Scheduled/arranged objects are sequentially printable: %s\n", (printable ? "YES" : "NO"));
|
||||
}
|
||||
#endif
|
||||
REQUIRE(printable);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Checking sequential printability ... finished\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#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});
|
||||
|
||||
#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);
|
||||
|
||||
#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;
|
||||
|
||||
#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)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Cannot load printer geometry (code: %d).\n", result);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
solver_configuration.setup(printer_geometry);
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Loading printer geometry ... finished\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<ScheduledPlate> scheduled_plates;
|
||||
#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); });
|
||||
|
||||
#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)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#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);
|
||||
|
||||
}
|
||||
start = clock();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Checking sequential printability ...\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
bool printable = check_ScheduledObjectsForSequentialPrintability(solver_configuration,
|
||||
printer_geometry,
|
||||
objects_to_print,
|
||||
scheduled_plates);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf(" Scheduled/arranged objects are sequentially printable: %s\n", (printable ? "YES" : "NO"));
|
||||
}
|
||||
#endif
|
||||
REQUIRE(printable);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Checking sequential printability ... finished\n");
|
||||
|
||||
}
|
||||
finish = clock();
|
||||
printf("Checking time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
#endif
|
||||
|
||||
printf("Testing interface 6 ... finished\n");
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Checking time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
}
|
||||
#endif
|
||||
|
||||
INFO("Testing interface 6 ... finished");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*================================================================*/
|
||||
/*
|
||||
* Author: Pavel Surynek, 2023 - 2024
|
||||
* Author: Pavel Surynek, 2023 - 2025
|
||||
* Company: Prusa Research
|
||||
*
|
||||
* File: seq_test_interface.hpp
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*================================================================*/
|
||||
/*
|
||||
* Author: Pavel Surynek, 2023 - 2024
|
||||
* Author: Pavel Surynek, 2023 - 2025
|
||||
* Company: Prusa Research
|
||||
*
|
||||
* File: seq_test_polygon.cpp
|
||||
@ -879,8 +879,6 @@ void polygon_test_6(void)
|
||||
|
||||
z3::expr lino_1 = (valo_1 * deco_1 == 0);
|
||||
|
||||
printf("value: %.3f\n", value);
|
||||
|
||||
cout << float(z_model[i]) << "\n";
|
||||
|
||||
switch (z_model.get_const_interp(z_model[i]).bool_value())
|
||||
@ -1447,36 +1445,6 @@ void polygon_test_8(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();
|
||||
@ -1501,6 +1469,7 @@ void polygon_test_8(void)
|
||||
value = Y_positions[i].as_double();
|
||||
printf("Orig Y: %.3f\n", value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SVG preview_svg("polygon_test_8.svg");
|
||||
@ -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();
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*================================================================*/
|
||||
/*
|
||||
* Author: Pavel Surynek, 2023 - 2024
|
||||
* Author: Pavel Surynek, 2023 - 2025
|
||||
* Company: Prusa Research
|
||||
*
|
||||
* File: seq_test_polygon.hpp
|
||||
|
@ -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;
|
||||
@ -111,28 +113,39 @@ TEST_CASE("Preprocessing test 1", "[Sequential Arrangement Preprocessing]")
|
||||
preview_svg.draw(display_polygon, "blue");
|
||||
preview_svg.Close();
|
||||
}
|
||||
#ifdef DEBUG
|
||||
finish = clock();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
printf("Testing preprocessing 1 ... finished\n");
|
||||
}
|
||||
#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,10 +182,16 @@ TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
|
||||
decided_polygons,
|
||||
remaining_polygons);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("----> Optimization finished <----\n");
|
||||
}
|
||||
#endif
|
||||
REQUIRE(optimized);
|
||||
|
||||
if (optimized)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Polygon positions:\n");
|
||||
for (unsigned int i = 0; i < decided_polygons.size(); ++i)
|
||||
@ -184,6 +203,8 @@ TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
|
||||
{
|
||||
printf(" %d\n", remaining_polygons[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SVG preview_svg("preprocess_test_2.svg");
|
||||
|
||||
@ -194,20 +215,18 @@ 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
|
||||
{
|
||||
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]].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
|
||||
@ -218,7 +237,6 @@ TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
|
||||
preview_svg.draw(display_unreachable_polygon, "lightgrey");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < decided_polygons.size(); ++i)
|
||||
{
|
||||
@ -302,20 +320,34 @@ TEST_CASE("Preprocessing test 2", "[Sequential Arrangement Preprocessing]")
|
||||
preview_svg.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Polygon optimization FAILED.\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG
|
||||
finish = clock();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Intermediate time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<Polygon> next_polygons;
|
||||
vector<Polygon> next_unreachable_polygons;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
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();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
printf("Testing preprocess 2 ... finished\n");
|
||||
}
|
||||
#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();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
printf("Testing preprocess 3 ... finished\n");
|
||||
|
||||
}
|
||||
#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,10 +710,16 @@ TEST_CASE("Preprocessing test 4", "[Sequential Arrangement Preprocessing]")
|
||||
decided_polygons,
|
||||
remaining_polygons);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("----> Optimization finished <----\n");
|
||||
}
|
||||
#endif
|
||||
REQUIRE(optimized);
|
||||
|
||||
if (optimized)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Polygon positions:\n");
|
||||
for (unsigned int i = 0; i < decided_polygons.size(); ++i)
|
||||
@ -673,6 +731,8 @@ TEST_CASE("Preprocessing test 4", "[Sequential Arrangement Preprocessing]")
|
||||
{
|
||||
printf(" %d\n", remaining_polygons[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SVG preview_svg("preprocess_test_4.svg");
|
||||
|
||||
@ -683,20 +743,22 @@ 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)
|
||||
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)
|
||||
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],
|
||||
@ -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
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Polygon optimization FAILED.\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#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;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
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();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
printf("Testing preprocess 4 ... finished\n");
|
||||
}
|
||||
#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();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
printf("Testing preprocess 5 ... finished\n");
|
||||
}
|
||||
#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,10 +1051,16 @@ TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
|
||||
decided_polygons,
|
||||
remaining_polygons);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("----> Optimization finished <----\n");
|
||||
}
|
||||
#endif
|
||||
REQUIRE(optimized);
|
||||
|
||||
if (optimized)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Polygon positions:\n");
|
||||
for (unsigned int i = 0; i < decided_polygons.size(); ++i)
|
||||
@ -970,6 +1072,8 @@ TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
|
||||
{
|
||||
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());
|
||||
}
|
||||
@ -1086,19 +1190,34 @@ TEST_CASE("Preprocessing test 6", "[Sequential Arrangement Preprocessing]")
|
||||
preview_svg.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Polygon optimization FAILED.\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#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;
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
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();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
printf("Time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC);
|
||||
printf("Testing preprocess 6 ... finished\n");
|
||||
}
|
||||
#endif
|
||||
INFO("Testing preprocess 6 ... finished");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
@ -1,6 +1,6 @@
|
||||
/*================================================================*/
|
||||
/*
|
||||
* Author: Pavel Surynek, 2023 - 2024
|
||||
* Author: Pavel Surynek, 2023 - 2025
|
||||
* Company: Prusa Research
|
||||
*
|
||||
* File: seq_test_sequential.hpp
|
||||
|
Loading…
x
Reference in New Issue
Block a user