mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Fixed unit tests.
This commit is contained in:
		
							parent
							
								
									f01f02154c
								
							
						
					
					
						commit
						adcbe4347c
					
				
					 6 changed files with 24 additions and 20 deletions
				
			
		| 
						 | 
				
			
			@ -150,6 +150,7 @@ Flow Flow::with_spacing(float new_spacing) const
 | 
			
		|||
        auto  new_diameter = new_spacing - gap;
 | 
			
		||||
        out.m_width        = out.m_height = new_diameter;
 | 
			
		||||
    } else {
 | 
			
		||||
        assert(m_width >= m_height);
 | 
			
		||||
        out.m_width += new_spacing - m_spacing;
 | 
			
		||||
        if (out.m_width < out.m_height)
 | 
			
		||||
            throw Slic3r::InvalidArgument("Invalid spacing supplied to Flow::with_spacing()");
 | 
			
		||||
| 
						 | 
				
			
			@ -162,7 +163,7 @@ Flow Flow::with_spacing(float new_spacing) const
 | 
			
		|||
Flow Flow::with_cross_section(float area_new) const
 | 
			
		||||
{
 | 
			
		||||
    assert(! m_bridge);
 | 
			
		||||
    assert(flow.width() >= flow.height());
 | 
			
		||||
    assert(m_width >= m_height);
 | 
			
		||||
 | 
			
		||||
    // Adjust for bridge_flow_ratio, maintain the extrusion spacing.
 | 
			
		||||
    float area = this->mm3_per_mm();
 | 
			
		||||
| 
						 | 
				
			
			@ -179,7 +180,7 @@ Flow Flow::with_cross_section(float area_new) const
 | 
			
		|||
    } else if (area_new < area - EPSILON) {
 | 
			
		||||
        // Decreasing the flow rate.
 | 
			
		||||
        float width_new = m_width - (area - area_new) / m_height;
 | 
			
		||||
        assert(width_dif > 0);
 | 
			
		||||
        assert(width_new > 0);
 | 
			
		||||
        if (width_new > m_height) {
 | 
			
		||||
            // Shrink the extrusion width.
 | 
			
		||||
            return this->with_width(width_new);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -117,7 +117,8 @@ public:
 | 
			
		|||
 | 
			
		||||
private:
 | 
			
		||||
    Flow(float width, float height, float spacing, float nozzle_diameter, bool bridge) : 
 | 
			
		||||
        m_width(width), m_height(height), m_spacing(spacing), m_nozzle_diameter(nozzle_diameter), m_bridge(bridge) {}
 | 
			
		||||
        m_width(width), m_height(height), m_spacing(spacing), m_nozzle_diameter(nozzle_diameter), m_bridge(bridge) 
 | 
			
		||||
        { assert(width >= height); }
 | 
			
		||||
 | 
			
		||||
    float       m_width { 0 };
 | 
			
		||||
    float       m_height { 0 };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1815,7 +1815,8 @@ namespace Skirt {
 | 
			
		|||
        // Extrude skirt at the print_z of the raft layers and normal object layers
 | 
			
		||||
        // not at the print_z of the interlaced support material layers.
 | 
			
		||||
        std::map<unsigned int, std::pair<size_t, size_t>> skirt_loops_per_extruder_out;
 | 
			
		||||
        assert(skirt_done.empty());
 | 
			
		||||
        //For sequential print, the following test may fail when extruding the 2nd and other objects.
 | 
			
		||||
        // assert(skirt_done.empty());
 | 
			
		||||
        if (skirt_done.empty() && print.has_skirt() && ! print.skirt().entities.empty() && layer_tools.has_skirt) {
 | 
			
		||||
            skirt_loops_per_extruder_all_printing(print, layer_tools, skirt_loops_per_extruder_out);
 | 
			
		||||
            skirt_done.emplace_back(layer_tools.print_z);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -96,7 +96,7 @@ SCENARIO("Flow: Flow math for non-bridges", "[Flow]") {
 | 
			
		|||
    GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") {
 | 
			
		||||
        ConfigOptionFloatOrPercent	width(1.0, false);
 | 
			
		||||
        float nozzle_diameter	= 0.4f;
 | 
			
		||||
        float layer_height		= 0.5f;
 | 
			
		||||
        float layer_height		= 0.4f;
 | 
			
		||||
 | 
			
		||||
        // Spacing for non-bridges is has some overlap
 | 
			
		||||
        THEN("External perimeter flow has spacing fixed to 1.125 * nozzle_diameter") {
 | 
			
		||||
| 
						 | 
				
			
			@ -126,8 +126,8 @@ SCENARIO("Flow: Flow math for non-bridges", "[Flow]") {
 | 
			
		|||
                REQUIRE(flow.width() == Approx(1.125 * nozzle_diameter));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        WHEN("Layer height is set to 0.2") {
 | 
			
		||||
            layer_height = 0.3f;
 | 
			
		||||
        WHEN("Layer height is set to 0.25") {
 | 
			
		||||
            layer_height = 0.25f;
 | 
			
		||||
            THEN("Min width is set.") {
 | 
			
		||||
                auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height);
 | 
			
		||||
                REQUIRE(flow.width() == Approx(1.125 * nozzle_diameter));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,8 +53,8 @@ SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces t
 | 
			
		|||
		config.set_deserialize({
 | 
			
		||||
			{ "top_solid_layers",		2 },
 | 
			
		||||
			{ "bottom_solid_layers",	1 },
 | 
			
		||||
			{ "layer_height",			0.5 }, // get a known number of layers
 | 
			
		||||
			{ "first_layer_height",		0.5 }
 | 
			
		||||
			{ "layer_height",			0.25 }, // get a known number of layers
 | 
			
		||||
			{ "first_layer_height",		0.25 }
 | 
			
		||||
			});
 | 
			
		||||
        Slic3r::Print print;
 | 
			
		||||
        Slic3r::Model model;
 | 
			
		||||
| 
						 | 
				
			
			@ -72,8 +72,8 @@ SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces t
 | 
			
		|||
		};
 | 
			
		||||
        print.process();
 | 
			
		||||
        test_is_solid_infill(0,  0); // should be solid
 | 
			
		||||
        test_is_solid_infill(0, 39); // should be solid
 | 
			
		||||
        test_is_solid_infill(0, 38); // should be solid
 | 
			
		||||
        test_is_solid_infill(0, 79); // should be solid
 | 
			
		||||
        test_is_solid_infill(0, 78); // should be solid
 | 
			
		||||
        WHEN("Model is re-sliced with top_solid_layers == 3") {
 | 
			
		||||
			config.set("top_solid_layers", 3);
 | 
			
		||||
			print.apply(model, config);
 | 
			
		||||
| 
						 | 
				
			
			@ -82,9 +82,9 @@ SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces t
 | 
			
		|||
                test_is_solid_infill(0, 0);
 | 
			
		||||
            }
 | 
			
		||||
            AND_THEN("Print object has 3 top solid layers") {
 | 
			
		||||
                test_is_solid_infill(0, 39);
 | 
			
		||||
                test_is_solid_infill(0, 38);
 | 
			
		||||
                test_is_solid_infill(0, 37);
 | 
			
		||||
                test_is_solid_infill(0, 79);
 | 
			
		||||
                test_is_solid_infill(0, 78);
 | 
			
		||||
                test_is_solid_infill(0, 77);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -244,23 +244,24 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
 | 
			
		|||
				{ "complete_objects",               true },
 | 
			
		||||
                { "gcode_comments",                 true },
 | 
			
		||||
                { "layer_gcode",                    ";Layer:[layer_num] ([layer_z] mm)" },
 | 
			
		||||
                { "layer_height",                   1.0 },
 | 
			
		||||
                { "first_layer_height",             1.0 }
 | 
			
		||||
                { "layer_height",                   0.1 },
 | 
			
		||||
                { "first_layer_height",             0.1 }
 | 
			
		||||
                });
 | 
			
		||||
			// End of the 1st object.
 | 
			
		||||
			size_t pos = gcode.find(";Layer:19 ");
 | 
			
		||||
            std::string token = ";Layer:199 ";
 | 
			
		||||
			size_t pos = gcode.find(token);
 | 
			
		||||
			THEN("First and second object last layer is emitted") {
 | 
			
		||||
				// First object
 | 
			
		||||
				REQUIRE(pos != std::string::npos);
 | 
			
		||||
				pos += 10;
 | 
			
		||||
				pos += token.size();
 | 
			
		||||
				REQUIRE(pos < gcode.size());
 | 
			
		||||
				double z = 0;
 | 
			
		||||
				REQUIRE((sscanf(gcode.data() + pos, "(%lf mm)", &z) == 1));
 | 
			
		||||
				REQUIRE(z == Approx(20.));
 | 
			
		||||
				// Second object
 | 
			
		||||
				pos = gcode.find(";Layer:39 ", pos);
 | 
			
		||||
				pos = gcode.find(";Layer:399 ", pos);
 | 
			
		||||
				REQUIRE(pos != std::string::npos);
 | 
			
		||||
				pos += 10;
 | 
			
		||||
				pos += token.size();
 | 
			
		||||
				REQUIRE(pos < gcode.size());
 | 
			
		||||
				REQUIRE((sscanf(gcode.data() + pos, "(%lf mm)", &z) == 1));
 | 
			
		||||
				REQUIRE(z == Approx(20.));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue