mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-30 18:14:36 +08:00
Renamed Line::offset to extend
Don't use unscaled constants! What if the scaling constant changes in the future?
This commit is contained in:
parent
958acad85b
commit
3e50699576
@ -625,7 +625,7 @@ static Line create_offset_line(const Line &line_to_offset, const Intersection &i
|
|||||||
Line offset_line = line_to_offset;
|
Line offset_line = line_to_offset;
|
||||||
offset_line.translate(offset_vector.x(), offset_vector.y());
|
offset_line.translate(offset_vector.x(), offset_vector.y());
|
||||||
// Extend the line by small value to guarantee a collision with adjacent lines
|
// Extend the line by small value to guarantee a collision with adjacent lines
|
||||||
offset_line.offset(1000000);
|
offset_line.extend(coord_t(scale_(1.)));
|
||||||
return offset_line;
|
return offset_line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ bool Line::clip_with_bbox(const BoundingBox &bbox)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Line::offset(double offset)
|
void Line::extend(double offset)
|
||||||
{
|
{
|
||||||
Vector offset_vector = (offset * this->vector().cast<double>().normalized()).cast<coord_t>();
|
Vector offset_vector = (offset * this->vector().cast<double>().normalized()).cast<coord_t>();
|
||||||
this->a -= offset_vector;
|
this->a -= offset_vector;
|
||||||
|
@ -75,8 +75,8 @@ public:
|
|||||||
double ccw(const Point& point) const { return point.ccw(*this); }
|
double ccw(const Point& point) const { return point.ccw(*this); }
|
||||||
// Clip a line with a bounding box. Returns false if the line is completely outside of the bounding box.
|
// Clip a line with a bounding box. Returns false if the line is completely outside of the bounding box.
|
||||||
bool clip_with_bbox(const BoundingBox &bbox);
|
bool clip_with_bbox(const BoundingBox &bbox);
|
||||||
// Resize a line from both sides by the offset.
|
// Extend the line from both sides by an offset.
|
||||||
void offset(double offset);
|
void extend(double offset);
|
||||||
|
|
||||||
static inline double distance_to_squared(const Point &point, const Point &a, const Point &b) { return line_alg::distance_to_squared(Line{a, b}, Vec<2, coord_t>{point}); }
|
static inline double distance_to_squared(const Point &point, const Point &a, const Point &b) { return line_alg::distance_to_squared(Line{a, b}, Vec<2, coord_t>{point}); }
|
||||||
static double distance_to(const Point &point, const Point &a, const Point &b) { return sqrt(distance_to_squared(point, a, b)); }
|
static double distance_to(const Point &point, const Point &a, const Point &b) { return sqrt(distance_to_squared(point, a, b)); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user