mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Reduce reallocations and memory usage in gyroid
This commit is contained in:
		
							parent
							
								
									b9901f1730
								
							
						
					
					
						commit
						5932881291
					
				
					 1 changed files with 3 additions and 0 deletions
				
			
		|  | @ -35,6 +35,7 @@ static inline Polyline make_wave( | |||
| { | ||||
|     std::vector<Vec2d> points = one_period; | ||||
|     double period = points.back()(0); | ||||
|     points.reserve(one_period.size() * floor(width / period)); | ||||
|     points.pop_back(); | ||||
|     int n = points.size(); | ||||
|     do { | ||||
|  | @ -44,6 +45,7 @@ static inline Polyline make_wave( | |||
| 
 | ||||
|     // and construct the final polyline to return:
 | ||||
|     Polyline polyline; | ||||
|     polyline.points.reserve(points.size()); | ||||
|     for (auto& point : points) { | ||||
|         point(1) += offset; | ||||
|         point(1) = clamp(0., height, double(point(1))); | ||||
|  | @ -60,6 +62,7 @@ static std::vector<Vec2d> make_one_period(double width, double scaleFactor, doub | |||
|     std::vector<Vec2d> points; | ||||
|     double dx = M_PI_2; // exact coordinates on main inflexion lobes
 | ||||
|     double limit = std::min(2*M_PI, width); | ||||
|     points.reserve(ceil(limit / tolerance / 3)); | ||||
|     for (double x = 0.; x < limit + EPSILON; x += dx) {  // so the last point is there too
 | ||||
|         x = std::min(x, limit); | ||||
|         points.emplace_back(Vec2d(x, f(x, z_sin, z_cos, vertical, flip))); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yuri D'Elia
						Yuri D'Elia