Removed the x(), y(), z() Point/Pointf/Point3/Pointf3 accessors.

This commit is contained in:
bubnikv 2018-08-17 15:53:43 +02:00
parent 1ba64da3fe
commit 65011f9382
60 changed files with 1083 additions and 1111 deletions

View file

@ -55,8 +55,8 @@ static std::vector<coordf_t> perpendPoints(const coordf_t offset, const size_t b
static inline void trim(Pointfs &pts, coordf_t minX, coordf_t minY, coordf_t maxX, coordf_t maxY)
{
for (Pointf &pt : pts) {
pt.x() = clamp(minX, maxX, pt.x());
pt.y() = clamp(minY, maxY, pt.y());
pt(0) = clamp(minX, maxX, pt(0));
pt(1) = clamp(minY, maxY, pt(1));
}
}
@ -128,7 +128,7 @@ static Polylines makeGrid(coord_t z, coord_t gridSize, size_t gridWidth, size_t
result.push_back(Polyline());
Polyline &polyline = result.back();
for (Pointfs::const_iterator it = it_polylines->begin(); it != it_polylines->end(); ++ it)
polyline.points.push_back(Point(coord_t(it->x() * scaleFactor), coord_t(it->y() * scaleFactor)));
polyline.points.push_back(Point(coord_t((*it)(0) * scaleFactor), coord_t((*it)(1) * scaleFactor)));
}
return result;
}
@ -153,13 +153,13 @@ void Fill3DHoneycomb::_fill_surface_single(
Polylines polylines = makeGrid(
scale_(this->z),
distance,
ceil(bb.size().x() / distance) + 1,
ceil(bb.size().y() / distance) + 1,
ceil(bb.size()(0) / distance) + 1,
ceil(bb.size()(1) / distance) + 1,
((this->layer_id/thickness_layers) % 2) + 1);
// move pattern in place
for (Polylines::iterator it = polylines.begin(); it != polylines.end(); ++ it)
it->translate(bb.min.x(), bb.min.y());
it->translate(bb.min(0), bb.min(1));
// clip pattern to boundaries
polylines = intersection_pl(polylines, (Polygons)expolygon);

View file

@ -121,11 +121,11 @@ public:
return aligned;
}
static Point _align_to_grid(Point coord, Point spacing)
{ return Point(_align_to_grid(coord.x(), spacing.x()), _align_to_grid(coord.y(), spacing.y())); }
{ return Point(_align_to_grid(coord(0), spacing(0)), _align_to_grid(coord(1), spacing(1))); }
static coord_t _align_to_grid(coord_t coord, coord_t spacing, coord_t base)
{ return base + _align_to_grid(coord - base, spacing); }
static Point _align_to_grid(Point coord, Point spacing, Point base)
{ return Point(_align_to_grid(coord.x(), spacing.x(), base.x()), _align_to_grid(coord.y(), spacing.y(), base.y())); }
{ return Point(_align_to_grid(coord(0), spacing(0), base(0)), _align_to_grid(coord(1), spacing(1), base(1))); }
};
} // namespace Slic3r

View file

@ -20,7 +20,7 @@ void FillConcentric::_fill_surface_single(
coord_t distance = coord_t(min_spacing / params.density);
if (params.density > 0.9999f && !params.dont_adjust) {
distance = this->_adjust_solid_spacing(bounding_box.size().x(), distance);
distance = this->_adjust_solid_spacing(bounding_box.size()(0), distance);
this->spacing = unscale(distance);
}

View file

@ -34,21 +34,21 @@ static inline Polyline make_wave(
double z_cos, double z_sin, bool vertical)
{
std::vector<Pointf> points = one_period;
double period = points.back().x();
double period = points.back()(0);
points.pop_back();
int n = points.size();
do {
points.emplace_back(Pointf(points[points.size()-n].x() + period, points[points.size()-n].y()));
} while (points.back().x() < width);
points.back().x() = width;
points.emplace_back(Pointf(points[points.size()-n](0) + period, points[points.size()-n](1)));
} while (points.back()(0) < width);
points.back()(0) = width;
// and construct the final polyline to return:
Polyline polyline;
for (auto& point : points) {
point.y() += offset;
point.y() = clamp(0., height, double(point.y()));
point(1) += offset;
point(1) = clamp(0., height, double(point(1)));
if (vertical)
std::swap(point.x(), point.y());
std::swap(point(0), point(1));
polyline.points.emplace_back((point * scaleFactor).cast<coord_t>());
}
@ -73,12 +73,12 @@ static std::vector<Pointf> make_one_period(double width, double scaleFactor, dou
auto& tp = points[i]; // this point
auto& rp = points[i+1]; // right point
// calculate distance of the point to the line:
double dist_mm = unscale(scaleFactor * std::abs( (rp.y() - lp.y())*tp.x() + (lp.x() - rp.x())*tp.y() + (rp.x()*lp.y() - rp.y()*lp.x()) ) / std::hypot((rp.y() - lp.y()),(lp.x() - rp.x())));
double dist_mm = unscale(scaleFactor * std::abs( (rp(1) - lp(1))*tp(0) + (lp(0) - rp(0))*tp(1) + (rp(0)*lp(1) - rp(1)*lp(0)) ) / std::hypot((rp(1) - lp(1)),(lp(0) - rp(0))));
if (dist_mm > tolerance) { // if the difference from straight line is more than this
double x = 0.5f * (points[i-1].x() + points[i].x());
double x = 0.5f * (points[i-1](0) + points[i](0));
points.emplace_back(Pointf(x, f(x, z_sin, z_cos, vertical, flip)));
x = 0.5f * (points[i+1].x() + points[i].x());
x = 0.5f * (points[i+1](0) + points[i](0));
points.emplace_back(Pointf(x, f(x, z_sin, z_cos, vertical, flip)));
std::sort(points.begin(), points.end()); // we added the points to the end, but need them all in order
--i; // decrement i so we also check the first newly added point
@ -143,12 +143,12 @@ void FillGyroid::_fill_surface_single(
scale_(this->z),
density_adjusted,
this->spacing,
ceil(bb.size().x() / distance) + 1.,
ceil(bb.size().y() / distance) + 1.);
ceil(bb.size()(0) / distance) + 1.,
ceil(bb.size()(1) / distance) + 1.);
// move pattern in place
for (Polyline &polyline : polylines)
polyline.translate(bb.min.x(), bb.min.y());
polyline.translate(bb.min(0), bb.min(1));
// clip pattern to boundaries
polylines = intersection_pl(polylines, (Polygons)expolygon);

View file

@ -50,13 +50,13 @@ void FillHoneycomb::_fill_surface_single(
bounding_box.merge(_align_to_grid(bounding_box.min, Point(m.hex_width, m.pattern_height)));
}
coord_t x = bounding_box.min.x();
while (x <= bounding_box.max.x()) {
coord_t x = bounding_box.min(0);
while (x <= bounding_box.max(0)) {
Polygon p;
coord_t ax[2] = { x + m.x_offset, x + m.distance - m.x_offset };
for (size_t i = 0; i < 2; ++ i) {
std::reverse(p.points.begin(), p.points.end()); // turn first half upside down
for (coord_t y = bounding_box.min.y(); y <= bounding_box.max.y(); y += m.y_short + m.hex_side + m.y_short + m.hex_side) {
for (coord_t y = bounding_box.min(1); y <= bounding_box.max(1); y += m.y_short + m.hex_side + m.y_short + m.hex_side) {
p.points.push_back(Point(ax[1], y + m.y_offset));
p.points.push_back(Point(ax[0], y + m.y_short - m.y_offset));
p.points.push_back(Point(ax[0], y + m.y_short + m.hex_side + m.y_offset));

View file

@ -24,14 +24,14 @@ void FillPlanePath::_fill_surface_single(
Point shift = this->_centered() ?
bounding_box.center() :
bounding_box.min;
expolygon.translate(-shift.x(), -shift.y());
bounding_box.translate(-shift.x(), -shift.y());
expolygon.translate(-shift(0), -shift(1));
bounding_box.translate(-shift(0), -shift(1));
Pointfs pts = _generate(
coord_t(ceil(coordf_t(bounding_box.min.x()) / distance_between_lines)),
coord_t(ceil(coordf_t(bounding_box.min.y()) / distance_between_lines)),
coord_t(ceil(coordf_t(bounding_box.max.x()) / distance_between_lines)),
coord_t(ceil(coordf_t(bounding_box.max.y()) / distance_between_lines)));
coord_t(ceil(coordf_t(bounding_box.min(0)) / distance_between_lines)),
coord_t(ceil(coordf_t(bounding_box.min(1)) / distance_between_lines)),
coord_t(ceil(coordf_t(bounding_box.max(0)) / distance_between_lines)),
coord_t(ceil(coordf_t(bounding_box.max(1)) / distance_between_lines)));
Polylines polylines;
if (pts.size() >= 2) {
@ -41,8 +41,8 @@ void FillPlanePath::_fill_surface_single(
polyline.points.reserve(pts.size());
for (Pointfs::iterator it = pts.begin(); it != pts.end(); ++ it)
polyline.points.push_back(Point(
coord_t(floor(it->x() * distance_between_lines + 0.5)),
coord_t(floor(it->y() * distance_between_lines + 0.5))));
coord_t(floor((*it)(0) * distance_between_lines + 0.5)),
coord_t(floor((*it)(1) * distance_between_lines + 0.5))));
// intersection(polylines_src, offset((Polygons)expolygon, scale_(0.02)), &polylines);
polylines = intersection_pl(polylines, to_polygons(expolygon));
@ -62,7 +62,7 @@ void FillPlanePath::_fill_surface_single(
// paths must be repositioned and rotated back
for (Polylines::iterator it = polylines.begin(); it != polylines.end(); ++ it) {
it->translate(shift.x(), shift.y());
it->translate(shift(0), shift(1));
it->rotate(direction.first);
}
}
@ -162,7 +162,7 @@ Pointfs FillHilbertCurve::_generate(coord_t min_x, coord_t min_y, coord_t max_x,
line.reserve(sz2);
for (size_t i = 0; i < sz2; ++ i) {
Point p = hilbert_n_to_xy(i);
line.push_back(Pointf(p.x() + min_x, p.y() + min_y));
line.push_back(Pointf(p(0) + min_x, p(1) + min_y));
}
return line;
}

View file

@ -26,7 +26,7 @@ void FillRectilinear::_fill_surface_single(
// define flow spacing according to requested density
if (params.density > 0.9999f && !params.dont_adjust) {
this->_line_spacing = this->_adjust_solid_spacing(bounding_box.size().x(), this->_line_spacing);
this->_line_spacing = this->_adjust_solid_spacing(bounding_box.size()(0), this->_line_spacing);
this->spacing = unscale(this->_line_spacing);
} else {
// extend bounding box so that our pattern will be aligned with other layers
@ -38,14 +38,14 @@ void FillRectilinear::_fill_surface_single(
}
// generate the basic pattern
coord_t x_max = bounding_box.max.x() + SCALED_EPSILON;
coord_t x_max = bounding_box.max(0) + SCALED_EPSILON;
Lines lines;
for (coord_t x = bounding_box.min.x(); x <= x_max; x += this->_line_spacing)
lines.push_back(this->_line(lines.size(), x, bounding_box.min.y(), bounding_box.max.y()));
for (coord_t x = bounding_box.min(0); x <= x_max; x += this->_line_spacing)
lines.push_back(this->_line(lines.size(), x, bounding_box.min(1), bounding_box.max(1)));
if (this->_horizontal_lines()) {
coord_t y_max = bounding_box.max.y() + SCALED_EPSILON;
for (coord_t y = bounding_box.min.y(); y <= y_max; y += this->_line_spacing)
lines.push_back(Line(Point(bounding_box.min.x(), y), Point(bounding_box.max.x(), y)));
coord_t y_max = bounding_box.max(1) + SCALED_EPSILON;
for (coord_t y = bounding_box.min(1); y <= y_max; y += this->_line_spacing)
lines.push_back(Line(Point(bounding_box.min(0), y), Point(bounding_box.max(0), y)));
}
// clip paths against a slightly larger expolygon, so that the first and last paths
@ -106,7 +106,7 @@ void FillRectilinear::_fill_surface_single(
const Vector distance = last_point - first_point;
// TODO: we should also check that both points are on a fill_boundary to avoid
// connecting paths on the boundaries of internal regions
if (this->_can_connect(std::abs(distance.x()), std::abs(distance.y())) &&
if (this->_can_connect(std::abs(distance(0)), std::abs(distance(1))) &&
expolygon_off.contains(Line(last_point, first_point))) {
// Append the polyline.
pts_end.insert(pts_end.end(), it_polyline->points.begin(), it_polyline->points.end());
@ -122,7 +122,7 @@ void FillRectilinear::_fill_surface_single(
// paths must be rotated back
for (Polylines::iterator it = polylines_out.begin() + n_polylines_out_old; it != polylines_out.end(); ++ it) {
// No need to translate, the absolute position is irrelevant.
// it->translate(- direction.second.x(), - direction.second.y());
// it->translate(- direction.second(0), - direction.second(1));
it->rotate(direction.first);
}
}

View file

@ -42,12 +42,12 @@ static inline coordf_t segment_length(const Polygon &poly, size_t seg1, const Po
Point px = (i == 0) ? p1 : p2;
Point pa = poly.points[((seg == 0) ? poly.points.size() : seg) - 1];
Point pb = poly.points[seg];
if (pa.x() > pb.x())
std::swap(pa.x(), pb.x());
if (pa.y() > pb.y())
std::swap(pa.y(), pb.y());
assert(px.x() >= pa.x() && px.x() <= pb.x());
assert(px.y() >= pa.y() && px.y() <= pb.y());
if (pa(0) > pb(0))
std::swap(pa(0), pb(0));
if (pa(1) > pb(1))
std::swap(pa(1), pb(1));
assert(px(0) >= pa(0) && px(0) <= pb(0));
assert(px(1) >= pa(1) && px(1) <= pb(1));
}
#endif /* SLIC3R_DEBUG */
const Point *pPrev = &p1;
@ -791,7 +791,7 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
// define flow spacing according to requested density
if (params.full_infill() && !params.dont_adjust) {
line_spacing = this->_adjust_solid_spacing(bounding_box.size().x(), line_spacing);
line_spacing = this->_adjust_solid_spacing(bounding_box.size()(0), line_spacing);
this->spacing = unscale(line_spacing);
} else {
// extend bounding box so that our pattern will be aligned with other layers
@ -799,7 +799,7 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
Point refpt = rotate_vector.second.rotated(- rotate_vector.first);
// _align_to_grid will not work correctly with positive pattern_shift.
coord_t pattern_shift_scaled = coord_t(scale_(pattern_shift)) % line_spacing;
refpt.x() -= (pattern_shift_scaled >= 0) ? pattern_shift_scaled : (line_spacing + pattern_shift_scaled);
refpt(0) -= (pattern_shift_scaled >= 0) ? pattern_shift_scaled : (line_spacing + pattern_shift_scaled);
bounding_box.merge(_align_to_grid(
bounding_box.min,
Point(line_spacing, line_spacing),
@ -808,8 +808,8 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
// Intersect a set of euqally spaced vertical lines wiht expolygon.
// n_vlines = ceil(bbox_width / line_spacing)
size_t n_vlines = (bounding_box.max.x() - bounding_box.min.x() + line_spacing - 1) / line_spacing;
coord_t x0 = bounding_box.min.x();
size_t n_vlines = (bounding_box.max(0) - bounding_box.min(0) + line_spacing - 1) / line_spacing;
coord_t x0 = bounding_box.min(0);
if (params.full_infill())
x0 += (line_spacing + SCALED_EPSILON) / 2;
@ -842,8 +842,8 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
const Point &p1 = contour[iPrev];
const Point &p2 = contour[iSegment];
// Which of the equally spaced vertical lines is intersected by this segment?
coord_t l = p1.x();
coord_t r = p2.x();
coord_t l = p1(0);
coord_t r = p2(0);
if (l > r)
std::swap(l, r);
// il, ir are the left / right indices of vertical lines intersecting a segment
@ -869,33 +869,33 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
assert(l <= this_x);
assert(r >= this_x);
// Calculate the intersection position in y axis. x is known.
if (p1.x() == this_x) {
if (p2.x() == this_x) {
if (p1(0) == this_x) {
if (p2(0) == this_x) {
// Ignore strictly vertical segments.
continue;
}
is.pos_p = p1.y();
is.pos_p = p1(1);
is.pos_q = 1;
} else if (p2.x() == this_x) {
is.pos_p = p2.y();
} else if (p2(0) == this_x) {
is.pos_p = p2(1);
is.pos_q = 1;
} else {
// First calculate the intersection parameter 't' as a rational number with non negative denominator.
if (p2.x() > p1.x()) {
is.pos_p = this_x - p1.x();
is.pos_q = p2.x() - p1.x();
if (p2(0) > p1(0)) {
is.pos_p = this_x - p1(0);
is.pos_q = p2(0) - p1(0);
} else {
is.pos_p = p1.x() - this_x;
is.pos_q = p1.x() - p2.x();
is.pos_p = p1(0) - this_x;
is.pos_q = p1(0) - p2(0);
}
assert(is.pos_p >= 0 && is.pos_p <= is.pos_q);
// Make an intersection point from the 't'.
is.pos_p *= int64_t(p2.y() - p1.y());
is.pos_p += p1.y() * int64_t(is.pos_q);
is.pos_p *= int64_t(p2(1) - p1(1));
is.pos_p += p1(1) * int64_t(is.pos_q);
}
// +-1 to take rounding into account.
assert(is.pos() + 1 >= std::min(p1.y(), p2.y()));
assert(is.pos() <= std::max(p1.y(), p2.y()) + 1);
assert(is.pos() + 1 >= std::min(p1(1), p2(1)));
assert(is.pos() <= std::max(p1(1), p2(1)) + 1);
segs[i].intersections.push_back(is);
}
}
@ -919,7 +919,7 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
const Points &contour = poly_with_offset.contour(iContour).points;
size_t iSegment = sil.intersections[i].iSegment;
size_t iPrev = ((iSegment == 0) ? contour.size() : iSegment) - 1;
coord_t dir = contour[iSegment].x() - contour[iPrev].x();
coord_t dir = contour[iSegment](0) - contour[iPrev](0);
bool low = dir > 0;
sil.intersections[i].type = poly_with_offset.is_contour_outer(iContour) ?
(low ? SegmentIntersection::OUTER_LOW : SegmentIntersection::OUTER_HIGH) :
@ -1066,7 +1066,7 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
intrsctn.consumed_vertical_up :
seg.intersections[i-1].consumed_vertical_up;
if (! consumed) {
coordf_t dist2 = sqr(coordf_t(pointLast.x() - seg.pos)) + sqr(coordf_t(pointLast.y() - intrsctn.pos()));
coordf_t dist2 = sqr(coordf_t(pointLast(0) - seg.pos)) + sqr(coordf_t(pointLast(1) - intrsctn.pos()));
if (dist2 < dist2min) {
dist2min = dist2;
i_vline = i_vline2;
@ -1356,8 +1356,8 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
// Handle nearly zero length edges.
if (polyline_current->points.size() <= 1 ||
(polyline_current->points.size() == 2 &&
std::abs(polyline_current->points.front().x() - polyline_current->points.back().x()) < SCALED_EPSILON &&
std::abs(polyline_current->points.front().y() - polyline_current->points.back().y()) < SCALED_EPSILON))
std::abs(polyline_current->points.front()(0) - polyline_current->points.back()(0)) < SCALED_EPSILON &&
std::abs(polyline_current->points.front()(1) - polyline_current->points.back()(1)) < SCALED_EPSILON))
polylines_out.pop_back();
intrsctn = NULL;
i_intersection = -1;
@ -1383,7 +1383,7 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
// paths must be rotated back
for (Polylines::iterator it = polylines_out.begin() + n_polylines_out_initial; it != polylines_out.end(); ++ it) {
// No need to translate, the absolute position is irrelevant.
// it->translate(- rotate_vector.second.x(), - rotate_vector.second.y());
// it->translate(- rotate_vector.second(0), - rotate_vector.second(1));
assert(! it->has_duplicate_points());
it->rotate(rotate_vector.first);
//FIXME rather simplify the paths to avoid very short edges?

View file

@ -223,24 +223,24 @@ Point SegmentIntersection::pos() const
const Pointf p2(line->pos.cast<coordf_t>());
const Pointf v2(line->dir.cast<coordf_t>());
// Intersect the two rays.
double denom = v1.x() * v2.y() - v2.x() * v1.y();
double denom = v1(0) * v2(1) - v2(0) * v1(1);
Point out;
if (denom == 0.) {
// Lines are collinear. As the pos() method is not supposed to be called on collinear vectors,
// the source vectors are not quite collinear. Return the center of the contour segment.
out = seg_start + seg_end;
out.x() >>= 1;
out.y() >>= 1;
out(0) >>= 1;
out(1) >>= 1;
} else {
// Find the intersection point.
double t = (v2.x() * (p1.y() - p2.y()) - v2.y() * (p1.x() - p2.x())) / denom;
double t = (v2(0) * (p1(1) - p2(1)) - v2(1) * (p1(0) - p2(0))) / denom;
if (t < 0.)
out = seg_start;
else if (t > 1.)
out = seg_end;
else {
out.x() = coord_t(floor(p1.x() + t * v1.x() + 0.5));
out.y() = coord_t(floor(p1.y() + t * v1.y() + 0.5));
out(0) = coord_t(floor(p1(0) + t * v1(0) + 0.5));
out(1) = coord_t(floor(p1(1) + t * v1(1) + 0.5));
}
}
return out;
@ -317,8 +317,8 @@ int SegmentIntersection::ordering_along_line(const SegmentIntersection &other) c
int64_t denom2 = cross2(this->line->dir.cast<int64_t>(), vec_b);
Vec2i64 vx_a = (seg_start_a - this->line->pos).cast<int64_t>();
Vec2i64 vx_b = (seg_start_b - this->line->pos).cast<int64_t>();
int64_t t1_times_denom1 = vx_a.x() * vec_a.y() - vx_a.y() * vec_a.x();
int64_t t2_times_denom2 = vx_b.x() * vec_b.y() - vx_b.y() * vec_b.x();
int64_t t1_times_denom1 = vx_a(0) * vec_a(1) - vx_a(1) * vec_a(0);
int64_t t2_times_denom2 = vx_b(0) * vec_b(1) - vx_b(1) * vec_b(0);
assert(denom1 != 0);
assert(denom2 != 0);
return Int128::compare_rationals_filtered(t1_times_denom1, denom1, t2_times_denom2, denom2);
@ -389,7 +389,7 @@ static bool prepare_infill_hatching_segments(
// Define the flow spacing according to requested density.
if (params.full_infill() && ! params.dont_adjust) {
// Full infill, adjust the line spacing to fit an integer number of lines.
out.line_spacing = Fill::_adjust_solid_spacing(bounding_box.size().x(), line_spacing);
out.line_spacing = Fill::_adjust_solid_spacing(bounding_box.size()(0), line_spacing);
// Report back the adjusted line spacing.
fill_dir_params.spacing = float(unscale(line_spacing));
} else {
@ -398,7 +398,7 @@ static bool prepare_infill_hatching_segments(
Point refpt = rotate_vector.second.rotated(- out.angle);
// _align_to_grid will not work correctly with positive pattern_shift.
coord_t pattern_shift_scaled = coord_t(scale_(fill_dir_params.pattern_shift)) % line_spacing;
refpt.x() -= (pattern_shift_scaled >= 0) ? pattern_shift_scaled : (line_spacing + pattern_shift_scaled);
refpt(0) -= (pattern_shift_scaled >= 0) ? pattern_shift_scaled : (line_spacing + pattern_shift_scaled);
bounding_box.merge(Fill::_align_to_grid(
bounding_box.min,
Point(line_spacing, line_spacing),
@ -407,13 +407,13 @@ static bool prepare_infill_hatching_segments(
// Intersect a set of euqally spaced vertical lines wiht expolygon.
// n_vlines = ceil(bbox_width / line_spacing)
size_t n_vlines = (bounding_box.max.x() - bounding_box.min.x() + line_spacing - 1) / line_spacing;
coord_t x0 = bounding_box.min.x();
size_t n_vlines = (bounding_box.max(0) - bounding_box.min(0) + line_spacing - 1) / line_spacing;
coord_t x0 = bounding_box.min(0);
if (params.full_infill())
x0 += coord_t((line_spacing + SCALED_EPSILON) / 2);
out.line_spacing = line_spacing;
out.start_point = Point(x0, bounding_box.min.y());
out.start_point = Point(x0, bounding_box.min(1));
out.start_point.rotate(out.angle);
#ifdef SLIC3R_DEBUG
@ -436,10 +436,10 @@ static bool prepare_infill_hatching_segments(
for (size_t i = 0; i < n_vlines; ++ i) {
auto &seg = out.segs[i];
seg.idx = i;
// seg.x() = x0 + coord_t(i) * line_spacing;
// seg(0) = x0 + coord_t(i) * line_spacing;
coord_t x = x0 + coord_t(i) * line_spacing;
seg.pos.x() = coord_t(floor(cos_a * x - sin_a * bounding_box.min.y() + 0.5));
seg.pos.y() = coord_t(floor(cos_a * bounding_box.min.y() + sin_a * x + 0.5));
seg.pos(0) = coord_t(floor(cos_a * x - sin_a * bounding_box.min(1) + 0.5));
seg.pos(1) = coord_t(floor(cos_a * bounding_box.min(1) + sin_a * x + 0.5));
seg.dir = out.direction;
}
@ -454,7 +454,7 @@ static bool prepare_infill_hatching_segments(
const Point *pr = &contour[iSegment];
// Orient the segment to the direction vector.
const Point v = *pr - *pl;
int orientation = Int128::sign_determinant_2x2_filtered(v.x(), v.y(), out.direction.x(), out.direction.y());
int orientation = Int128::sign_determinant_2x2_filtered(v(0), v(1), out.direction(0), out.direction(1));
if (orientation == 0)
// Ignore strictly vertical segments.
continue;
@ -462,8 +462,8 @@ static bool prepare_infill_hatching_segments(
// Always orient the input segment consistently towards the hatching direction.
std::swap(pl, pr);
// Which of the equally spaced vertical lines is intersected by this segment?
coord_t l = (coord_t)floor(cos_a * pl->x() + sin_a * pl->y() - SCALED_EPSILON);
coord_t r = (coord_t)ceil (cos_a * pr->x() + sin_a * pr->y() + SCALED_EPSILON);
coord_t l = (coord_t)floor(cos_a * (*pl)(0) + sin_a * (*pl)(1) - SCALED_EPSILON);
coord_t r = (coord_t)ceil (cos_a * (*pr)(0) + sin_a * (*pr)(1) + SCALED_EPSILON);
assert(l < r - SCALED_EPSILON);
// il, ir are the left / right indices of vertical lines intersecting a segment
int il = std::max<int>(0, (l - x0 + line_spacing) / line_spacing);
@ -479,9 +479,9 @@ static bool prepare_infill_hatching_segments(
// 2) all lines from il to ir intersect <pl, pr>.
assert(il >= 0 && ir < int(out.segs.size()));
for (int i = il; i <= ir; ++ i) {
// assert(out.segs[i].x() == i * line_spacing + x0);
// assert(l <= out.segs[i].x());
// assert(r >= out.segs[i].x());
// assert(out.segs[i](0) == i * line_spacing + x0);
// assert(l <= out.segs[i](0));
// assert(r >= out.segs[i](0));
SegmentIntersection is;
is.line = &out.segs[i];
is.expoly_with_offset = &poly_with_offset;
@ -491,10 +491,10 @@ static bool prepare_infill_hatching_segments(
// +-1 to take rounding into account.
assert(int128::orient(out.segs[i].pos, out.segs[i].pos + out.direction, *pl) >= 0);
assert(int128::orient(out.segs[i].pos, out.segs[i].pos + out.direction, *pr) <= 0);
assert(is.pos().x() + 1 >= std::min(pl->x(), pr->x()));
assert(is.pos().y() + 1 >= std::min(pl->y(), pr->y()));
assert(is.pos().x() <= std::max(pl->x(), pr->x()) + 1);
assert(is.pos().y() <= std::max(pl->y(), pr->y()) + 1);
assert(is.pos()(0) + 1 >= std::min((*pl)(0), (*pr)(0)));
assert(is.pos()(1) + 1 >= std::min((*pl)(1), (*pr)(1)));
assert(is.pos()(0) <= std::max((*pl)(0), (*pr)(0)) + 1);
assert(is.pos()(1) <= std::max((*pl)(1), (*pr)(1)) + 1);
out.segs[i].intersections.push_back(is);
}
}
@ -659,12 +659,12 @@ static inline coordf_t segment_length(const Polygon &poly, size_t seg1, const Po
Point px = (i == 0) ? p1 : p2;
Point pa = poly.points[((seg == 0) ? poly.points.size() : seg) - 1];
Point pb = poly.points[seg];
if (pa.x() > pb.x())
std::swap(pa.x(), pb.x());
if (pa.y() > pb.y())
std::swap(pa.y(), pb.y());
assert(px.x() >= pa.x() && px.x() <= pb.x());
assert(px.y() >= pa.y() && px.y() <= pb.y());
if (pa(0) > pb(0))
std::swap(pa(0), pb(0));
if (pa(1) > pb(1))
std::swap(pa(1), pb(1));
assert(px(0) >= pa(0) && px(0) <= pb(0));
assert(px(1) >= pa(1) && px(1) <= pb(1));
}
#endif /* SLIC3R_DEBUG */
const Point *pPrev = &p1;
@ -1481,8 +1481,8 @@ static bool fill_hatching_segments_legacy(
// Handle nearly zero length edges.
if (polyline_current->points.size() <= 1 ||
(polyline_current->points.size() == 2 &&
std::abs(polyline_current->points.front().x() - polyline_current->points.back().x()) < SCALED_EPSILON &&
std::abs(polyline_current->points.front().y() - polyline_current->points.back().y()) < SCALED_EPSILON))
std::abs(polyline_current->points.front()(0) - polyline_current->points.back()(0)) < SCALED_EPSILON &&
std::abs(polyline_current->points.front()(1) - polyline_current->points.back()(1)) < SCALED_EPSILON))
polylines_out.pop_back();
intrsctn = NULL;
i_intersection = -1;
@ -1510,7 +1510,7 @@ static bool fill_hatching_segments_legacy(
// paths must be rotated back
for (Polylines::iterator it = polylines_out.begin() + n_polylines_out_initial; it != polylines_out.end(); ++ it) {
// No need to translate, the absolute position is irrelevant.
// it->translate(- rotate_vector.second.x(), - rotate_vector.second.y());
// it->translate(- rotate_vector.second(0), - rotate_vector.second(1));
assert(! it->has_duplicate_points());
//it->rotate(rotate_vector.first);
//FIXME rather simplify the paths to avoid very short edges?