diff options
-rw-r--r-- | resources/profiles/Basic.ini | 21 | ||||
-rw-r--r-- | resources/profiles/Creality.ini | 13 | ||||
-rw-r--r-- | src/admesh/stl.h | 2 | ||||
-rw-r--r-- | src/libslic3r/Config.cpp | 18 | ||||
-rw-r--r-- | src/libslic3r/GCode.cpp | 2 | ||||
-rw-r--r-- | src/libslic3r/PrintConfig.hpp | 3 | ||||
-rw-r--r-- | src/libslic3r/PrintObject.cpp | 24 | ||||
-rw-r--r-- | src/slic3r/GUI/ConfigWizard.cpp | 4 | ||||
-rw-r--r-- | src/slic3r/GUI/MainFrame.cpp | 2 | ||||
-rw-r--r-- | src/test/libslic3r/test_denserinfill.cpp | 191 | ||||
-rw-r--r-- | src/test/test_data.cpp | 14 |
11 files changed, 227 insertions, 67 deletions
diff --git a/resources/profiles/Basic.ini b/resources/profiles/Basic.ini index d3f0ddb61..b6c90dddb 100644 --- a/resources/profiles/Basic.ini +++ b/resources/profiles/Basic.ini @@ -28,7 +28,7 @@ variants = 0.4; 0.15; 0.2; 0.25; 0.3; 0.35; 0.5; 0.6; 0.8; 1.0; 1.2; [printer:*common*] end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X195 Y1\nG1 X190 E4\nG1 F4000\nG1 X180 E2.7 \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3 \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; turn off fan\n{if layer_z < max_print_height}G1 Z{z_offset+min(layer_z+30, max_print_height)}{endif} ; Move print head up\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0 ; home X axis\nM84 ; disable motors\n\n extruder_offset = 0x0 -gcode_flavor = marlin +gcode_flavor = reprap before_layer_gcode = ;BEFORE_LAYER_CHANGE\nG92 E0.0\n;[layer_z]\n\n layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z] pressure_advance = 0 @@ -42,7 +42,7 @@ retract_lift_below = 9999 retract_restart_extra = 0 retract_restart_extra_toolchange = 0 retract_speed = 35 -start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM83 ; extruder relative mode\nM204 S[machine_max_acceleration_extruding] T[machine_max_acceleration_retracting] ; ENDER3 firmware may only supports the old M204 format\nG28 W ; home all\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X150.0 E20 F1000.0 ; intro line\nG92 E0.0 +start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM83 ; extruder relative mode\nM204 S[machine_max_acceleration_extruding] T[machine_max_acceleration_retracting] ; ENDER3 firmware may only supports the old M204 format\nG28 W ; home all\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG1 X0.0 Y0.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X150.0 E20 F1000.0 ; intro line\nG92 E0.0 use_firmware_retraction = 0 use_relative_e_distances = 0 use_volumetric_e = 0 @@ -175,7 +175,7 @@ printer_model = Custom_1.75mm # Common print preset, mostly derived from MK2 single material with a 0.4mm nozzle. # All other print presets will derive from the *common* print preset. [print:*common*] -avoid_crossing_perimeters = 1 +avoid_crossing_perimeters = 0 bridge_acceleration = 1000 bridge_angle = 0 bridge_flow_ratio = 0.8 @@ -187,20 +187,20 @@ compatible_printers = complete_objects = 0 default_acceleration = 1000 dont_support_bridges = 1 -ensure_vertical_shell_thickness = 0 +ensure_vertical_shell_thickness = 1 top_fill_pattern = smooth bottom_fill_pattern = concentricgapfill external_perimeters_first = 0 extra_perimeters = 0 only_one_perimeter_top = 1 -elefant_foot_compensation = -0.01 +elefant_foot_compensation = -0.05 extruder_clearance_height = 20 extruder_clearance_radius = 20 fill_angle = 45 fill_density = 13% fill_pattern = gyroid first_layer_acceleration = 1000 -first_layer_height = 50% +first_layer_height = 100% first_layer_speed = 30 gap_fill_speed = 40 gcode_comments = 0 @@ -208,7 +208,7 @@ gcode_label_objects = 1 hole_size_compensation = -0.03 infill_acceleration = 1000 infill_dense = 1 -infill_dense_algo = automatic +infill_dense_algo = autosmall infill_every_layers = 1 infill_extruder = 1 infill_first = 0 @@ -236,8 +236,8 @@ raft_layers = 0 resolution = 0 seam_position = hidden skirts = 0 -skirt_distance = 2 -skirt_height = 3 +skirt_distance = 3 +skirt_height = 1 small_perimeter_speed = 25 solid_infill_below_area = 0 solid_infill_every_layers = 0 @@ -266,7 +266,8 @@ support_material_threshold = 45 support_material_with_sheath = 0 support_material_xy_spacing = 60% thin_walls = 1 -thin_walls_min_width = 100% +thin_walls_min_width = 50% +thin_walls_overlap = 50% top_solid_infill_speed = 40 travel_speed = 180 wipe_tower = 0 diff --git a/resources/profiles/Creality.ini b/resources/profiles/Creality.ini index 86a1b3c00..ae89ce8b8 100644 --- a/resources/profiles/Creality.ini +++ b/resources/profiles/Creality.ini @@ -50,7 +50,7 @@ retract_speed = 35 start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM83 ; extruder relative mode\nM204 S[machine_max_acceleration_extruding] T[machine_max_acceleration_retracting] ; ENDER3 firmware may only supports the old M204 format\nG28 W ; home all\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X150.0 E20 F1000.0 ; intro line\nG92 E0.0 toolchange_gcode = use_firmware_retraction = 0 -use_relative_e_distances = 1 +use_relative_e_distances = 0 use_volumetric_e = 0 variable_layer_height = 1 wipe = 1 @@ -180,22 +180,22 @@ bottom_fill_pattern = rectilinear external_perimeters_first = 0 extra_perimeters = 0 only_one_perimeter_top = 0 -elefant_foot_compensation = -0.2 +elefant_foot_compensation = -0.05 extruder_clearance_height = 20 extruder_clearance_radius = 20 fill_angle = 45 fill_density = 20% fill_pattern = gyroid first_layer_acceleration = 1000 -first_layer_extrusion_width = 0.42 -first_layer_height = 0.2 +first_layer_extrusion_width = 140% +first_layer_height = 100% first_layer_speed = 30 gap_fill_speed = 40 gcode_comments = 0 hole_size_compensation = -0.03 infill_acceleration = 1000 infill_dense = 1 -infill_dense_algo = automatic +infill_dense_algo = autosmall infill_every_layers = 1 infill_extruder = 1 infill_first = 0 @@ -253,7 +253,8 @@ support_material_threshold = 45 support_material_with_sheath = 0 support_material_xy_spacing = 60% thin_walls = 1 -thin_walls_min_width = 33% +thin_walls_min_width = 50% +thin_walls_overlap = 50% top_solid_infill_speed = 40 travel_speed = 180 wipe_tower = 1 diff --git a/src/admesh/stl.h b/src/admesh/stl.h index 2ac6c7fd2..53326b569 100644 --- a/src/admesh/stl.h +++ b/src/admesh/stl.h @@ -41,7 +41,7 @@ typedef Eigen::Matrix<float, 3, 1, Eigen::DontAlign> stl_vertex; typedef Eigen::Matrix<float, 3, 1, Eigen::DontAlign> stl_normal; -typedef Eigen::Matrix<int, 3, 1, Eigen::DontAlign> stl_triangle_vertex_indices; +typedef Eigen::Matrix<int32_t, 3, 1, Eigen::DontAlign> stl_triangle_vertex_indices; static_assert(sizeof(stl_vertex) == 12, "size of stl_vertex incorrect"); static_assert(sizeof(stl_normal) == 12, "size of stl_normal incorrect"); diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 6821f3d6d..486bfb056 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -531,16 +531,18 @@ void ConfigBase::load(const boost::property_tree::ptree &tree) void ConfigBase::load_from_gcode_file(const std::string &file) { // Read a 64k block from the end of the G-code. - boost::nowide::ifstream ifs(file); - { - const char slic3r_gcode_header[] = "; generated by Slic3r "; + boost::nowide::ifstream ifs(file); + { + const char slic3r_gcode_header[] = "; generated by Slic3r "; + const char slic3rpp_gcode_header[] = "; generated by Slic3r++ "; const char prusaslicer_gcode_header[] = "; generated by PrusaSlicer "; - std::string firstline; - std::getline(ifs, firstline); - if (strncmp(slic3r_gcode_header, firstline.c_str(), strlen(slic3r_gcode_header)) != 0 && + std::string firstline; + std::getline(ifs, firstline); + if (strncmp(slic3r_gcode_header, firstline.c_str(), strlen(slic3r_gcode_header)) != 0 && + strncmp(slic3rpp_gcode_header, firstline.c_str(), strlen(slic3rpp_gcode_header)) != 0&& strncmp(prusaslicer_gcode_header, firstline.c_str(), strlen(prusaslicer_gcode_header)) != 0) - throw std::runtime_error("Not a PrusaSlicer / Slic3r PE generated g-code."); - } + throw std::runtime_error("Not a PrusaSlicer / Slic3r PE / Slic3r++ generated g-code."); + } ifs.seekg(0, ifs.end); auto file_length = ifs.tellg(); auto data_length = std::min<std::fstream::streampos>(65535, file_length); diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 78a01b9de..effe3caea 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2546,7 +2546,7 @@ void GCode::_write(FILE* file, const char *what) if (what != nullptr) { //const char * gcode_pp = _post_process(what).c_str(); - std::string str_preproc = what; + std::string str_preproc{ what }; _post_process(str_preproc); const std::string str_ana = m_analyzer.process_gcode(str_preproc); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index f38d00e73..68bd4af4c 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -61,7 +61,7 @@ enum FilamentType { */ enum DenseInfillAlgo { - dfaNone, dfaAutomatic, dfaAutoNotFull, dfaEnlarged, + dfaAutomatic, dfaAutoNotFull, dfaEnlarged, }; enum NoPerimeterUnsupportedAlgo { @@ -209,7 +209,6 @@ template<> inline const t_config_enum_values& ConfigOptionEnum<FilamentType>::ge template<> inline const t_config_enum_values& ConfigOptionEnum<DenseInfillAlgo>::get_enum_values() { static const t_config_enum_values keys_map = { - { "none", dfaNone }, { "automatic", dfaAutomatic }, { "autosmall", dfaAutoNotFull }, { "enlarged", dfaEnlarged } diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index ca8bd517d..d78bf8043 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -94,22 +94,6 @@ PrintBase::ApplyStatus PrintObject::set_copies(const Points &points) return status; } -void print_vertices(ModelObject * obj) { - auto objs = obj->volumes; - if (objs.size() > 0) { - TriangleMesh mesh = objs[0]->mesh(); - std::cout << "vertices = std::vector<Vec3d>{\n\t"; - for (Vec3f vert : mesh.its.vertices) { - std::cout << "Vec3d(" << vert.x() << "," << vert.y() << "," << vert.z() << "),"; - } - std::cout << "\n};\nfacets = std::vector<Vec3i32>{ \n\t"; - for (Vec3i32 face : mesh.its.indices) { - std::cout << "Vec3i32(" << face(0) << "," << face(1) << "," << face(2) << "),"; - } - std::cout << "\n};"; - } -} - // 1) Decides Z positions of the layers, // 2) Initializes layers and their regions // 3) Slices the object meshes @@ -121,7 +105,6 @@ void print_vertices(ModelObject * obj) { // this should be idempotent void PrintObject::slice() { - print_vertices(this->model_object()); if (! this->set_started(posSlice)) return; @@ -1494,10 +1477,8 @@ void PrintObject::bridge_over_infill() for (size_t region_id = 0; region_id < this->region_volumes.size(); ++ region_id) { const PrintRegion ®ion = *m_print->regions()[region_id]; - // skip over-bridging in case there are no voids + // skip bridging in case there are no voids if (region.config().fill_density.value == 100) continue; - // skip over-bridging in case there are no modification - if (region.config().over_bridge_flow_ratio == 1) continue; // get bridge flow Flow bridge_flow = region.flow( @@ -1628,6 +1609,9 @@ PrintObject::replaceSurfaceType(SurfaceType st_to_replace, SurfaceType st_replac for (size_t region_id = 0; region_id < this->region_volumes.size(); ++region_id) { const PrintRegion ®ion = *m_print->regions()[region_id]; + // skip over-bridging in case there are no modification + if (region.config().over_bridge_flow_ratio.value == 1) continue; + for (LayerPtrs::iterator layer_it = m_layers.begin(); layer_it != m_layers.end(); ++layer_it) { // skip first layer if (layer_it == this->layers().begin()) continue; diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 657bd136a..9b09007df 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -413,7 +413,7 @@ PageUpdate::PageUpdate(ConfigWizard *parent) boldfont.SetWeight(wxFONTWEIGHT_BOLD); auto *box_slic3r = new wxCheckBox(this, wxID_ANY, _(L("Check for application updates"))); - box_slic3r->SetValue(app_config->get("version_check") == "1"); + box_slic3r->SetValue(false);// app_config->get("version_check") == "1"); // default to no, becasue the conf is never updated anyway. Remove that change if corrected later. append(box_slic3r); append_text(wxString::Format(_(L( "If enabled, %s checks for new application versions online. When a new version becomes available, " @@ -423,7 +423,7 @@ PageUpdate::PageUpdate(ConfigWizard *parent) append_spacer(VERTICAL_SPACING); auto *box_presets = new wxCheckBox(this, wxID_ANY, _(L("Update built-in Presets automatically"))); - box_presets->SetValue(app_config->get("preset_update") == "1"); + box_presets->SetValue(false);// app_config->get("preset_update") == "1"); // default to no, becasue the conf is never updated anyway. Remove that change if corrected later. append(box_presets); append_text(wxString::Format(_(L( "If enabled, %s downloads updates of built-in system presets in the background." diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index d2ea8b8c8..d394f0e50 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -153,7 +153,7 @@ void MainFrame::update_title() if (!project.empty()) title += (project + " - "); } - title += (wxString(SLIC3R_BUILD_ID) + " " + _(L("based on Slic3r"))); + title += (wxString(SLIC3R_APP_NAME) + " " + _(L("based on PrusaSlicer & Slic3r"))); SetTitle(title); } diff --git a/src/test/libslic3r/test_denserinfill.cpp b/src/test/libslic3r/test_denserinfill.cpp index a00c2841a..8c54002c4 100644 --- a/src/test/libslic3r/test_denserinfill.cpp +++ b/src/test/libslic3r/test_denserinfill.cpp @@ -13,25 +13,198 @@ SCENARIO("denser infills: ") GIVEN("center hole") { - WHEN("creating the medial axis"){ + WHEN("dense infill to enlarged") { Model model{}; Print print{}; DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults(); + config->set_key_value("layer_height", new ConfigOptionFloat(0.2)); + config->set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false)); + config->set_key_value("infill_dense", new ConfigOptionBool(true)); + config->set_key_value("infill_dense_algo", new ConfigOptionEnum<DenseInfillAlgo>(dfaEnlarged)); + config->save("C:\\Users\\Admin\\Desktop\\config_def.ini"); + std::cout << "dense infill : " << config->opt_bool("infill_dense") << "\n"; Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_5mm_center_notch }, model, config, false); print.process(); PrintObject& object = *(print.objects().at(0)); - THEN("67 layers exist in the model") { - REQUIRE(object.layers().size() == 67); + //for (int lidx = 0; lidx < object.layers().size(); lidx++) { + // std::cout << "layer " << lidx << " : \n"; + // std::cout << " - region_count= " << object.layers()[lidx]->region_count() << "\n"; + // for (int ridx = 0; ridx < object.layers()[lidx]->regions().size(); ridx++) { + // std::cout << " region " << ridx << " : \n"; + // std::cout << " - fills= " << object.layers()[lidx]->regions()[ridx]->fills.entities.size() << "\n"; + // std::cout << " - surfaces= " << object.layers()[lidx]->regions()[ridx]->fill_surfaces.surfaces.size() << "\n"; + // for (int sidx = 0; sidx < object.layers()[lidx]->regions()[ridx]->fill_surfaces.surfaces.size(); sidx++) { + // std::cout << " - type= " << object.layers()[lidx]->regions()[ridx]->fill_surfaces.surfaces[sidx].surface_type << "\n"; + // } + // } + //} + /*THEN("67 layers exist in the model") { + REQUIRE(object.layers().size() == 25); } - THEN("at layer 13 , there are 1 region") { - REQUIRE(object.layers()[13]->region_count() == 2); + THEN("at layer 16 , there are 1 region") { + REQUIRE(object.layers()[16]->region_count() == 1); } - THEN("at layer 14 , there are 2 region") { - REQUIRE(object.layers()[14]->region_count() == 2); + THEN("at layer 17 , there are 2 region") { + REQUIRE(object.layers()[17]->region_count() == 2); } - THEN("at layer 15 , there are 2 region") { - REQUIRE(object.layers()[15]->region_count() == 2); + THEN("at layer 18 , there are 2 region") { + REQUIRE(object.layers()[18]->region_count() == 2); + }*/ + THEN("correct number of fills") { + REQUIRE(object.layers()[20]->regions()[0]->fills.entities.size() == 1); //sparse + REQUIRE(object.layers()[21]->regions()[0]->fills.entities.size() == 2); //sparse + dense + REQUIRE(object.layers()[21]->regions()[0]->fill_surfaces.surfaces.size() == 2); + REQUIRE(object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + REQUIRE(object.layers()[21]->regions()[0]->fill_surfaces.surfaces[1].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + REQUIRE(std::min(object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop, object.layers()[21]->regions()[0]->fill_surfaces.surfaces[1].maxNbSolidLayersOnTop) == 1); + Surface* srfSparse = &object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0]; + Surface* srfDense = &object.layers()[21]->regions()[0]->fill_surfaces.surfaces[1]; + if (srfSparse->maxNbSolidLayersOnTop == 1) { + srfSparse = srfDense; + srfDense = &object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0]; + } + std::cout << "sparse area = " << unscaled(unscaled(srfSparse->area())) << " , dense area = " << unscaled(unscaled(srfDense->area())) << "\n"; + REQUIRE(unscaled(unscaled(srfSparse->area())) > unscaled(unscaled(srfDense->area()))); + REQUIRE(object.layers()[22]->regions()[0]->fills.entities.size() == 2); //sparse + solid-bridge + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces.size() == 2); + if (object.layers()[22]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)) { + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces[1].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosInternal | SurfaceType::stModBridge)); + } else { + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosInternal | SurfaceType::stModBridge)); + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces[1].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + } + REQUIRE(object.layers()[23]->regions()[0]->fills.entities.size() == 2); //sparse + solid + REQUIRE(object.layers()[24]->regions()[0]->fills.entities.size() == 3); //sparse + solid-top + solid-top (over perimeters) + REQUIRE(object.layers()[25]->regions()[0]->fills.entities.size() == 1); //sparse + } + } + } + + GIVEN("side hole") + { + WHEN("dense infill to auto") { + Model model{}; + Print print{}; + DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults(); + config->set_key_value("layer_height", new ConfigOptionFloat(0.2)); + config->set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false)); + config->set_key_value("infill_dense", new ConfigOptionBool(true)); + config->set_key_value("infill_dense_algo", new ConfigOptionEnum<DenseInfillAlgo>(dfaAutomatic)); + config->save("C:\\Users\\Admin\\Desktop\\config_def.ini"); + std::cout << "dense infill : " << config->opt_bool("infill_dense") << "\n"; + Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_10mm_notch }, model, config, false); + print.process(); + PrintObject& object = *(print.objects().at(0)); + THEN("correct number of fills") { + REQUIRE(object.layers().size() == 50); + REQUIRE(object.layers()[20]->regions()[0]->fills.entities.size() == 1); //sparse + REQUIRE(object.layers()[21]->regions()[0]->fills.entities.size() == 2); //sparse + dense + REQUIRE(object.layers()[21]->regions()[0]->fill_surfaces.surfaces.size() == 2); + REQUIRE(object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + REQUIRE(object.layers()[21]->regions()[0]->fill_surfaces.surfaces[1].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + REQUIRE(std::min(object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop, object.layers()[21]->regions()[0]->fill_surfaces.surfaces[1].maxNbSolidLayersOnTop) == 1); + Surface* srfSparse = &object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0]; + Surface* srfDense = &object.layers()[21]->regions()[0]->fill_surfaces.surfaces[1]; + if (srfSparse->maxNbSolidLayersOnTop == 1) { + srfSparse = srfDense; + srfDense = &object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0]; + } + REQUIRE(unscaled(unscaled(srfSparse->area())) > unscaled(unscaled(srfDense->area()))); + REQUIRE(object.layers()[22]->regions()[0]->fills.entities.size() == 2); //sparse + solid-bridge + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces.size() == 2); + if (object.layers()[22]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)) { + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces[1].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosInternal | SurfaceType::stModBridge)); + } else { + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosInternal | SurfaceType::stModBridge)); + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces[1].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + } + REQUIRE(object.layers()[23]->regions()[0]->fills.entities.size() == 2); //sparse + solid + REQUIRE(object.layers()[24]->regions()[0]->fills.entities.size() == 3); //sparse + solid-top + solid-top (over perimeters) + REQUIRE(object.layers()[25]->regions()[0]->fills.entities.size() == 1); //sparse + REQUIRE(object.layers()[45]->regions()[0]->fills.entities.size() == 1); //sparse + REQUIRE(object.layers()[45]->regions()[0]->fill_surfaces.surfaces.size() == 1); + REQUIRE(object.layers()[45]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + REQUIRE(object.layers()[45]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop > 1); + REQUIRE(object.layers()[46]->regions()[0]->fills.entities.size() == 1); //dense + REQUIRE(object.layers()[46]->regions()[0]->fills.entities.size() == 1); + REQUIRE(object.layers()[46]->regions()[0]->fill_surfaces.surfaces.size() == 1); + REQUIRE(object.layers()[46]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + REQUIRE(object.layers()[46]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop == 1); + REQUIRE(object.layers()[47]->regions()[0]->fills.entities.size() == 1); //solid-bridge + REQUIRE(object.layers()[47]->regions()[0]->fill_surfaces.surfaces.size() == 1); + REQUIRE(object.layers()[47]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosInternal | SurfaceType::stModBridge)); + REQUIRE(object.layers()[47]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop > 1); + REQUIRE(object.layers()[48]->regions()[0]->fills.entities.size() == 1); //solid + REQUIRE(object.layers()[48]->regions()[0]->fill_surfaces.surfaces.size() == 1); + REQUIRE(object.layers()[48]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosInternal)); + REQUIRE(object.layers()[48]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop > 1); + REQUIRE(object.layers()[49]->regions()[0]->fills.entities.size() == 1); //top + REQUIRE(object.layers()[49]->regions()[0]->fill_surfaces.surfaces.size() == 1); + REQUIRE(object.layers()[49]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosTop)); + REQUIRE(object.layers()[49]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop > 1); + } + } + + WHEN("dense infill to auto-not-full") { + Model model{}; + Print print{}; + DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults(); + config->set_key_value("layer_height", new ConfigOptionFloat(0.2)); + config->set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false)); + config->set_key_value("infill_dense", new ConfigOptionBool(true)); + config->set_key_value("infill_dense_algo", new ConfigOptionEnum<DenseInfillAlgo>(dfaAutoNotFull)); + config->save("C:\\Users\\Admin\\Desktop\\config_def.ini"); + std::cout << "dense infill : " << config->opt_bool("infill_dense") << "\n"; + Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_10mm_notch }, model, config, false); + print.process(); + PrintObject& object = *(print.objects().at(0)); + THEN("correct number of fills") { + REQUIRE(object.layers().size() == 50); + REQUIRE(object.layers()[20]->regions()[0]->fills.entities.size() == 1); //sparse + REQUIRE(object.layers()[21]->regions()[0]->fills.entities.size() == 2); //sparse + dense + REQUIRE(object.layers()[21]->regions()[0]->fill_surfaces.surfaces.size() == 2); + REQUIRE(object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + REQUIRE(object.layers()[21]->regions()[0]->fill_surfaces.surfaces[1].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + REQUIRE(std::min(object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop, object.layers()[21]->regions()[0]->fill_surfaces.surfaces[1].maxNbSolidLayersOnTop) == 1); + Surface* srfSparse = &object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0]; + Surface* srfDense = &object.layers()[21]->regions()[0]->fill_surfaces.surfaces[1]; + if (srfSparse->maxNbSolidLayersOnTop == 1) { + srfSparse = srfDense; + srfDense = &object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0]; + } + REQUIRE(unscaled(unscaled(srfSparse->area())) > unscaled(unscaled(srfDense->area()))); + REQUIRE(object.layers()[22]->regions()[0]->fills.entities.size() == 2); //sparse + solid-bridge + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces.size() == 2); + if (object.layers()[22]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)) { + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces[1].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosInternal | SurfaceType::stModBridge)); + } else { + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosInternal | SurfaceType::stModBridge)); + REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces[1].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + } + REQUIRE(object.layers()[23]->regions()[0]->fills.entities.size() == 2); //sparse + solid + REQUIRE(object.layers()[24]->regions()[0]->fills.entities.size() == 3); //sparse + solid-top + solid-top (over perimeters) + REQUIRE(object.layers()[25]->regions()[0]->fills.entities.size() == 1); //sparse + REQUIRE(object.layers()[45]->regions()[0]->fills.entities.size() == 1); //sparse + REQUIRE(object.layers()[45]->regions()[0]->fill_surfaces.surfaces.size() == 1); + REQUIRE(object.layers()[45]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + REQUIRE(object.layers()[45]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop > 1); + REQUIRE(object.layers()[46]->regions()[0]->fills.entities.size() == 1); //dense + REQUIRE(object.layers()[46]->regions()[0]->fill_surfaces.surfaces.size() == 1); + REQUIRE(object.layers()[46]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSparse | SurfaceType::stPosInternal)); + REQUIRE(object.layers()[46]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop > 1); + REQUIRE(object.layers()[47]->regions()[0]->fills.entities.size() == 1); //solid-bridge + REQUIRE(object.layers()[47]->regions()[0]->fill_surfaces.surfaces.size() == 1); + REQUIRE(object.layers()[47]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosInternal | SurfaceType::stModBridge)); + REQUIRE(object.layers()[47]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop > 1); + REQUIRE(object.layers()[48]->regions()[0]->fills.entities.size() == 1); //solid + REQUIRE(object.layers()[48]->regions()[0]->fill_surfaces.surfaces.size() == 1); + REQUIRE(object.layers()[48]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosInternal)); + REQUIRE(object.layers()[48]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop > 1); + REQUIRE(object.layers()[49]->regions()[0]->fills.entities.size() == 1); //top + REQUIRE(object.layers()[49]->regions()[0]->fill_surfaces.surfaces.size() == 1); + REQUIRE(object.layers()[49]->regions()[0]->fill_surfaces.surfaces[0].surface_type == (SurfaceType::stDensSolid | SurfaceType::stPosTop)); + REQUIRE(object.layers()[49]->regions()[0]->fill_surfaces.surfaces[0].maxNbSolidLayersOnTop > 1); } } } diff --git a/src/test/test_data.cpp b/src/test/test_data.cpp index 1954530a7..9fd92e388 100644 --- a/src/test/test_data.cpp +++ b/src/test/test_data.cpp @@ -206,7 +206,7 @@ TriangleMesh mesh(TestMesh m) { break; case TestMesh::di_5mm_center_notch: vertices = std::vector<Vec3d>{ - Vec3d(-15,-15,-5),Vec3d(-15,15,5),Vec3d(-15,15,-5),Vec3d(-15,-15,5),Vec3d(3,-2,5),Vec3d(15,15,5),Vec3d(3,3,5),Vec3d(-2,3,5),Vec3d(-2,-2,5),Vec3d(15,-15,5),Vec3d(15,15,-5),Vec3d(15,-15,-5),Vec3d(-2,3,0),Vec3d(-2,-2,0),Vec3d(3,-2,0),Vec3d(3,3,0) + Vec3d(-15,-15,0),Vec3d(-15,15,10),Vec3d(-15,15,0),Vec3d(-15,-15,10),Vec3d(3,-2,10),Vec3d(15,15,10),Vec3d(3,3,10),Vec3d(-2,3,10),Vec3d(-2,-2,10),Vec3d(15,-15,10),Vec3d(15,15,0),Vec3d(15,-15,0),Vec3d(-2,3,5),Vec3d(-2,-2,5),Vec3d(3,-2,5),Vec3d(3,3,5) }; facets = std::vector<Vec3i32>{ Vec3i32(0,1,2),Vec3i32(1,0,3),Vec3i32(4,5,6),Vec3i32(5,7,6),Vec3i32(7,1,8),Vec3i32(1,7,5),Vec3i32(5,4,9),Vec3i32(8,9,4),Vec3i32(8,3,9),Vec3i32(3,8,1),Vec3i32(9,10,5),Vec3i32(10,9,11),Vec3i32(10,1,5),Vec3i32(1,10,2),Vec3i32(0,10,11),Vec3i32(10,0,2),Vec3i32(0,9,3),Vec3i32(9,0,11), @@ -215,29 +215,29 @@ TriangleMesh mesh(TestMesh m) { break; case TestMesh::di_10mm_notch: vertices = std::vector<Vec3d>{ - Vec3d(-15,15,-5),Vec3d(-15,-5,0),Vec3d(-15,15,5),Vec3d(-15,-15,-5),Vec3d(-15,-15,0),Vec3d(-15,-5,5),Vec3d(15,15,5),Vec3d(-5,-5,5),Vec3d(15,-15,5),Vec3d(-5,-15,5),Vec3d(15,15,-5),Vec3d(15,-15,-5),Vec3d(-5,-15,0),Vec3d(-5,-5,0) + Vec3d(-15,15,0),Vec3d(-15,-5,5),Vec3d(-15,15,10),Vec3d(-15,-15,0),Vec3d(-15,-15,5),Vec3d(-15,-5,10),Vec3d(15,15,10),Vec3d(-5,-5,10),Vec3d(15,-15,10),Vec3d(-5,-15,10),Vec3d(15,15,0),Vec3d(15,-15,0),Vec3d(-5,-15,5),Vec3d(-5,-5,5) }; facets = std::vector<Vec3i32>{ Vec3i32(0,1,2),Vec3i32(3,1,0),Vec3i32(1,3,4),Vec3i32(2,1,5),Vec3i32(6,7,8),Vec3i32(2,7,6),Vec3i32(7,2,5),Vec3i32(8,7,9),Vec3i32(8,10,6),Vec3i32(10,8,11),Vec3i32(10,2,6),Vec3i32(2,10,0),Vec3i32(3,10,11),Vec3i32(10,3,0),Vec3i32(4,3,12),Vec3i32(12,8,9),Vec3i32(11,12,3),Vec3i32(12,11,8), - Vec3i32(12,7,13),Vec3i32(7,12,9),Vec3i32(1,7,5),Vec3i32(7,1,13),Vec3i32(1,12,13),Vec3i32(12,1,4), + Vec3i32(12,7,13),Vec3i32(7,12,9),Vec3i32(1,7,5),Vec3i32(7,1,13),Vec3i32(1,12,13),Vec3i32(12,1,4) }; break; case TestMesh::di_20mm_notch: vertices = std::vector<Vec3d>{ - Vec3d(-15,15,-5),Vec3d(-15,5,0),Vec3d(-15,15,5),Vec3d(-15,-15,-5),Vec3d(-15,-15,0),Vec3d(-15,5,5),Vec3d(15,15,5),Vec3d(5,5,5),Vec3d(15,-15,5),Vec3d(5,-15,5),Vec3d(15,15,-5),Vec3d(15,-15,-5),Vec3d(5,-15,0),Vec3d(5,5,0), + Vec3d(-15,15,0),Vec3d(-15,5,5),Vec3d(-15,15,10),Vec3d(-15,-15,0),Vec3d(-15,-15,5),Vec3d(-15,5,10),Vec3d(15,15,10),Vec3d(5,5,10),Vec3d(15,-15,10),Vec3d(5,-15,10),Vec3d(15,15,0),Vec3d(15,-15,0),Vec3d(5,-15,5),Vec3d(5,5,5) }; facets = std::vector<Vec3i32>{ Vec3i32(0,1,2),Vec3i32(3,1,0),Vec3i32(1,3,4),Vec3i32(2,1,5),Vec3i32(6,7,8),Vec3i32(2,7,6),Vec3i32(7,2,5),Vec3i32(8,7,9),Vec3i32(8,10,6),Vec3i32(10,8,11),Vec3i32(3,10,11),Vec3i32(10,3,0),Vec3i32(4,3,12),Vec3i32(12,8,9),Vec3i32(12,11,8),Vec3i32(11,12,3),Vec3i32(10,2,6),Vec3i32(2,10,0), - Vec3i32(12,7,13),Vec3i32(7,12,9),Vec3i32(1,12,13),Vec3i32(12,1,4),Vec3i32(1,7,5),Vec3i32(7,1,13), + Vec3i32(12,7,13),Vec3i32(7,12,9),Vec3i32(1,12,13),Vec3i32(12,1,4),Vec3i32(1,7,5),Vec3i32(7,1,13) }; break; case TestMesh::di_25mm_notch: vertices = std::vector<Vec3d>{ - Vec3d(-15,15,-5),Vec3d(-15,10,0),Vec3d(-15,15,5),Vec3d(-15,-15,-5),Vec3d(-15,-15,0),Vec3d(-15,10,5),Vec3d(15,15,5),Vec3d(10,10,5),Vec3d(15,-15,5),Vec3d(10,-15,5),Vec3d(15,15,-5),Vec3d(15,-15,-5),Vec3d(10,-15,0),Vec3d(10,10,0), + Vec3d(-15,15,0),Vec3d(-15,10,5),Vec3d(-15,15,10),Vec3d(-15,-15,0),Vec3d(-15,-15,5),Vec3d(-15,10,10),Vec3d(15,15,10),Vec3d(10,10,10),Vec3d(15,-15,10),Vec3d(10,-15,10),Vec3d(15,15,0),Vec3d(15,-15,0),Vec3d(10,-15,5),Vec3d(10,10,5) }; facets = std::vector<Vec3i32>{ Vec3i32(0,1,2),Vec3i32(3,1,0),Vec3i32(1,3,4),Vec3i32(2,1,5),Vec3i32(6,7,8),Vec3i32(2,7,6),Vec3i32(7,2,5),Vec3i32(8,7,9),Vec3i32(8,10,6),Vec3i32(10,8,11),Vec3i32(3,10,11),Vec3i32(10,3,0),Vec3i32(4,3,12),Vec3i32(12,8,9),Vec3i32(12,11,8),Vec3i32(11,12,3),Vec3i32(10,2,6),Vec3i32(2,10,0), - Vec3i32(12,7,13),Vec3i32(7,12,9),Vec3i32(1,7,5),Vec3i32(7,1,13),Vec3i32(1,12,13),Vec3i32(12,1,4), + Vec3i32(12,7,13),Vec3i32(7,12,9),Vec3i32(1,7,5),Vec3i32(7,1,13),Vec3i32(1,12,13),Vec3i32(12,1,4) }; break; default: |