mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 12:41:20 -06:00 
			
		
		
		
	Remove: "ENH: Flatten: refine the flatten logic"
This reverts commit b8a4530eccb76dd5673cced468deeb10bdcade01. Change-Id: I22304b0396f1c17c1cb741751cfa8fb928d3fd99
This commit is contained in:
		
							parent
							
								
									782a35f750
								
							
						
					
					
						commit
						d91fe4e38c
					
				
					 1 changed files with 9 additions and 20 deletions
				
			
		|  | @ -13,7 +13,6 @@ | |||
| namespace Slic3r { | ||||
| namespace GUI { | ||||
| 
 | ||||
| static double g_normal_precise = 0.0015; | ||||
| 
 | ||||
| GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) | ||||
|     : GLGizmoBase(parent, icon_filename, sprite_id) | ||||
|  | @ -140,8 +139,8 @@ void GLGizmoFlatten::update_planes() | |||
|     const Transform3d& inst_matrix = mo->instances.front()->get_matrix(true); | ||||
| 
 | ||||
|     // Following constants are used for discarding too small polygons.
 | ||||
|     const float minimal_area = 4.f; // in square mm (world coordinates)
 | ||||
|     const float minimal_side = 2.f; // mm
 | ||||
|     const float minimal_area = 5.f; // in square mm (world coordinates)
 | ||||
|     const float minimal_side = 1.f; // mm
 | ||||
| 
 | ||||
|     // Now we'll go through all the facets and append Points of facets sharing the same normal.
 | ||||
|     // This part is still performed in mesh coordinate system.
 | ||||
|  | @ -169,7 +168,7 @@ void GLGizmoFlatten::update_planes() | |||
|         while (facet_queue_cnt > 0) { | ||||
|             int facet_idx = facet_queue[-- facet_queue_cnt]; | ||||
|             const stl_normal& this_normal = face_normals[facet_idx]; | ||||
|             if (std::abs(this_normal(0) - (*normal_ptr)(0)) <= g_normal_precise && std::abs(this_normal(1) - (*normal_ptr)(1)) <= g_normal_precise && std::abs(this_normal(2) - (*normal_ptr)(2)) <= g_normal_precise) { | ||||
|             if (std::abs(this_normal(0) - (*normal_ptr)(0)) < 0.001 && std::abs(this_normal(1) - (*normal_ptr)(1)) < 0.001 && std::abs(this_normal(2) - (*normal_ptr)(2)) < 0.001) { | ||||
|                 const Vec3i face = ch.its.indices[facet_idx]; | ||||
|                 for (int j=0; j<3; ++j) | ||||
|                     m_planes.back().vertices.emplace_back(ch.its.vertices[face[j]].cast<double>()); | ||||
|  | @ -236,28 +235,18 @@ void GLGizmoFlatten::update_planes() | |||
|             discard = true; | ||||
|         else { | ||||
|             // We also check the inner angles and discard polygons with angles smaller than the following threshold
 | ||||
|             const double angle_threshold = ::cos(9.0 * (double)PI / 180.0); | ||||
|             int count = 0, side_count = polygon.size(); | ||||
|             const double angle_threshold = ::cos(10.0 * (double)PI / 180.0); | ||||
| 
 | ||||
|             for (unsigned int i = 0; i < side_count; ++i) { | ||||
|             for (unsigned int i = 0; i < polygon.size(); ++i) { | ||||
|                 const Vec3d& prec = polygon[(i == 0) ? polygon.size() - 1 : i - 1]; | ||||
|                 const Vec3d& curr = polygon[i]; | ||||
|                 const Vec3d& next = polygon[(i == polygon.size() - 1) ? 0 : i + 1]; | ||||
|                 double len = (next - curr).norm(); | ||||
|                 if (len >= minimal_side) | ||||
|                     count ++; | ||||
| 
 | ||||
|                 if ((prec - curr).normalized().dot((next - curr).normalized()) > angle_threshold) { | ||||
|                     discard = true; | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|             if (!discard | ||||
|                 //&& ((side_count == 3) || (side_count == 5))
 | ||||
|                 && (side_count <= 5) | ||||
|                 && (count <= 2)) { | ||||
|                 discard = true; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if (discard) { | ||||
|  | @ -269,14 +258,14 @@ void GLGizmoFlatten::update_planes() | |||
|         Vec3d centroid = std::accumulate(polygon.begin(), polygon.end(), Vec3d(0.0, 0.0, 0.0)); | ||||
|         centroid /= (double)polygon.size(); | ||||
|         for (auto& vertex : polygon) | ||||
|             vertex = 0.95f*vertex + 0.05f*centroid; | ||||
|             vertex = 0.9f*vertex + 0.1f*centroid; | ||||
| 
 | ||||
|         // Polygon is now simple and convex, we'll round the corners to make them look nicer.
 | ||||
|         // The algorithm takes a vertex, calculates middles of respective sides and moves the vertex
 | ||||
|         // towards their average (controlled by 'aggressivity'). This is repeated k times.
 | ||||
|         // In next iterations, the neighbours are not always taken at the middle (to increase the
 | ||||
|         // rounding effect at the corners, where we need it most).
 | ||||
|         /*const unsigned int k = 10; // number of iterations
 | ||||
|         const unsigned int k = 10; // number of iterations
 | ||||
|         const float aggressivity = 0.2f;  // agressivity
 | ||||
|         const unsigned int N = polygon.size(); | ||||
|         std::vector<std::pair<unsigned int, unsigned int>> neighbours; | ||||
|  | @ -308,7 +297,7 @@ void GLGizmoFlatten::update_planes() | |||
|                 } | ||||
|             } | ||||
|             polygon = points_out; // replace the coarse polygon with the smooth one that we just created
 | ||||
|         }*/ | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         // Raise a bit above the object surface to avoid flickering:
 | ||||
|  | @ -321,7 +310,7 @@ void GLGizmoFlatten::update_planes() | |||
| 
 | ||||
|     // We'll sort the planes by area and only keep the 254 largest ones (because of the picking pass limitations):
 | ||||
|     std::sort(m_planes.rbegin(), m_planes.rend(), [](const PlaneData& a, const PlaneData& b) { return a.area < b.area; }); | ||||
|     m_planes.resize(std::min((int)m_planes.size(), 512)); | ||||
|     m_planes.resize(std::min((int)m_planes.size(), 254)); | ||||
| 
 | ||||
|     // Planes are finished - let's save what we calculated it from:
 | ||||
|     m_volumes_matrices.clear(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 lane.wei
						lane.wei