diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2bad952679..ff579e82e7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -139,39 +139,38 @@ if (NOT WIN32 AND NOT APPLE) endif () -target_link_libraries(PrusaSlicer libslic3r libcereal slic3r-arrange-wrapper libseqarrange stb_image) +target_link_libraries(PrusaSlicer PRIVATE libslic3r libcereal slic3r-arrange-wrapper libseqarrange stb_image) if (APPLE) # add_compile_options(-stdlib=libc++) # add_definitions(-DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE) # -liconv: boost links to libiconv by default - target_link_libraries(PrusaSlicer "-liconv -framework IOKit" "-framework CoreFoundation" -lc++) + target_link_libraries(PrusaSlicer PRIVATE "-liconv -framework IOKit" "-framework CoreFoundation" -lc++) elseif (MSVC) # Manifest is provided through PrusaSlicer.rc, don't generate your own. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") else () # Boost on Raspberry-Pi does not link to pthreads explicitely. - target_link_libraries(PrusaSlicer ${CMAKE_DL_LIBS} -lstdc++ Threads::Threads) + target_link_libraries(PrusaSlicer PRIVATE ${CMAKE_DL_LIBS} -lstdc++ Threads::Threads) endif () # Add the Slic3r GUI library, libcurl, OpenGL and GLU libraries. if (SLIC3R_GUI) -# target_link_libraries(PrusaSlicer ws2_32 uxtheme setupapi libslic3r_gui ${wxWidgets_LIBRARIES}) -target_link_libraries(PrusaSlicer libslic3r_gui) + target_link_libraries(PrusaSlicer PRIVATE libslic3r_gui) if (MSVC) # Generate debug symbols even in release mode. target_link_options(PrusaSlicer PUBLIC "$<$:/DEBUG>") - target_link_libraries(PrusaSlicer user32.lib Setupapi.lib) + target_link_libraries(PrusaSlicer PRIVATE user32.lib Setupapi.lib) elseif (MINGW) - target_link_libraries(PrusaSlicer ws2_32 uxtheme setupapi) + target_link_libraries(PrusaSlicer PRIVATE ws2_32 uxtheme setupapi) elseif (APPLE) - target_link_libraries(PrusaSlicer "-framework OpenGL") + target_link_libraries(PrusaSlicer PRIVATE "-framework OpenGL") else () - target_link_libraries(PrusaSlicer -ldl) + target_link_libraries(PrusaSlicer PRIVATE -ldl) endif () if (WIN32) find_library(PSAPI_LIB NAMES Psapi) - target_link_libraries(PrusaSlicer ${PSAPI_LIB}) + target_link_libraries(PrusaSlicer PRIVATE ${PSAPI_LIB}) endif () endif () diff --git a/src/libseqarrange/CMakeLists.txt b/src/libseqarrange/CMakeLists.txt index 656acf3be8..2e14ceca48 100644 --- a/src/libseqarrange/CMakeLists.txt +++ b/src/libseqarrange/CMakeLists.txt @@ -1,42 +1,35 @@ find_package(Z3 REQUIRED) slic3r_remap_configs("z3::libz3" RelWithDebInfo Release) -#find_package(Catch2 2.9 REQUIRED) -#include(Catch) + add_library(libseqarrange STATIC src/seq_interface.cpp src/seq_preprocess.cpp src/seq_sequential.cpp src/seq_utilities.cpp) -target_include_directories(libseqarrange PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/include/libseqarrange) +target_include_directories(libseqarrange PUBLIC include PRIVATE src ) target_link_libraries(libseqarrange PUBLIC libslic3r PRIVATE z3::libz3) -add_executable(sequential_arrange src/sequential_prusa.cpp) -target_include_directories(sequential_arrange PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/libseqarrange) -target_link_libraries(sequential_arrange PRIVATE libseqarrange) - add_executable(sequential_decimator src/sequential_decimator.cpp) -target_include_directories(sequential_decimator PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/libseqarrange) +target_include_directories(sequential_decimator PRIVATE include) target_link_libraries(sequential_decimator PRIVATE libseqarrange) -# Tests - commented out for now -#add_executable(seq_test_polygon test/seq_test_polygon.cpp test/prusaparts.cpp) -#target_link_libraries(seq_test_polygon PRIVATE Catch2::Catch2 libseqarrange) -#target_include_directories(seq_test_polygon PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/include/libseqarrange") -#add_executable(seq_test_sequential test/seq_test_sequential.cpp) -#target_link_libraries(seq_test_sequential PRIVATE libseqarrange) -#target_include_directories(seq_test_sequential PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/include/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) + target_include_directories(libseqarrange_tests PRIVATE src ) + target_link_libraries(libseqarrange_tests PRIVATE Catch2::Catch2WithMain libseqarrange) + + set(_catch_args "exclude:[NotWorking] exclude:[Slow]") + list(APPEND _catch_args "${CATCH_EXTRA_ARGS}") + add_test(NAME libseqarrange_tests + COMMAND libseqarrange_tests ${_catch_args} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + +endif() + -#add_executable(seq_test_preprocess test/seq_test_preprocess.cpp test/prusaparts.cpp) -#target_link_libraries(seq_test_preprocess PRIVATE libseqarrange) -#target_include_directories(seq_test_preprocess PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/include/libseqarrange") -#add_executable(seq_test_interface test/seq_test_interface.cpp) -#target_link_libraries(seq_test_interface PUBLIC libseqarrange) -#target_include_directories(seq_test_interface PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/include/libseqarrange") -#add_test(seq_test_polygon seq_test_polygon) -#add_test(seq_test_preprocess seq_test_preprocess) -#add_test(seq_test_sequential seq_test_sequential) -#add_test(seq_test_interface seq_test_interface) diff --git a/src/libseqarrange/src/seq_interface.cpp b/src/libseqarrange/src/seq_interface.cpp index 7359ba6f35..1e44da9b16 100644 --- a/src/libseqarrange/src/seq_interface.cpp +++ b/src/libseqarrange/src/seq_interface.cpp @@ -13,7 +13,7 @@ #include "seq_sequential.hpp" #include "seq_preprocess.hpp" -#include "seq_interface.hpp" +#include "libseqarrange/seq_interface.hpp" /*----------------------------------------------------------------*/ diff --git a/src/libseqarrange/src/seq_preprocess.cpp b/src/libseqarrange/src/seq_preprocess.cpp index 59ccbfbef2..aa3a846f06 100644 --- a/src/libseqarrange/src/seq_preprocess.cpp +++ b/src/libseqarrange/src/seq_preprocess.cpp @@ -15,7 +15,7 @@ #include "libslic3r/ClipperUtils.hpp" #include "seq_preprocess.hpp" -#include "seq_interface.hpp" +#include "libseqarrange/seq_interface.hpp" /*----------------------------------------------------------------*/ diff --git a/src/libseqarrange/src/seq_sequential.hpp b/src/libseqarrange/src/seq_sequential.hpp index f9ec99fb14..0ed4799796 100644 --- a/src/libseqarrange/src/seq_sequential.hpp +++ b/src/libseqarrange/src/seq_sequential.hpp @@ -31,7 +31,7 @@ #include "seq_defs.hpp" -#include "seq_interface.hpp" +#include "libseqarrange/seq_interface.hpp" /*----------------------------------------------------------------*/ diff --git a/src/libseqarrange/src/seq_utilities.hpp b/src/libseqarrange/src/seq_utilities.hpp index 3713039462..d2264cee0d 100644 --- a/src/libseqarrange/src/seq_utilities.hpp +++ b/src/libseqarrange/src/seq_utilities.hpp @@ -16,7 +16,7 @@ /*----------------------------------------------------------------*/ #include "seq_sequential.hpp" -#include "seq_interface.hpp" +#include "libseqarrange/seq_interface.hpp" /*----------------------------------------------------------------*/ diff --git a/src/libseqarrange/src/seq_version.hpp b/src/libseqarrange/src/seq_version.hpp deleted file mode 100644 index e8bc06c6ee..0000000000 --- a/src/libseqarrange/src/seq_version.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __SEQ_VERSION_HPP__ -#define __SEQ_VERSION_HPP__ - - -#define SEQ_SEQUENTIAL_BUILD "200" - -#endif /* __SEQ_VERSION_HPP__ */ diff --git a/src/libseqarrange/src/sequential_decimator.cpp b/src/libseqarrange/src/sequential_decimator.cpp index aa787881ed..a2330ebd6c 100644 --- a/src/libseqarrange/src/sequential_decimator.cpp +++ b/src/libseqarrange/src/sequential_decimator.cpp @@ -18,9 +18,7 @@ #include "libslic3r/Geometry/ConvexHull.hpp" #include "libslic3r/SVG.hpp" -#include "seq_version.hpp" #include "seq_utilities.hpp" -#include "seq_interface.hpp" #include "sequential_decimator.hpp" diff --git a/src/libseqarrange/src/sequential_decimator.hpp b/src/libseqarrange/src/sequential_decimator.hpp index ec86021c21..7c4d9f5067 100644 --- a/src/libseqarrange/src/sequential_decimator.hpp +++ b/src/libseqarrange/src/sequential_decimator.hpp @@ -16,7 +16,7 @@ #include "seq_sequential.hpp" #include "seq_preprocess.hpp" -#include "seq_interface.hpp" +#include "libseqarrange/seq_interface.hpp" /*----------------------------------------------------------------*/ diff --git a/src/libseqarrange/src/sequential_prusa.cpp b/src/libseqarrange/src/sequential_prusa.cpp deleted file mode 100644 index 365af39339..0000000000 --- a/src/libseqarrange/src/sequential_prusa.cpp +++ /dev/null @@ -1,866 +0,0 @@ -/*================================================================*/ -/* - * Author: Pavel Surynek, 2023 - 2025 - * Company: Prusa Research - * - * File: sequential_prusa.cpp - * - * SEQUENTIAL 3D Print Scheduler|Arranger. - */ -/*================================================================*/ - - -#include "libslic3r/Polygon.hpp" -#include "libslic3r/Geometry/ConvexHull.hpp" -#include "libslic3r/SVG.hpp" - -#include "seq_version.hpp" -#include "seq_preprocess.hpp" -#include "seq_utilities.hpp" - -#include "sequential_prusa.hpp" - -/*----------------------------------------------------------------*/ - -using namespace Slic3r; -using namespace Sequential; - - -/*----------------------------------------------------------------*/ - -const int SEQ_PRUSA_MK3S_X_SIZE = 2500; -const int SEQ_PRUSA_MK3S_Y_SIZE = 2100; - - -/*----------------------------------------------------------------*/ - - -void print_IntroductoryMessage(void) -{ - printf("----------------------------------------------------------------\n"); - printf("SEQUENTIAL 3D Print Scheduler|Arranger - build %s\n", SEQ_SEQUENTIAL_BUILD); - printf("(C) 2024 Prusa Research \n"); - printf("================================================================\n"); -} - - -void print_ConcludingMessage(void) -{ - printf("----------------------------------------------------------------\n"); -} - - -void print_Help(void) -{ - printf("Usage:\n"); - printf("sequential_prusa [--input-file=]\n"); - printf(" [--output-file=]\n"); - printf(" [--printer-file=]\n"); - printf(" [--decimation={yes|no}]\n"); - printf(" [--precision={low|high}]\n"); - printf(" [--assumptions={yes|no}]\n"); - printf(" [--interactive={yes|no}]\n"); - printf(" [--object-group-size=]\n"); - printf(" [--help]\n"); - printf("\n"); - printf("\n"); - printf("Defaults: --input-file=arrange_data_export.txt\n"); - printf(" --output-file=arrange_data_import.txt\n"); - printf(" --printer-file=../printers/printer_geometry.mk4.compatibility.txt\n"); - printf(" --object-group-size=4 \n"); - printf(" --decimation=yes\n"); - printf(" --precision=high\n"); - printf(" --assumptions=yes\n"); - printf(" --interactive=no\n"); - printf("\n"); -} - - -int parse_CommandLineParameter(const string ¶meter, CommandParameters &command_parameters) -{ - if (parameter.find("--input-file=") == 0) - { - command_parameters.input_filename = parameter.substr(13, parameter.size()); - } - else if (parameter.find("--output-file=") == 0) - { - command_parameters.output_filename = parameter.substr(14, parameter.size()); - } - else if (parameter.find("--printer-file=") == 0) - { - command_parameters.printer_filename = parameter.substr(15, parameter.size()); - } - else if (parameter.find("--object-group-size=") == 0) - { - command_parameters.object_group_size = std::atoi(parameter.substr(20, parameter.size()).c_str()); - } - else if (parameter.find("--decimation=") == 0) - { - string decimation_str = parameter.substr(13, parameter.size()); - - if (decimation_str == "yes") - { - command_parameters.decimation = true; - } - else if (decimation_str == "no") - { - command_parameters.decimation = false; - } - else - { - return -2; - } - } - else if (parameter.find("--precision=") == 0) - { - string decimation_str = parameter.substr(12, parameter.size()); - - if (decimation_str == "high") - { - command_parameters.precision = true; - } - else if (decimation_str == "low") - { - command_parameters.precision = false; - } - else - { - return -2; - } - } - else if (parameter.find("--assumptions=") == 0) - { - string assumptions_str = parameter.substr(14, parameter.size()); - - if (assumptions_str == "yes") - { - command_parameters.assumptions = true; - } - else if (assumptions_str == "no") - { - command_parameters.assumptions = false; - } - else - { - return -2; - } - } - else if (parameter.find("--interactive=") == 0) - { - string interactive_str = parameter.substr(14, parameter.size()); - - if (interactive_str == "yes") - { - command_parameters.interactive = true; - } - else if (interactive_str == "no") - { - command_parameters.interactive = false; - } - else - { - return -2; - } - } - else if (parameter.find("--help") == 0) - { - command_parameters.help = true; - } - else - { - return -1; - } - return 0; -} - - -string convert_Index2Suffix(int index) -{ - string buffer = "000"; - - string index_str = std::to_string(index); - buffer.replace(buffer.length() - index_str.length(), index_str.length(), index_str); - - return buffer; -} - - -bool is_scheduled(int i, const std::vector &decided_polygons) -{ - for (unsigned int j = 0; j < decided_polygons.size(); ++j) - { - if (decided_polygons[j] == i) - { - return true; - } - } - return false; -} - - -int solve_SequentialPrint(const CommandParameters &command_parameters) -{ - clock_t start, finish; - - printf("Sequential scheduling/arranging ...\n"); - - start = clock(); - - SolverConfiguration solver_configuration; - solver_configuration.object_group_size = command_parameters.object_group_size; - - PrinterGeometry printer_geometry; - - if (!command_parameters.printer_filename.empty()) - { - printf(" Loading printer geometry ...\n"); - int result = load_printer_geometry_from_file(command_parameters.printer_filename, printer_geometry); - - if (result != 0) - { - printf("Cannot load printer geometry (code: %d).\n", result); - return result; - } - solver_configuration.setup(printer_geometry); - printf(" Loading printer geometry ... finished\n"); - } - - std::vector objects_to_print = load_exported_data_from_file(command_parameters.input_filename); - - std::vector polygons; - std::vector > unreachable_polygons; - std::vector lepox_to_next; - - printf(" Preparing objects ...\n"); - - map original_index_map; - - for (unsigned int i = 0; i < objects_to_print.size(); ++i) - { - Polygon nozzle_polygon; - Polygon extruder_polygon; - Polygon hose_polygon; - Polygon gantry_polygon; - - std::vector convex_level_polygons; - std::vector box_level_polygons; - - std::vector > extruder_convex_level_polygons; - std::vector > extruder_box_level_polygons; - - std::vector scale_down_unreachable_polygons; - - original_index_map[i] = objects_to_print[i].id; - - if (command_parameters.printer_filename.empty()) - { - for (unsigned int j = 0; j < objects_to_print[i].pgns_at_height.size(); ++j) - { - coord_t height = objects_to_print[i].pgns_at_height[j].first; - - if (!objects_to_print[i].pgns_at_height[j].second.points.empty()) - { - Polygon decimated_polygon; - - if (command_parameters.decimation) - { - if (command_parameters.precision) - { - solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_HIGH; - } - else - { - solver_configuration.decimation_precision = SEQ_DECIMATION_PRECISION_LOW; - } - decimate_PolygonForSequentialSolver(solver_configuration, - objects_to_print[i].pgns_at_height[j].second, - decimated_polygon, - true); - } - else - { - decimated_polygon = objects_to_print[i].pgns_at_height[j].second; - decimated_polygon.make_counter_clockwise(); - } - if (!check_PolygonSizeFitToPlate(solver_configuration, SEQ_SLICER_SCALE_FACTOR, decimated_polygon)) - { - printf("Object too large to fit onto plate [ID:%d RID:%d].\n", original_index_map[i], i); - return -1; - } - - switch (height) - { - case 0: // nozzle - { - nozzle_polygon = decimated_polygon; - break; - } - case 2000000: // extruder - { - extruder_polygon = decimated_polygon; - break; - } - case 18000000: // hose - { - hose_polygon = decimated_polygon; - break; - } - case 26000000: // gantry - { - gantry_polygon = decimated_polygon; - break; - } - default: - { - throw std::runtime_error("UNSUPPORTED POLYGON HEIGHT"); - break; - } - } - } - } - - Polygon scale_down_polygon; - scaleDown_PolygonForSequentialSolver(nozzle_polygon, scale_down_polygon); - polygons.push_back(scale_down_polygon); - - convex_level_polygons.push_back(nozzle_polygon); - convex_level_polygons.push_back(extruder_polygon); - box_level_polygons.push_back(hose_polygon); - box_level_polygons.push_back(gantry_polygon); - - prepare_UnreachableZonePolygons(solver_configuration, - convex_level_polygons, - box_level_polygons, - SEQ_UNREACHABLE_POLYGON_CONVEX_LEVELS_MK4, - SEQ_UNREACHABLE_POLYGON_BOX_LEVELS_MK4, - scale_down_unreachable_polygons); - - unreachable_polygons.push_back(scale_down_unreachable_polygons); - lepox_to_next.push_back(objects_to_print[i].glued_to_next); - } - else - { - Polygon scale_down_object_polygon; - - prepare_ExtruderPolygons(solver_configuration, - printer_geometry, - objects_to_print[i], - convex_level_polygons, - box_level_polygons, - extruder_convex_level_polygons, - extruder_box_level_polygons, - true); - - prepare_ObjectPolygons(solver_configuration, - convex_level_polygons, - box_level_polygons, - extruder_convex_level_polygons, - extruder_box_level_polygons, - scale_down_object_polygon, - scale_down_unreachable_polygons); - - unreachable_polygons.push_back(scale_down_unreachable_polygons); - polygons.push_back(scale_down_object_polygon); - - lepox_to_next.push_back(objects_to_print[i].glued_to_next); - } - - SVG preview_svg("sequential_prusa.svg"); - for (unsigned int k = 0; k < unreachable_polygons.back().size(); ++k) - { - Polygon display_unreachable_polygon = transform_UpsideDown(solver_configuration, SEQ_SVG_SCALE_FACTOR, scaleUp_PolygonForSlicer(SEQ_SVG_SCALE_FACTOR, unreachable_polygons.back()[k], 0, 0)); - preview_svg.draw(display_unreachable_polygon, "lightgrey"); - } - /* - Polygon display_unreachable_polygon = scale_UP(polygons.back(), 0, 0); - preview_svg.draw(display_unreachable_polygon, "blue"); - */ - preview_svg.Close(); - } - - vector remaining_polygons; - vector polygon_index_map; - vector decided_polygons; - - for (unsigned int index = 0; index < polygons.size(); ++index) - { - polygon_index_map.push_back(index); - } - - vector poly_positions_X; - vector poly_positions_Y; - vector times_T; - - printf(" Preparing objects ... finished\n"); - - int plate_index = 0; - - int progress_objects_done = 0; - int progress_objects_total = objects_to_print.size(); - - bool trans_bed_lepox = false; - - do - { - decided_polygons.clear(); - remaining_polygons.clear(); - - printf(" Object scheduling/arranging ...\n"); - bool optimized; - - if (command_parameters.assumptions) - { - optimized = optimize_SubglobalConsequentialPolygonNonoverlappingBinaryCentered(solver_configuration, - poly_positions_X, - poly_positions_Y, - times_T, - polygons, - unreachable_polygons, - lepox_to_next, - trans_bed_lepox, - polygon_index_map, - decided_polygons, - remaining_polygons, - progress_objects_done, - progress_objects_total); - - } - else - { - optimized = optimize_SubglobalSequentialPolygonNonoverlappingBinaryCentered(solver_configuration, - poly_positions_X, - poly_positions_Y, - times_T, - polygons, - unreachable_polygons, - polygon_index_map, - decided_polygons, - remaining_polygons); - - } - - printf(" Object scheduling/arranging ... finished\n"); - - if (optimized) - { - printf("Polygon positions:\n"); - for (unsigned int i = 0; i < decided_polygons.size(); ++i) - { - printf(" [ID:%d,RID:%d] x:%.3f, y:%.3f (t:%.3f)\n", - original_index_map[decided_polygons[i]], - 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(" ID:%d\n", original_index_map[remaining_polygons[i]]); - } - - bool split = false; - for (unsigned int i = 0; i < decided_polygons.size(); ++i) - { - if (lepox_to_next[i] && !is_scheduled(i + 1, decided_polygons)) - { - split = true; - } - } - if (split) - { - trans_bed_lepox = true; - printf("Lopoxed group split, potential danger!!!\n"); - } - else - { - trans_bed_lepox = false; - } - std::map scheduled_polygons; - for (unsigned int i = 0; i < decided_polygons.size(); ++i) - { - scheduled_polygons.insert(std::pair(times_T[decided_polygons[i]].as_double(), decided_polygons[i])); - } - progress_objects_done += decided_polygons.size(); - - string output_filename; - - if (command_parameters.interactive) - { - output_filename = command_parameters.output_filename; - } - else - { - int suffix_position = command_parameters.output_filename.find("."); - - output_filename = command_parameters.output_filename.substr(0, suffix_position) + "_" - + convert_Index2Suffix(plate_index) - + command_parameters.output_filename.substr(suffix_position, command_parameters.output_filename.length()); - } - - save_import_data_to_file(output_filename, - scheduled_polygons, - original_index_map, - poly_positions_X, - poly_positions_Y); - - string svg_filename; - - if (command_parameters.interactive) - { - svg_filename = "sequential_prusa.svg"; - } - else - { - svg_filename = "sequential_prusa_" + convert_Index2Suffix(plate_index) + ".svg"; - } - - SVG preview_svg(svg_filename); - - if (!unreachable_polygons.empty()) - { - for (unsigned int i = 0; i < decided_polygons.size(); ++i) - { - for (unsigned int j = 0; j < unreachable_polygons[decided_polygons[i]].size(); ++j) - { - Polygon display_unreachable_polygon = transform_UpsideDown(solver_configuration, SEQ_SVG_SCALE_FACTOR, scaleUp_PolygonForSlicer(SEQ_SVG_SCALE_FACTOR, - unreachable_polygons[decided_polygons[i]][j], - poly_positions_X[decided_polygons[i]].as_double(), - poly_positions_Y[decided_polygons[i]].as_double())); - - string unreachable_color; - - switch(j % 8) - { - case 0: - { - unreachable_color = "lightgray"; - break; - } - case 1: - { - unreachable_color = "darkgray"; - break; - } - case 2: - { - unreachable_color = "dimgrey"; - break; - } - case 3: - { - unreachable_color = "silver"; - break; - } - case 4: - { - unreachable_color = "gainsboro"; - break; - } - case 5: - { - unreachable_color = "lavender"; - break; - } - case 6: - { - unreachable_color = "lavenderblush"; - break; - } - case 7: - { - unreachable_color = "beige"; - break; - } - default: - { - break; - } - } - preview_svg.draw(display_unreachable_polygon, unreachable_color); - } - } - } - - for (unsigned int i = 0; i < decided_polygons.size(); ++i) - { - Polygon display_polygon = transform_UpsideDown(solver_configuration, SEQ_SVG_SCALE_FACTOR, scaleUp_PolygonForSlicer(SEQ_SVG_SCALE_FACTOR, - polygons[decided_polygons[i]], - poly_positions_X[decided_polygons[i]].as_double(), - poly_positions_Y[decided_polygons[i]].as_double())); - - string color; - - switch(i % 12) - { - case 0: - { - color = "green"; - break; - } - case 1: - { - color = "blue"; - break; - } - case 2: - { - color = "red"; - break; - } - case 3: - { - color = "grey"; - break; - } - case 4: - { - color = "cyan"; - break; - } - case 5: - { - color = "magenta"; - break; - } - case 6: - { - color = "yellow"; - break; - } - - case 7: - { - color = "rosybrown"; - break; - } - - case 8: - { - color = "indigo"; - break; - } - case 9: - { - color = "olive"; - break; - } - case 10: - { - color = "firebrick"; - break; - } - case 11: - { - color = "violet"; - break; - } - case 12: - { - color = "midnightblue"; - break; - } - case 13: - { - color = "khaki"; - break; - } - case 14: - { - color = "darkslategrey"; - break; - } - case 15: - { - color = "hotpink"; - break; - } - - default: - { - break; - } - } - - preview_svg.draw(display_polygon, color); - } - std::map::const_iterator scheduled_polygon = scheduled_polygons.begin(); - for (unsigned int i = 0; i < decided_polygons.size(); ++i, ++scheduled_polygon) - { - coord_t sx, sy, x, y; - - scaleUp_PositionForSlicer(SEQ_SVG_SCALE_FACTOR, - poly_positions_X[decided_polygons[i]].as_double(), - poly_positions_Y[decided_polygons[i]].as_double(), - sx, sy); - transform_UpsideDown(solver_configuration, SEQ_SVG_SCALE_FACTOR, sx, sy, x, y); - - string text_color; - - switch(i % 12) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - { - text_color = "black"; - break; - } - case 7: - { - text_color = "grey"; - break; - } - case 8: - case 9: - case 10: - case 11: - { - text_color = "black"; - break; - } - default: - { - break; - } - } - - preview_svg.draw_text(Point(x, y), ("ID:" + std::to_string(original_index_map[decided_polygons[i]]) + " T:" + std::to_string(times_T[decided_polygons[i]].as_int64())).c_str(), text_color.c_str()); - } - solver_configuration.plate_bounding_box = BoundingBox({0,0}, {SEQ_PRUSA_MK3S_X_SIZE, SEQ_PRUSA_MK3S_Y_SIZE}); - - Polygon plate_polygon({ { solver_configuration.plate_bounding_box.min.x(), solver_configuration.plate_bounding_box.min.y() }, - { solver_configuration.plate_bounding_box.max.x(), solver_configuration.plate_bounding_box.min.y() }, - { solver_configuration.plate_bounding_box.max.x(), solver_configuration.plate_bounding_box.max.y() }, - { solver_configuration.plate_bounding_box.min.x(), solver_configuration.plate_bounding_box.max.y() } }); - - Polygon display_plate_polygon = scaleUp_PolygonForSlicer(SEQ_SVG_SCALE_FACTOR, - plate_polygon, - 0, - 0); - preview_svg.draw_outline(display_plate_polygon, "black"); - - preview_svg.Close(); - } - else - { - printf("Polygon optimization FAILED.\n"); - } - finish = clock(); - printf("Intermediate CPU time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC); - - if (!remaining_polygons.empty()) - { - printf("Some object did not fit into plate.\n"); - - if (command_parameters.interactive) - { - printf("Press ENTER to continue to the next plate ...\n"); - getchar(); - } - else - { - ++plate_index; - printf("Continuing to the next plate number %d ...\n", plate_index); - } - } - else - { - printf("All objects fit onto plate.\n"); - } - - std::vector next_polygons; - std::vector > next_unreachable_polygons; - std::vector next_lepox_to_next; - - #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]]); - next_unreachable_polygons.push_back(unreachable_polygons[remaining_polygons[i]]); - next_lepox_to_next.push_back(lepox_to_next[remaining_polygons[i]]); - } - - polygon_index_map.clear(); - - polygons = next_polygons; - unreachable_polygons = next_unreachable_polygons; - lepox_to_next = next_lepox_to_next; - - std::vector next_polygon_index_map; - std::map next_original_index_map; - - for (unsigned int index = 0; index < polygons.size(); ++index) - { - next_polygon_index_map.push_back(index); - next_original_index_map[index] = original_index_map[remaining_polygons[index]]; - } - polygon_index_map = next_polygon_index_map; - original_index_map = next_original_index_map; - } - while (!remaining_polygons.empty()); - - finish = clock(); - - printf("Sequential scheduling/arranging ... finished\n"); - printf("Total CPU time: %.3f\n", (finish - start) / (double)CLOCKS_PER_SEC); - - return 0; -} - - -/*----------------------------------------------------------------------------*/ -// main program - -int main(int argc, char **argv) -{ - int result; - CommandParameters command_parameters; - - print_IntroductoryMessage(); - - if (argc >= 1 && argc <= 10) - { - for (int i = 1; i < argc; ++i) - { - result = parse_CommandLineParameter(argv[i], command_parameters); - if (result < 0) - { - printf("Error: Cannot parse command line parameters (code = %d).\n", result); - print_Help(); - - return result; - } - } - if (command_parameters.help) - { - print_Help(); - } - else - { - result = solve_SequentialPrint(command_parameters); - if (result < 0) - { - return result; - } - } - } - else - { - print_Help(); - } - print_ConcludingMessage(); - - return 0; -} diff --git a/src/libseqarrange/src/sequential_prusa.hpp b/src/libseqarrange/src/sequential_prusa.hpp deleted file mode 100644 index c3e82fe24d..0000000000 --- a/src/libseqarrange/src/sequential_prusa.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/*================================================================*/ -/* - * Author: Pavel Surynek, 2023 - 2025 - * Company: Prusa Research - * - * File: sequential_prusa.hpp - * - * SEQUENTIAL 3D Print Scheduler|Arranger. - */ -/*================================================================*/ - -#ifndef __SEQUENTIAL_PRUSA_HPP__ -#define __SEQUENTIAL_PRUSA_HPP__ - -/*----------------------------------------------------------------*/ - -#include "seq_sequential.hpp" -#include "seq_preprocess.hpp" -#include "seq_interface.hpp" - - -/*----------------------------------------------------------------*/ - -struct CommandParameters -{ - CommandParameters() - : decimation(true) - , precision(true) - , assumptions(true) - , interactive(false) - , object_group_size(4) - , input_filename("arrange_data_export.txt") - , output_filename("arrange_data_import.txt") - , printer_filename("../printers/printer_geometry.mk4.compatibility.txt") - , help(false) - { - /* nothing */ - } - - bool decimation; - bool precision; - bool assumptions; - bool interactive; - int object_group_size; - - string input_filename; - string output_filename; - string printer_filename; - - bool help; -}; - - -/*----------------------------------------------------------------------------*/ - - void print_IntroductoryMessage(void); - void print_ConcludingMessage(void); - void print_Help(void); - - int parse_CommandLineParameter(const string ¶meter, CommandParameters ¶meters); - int solve_SequentialPrint(const CommandParameters &command_parameters); - -/*----------------------------------------------------------------*/ - -#endif /* __SEQUENTIAL_PRUSA_HPP__ */ diff --git a/src/libseqarrange/test/seq_test_arrangement.cpp b/src/libseqarrange/test/seq_test_arrangement.cpp deleted file mode 100644 index a297f95cf3..0000000000 --- a/src/libseqarrange/test/seq_test_arrangement.cpp +++ /dev/null @@ -1,1006 +0,0 @@ -/*================================================================*/ -/* - * Author: Pavel Surynek, 2023 - 2024 - * Company: Prusa Research - * - * File: seq_test_arrangement.cpp - * - * Basic steel sheet object arrangement test via - * Constraint Programming tools. - */ -/*================================================================*/ - -#include -#include -#include - -#include -#include -#include -#include - -#define CATCH_CONFIG_EXTERNAL_INTERFACES -#define CATCH_CONFIG_MAIN -#include "catch2/catch.hpp" - -#include "seq_defs.hpp" - -#include "seq_test_arrangement.hpp" - - -/*----------------------------------------------------------------*/ - - -using namespace Gecode; - - -/*----------------------------------------------------------------*/ - -class Queens : public Script { -public: - /// Position of queens on boards - IntVarArray q; - /// Propagation to use for model - - Queens(const SizeOptions& opt) - : Script(opt), q(*this, opt.size(), 0, opt.size()-1) { - - const int n = q.size(); - - for (int i = 0; i(opt); - - - printf("Testing plate arrangement 1 ... finished\n"); -} - - -class SimpleProblem : public Space -{ -public: - IntVarArray vars; - IntVar X, Y, Z; - -public: - SimpleProblem() - : vars(*this, 3, 0, 3) - , X(vars[0]) - , Y(vars[1]) - , Z(vars[2]) - { - rel(*this, X != Y); - rel(*this, Y != Z); - rel(*this, X != Z); - - branch(*this, vars, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - }; - - SimpleProblem(SimpleProblem &s) - : Space(s) - { - X.update(*this, s.X); - Y.update(*this, s.Y); - Z.update(*this, s.Z); - } - - virtual Space* copy(void) { - return new SimpleProblem(*this); - }; - - void print(void) const - { - /* - cout << X << endl; - cout << Y << endl; - cout << Z << endl; - */ - printf("XYZ: %d, %d, %d\n", X.val(), Y.val(), Z.val()); - }; -}; - - -const int plate_size = 9; - -const int Obj1_width = 5; -const int Obj1_height = 4; - -const int Obj2_width = 3; -const int Obj2_height = 7; - -const int Obj3_width = 5; -const int Obj3_height = 5; - -class ArrangementProblem : public Space -{ -public: - IntVarArray vars; - IntVar Obj1_x, Obj1_y; - IntVar Obj2_x, Obj2_y; - IntVar Obj3_x, Obj3_y; - -public: - ArrangementProblem() - : vars(*this, 6, 0, plate_size - 1) - , Obj1_x(vars[0]) - , Obj1_y(vars[1]) - , Obj2_x(vars[2]) - , Obj2_y(vars[3]) - , Obj3_x(vars[4]) - , Obj3_y(vars[5]) - { - IntArgs widths(3); - widths[0] = Obj1_width; - widths[1] = Obj2_width; - widths[2] = Obj3_width; - - IntArgs heights(3); - heights[0] = Obj1_height; - heights[1] = Obj2_height; - heights[2] = Obj3_height; - - IntVarArgs Xs(3); - Xs[0] = Obj1_x; - Xs[1] = Obj2_x; - Xs[2] = Obj3_x; - - IntVarArgs Ys(3); - Ys[0] = Obj1_y; - Ys[1] = Obj2_y; - Ys[2] = Obj3_y; - - nooverlap(*this, Xs, widths, Ys, heights); - - rel(*this, Obj1_x + Obj1_width <= plate_size); - rel(*this, Obj2_x + Obj2_width <= plate_size); - rel(*this, Obj3_x + Obj3_width <= plate_size); - - rel(*this, Obj2_x == Obj1_x + 5); - rel(*this, Obj2_y == Obj1_y + 1); - - rel(*this, Obj1_y + Obj1_height <= plate_size); - rel(*this, Obj2_y + Obj2_height <= plate_size); - rel(*this, Obj3_y + Obj3_height <= plate_size); - - branch(*this, vars, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - }; - - ArrangementProblem(ArrangementProblem &s) - : Space(s) - { - Obj1_x.update(*this, s.Obj1_x); - Obj1_y.update(*this, s.Obj1_y); - - Obj2_x.update(*this, s.Obj2_x); - Obj2_y.update(*this, s.Obj2_y); - - Obj3_x.update(*this, s.Obj3_x); - Obj3_y.update(*this, s.Obj3_y); - } - - virtual Space* copy(void) { - return new ArrangementProblem(*this); - }; - - void print(void) const - { - /* - cout << X << endl; - cout << Y << endl; - cout << Z << endl; - */ - printf("Position obj1: %d, %d\n", Obj1_x.val(), Obj1_y.val()); - printf("Position obj2: %d, %d\n", Obj2_x.val(), Obj2_y.val()); - printf("Position obj2: %d, %d\n", Obj3_x.val(), Obj3_y.val()); - }; -}; - - -const int plate_resolution = 20; -const int time_resolution = 80; - -const int low_Obj1_width = 5; -const int low_Obj1_height = 4; -const int low_Obj1_duration = 10; - -const int low_Obj2_width = 3; -const int low_Obj2_height = 7; -const int low_Obj2_duration = 15; - -const int low_Obj3_width = 4; -const int low_Obj3_height = 4; -const int low_Obj3_duration = 5; - -const int high_Obj1_width = 2; -const int high_Obj1_height = 2; -const int high_Obj1_duration = 35; - -const int kine_width = 100; -const int kine_height = 10; - - -class SimpleSequentialProblem : public Space -{ -public: - IntVarArray space_vars; - IntVarArray time_vars; - IntVarArray kine_vars; - - IntVar low_Obj1_x, low_Obj1_y, low_Obj1_t; - IntVar low_Obj2_x, low_Obj2_y, low_Obj2_t; - IntVar low_Obj3_x, low_Obj3_y, low_Obj3_t; - - IntVar high_Obj1_x, high_Obj1_y, high_Obj1_t; - -public: - SimpleSequentialProblem() - : space_vars(*this, 8, 0, plate_resolution) - , time_vars(*this, 4, 0, time_resolution) - , kine_vars(*this, 2, 0, plate_resolution) - - , low_Obj1_x(space_vars[0]) - , low_Obj1_y(space_vars[1]) - , low_Obj1_t(time_vars[0]) - - , low_Obj2_x(space_vars[2]) - , low_Obj2_y(space_vars[3]) - , low_Obj2_t(time_vars[1]) - - , low_Obj3_x(space_vars[4]) - , low_Obj3_y(space_vars[5]) - , low_Obj3_t(time_vars[2]) - - , high_Obj1_x(space_vars[6]) - , high_Obj1_y(space_vars[7]) - , high_Obj1_t(time_vars[3]) - { - BoolVar low_Obj1_present = expr(*this, low_Obj1_t >= 0); - BoolVar low_Obj2_present = expr(*this, low_Obj2_t >= 0); - BoolVar low_Obj3_present = expr(*this, low_Obj3_t >= 0); - BoolVar high_Obj1_present = expr(*this, high_Obj1_t >= 0); - //BoolVar low_Obj1_above_high_Obj1 = expr(*this, low_Obj1_t >= high_Obj1_t); - - BoolVarArgs objects_present(4); - objects_present[0] = low_Obj1_present; - objects_present[1] = low_Obj2_present; - objects_present[2] = low_Obj3_present; - objects_present[3] = high_Obj1_present; - //objects_present[3] = low_Obj1_above_high_Obj1; - - IntArgs kine_widths(1); - IntArgs kine_heights(1); - - IntVar kine_Obj1_x(kine_vars[0]); - IntVar kine_Obj1_y(kine_vars[1]); - - kine_widths[0] = kine_width; - kine_heights[0] = kine_height; - - rel(*this, kine_Obj1_x == high_Obj1_x + high_Obj1_width); - rel(*this, kine_Obj1_y == high_Obj1_y - 3); - - IntArgs widths(4); - widths[0] = low_Obj1_width; - widths[1] = low_Obj2_width; - widths[2] = low_Obj3_width; - widths[3] = high_Obj1_width; - //widths[3] = kine_width; - - IntArgs heights(4); - heights[0] = low_Obj1_height; - heights[1] = low_Obj2_height; - heights[2] = low_Obj3_height; - heights[3] = high_Obj1_height; - //heights[3] = kine_height; - - IntVarArgs Xs(4); - Xs[0] = low_Obj1_x; - Xs[1] = low_Obj2_x; - Xs[2] = low_Obj3_x; - Xs[3] = high_Obj1_x; - //Xs[3] = kine_Obj1_x; - - IntVarArgs Ys(4); - Ys[0] = low_Obj1_y; - Ys[1] = low_Obj2_y; - Ys[2] = low_Obj3_y; - Ys[3] = high_Obj1_y; - //Ys[3] = kine_Obj1_y; - - nooverlap(*this, Xs, widths, Ys, heights/*, objects_present*/); - - rel(*this, low_Obj1_t >= low_Obj2_t + low_Obj2_duration || low_Obj2_t >= low_Obj1_t + low_Obj1_duration); - rel(*this, low_Obj1_t >= low_Obj3_t + low_Obj3_duration || low_Obj3_t >= low_Obj1_t + low_Obj1_duration); - rel(*this, low_Obj2_t >= low_Obj3_t + low_Obj3_duration || low_Obj3_t >= low_Obj2_t + low_Obj2_duration); - - rel(*this, low_Obj3_t >= high_Obj1_t + high_Obj1_duration || high_Obj1_t >= low_Obj3_t + low_Obj3_duration); - rel(*this, low_Obj2_t >= high_Obj1_t + high_Obj1_duration || high_Obj1_t >= low_Obj2_t + low_Obj2_duration); - rel(*this, low_Obj1_t >= high_Obj1_t + high_Obj1_duration || high_Obj1_t >= low_Obj1_t + low_Obj1_duration); - - rel(*this, low_Obj1_x + low_Obj1_width <= plate_resolution); - rel(*this, low_Obj2_x + low_Obj2_width <= plate_resolution); - rel(*this, low_Obj3_x + low_Obj3_width <= plate_resolution); - rel(*this, high_Obj1_x + high_Obj1_width <= plate_resolution); - - rel(*this, low_Obj1_y + low_Obj1_height <= plate_resolution); - rel(*this, low_Obj2_y + low_Obj2_height <= plate_resolution); - rel(*this, low_Obj3_y + low_Obj3_height <= plate_resolution); - rel(*this, high_Obj1_y + high_Obj1_height <= plate_resolution); - - rel(*this, low_Obj1_t + low_Obj1_duration <= time_resolution); - rel(*this, low_Obj2_t + low_Obj2_duration <= time_resolution); - rel(*this, low_Obj3_t + low_Obj3_duration <= time_resolution); - rel(*this, high_Obj1_t + high_Obj1_duration <= time_resolution); - - rel(*this, low_Obj1_t < high_Obj1_t || low_Obj1_x >= kine_Obj1_x + kine_width || kine_Obj1_x >= low_Obj1_x + low_Obj1_width - || low_Obj1_y >= kine_Obj1_y + kine_height || kine_Obj1_y >= low_Obj1_y + low_Obj1_height); - - rel(*this, low_Obj2_t < high_Obj1_t || low_Obj2_x >= kine_Obj1_x + kine_width || kine_Obj1_x >= low_Obj2_x + low_Obj2_width - || low_Obj2_y >= kine_Obj1_y + kine_height || kine_Obj1_y >= low_Obj2_y + low_Obj2_height); - - rel(*this, low_Obj3_t < high_Obj1_t || low_Obj3_x >= kine_Obj1_x + kine_width || kine_Obj1_x >= low_Obj3_x + low_Obj3_width - || low_Obj3_y >= kine_Obj1_y + kine_height || kine_Obj1_y >= low_Obj3_y + low_Obj3_height); - - rel(*this, high_Obj1_t < 10); - rel(*this, high_Obj1_x == 0); - - - branch(*this, space_vars, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - branch(*this, time_vars, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - branch(*this, kine_vars, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - }; - - SimpleSequentialProblem(SimpleSequentialProblem &s) - : Space(s) - { - low_Obj1_x.update(*this, s.low_Obj1_x); - low_Obj1_y.update(*this, s.low_Obj1_y); - low_Obj1_t.update(*this, s.low_Obj1_t); - - low_Obj2_x.update(*this, s.low_Obj2_x); - low_Obj2_y.update(*this, s.low_Obj2_y); - low_Obj2_t.update(*this, s.low_Obj2_t); - - low_Obj3_x.update(*this, s.low_Obj3_x); - low_Obj3_y.update(*this, s.low_Obj3_y); - low_Obj3_t.update(*this, s.low_Obj3_t); - - high_Obj1_x.update(*this, s.high_Obj1_x); - high_Obj1_y.update(*this, s.high_Obj1_y); - high_Obj1_t.update(*this, s.high_Obj1_t); - } - - virtual Space* copy(void) { - return new SimpleSequentialProblem(*this); - }; - - void print(void) const - { - /* - cout << X << endl; - cout << Y << endl; - cout << Z << endl; - */ - printf("Position low obj1 : x:%d, y:%d, t:%d\n", low_Obj1_x.val(), low_Obj1_y.val(), low_Obj1_t.val()); - printf("Position low obj2 : x:%d, y:%d, t:%d\n", low_Obj2_x.val(), low_Obj2_y.val(), low_Obj2_t.val()); - printf("Position low obj3 : x:%d, y:%d, t:%d\n", low_Obj3_x.val(), low_Obj3_y.val(), low_Obj3_t.val()); - printf("Position high obj1: x:%d, y:%d, t:%d\n", high_Obj1_x.val(), high_Obj1_y.val(), high_Obj1_t.val()); - }; -}; - - -int complex_plate_resolution = 30; - -int complex_plate_resolution_min = 10; -int complex_plate_resolution_max = 200; - -int complex_time_resolution = 1000; -int complex_height_threshold = 25; - -const int complex_Obj_count = 10; - -int complex_Obj_widths[complex_Obj_count]; -int complex_Obj_heights[complex_Obj_count]; -int complex_Obj_durations[complex_Obj_count]; - -const int min_width = 4; -const int max_width = 20; - -const int min_height = 4; -const int max_height = 20; - -const int min_duration = 2; -const int max_duration = 50; - -const int gantry_left_height = 10; -const int gantry_left_shift = 4; - -const int gantry_right_height = 10; -const int gantry_right_shift = 4; - - -class ComplexSequentialProblem : public Space -{ -public: - IntVarArray space_vars; - IntVarArray time_vars; - IntVarArray kine_vars; - - IntVar complex_Obj_x[complex_Obj_count]; - IntVar complex_Obj_y[complex_Obj_count]; - IntVar complex_Obj_t[complex_Obj_count]; - - IntVar gantry_left_y[complex_Obj_count]; - IntVar gantry_right_y[complex_Obj_count]; - -public: - ComplexSequentialProblem() - : space_vars(*this, 2 * complex_Obj_count, 0, complex_plate_resolution) - , time_vars(*this, complex_Obj_count, 0, complex_time_resolution) - , kine_vars(*this, 2 * complex_Obj_count, 0, complex_plate_resolution) - { - /* - int width_span = max_width - min_width; - int height_span = max_height - min_height; - int duration_span = max_duration - min_duration; - - for (int i = 0; i < complex_Obj_count; ++i) - { - complex_Obj_widths[i] = min_width + rand() % width_span; - complex_Obj_heights[i] = min_height + rand() % height_span; - complex_Obj_durations[i] = min_duration + rand() % duration_span; - } - */ - for (int i = 0; i < complex_Obj_count; ++i) - { - complex_Obj_x[i] = space_vars[2 * i]; - complex_Obj_y[i] = space_vars[2 * i + 1]; - complex_Obj_t[i] = time_vars[i]; - - gantry_left_y[i] = kine_vars[2 * i]; - gantry_right_y[i] = kine_vars[2 * i + 1]; - } - - IntArgs widths(complex_Obj_count); - IntArgs heights(complex_Obj_count); - - IntVarArgs X_vars(complex_Obj_count); - IntVarArgs Y_vars(complex_Obj_count); - - for (int i = 0; i < complex_Obj_count; ++i) - { - widths[i] = complex_Obj_widths[i]; - heights[i] = complex_Obj_heights[i]; - - X_vars[i] = complex_Obj_x[i]; - Y_vars[i] = complex_Obj_y[i]; - } - - nooverlap(*this, X_vars, widths, Y_vars, heights, IPL_BND); - - for (int i = 0; i < complex_Obj_count - 1; ++i) - { - for (int j = i + 1; j < complex_Obj_count; ++j) - { - rel(*this, complex_Obj_t[i] >= complex_Obj_t[j] + complex_Obj_durations[j] || complex_Obj_t[j] >= complex_Obj_t[i] + complex_Obj_durations[i], IPL_BND); - } - } - - for (int i = 0; i < complex_Obj_count; ++i) - { - rel(*this, complex_Obj_x[i] + complex_Obj_widths[i] <= complex_plate_resolution, IPL_BND); - rel(*this, complex_Obj_y[i] + complex_Obj_heights[i] <= complex_plate_resolution, IPL_BND); - } - - for (int i = 0; i < complex_Obj_count; ++i) - { - if (complex_Obj_durations[i] >= complex_height_threshold) - { - rel(*this, gantry_left_y[i] == complex_Obj_y[i] + gantry_left_shift); - rel(*this, gantry_right_y[i] == complex_Obj_y[i] + gantry_right_shift); - } - } - - for (int i = 0; i < complex_Obj_count; ++i) - { - if (complex_Obj_durations[i] >= complex_height_threshold) - { - for (int j = 0; j < complex_Obj_count; ++j) - { - if (j != i) - { - rel(*this, complex_Obj_t[j] < complex_Obj_t[i] - || complex_Obj_y[j] >= gantry_right_y[i] + gantry_right_height - || gantry_right_y[i] >= complex_Obj_y[j] + complex_Obj_heights[j], IPL_BND); - - rel(*this, complex_Obj_t[j] < complex_Obj_t[i] - || complex_Obj_y[j] >= gantry_left_y[i] + gantry_left_height - || gantry_left_y[i] >= complex_Obj_y[j] + complex_Obj_heights[j], IPL_BND); - } - } - } - } - - branch(*this, space_vars, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - branch(*this, time_vars, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - branch(*this, kine_vars, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - }; - - ComplexSequentialProblem(ComplexSequentialProblem &s) - : Space(s) - { - for (int i = 0; i < complex_Obj_count; ++i) - { - complex_Obj_x[i].update(*this, s.complex_Obj_x[i]); - complex_Obj_y[i].update(*this, s.complex_Obj_y[i]); - complex_Obj_t[i].update(*this, s.complex_Obj_t[i]); - - gantry_left_y[i].update(*this, s.gantry_left_y[i]); - gantry_right_y[i].update(*this, s.gantry_right_y[i]); - } - } - - virtual Space* copy(void) { - return new ComplexSequentialProblem(*this); - }; - - void print(void) const - { - for (int i = 0; i < complex_Obj_count; ++i) - { - printf("Position object: x:%d, y:%d, t:%d (w:%d, h:%d, d:%d)\n", - complex_Obj_x[i].val(), - complex_Obj_y[i].val(), - complex_Obj_t[i].val(), - complex_Obj_widths[i], - complex_Obj_heights[i], - complex_Obj_durations[i]); - } - - for (int i = 0; i < complex_Obj_count; ++i) - { - if (complex_Obj_durations[i] >= complex_height_threshold) - { - printf("Gantry position (%d): left_y:%d right_y:%d\n", i, - gantry_left_y[i].val(), - gantry_right_y[i].val()); - } - } - }; -}; - - -int complex_plate_resolution_X = 200; - -int complex_plate_resolution_X_min = 10; -int complex_plate_resolution_X_max = 200; - - -int complex_plate_resolution_Y = 30; - -int complex_plate_resolution_Y_min = 10; -int complex_plate_resolution_Y_max = 200; - - -void generate_random_complex_objects(void) -{ - int width_span = max_width - min_width; - int height_span = max_height - min_height; - int duration_span = max_duration - min_duration; - - for (int i = 0; i < complex_Obj_count; ++i) - { - printf("Generating random object %d ...\n", i); - complex_Obj_widths[i] = min_width + rand() % width_span; - complex_Obj_heights[i] = min_height + rand() % height_span; - complex_Obj_durations[i] = min_duration + rand() % duration_span; - } -} - - -class ComplexSequentialProblemXY : public Space -{ -public: - IntVarArray space_vars_X; - IntVarArray space_vars_Y; - - IntVarArray time_vars; - - IntVarArray kine_vars_L; - IntVarArray kine_vars_R; - - IntVar complex_Obj_x[complex_Obj_count]; - IntVar complex_Obj_y[complex_Obj_count]; - IntVar complex_Obj_t[complex_Obj_count]; - - IntVar gantry_left_y[complex_Obj_count]; - IntVar gantry_right_y[complex_Obj_count]; - -public: - ComplexSequentialProblemXY() - : space_vars_X(*this, 2 * complex_Obj_count, 0, complex_plate_resolution_X) - , space_vars_Y(*this, 2 * complex_Obj_count, 0, complex_plate_resolution_Y) - , time_vars(*this, complex_Obj_count, 0, complex_time_resolution) - , kine_vars_L(*this, complex_Obj_count, 0, complex_plate_resolution_Y) - , kine_vars_R(*this, complex_Obj_count, 0, complex_plate_resolution_Y) - { - for (int i = 0; i < complex_Obj_count; ++i) - { - complex_Obj_x[i] = space_vars_X[2 * i]; - complex_Obj_y[i] = space_vars_X[2 * i + 1]; - - complex_Obj_t[i] = time_vars[i]; - - gantry_left_y[i] = kine_vars_L[i]; - gantry_right_y[i] = kine_vars_R[i]; - } - - IntArgs widths(complex_Obj_count); - IntArgs heights(complex_Obj_count); - - IntVarArgs X_vars(complex_Obj_count); - IntVarArgs Y_vars(complex_Obj_count); - - for (int i = 0; i < complex_Obj_count; ++i) - { - widths[i] = complex_Obj_widths[i]; - heights[i] = complex_Obj_heights[i]; - - X_vars[i] = complex_Obj_x[i]; - Y_vars[i] = complex_Obj_y[i]; - } - - nooverlap(*this, X_vars, widths, Y_vars, heights, IPL_BND); - - for (int i = 0; i < complex_Obj_count - 1; ++i) - { - for (int j = i + 1; j < complex_Obj_count; ++j) - { - rel(*this, complex_Obj_t[i] >= complex_Obj_t[j] + complex_Obj_durations[j] || complex_Obj_t[j] >= complex_Obj_t[i] + complex_Obj_durations[i], IPL_BND); - } - } - - for (int i = 0; i < complex_Obj_count; ++i) - { - rel(*this, complex_Obj_x[i] + complex_Obj_widths[i] <= complex_plate_resolution_X, IPL_BND); - rel(*this, complex_Obj_y[i] + complex_Obj_heights[i] <= complex_plate_resolution_Y, IPL_BND); - } - - - for (int i = 0; i < complex_Obj_count; ++i) - { - if (complex_Obj_durations[i] >= complex_height_threshold) - { - rel(*this, gantry_left_y[i] == complex_Obj_y[i] + gantry_left_shift); - rel(*this, gantry_right_y[i] == complex_Obj_y[i] + gantry_right_shift); - } - } - - for (int i = 0; i < complex_Obj_count; ++i) - { - if (complex_Obj_durations[i] >= complex_height_threshold) - { - for (int j = 0; j < complex_Obj_count; ++j) - { - if (j != i) - { - rel(*this, complex_Obj_t[j] < complex_Obj_t[i] - || complex_Obj_y[j] >= gantry_right_y[i] + gantry_right_height - || gantry_right_y[i] >= complex_Obj_y[j] + complex_Obj_heights[j], IPL_BND); - - rel(*this, complex_Obj_t[j] < complex_Obj_t[i] - || complex_Obj_y[j] >= gantry_left_y[i] + gantry_left_height - || gantry_left_y[i] >= complex_Obj_y[j] + complex_Obj_heights[j], IPL_BND); - } - } - } - } - - branch(*this, space_vars_Y, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - branch(*this, space_vars_X, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - branch(*this, time_vars, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - branch(*this, kine_vars_L, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - branch(*this, kine_vars_R, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); - }; - - ComplexSequentialProblemXY(ComplexSequentialProblemXY &s) - : Space(s) - { - for (int i = 0; i < complex_Obj_count; ++i) - { - complex_Obj_x[i].update(*this, s.complex_Obj_x[i]); - complex_Obj_y[i].update(*this, s.complex_Obj_y[i]); - complex_Obj_t[i].update(*this, s.complex_Obj_t[i]); - - gantry_left_y[i].update(*this, s.gantry_left_y[i]); - gantry_right_y[i].update(*this, s.gantry_right_y[i]); - } - } - - virtual Space* copy(void) { - return new ComplexSequentialProblemXY(*this); - }; - - void print(void) const - { - for (int i = 0; i < complex_Obj_count; ++i) - { - printf("Position object: x:%d, y:%d, t:%d (w:%d, h:%d, d:%d)\n", - complex_Obj_x[i].val(), - complex_Obj_y[i].val(), - complex_Obj_t[i].val(), - complex_Obj_widths[i], - complex_Obj_heights[i], - complex_Obj_durations[i]); - } - - for (int i = 0; i < complex_Obj_count; ++i) - { - if (complex_Obj_durations[i] >= complex_height_threshold) - { - printf("Gantry position (%d): left_y:%d right_y:%d\n", i, - gantry_left_y[i].val(), - gantry_right_y[i].val()); - } - } - }; -}; - - -TEST_CASE("Arrangement test 2", "[Classical Arrangement]") -{ - printf("Testing plate arrangement 2 ...\n"); - - SimpleProblem *simple_problem = new SimpleProblem(); - DFS engine(simple_problem); - delete simple_problem; - - while (SimpleProblem *simple_P = engine.next()) - { - simple_P->print(); - delete simple_P; - } - Search::Statistics stat = engine.statistics(); - printf("Statistics: %ld, %ld, %ld, %ld, %ld\n", stat.fail, stat.node, stat.depth, stat.restart, stat.nogood); - - printf("Testing plate arrangement 2 ... finished\n"); -} - - -TEST_CASE("Arrangement test 3", "[Classical Arrangement]") -{ - printf("Testing plate arrangement 3 ...\n"); - - ArrangementProblem *arrangement_problem = new ArrangementProblem(); - DFS engine(arrangement_problem); - delete arrangement_problem; - - while (ArrangementProblem *arrangement_P = engine.next()) - { - arrangement_P->print(); - delete arrangement_P; - printf("\n"); - getchar(); - } - Search::Statistics stat = engine.statistics(); - printf("Statistics: %ld, %ld, %ld, %ld, %ld\n", stat.fail, stat.node, stat.depth, stat.restart, stat.nogood); - - printf("Testing plate arrangement 3 ... finished\n"); -} - - -TEST_CASE("Arrangement test 4", "[Classical Arrangement]") -{ - printf("Testing plate arrangement 4 ...\n"); - - SimpleSequentialProblem *sequential_problem = new SimpleSequentialProblem(); - DFS engine(sequential_problem); - delete sequential_problem; - - while (SimpleSequentialProblem *sequential_P = engine.next()) - { - sequential_P->print(); - delete sequential_P; - - Search::Statistics stat = engine.statistics(); - printf("Statistics: %ld, %ld, %ld, %ld, %ld\n", stat.fail, stat.node, stat.depth, stat.restart, stat.nogood); - printf("\n"); - getchar(); - } - - printf("Testing plate arrangement 4 ... finished\n"); -} - - -TEST_CASE("Arrangement test 5", "[Classical Arrangement]") -{ - printf("Testing plate arrangement 5 ...\n"); - generate_random_complex_objects(); - - ComplexSequentialProblem *sequential_problem = new ComplexSequentialProblem(); - Search::Options options; - options.cutoff = Search::Cutoff::linear(); - options.nogoods_limit = 512; - DFS engine(sequential_problem, options); - delete sequential_problem; - - clock_t begin = clock(); - - while (ComplexSequentialProblem *sequential_P = engine.next()) - { - sequential_P->print(); - clock_t end = clock(); - printf("Time (CPU): %.3fs\n", (end - begin) / (double)CLOCKS_PER_SEC); - - delete sequential_P; - - Search::Statistics stat = engine.statistics(); - printf("Statistics: %ld, %ld, %ld, %ld, %ld\n", stat.fail, stat.node, stat.depth, stat.restart, stat.nogood); - printf("\n"); - getchar(); - } - clock_t end = clock(); - printf("Time (CPU): %.3fs\n", (end - begin) / (double)CLOCKS_PER_SEC); - - printf("Testing plate arrangement 5 ... finished\n"); -} - - -TEST_CASE("Arrangement test 6", "[Classical Arrangement]") -{ - printf("Testing plate arrangement 6 ...\n"); - generate_random_complex_objects(); - - complex_plate_resolution = complex_plate_resolution_max; - - while (complex_plate_resolution > complex_plate_resolution_min) - { - printf("Trying plate resolution = %d\n", complex_plate_resolution); - - ComplexSequentialProblem *sequential_problem = new ComplexSequentialProblem(); - - Search::Options options; - /* - options.cutoff = Search::Cutoff::linear(); - options.nogoods_limit = 16 * 512; - */ - options.stop = Search::Stop::time(512); - - DFS engine(sequential_problem, options); - delete sequential_problem; - - clock_t begin = clock(); - - ComplexSequentialProblem *sequential_P = engine.next(); - - if (sequential_P != NULL) - { - sequential_P->print(); - clock_t end = clock(); - printf("Time (CPU): %.3fs\n", (end - begin) / (double)CLOCKS_PER_SEC); - - Search::Statistics stat = engine.statistics(); - printf("Statistics: %ld, %ld, %ld, %ld, %ld\n", stat.fail, stat.node, stat.depth, stat.restart, stat.nogood); - printf("\n"); - printf("SUCCESS\n"); - } - else - { - clock_t end = clock(); - printf("Time (CPU): %.3fs\n", (end - begin) / (double)CLOCKS_PER_SEC); - - Search::Statistics stat = engine.statistics(); - printf("Statistics: %ld, %ld, %ld, %ld, %ld\n", stat.fail, stat.node, stat.depth, stat.restart, stat.nogood); - - printf("FAIL\n"); - } - delete sequential_P; - - complex_plate_resolution -= 1; - - } - printf("Testing plate arrangement 6 ... finished\n"); -} - - -TEST_CASE("Arrangement test 7", "[Classical Arrangement]") -{ - printf("Testing plate arrangement 7 ...\n"); - generate_random_complex_objects(); - - complex_plate_resolution_X = complex_plate_resolution_X_max; - - while (complex_plate_resolution_X > complex_plate_resolution_X_min) - { - printf("Trying plate resolution X = %d, Y = %d\n", complex_plate_resolution_X, complex_plate_resolution_Y); - - ComplexSequentialProblemXY *sequential_problem = new ComplexSequentialProblemXY(); - Search::Options options; - /* - options.cutoff = Search::Cutoff::linear(); - options.nogoods_limit = 16 * 512; - */ - options.stop = Search::Stop::time(10 * 512); - - DFS engine(sequential_problem, options); - delete sequential_problem; - - clock_t begin = clock(); - - ComplexSequentialProblemXY *sequential_P = engine.next(); - - if (sequential_P != NULL) - { - sequential_P->print(); - - clock_t end = clock(); - printf("Time (CPU): %.3fs\n", (end - begin) / (double)CLOCKS_PER_SEC); - - Search::Statistics stat = engine.statistics(); - printf("Statistics: %ld, %ld, %ld, %ld, %ld\n", stat.fail, stat.node, stat.depth, stat.restart, stat.nogood); - printf("SUCCESS\n"); - } - else - { - clock_t end = clock(); - printf("Time (CPU): %.3fs\n", (end - begin) / (double)CLOCKS_PER_SEC); - Search::Statistics stat = engine.statistics(); - printf("Statistics: %ld, %ld, %ld, %ld, %ld\n", stat.fail, stat.node, stat.depth, stat.restart, stat.nogood); - - printf("FAIL\n"); - } - delete sequential_P; - - complex_plate_resolution_X -= 1; - - } - printf("Testing plate arrangement 7 ... finished\n"); -} - - - -/*----------------------------------------------------------------*/ diff --git a/src/libseqarrange/test/seq_test_arrangement.hpp b/src/libseqarrange/test/seq_test_arrangement.hpp deleted file mode 100644 index 417fd752b2..0000000000 --- a/src/libseqarrange/test/seq_test_arrangement.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/*================================================================*/ -/* - * Author: Pavel Surynek, 2023 - 2024 - * Company: Prusa Research - * - * File: seq_test_arrangement.hpp - * - * Basic steel sheet object arrangement test via - * Constraint Programming tools. - */ -/*================================================================*/ - -#ifndef __SEQ_TEST_ARRANGEMENT_HPP__ -#define __SEQ_TEST_ARRANGEMENT_HPP__ - -/*----------------------------------------------------------------*/ - - -#endif /* __SEQ_TEST_ARRANGEMENT_HPP__ */ diff --git a/src/libseqarrange/test/seq_test_interface.cpp b/src/libseqarrange/test/seq_test_interface.cpp index 29dc003d64..fa729c42f5 100644 --- a/src/libseqarrange/test/seq_test_interface.cpp +++ b/src/libseqarrange/test/seq_test_interface.cpp @@ -9,6 +9,10 @@ */ /*================================================================*/ +#include +#include +#include + #include #include #include @@ -19,13 +23,9 @@ #include "libslic3r/Geometry/ConvexHull.hpp" #include "libslic3r/SVG.hpp" -#define CATCH_CONFIG_EXTERNAL_INTERFACES -#define CATCH_CONFIG_MAIN -#include "catch2/catch.hpp" - #include -#include "seq_interface.hpp" +#include "libseqarrange/seq_interface.hpp" #include "seq_utilities.hpp" #include "seq_preprocess.hpp" diff --git a/src/libseqarrange/test/seq_test_polygon.cpp b/src/libseqarrange/test/seq_test_polygon.cpp index 93a229ffbe..22a2616104 100644 --- a/src/libseqarrange/test/seq_test_polygon.cpp +++ b/src/libseqarrange/test/seq_test_polygon.cpp @@ -9,6 +9,10 @@ */ /*================================================================*/ +#include +#include +#include + #include #include #include @@ -18,10 +22,6 @@ #include "libslic3r/Geometry/ConvexHull.hpp" #include "libslic3r/SVG.hpp" -#define CATCH_CONFIG_EXTERNAL_INTERFACES -#define CATCH_CONFIG_MAIN -#include "catch2/catch.hpp" - #include #include "prusaparts.hpp" @@ -608,9 +608,10 @@ TEST_CASE("Polygon test 5", "[Polygon]") printf("Testing polygon 5 ... finished\n"); } - -Polygon polygon_1 = {{0, 0}, {50, 0}, {50, 50}, {0, 50}}; -//Polygon polygon_1 = {{scale_(0), scale_(0)}, {scale_(50), scale_(0)}, {scale_(50), scale_(50)}, {scale_(0), scale_(50)}}; +namespace { + Polygon polygon_1 = { {0, 0}, {50, 0}, {50, 50}, {0, 50} }; + //Polygon polygon_1 = {{scale_(0), scale_(0)}, {scale_(50), scale_(0)}, {scale_(50), scale_(50)}, {scale_(0), scale_(50)}}; +} TEST_CASE("Polygon test 6", "[Polygon]") diff --git a/src/libseqarrange/test/seq_test_preprocess.cpp b/src/libseqarrange/test/seq_test_preprocess.cpp index 873013a240..ba3ba902c1 100644 --- a/src/libseqarrange/test/seq_test_preprocess.cpp +++ b/src/libseqarrange/test/seq_test_preprocess.cpp @@ -9,6 +9,9 @@ */ /*================================================================*/ +#include +#include +#include #include #include @@ -20,10 +23,6 @@ #include "libslic3r/Geometry/ConvexHull.hpp" #include "libslic3r/SVG.hpp" -#define CATCH_CONFIG_EXTERNAL_INTERFACES -#define CATCH_CONFIG_MAIN -#include "catch2/catch.hpp" - #include #include "prusaparts.hpp" @@ -58,7 +57,7 @@ const int SEQ_PRUSA_MK3S_Y_SIZE = 2100; /*----------------------------------------------------------------*/ -Polygon scale_UP(const Polygon &polygon) +static Polygon scale_UP(const Polygon &polygon) { Polygon poly = polygon; @@ -71,7 +70,7 @@ Polygon scale_UP(const Polygon &polygon) } -Polygon scale_UP(const Polygon &polygon, double x_pos, double y_pos) +static Polygon scale_UP(const Polygon &polygon, double x_pos, double y_pos) { Polygon poly = polygon; diff --git a/src/libseqarrange/test/seq_test_sequential.cpp b/src/libseqarrange/test/seq_test_sequential.cpp index 98553ef85d..da1f562420 100644 --- a/src/libseqarrange/test/seq_test_sequential.cpp +++ b/src/libseqarrange/test/seq_test_sequential.cpp @@ -9,6 +9,10 @@ */ /*================================================================*/ +#include +#include +#include + #include #include #include @@ -19,10 +23,6 @@ #include "libslic3r/Geometry/ConvexHull.hpp" #include "libslic3r/SVG.hpp" -#define CATCH_CONFIG_EXTERNAL_INTERFACES -#define CATCH_CONFIG_MAIN -#include "catch2/catch.hpp" - #include #include "seq_defs.hpp" @@ -53,7 +53,7 @@ const int SEQ_PRUSA_MK3S_Y_SIZE = 2100; /*----------------------------------------------------------------*/ -Polygon scale_UP(const Polygon &polygon) +static Polygon scale_UP(const Polygon &polygon) { Polygon poly = polygon; @@ -66,7 +66,7 @@ Polygon scale_UP(const Polygon &polygon) } -Polygon scale_UP(const Polygon &polygon, double x_pos, double y_pos) +static Polygon scale_UP(const Polygon &polygon, double x_pos, double y_pos) { Polygon poly = polygon; @@ -737,47 +737,48 @@ TEST_CASE("Sequential test 3", "[Sequential Arrangement Core]") printf("Testing sequential scheduling 3 ... finished\n"); } +namespace { + Polygon polygon_1 = { {0, 0}, {50, 0}, {50, 50}, {0, 50} }; + Polygon polygon_2 = { {0, 0}, {150, 10}, {150, 50}, {75, 120}, {0, 50} }; + //Polygon polygon_2 = {{0, 0}, {0, 50}, {75, 120}, {150, 50}, {150, 0} }; + Polygon polygon_3 = { {40, 0}, {80, 40}, {40, 80}, {0, 40} }; + //Polygon polygon_3 = {{40, 0}, {0, 40},{40, 80}, {80, 40}}; + Polygon polygon_4 = { {20, 0}, {40, 0}, {60, 30}, {30, 50}, {0, 30} }; + //Polygon polygon_4 = {{20, 0}, {0, 30}, {30, 50}, {60, 30}, {40, 0} }; -Polygon polygon_1 = {{0, 0}, {50, 0}, {50, 50}, {0, 50}}; -Polygon polygon_2 = {{0, 0}, {150, 10}, {150, 50}, {75, 120}, {0, 50} }; -//Polygon polygon_2 = {{0, 0}, {0, 50}, {75, 120}, {150, 50}, {150, 0} }; -Polygon polygon_3 = {{40, 0}, {80, 40}, {40, 80}, {0, 40}}; -//Polygon polygon_3 = {{40, 0}, {0, 40},{40, 80}, {80, 40}}; -Polygon polygon_4 = {{20, 0}, {40, 0}, {60, 30}, {30, 50}, {0, 30}}; -//Polygon polygon_4 = {{20, 0}, {0, 30}, {30, 50}, {60, 30}, {40, 0} }; - -Polygon unreachable_polygon_1 = {{-5, -5}, {60, -5}, {60, 60}, {-5, 60}}; -Polygon unreachable_polygon_2 = {{-20, -20}, {170, -20}, {170, 86}, {85, 140}, {-20, 60} }; -Polygon unreachable_polygon_3 = {{40, -10}, {90, 40}, {40, 90}, {-10, 40}}; -Polygon unreachable_polygon_4 = {{10, -10}, {40, -10}, {70, 40}, {30, 60}, {-10, 40}}; -//Polygon unreachable_polygon_4 = {{10, -1}, {40, -1}, {70, 40}, {30, 60}, {0, 40}}; -//Polygon unreachable_polygon_4 = {{10, -10}, {-10, 40}, {30, 60}, {70, 40}, {40, -10}}; + Polygon unreachable_polygon_1 = { {-5, -5}, {60, -5}, {60, 60}, {-5, 60} }; + Polygon unreachable_polygon_2 = { {-20, -20}, {170, -20}, {170, 86}, {85, 140}, {-20, 60} }; + Polygon unreachable_polygon_3 = { {40, -10}, {90, 40}, {40, 90}, {-10, 40} }; + Polygon unreachable_polygon_4 = { {10, -10}, {40, -10}, {70, 40}, {30, 60}, {-10, 40} }; + //Polygon unreachable_polygon_4 = {{10, -1}, {40, -1}, {70, 40}, {30, 60}, {0, 40}}; + //Polygon unreachable_polygon_4 = {{10, -10}, {-10, 40}, {30, 60}, {70, 40}, {40, -10}}; -std::vector unreachable_polygons_1 = { - {{-5, -5}, {60, -5}, {60, 60}, {-5, 60}}, -// {{-20,-20}, {-25,-20}, {-25,-25}, {-20,-25}} -// {{-20,20}, {-25,20}, {-25,25}, {-20,25}} -// {{-20,20}, {-40,20}, {-40,40}, {-20,40}} -// {{-20,20}, {-80,20}, {-80,40}, {-20,40}} /* CW */ - {{-20,20}, {-20,40}, {-180,40}, {-180,20}}, /* CCW */ - {{80,20}, {240,20}, {240,40}, {80,40}} /* CCW */ -// {{-5,-5}, {-100,-5}, {-100,10}, {-5,10}} -}; + std::vector unreachable_polygons_1 = { + {{-5, -5}, {60, -5}, {60, 60}, {-5, 60}}, + // {{-20,-20}, {-25,-20}, {-25,-25}, {-20,-25}} + // {{-20,20}, {-25,20}, {-25,25}, {-20,25}} + // {{-20,20}, {-40,20}, {-40,40}, {-20,40}} + // {{-20,20}, {-80,20}, {-80,40}, {-20,40}} /* CW */ + {{-20,20}, {-20,40}, {-180,40}, {-180,20}}, /* CCW */ + {{80,20}, {240,20}, {240,40}, {80,40}} /* CCW */ + // {{-5,-5}, {-100,-5}, {-100,10}, {-5,10}} + }; -std::vector unreachable_polygons_2 = { - {{-20, -20}, {170, -20}, {170, 86}, {85, 140}, {-20, 60} } -}; + std::vector unreachable_polygons_2 = { + {{-20, -20}, {170, -20}, {170, 86}, {85, 140}, {-20, 60} } + }; -std::vector unreachable_polygons_3 = { - {{40, -10}, {90, 40}, {40, 90}, {-10, 40}}, - {{-20,20}, {-20,40}, {-180,40}, {-180,20}}, /* CCW */ - {{80,20}, {240,20}, {240,40}, {80,40}} /* CCW */ -}; + std::vector unreachable_polygons_3 = { + {{40, -10}, {90, 40}, {40, 90}, {-10, 40}}, + {{-20,20}, {-20,40}, {-180,40}, {-180,20}}, /* CCW */ + {{80,20}, {240,20}, {240,40}, {80,40}} /* CCW */ + }; -std::vector unreachable_polygons_4 = { - {{10, -10}, {40, -10}, {70, 40}, {30, 60}, {-10, 40}} -}; + std::vector unreachable_polygons_4 = { + {{10, -10}, {40, -10}, {70, 40}, {30, 60}, {-10, 40}} + }; +} TEST_CASE("Sequential test 4", "[Sequential Arrangement Core]")