mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	3rd attempt to fix unit test for 2D convex hull of sinking object on RasperryPi
This commit is contained in:
		
							parent
							
								
									dfa85c2c37
								
							
						
					
					
						commit
						ca9fad002c
					
				
					 1 changed files with 40 additions and 16 deletions
				
			
		|  | @ -93,7 +93,10 @@ SCENARIO("2D convex hull of sinking object", "[3mf]") { | ||||||
| 
 | 
 | ||||||
|             // set instance's attitude so that it is rotated, scaled and sinking
 |             // set instance's attitude so that it is rotated, scaled and sinking
 | ||||||
|             ModelInstance* instance = object->instances.front(); |             ModelInstance* instance = object->instances.front(); | ||||||
|             instance->set_rotation(Y, -M_PI / 4.0); | //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||||
|  |             instance->set_rotation(X, -M_PI / 4.0); | ||||||
|  | //            instance->set_rotation(Y, -M_PI / 4.0);
 | ||||||
|  | //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||||
|             instance->set_offset(Vec3d::Zero()); |             instance->set_offset(Vec3d::Zero()); | ||||||
|             instance->set_scaling_factor({ 2.0, 2.0, 2.0 }); |             instance->set_scaling_factor({ 2.0, 2.0, 2.0 }); | ||||||
| 
 | 
 | ||||||
|  | @ -101,26 +104,47 @@ SCENARIO("2D convex hull of sinking object", "[3mf]") { | ||||||
|             Polygon hull_2d = object->convex_hull_2d(instance->get_transformation().get_matrix()); |             Polygon hull_2d = object->convex_hull_2d(instance->get_transformation().get_matrix()); | ||||||
| 
 | 
 | ||||||
|             // verify result
 |             // verify result
 | ||||||
|  | //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||||
|             Points result = { |             Points result = { | ||||||
|                 { -4242641, -16299551 }, |                 { -91501496, -15914144 }, | ||||||
|                 { -4241,    -19502998 }, |                 { 91501496, -15914144 }, | ||||||
|                 { 66824768, -19502998 }, |                 { 91501496, 4243 }, | ||||||
|                 { 66824768, 19502998 }, |                 { 78229680, 4246883 }, | ||||||
|                 { -4244,    19502998 }, |                 { 56898100, 4246883 }, | ||||||
|                 { -4242640, -8537523 } |                 { -85501496, 4242641 }, | ||||||
|  |                 { -91501496, 4243 } | ||||||
|             }; |             }; | ||||||
| 
 | 
 | ||||||
|             bool res = hull_2d.points.size() == result.size(); | //            Points result = {
 | ||||||
|             if (res) { | //                { -4242641, -16299551 },
 | ||||||
|                 for (size_t i = 0; i < result.size(); ++i) { | //                { -4241,    -19502998 },
 | ||||||
|                     Vec3d hull_p(unscale<double>(hull_2d.points[i].x()), unscale<double>(hull_2d.points[i].y()), 0.0); | //                { 66824768, -19502998 },
 | ||||||
|                     Vec3d res_p(unscale<double>(result[i].x()), unscale<double>(result[i].y()), 0.0); | //                { 66824768, 19502998 },
 | ||||||
|                     res &= res_p.isApprox(hull_p); | //                { -4244,    19502998 },
 | ||||||
|                 } | //                { -4242640, -8537523 }
 | ||||||
|  | //            };
 | ||||||
|  | //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||||
|  |             for (const Point& p : hull_2d.points) { | ||||||
|  |                 std::cout << p.x() << ", " << p.y() << "\n"; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // this does not work on RaspberryPi for float precision problem: the x of 1st vertex ending up being -4242640 instead of -4242641
 |             bool res = hull_2d.points == result; | ||||||
| //            bool res = hull_2d.points == result;
 | 
 | ||||||
|  | //            bool res = hull_2d.points.size() == result.size();
 | ||||||
|  | //            if (res) {
 | ||||||
|  | //                for (size_t i = 0; i < result.size(); ++i) {
 | ||||||
|  | //                    Vec3d hull_p(unscale<double>(hull_2d.points[i].x()), unscale<double>(hull_2d.points[i].y()), 0.0);
 | ||||||
|  | //                    Vec3d res_p(unscale<double>(result[i].x()), unscale<double>(result[i].y()), 0.0);
 | ||||||
|  | //                    res &= res_p.isApprox(hull_p);
 | ||||||
|  | //                }
 | ||||||
|  | //            }
 | ||||||
|  | //
 | ||||||
|  | //            // this does not work on RaspberryPi for float precision problem: the x of 1st vertex ending up being -4242640 instead of -4242641
 | ||||||
|  | ////            bool res = hull_2d.points == result;
 | ||||||
|  | //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||||
| 
 | 
 | ||||||
|             THEN("2D convex hull should match with reference") { |             THEN("2D convex hull should match with reference") { | ||||||
|                 REQUIRE(res); |                 REQUIRE(res); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966