mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-20 21:27:52 -06:00
Improvements in Inner Outer Inner wall ordering logic (#6138)
* Improvements in Inner Outer Inner wall ordering logic * Updated to BFS algorithm, made ordering more robust and corrected edge cases * Doc updates * Refinements in perimeter sorting * Removal of touch threshold and code debugging to improve sequencing * Code cleanup * Code refinements on perimeter distance thresholds * Extend perimeter re-ordering to more than inset index 2, to reduce travel moves when printing neighbouring features * Refinements to IOI perimeter re-ordering algorithm to improve travel scenarios where multiple external perimeters are contained in the same island. * Documentation updates * Removed unnecessary code * Removed bespoke to_points function and replaced with ExtrusionLine member already present. Removed squaredDistance and replaced with Eigen library call. * Refactor code to move distancing functions to the multipoint class. Renamed for more clarity on their purpose.
This commit is contained in:
parent
7082e945b1
commit
9a260010fc
4 changed files with 248 additions and 45 deletions
|
@ -370,6 +370,59 @@ Points MultiPoint::concave_hull_2d(const Points& pts, const double tolerence)
|
|||
}
|
||||
|
||||
|
||||
//Orca: Distancing function used by IOI wall ordering algorithm for arachne
|
||||
/**
|
||||
* @brief Calculates the squared distance between a point and a line segment defined by two points.
|
||||
*
|
||||
* @param p The point.
|
||||
* @param v The starting point of the line segment.
|
||||
* @param w The ending point of the line segment.
|
||||
* @return double The squared distance between the point and the line segment.
|
||||
*/
|
||||
double MultiPoint::squaredDistanceToLineSegment(const Point& p, const Point& v, const Point& w) {
|
||||
// Calculate the squared length of the line segment
|
||||
double l2 = (v - w).squaredNorm();
|
||||
// If the segment is a single point, return the squared distance to that point
|
||||
if (l2 == 0.0) return (p - v).squaredNorm();
|
||||
// Project point p onto the line defined by v and w, and clamp the projection to the segment
|
||||
double t = std::max(0.0, std::min(1.0, ((p - v).dot(w - v)) / l2));
|
||||
// Compute the projection point
|
||||
Point projection{v.x() + t * (w.x() - v.x()), v.y() + t * (w.y() - v.y())};
|
||||
// Return the squared distance between the point and the projection
|
||||
return (p - projection).squaredNorm();
|
||||
}
|
||||
|
||||
//Orca: Distancing function used by IOI wall ordering algorithm for arachne
|
||||
/**
|
||||
* @brief Calculates the minimum distance between two lines defined by sets of points.
|
||||
*
|
||||
* @param A The first set of points defining a polyline.
|
||||
* @param B The second set of points defining a polyline.
|
||||
* @return double The minimum distance between the two polylines.
|
||||
*/
|
||||
double MultiPoint::minimumDistanceBetweenLinesDefinedByPoints(const Points& A, const Points& B) {
|
||||
double min_distance = std::numeric_limits<double>::infinity();
|
||||
|
||||
// Calculate the minimum distance between segments in A and points in B
|
||||
for (size_t i = 0; i < A.size() - 1; ++i) {
|
||||
for (const auto& b : B) {
|
||||
double distance = squaredDistanceToLineSegment(b, A[i], A[i + 1]);
|
||||
min_distance = std::min(min_distance, std::sqrt(distance));
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the minimum distance between segments in B and points in A
|
||||
for (size_t i = 0; i < B.size() - 1; ++i) {
|
||||
for (const auto& a : A) {
|
||||
double distance = squaredDistanceToLineSegment(a, B[i], B[i + 1]);
|
||||
min_distance = std::min(min_distance, std::sqrt(distance));
|
||||
}
|
||||
}
|
||||
|
||||
return min_distance;
|
||||
}
|
||||
|
||||
|
||||
void MultiPoint3::translate(double x, double y)
|
||||
{
|
||||
for (Vec3crd &p : points) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue