mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Fix of a typo in KDTreeIndirect.
Improvement of the infill path planning. Regression fix of Gyroid infill crashes. Some unit tests for elephant foot and path planning.
This commit is contained in:
		
							parent
							
								
									ae887d5833
								
							
						
					
					
						commit
						dd59945098
					
				
					 9 changed files with 443 additions and 145 deletions
				
			
		| 
						 | 
				
			
			@ -222,6 +222,21 @@ static ExPolygon vase_with_fins()
 | 
			
		|||
 | 
			
		||||
SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
 | 
			
		||||
 | 
			
		||||
	GIVEN("Tiny contour") {
 | 
			
		||||
		ExPolygon expoly({ { 133382606, 94912473 }, { 134232493, 95001115 }, { 133783926, 95159440 }, { 133441897, 95180666 }, { 133408242, 95191984 }, { 133339012, 95166830 }, { 132991642, 95011087 }, { 133206549, 94908304 } });
 | 
			
		||||
		WHEN("Compensated") {
 | 
			
		||||
			ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f, false), 0.2f);
 | 
			
		||||
#ifdef TESTS_EXPORT_SVGS
 | 
			
		||||
			SVG::export_expolygons(debug_out_path("elephant_foot_compensation_tiny.svg").c_str(),
 | 
			
		||||
				{ { { expoly },             { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
 | 
			
		||||
				  { { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
 | 
			
		||||
#endif /* TESTS_EXPORT_SVGS */
 | 
			
		||||
			THEN("Tiny contour is not compensated") {
 | 
			
		||||
				REQUIRE(expoly_compensated == expoly);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	GIVEN("Large box") {
 | 
			
		||||
		ExPolygon expoly( { {50000000, 50000000 }, { 0, 50000000 }, { 0, 0 }, { 50000000, 0 } } );
 | 
			
		||||
        WHEN("Compensated") {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -252,15 +252,39 @@ SCENARIO("Circle Fit, TaubinFit with Newton's method", "[Geometry]") {
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE("Chained path working correctly", "[Geometry]"){
 | 
			
		||||
    // if chained_path() works correctly, these points should be joined with no diagonal paths
 | 
			
		||||
    // (thus 26 units long)
 | 
			
		||||
    std::vector<Point> points = {Point(26,26),Point(52,26),Point(0,26),Point(26,52),Point(26,0),Point(0,52),Point(52,52),Point(52,0)};
 | 
			
		||||
    std::vector<Points::size_type> indices = chain_points(points);
 | 
			
		||||
    for (Points::size_type i = 0; i + 1 < indices.size(); ++ i) {
 | 
			
		||||
        double dist = (points.at(indices.at(i)).cast<double>() - points.at(indices.at(i+1)).cast<double>()).norm();
 | 
			
		||||
        REQUIRE(std::abs(dist-26) <= EPSILON);
 | 
			
		||||
    }
 | 
			
		||||
SCENARIO("Path chaining", "[Geometry]") {
 | 
			
		||||
	GIVEN("A path") {
 | 
			
		||||
		std::vector<Point> points = { Point(26,26),Point(52,26),Point(0,26),Point(26,52),Point(26,0),Point(0,52),Point(52,52),Point(52,0) };
 | 
			
		||||
		THEN("Chained with no diagonals (thus 26 units long)") {
 | 
			
		||||
			std::vector<Points::size_type> indices = chain_points(points);
 | 
			
		||||
			for (Points::size_type i = 0; i + 1 < indices.size(); ++ i) {
 | 
			
		||||
				double dist = (points.at(indices.at(i)).cast<double>() - points.at(indices.at(i+1)).cast<double>()).norm();
 | 
			
		||||
				REQUIRE(std::abs(dist-26) <= EPSILON);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	GIVEN("Loop pieces") {
 | 
			
		||||
		Point a { 2185796, 19058485 };
 | 
			
		||||
		Point b { 3957902, 18149382 };
 | 
			
		||||
		Point c { 2912841, 18790564 };
 | 
			
		||||
		Point d { 2831848, 18832390 };
 | 
			
		||||
		Point e { 3179601, 18627769 };
 | 
			
		||||
		Point f { 3137952, 18653370 };
 | 
			
		||||
		Polylines polylines = { { a, b },
 | 
			
		||||
								{ c, d },
 | 
			
		||||
								{ e, f },
 | 
			
		||||
								{ d, a },
 | 
			
		||||
								{ f, c },
 | 
			
		||||
								{ b, e } };
 | 
			
		||||
		Polylines chained = chain_polylines(polylines, &a);
 | 
			
		||||
		THEN("Connected without a gap") {
 | 
			
		||||
			for (size_t i = 0; i < chained.size(); ++i) {
 | 
			
		||||
				const Polyline &pl1 = (i == 0) ? chained.back() : chained[i - 1];
 | 
			
		||||
				const Polyline &pl2 = chained[i];
 | 
			
		||||
				REQUIRE(pl1.points.back() == pl2.points.front());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SCENARIO("Line distances", "[Geometry]"){
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue