Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements in Inner Outer Inner wall ordering logic #6138

Merged
merged 24 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
827eb93
Improvements in Inner Outer Inner wall ordering logic
igiannakas Jul 14, 2024
d43f10b
Updated to BFS algorithm, made ordering more robust and corrected edg…
igiannakas Jul 16, 2024
62988d7
Merge remote-tracking branch 'upstream/main' into IOI-Improvements
igiannakas Jul 16, 2024
ffb846e
Doc updates
igiannakas Jul 16, 2024
4132260
Refinements in perimeter sorting
igiannakas Jul 17, 2024
aab5f88
Removal of touch threshold and code debugging to improve sequencing
igiannakas Jul 18, 2024
f1906d8
Code cleanup
igiannakas Jul 18, 2024
57ebc91
Code refinements on perimeter distance thresholds
igiannakas Jul 18, 2024
f5df687
Extend perimeter re-ordering to more than inset index 2, to reduce tr…
igiannakas Jul 18, 2024
de5a000
Refinements to IOI perimeter re-ordering algorithm to improve travel …
igiannakas Jul 19, 2024
2dcc80c
Documentation updates
igiannakas Jul 19, 2024
c133160
Removed unnecessary code
igiannakas Jul 23, 2024
7358c83
Merge remote-tracking branch 'upstream/main' into IOI-Improvements
igiannakas Jul 23, 2024
26ef51c
Merge branch 'SoftFever:main' into IOI-Improvements
igiannakas Jul 26, 2024
76fd384
Merge branch 'SoftFever:main' into IOI-Improvements
igiannakas Jul 31, 2024
d982d5d
Merge branch 'main' into IOI-Improvements
igiannakas Aug 2, 2024
180be8a
Merge branch 'main' into IOI-Improvements
igiannakas Aug 6, 2024
668dc10
Merge remote-tracking branch 'upstream/main' into IOI-Improvements
igiannakas Aug 6, 2024
ff87ce5
Merge branch 'main' into IOI-Improvements
igiannakas Aug 8, 2024
d2ce445
Removed bespoke to_points function and replaced with ExtrusionLine me…
igiannakas Aug 9, 2024
d0b5fab
Merge branch 'main' into IOI-Improvements
igiannakas Aug 9, 2024
c44179f
Merge branch 'main' into IOI-Improvements
igiannakas Aug 9, 2024
cee5fc5
Refactor code to move distancing functions to the multipoint class. R…
igiannakas Aug 9, 2024
e5e7857
Merge branch 'main' into IOI-Improvements
igiannakas Aug 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/libslic3r/Arachne/utils/ExtrusionLine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ static inline Polygon to_polygon(const ExtrusionLine &line)
return out;
}

static Points to_points(const ExtrusionLine &extrusion_line)
{
Points points;
points.reserve(extrusion_line.junctions.size());
for (const ExtrusionJunction &junction : extrusion_line.junctions)
points.emplace_back(junction.p);
return points;
}

#if 0
static BoundingBox get_extents(const ExtrusionLine &extrusion_line)
{
Expand Down Expand Up @@ -272,15 +281,6 @@ static BoundingBox get_extents(const std::vector<const ExtrusionLine *> &extrusi
return bbox;
}

static Points to_points(const ExtrusionLine &extrusion_line)
{
Points points;
points.reserve(extrusion_line.junctions.size());
for (const ExtrusionJunction &junction : extrusion_line.junctions)
points.emplace_back(junction.p);
return points;
}

static std::vector<Points> to_points(const std::vector<const ExtrusionLine *> &extrusion_lines)
{
std::vector<Points> points;
Expand Down
53 changes: 53 additions & 0 deletions src/libslic3r/MultiPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions src/libslic3r/MultiPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,20 @@ class MultiPoint
static Points _douglas_peucker(const Points &points, const double tolerance);
static Points visivalingam(const Points& pts, const double tolerance);
static Points concave_hull_2d(const Points& pts, const double tolerence);

//Orca: Distancing function used by IOI wall ordering algorithm for arachne
static double minimumDistanceBetweenLinesDefinedByPoints(const Points& A, const Points& B);

inline auto begin() { return points.begin(); }
inline auto begin() const { return points.begin(); }
inline auto end() { return points.end(); }
inline auto end() const { return points.end(); }
inline auto cbegin() const { return points.begin(); }
inline auto cend() const { return points.end(); }

private:
//Orca: Distancing function used by IOI wall ordering algorithm for arachne
static double squaredDistanceToLineSegment(const Point& p, const Point& v, const Point& w);
};

class MultiPoint3
Expand Down
Loading