mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Test sla support point generation determinism with seed parameter
This commit is contained in:
		
							parent
							
								
									8af6890cab
								
							
						
					
					
						commit
						ce49f0a294
					
				
					 2 changed files with 49 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -85,6 +85,53 @@ TEST_CASE("Pillar pairhash should be unique", "[SLASupportGeneration]") {
 | 
			
		|||
    test_pairhash<unsigned, unsigned long>();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE("Support point generator should be deterministic if seeded", 
 | 
			
		||||
          "[SLASupportGeneration], [SLAPointGen]") {
 | 
			
		||||
    TriangleMesh mesh = load_model("A_upsidedown.obj");
 | 
			
		||||
    
 | 
			
		||||
    sla::EigenMesh3D emesh{mesh};
 | 
			
		||||
    
 | 
			
		||||
    sla::SupportConfig supportcfg;
 | 
			
		||||
    sla::SupportPointGenerator::Config autogencfg;
 | 
			
		||||
    autogencfg.head_diameter = float(2 * supportcfg.head_front_radius_mm);
 | 
			
		||||
    sla::SupportPointGenerator point_gen{emesh, autogencfg, [] {}, [](int) {}};
 | 
			
		||||
    
 | 
			
		||||
    TriangleMeshSlicer slicer{&mesh};
 | 
			
		||||
    
 | 
			
		||||
    auto   bb      = mesh.bounding_box();
 | 
			
		||||
    double zmin    = bb.min.z();
 | 
			
		||||
    double zmax    = bb.max.z();
 | 
			
		||||
    double gnd     = zmin - supportcfg.object_elevation_mm;
 | 
			
		||||
    auto   layer_h = 0.05f;
 | 
			
		||||
    
 | 
			
		||||
    auto slicegrid = grid(float(gnd), float(zmax), layer_h);
 | 
			
		||||
    std::vector<ExPolygons> slices;
 | 
			
		||||
    slicer.slice(slicegrid, CLOSING_RADIUS, &slices, []{});
 | 
			
		||||
    
 | 
			
		||||
    point_gen.execute(slices, slicegrid, 0);
 | 
			
		||||
    
 | 
			
		||||
    auto get_chksum = [](const std::vector<sla::SupportPoint> &pts){
 | 
			
		||||
        long long chksum = 0;
 | 
			
		||||
        for (auto &pt : pts) {
 | 
			
		||||
            auto p = scaled(pt.pos);
 | 
			
		||||
            chksum += p.x() + p.y() + p.z();
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        return chksum;
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
    long long checksum = get_chksum(point_gen.output());
 | 
			
		||||
    size_t ptnum = point_gen.output().size();
 | 
			
		||||
    REQUIRE(point_gen.output().size() > 0);
 | 
			
		||||
    
 | 
			
		||||
    for (int i = 0; i < 20; ++i) {
 | 
			
		||||
        point_gen.output().clear();
 | 
			
		||||
        point_gen.execute(slices, slicegrid, 0);
 | 
			
		||||
        REQUIRE(point_gen.output().size() == ptnum);
 | 
			
		||||
        REQUIRE(checksum == get_chksum(point_gen.output()));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE("Flat pad geometry is valid", "[SLASupportGeneration]") {
 | 
			
		||||
    sla::PadConfig padcfg;
 | 
			
		||||
    
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue