test_dense_infill.cpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //#define CATCH_CONFIG_DISABLE
  2. //#include <catch2/catch.hpp>
  3. #include <catch_main.hpp>
  4. #include <string>
  5. #include "test_data.hpp"
  6. #include <libslic3r/libslic3r.h>
  7. //#include <libslic3r/ModelArrange.hpp>
  8. //#include <libslic3r/SVG.hpp>
  9. //#include <libslic3r/SVG.hpp>
  10. //#include <libslic3r/Print.hpp>
  11. using namespace Slic3r::Test;
  12. using namespace Slic3r;
  13. using namespace std::literals;
  14. Slic3r::Polygon get_polygon_scale(std::vector<std::vector<float>> points) {
  15. Slic3r::Polygon poly;
  16. for (std::vector<float>& point : points) {
  17. poly.points.push_back(Point::new_scale(point[0], point[1]));
  18. }
  19. return poly;
  20. }
  21. SCENARIO("test auto generation") {
  22. GIVEN("triangle with top to fill") {
  23. //DynamicPrintConfig& config = Slic3r::DynamicPrintConfig::full_print_config();
  24. //config.set_key_value("fill_density", new ConfigOptionPercent(0));
  25. //config.set_deserialize("nozzle_diameter", "0.4");
  26. //config.set_deserialize("layer_height", "0.3");
  27. //config.set_deserialize("infill_dense_algo", "50");
  28. //config.set_deserialize("extruder_clearance_radius", "10");
  29. WHEN("little surface") {
  30. ExPolygon expolygon_to_cover;
  31. expolygon_to_cover.contour = get_polygon_scale({ {0,0}, {10,0}, {10,10}, {0,10} });
  32. ExPolygon growing_area;
  33. growing_area.contour = get_polygon_scale({ {0,0}, {40,0}, {0,40} });
  34. //ExPolygons allowedPoints;
  35. //allowedPoints.emplace_back();
  36. //allowedPoints.back().contour = get_polygon_scale({ {0,0}, {40,0}, {0,40} });
  37. coord_t offset = scale_(2);
  38. float coverage = 1.f;
  39. ExPolygons solution = dense_fill_fit_to_size(expolygon_to_cover, growing_area, offset, coverage);
  40. THEN("little support") {
  41. double area_result = 0;
  42. for (ExPolygon& p : solution)
  43. area_result += unscaled(unscaled(p.area()));
  44. double area_full = unscaled(unscaled(growing_area.area()));
  45. //for (ExPolygon& p : allowedPoints)
  46. // area_full += unscaled(unscaled(p.area());
  47. for (ExPolygon& po : solution)
  48. for (Point& p : po.contour.points)
  49. std::cout << ", " << unscaled(p.x()) << ":" << unscaled(p.y());
  50. std::cout << "\n";
  51. std::cout << "area_result= " << area_result << "\n";
  52. std::cout << "area_full = " << area_full << "\n";
  53. REQUIRE(area_full > 1.5 * area_result);
  54. }
  55. }
  56. //THEN("(too near)") {
  57. // result = init_print_with_dist(config, 40)->validate();
  58. // REQUIRE(result.first == PrintBase::PrintValidationError::pveWrongPosition);
  59. //}
  60. //THEN("(ok far)") {
  61. // result = init_print_with_dist(config, 40.8)->validate();
  62. // REQUIRE(result.second == "");
  63. // REQUIRE(result.first == PrintBase::PrintValidationError::pveNone);
  64. //}
  65. }
  66. }