Changing the internal representation of Point / Pointf / Point3 / Pointf3 to Eigen Matrix types, first step

This commit is contained in:
bubnikv 2018-08-14 18:33:26 +02:00
parent 077680b806
commit 86da661097
60 changed files with 1228 additions and 1206 deletions

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().x();
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].x() + period, points[points.size()-n].y()));
} while (points.back().x() < width);
points.back().x() = 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.y() += offset;
point.y() = clamp(0., height, double(point.y()));
if (vertical)
std::swap(point.x, point.y);
std::swap(point.x(), point.y());
polyline.points.emplace_back(convert_to<Point>(point * scaleFactor));
}
@ -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.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())));
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].x() + points[i].x());
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].x() + points[i].x());
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().x() / distance) + 1.,
ceil(bb.size().y() / distance) + 1.);
// move pattern in place
for (Polyline &polyline : polylines)
polyline.translate(bb.min.x, bb.min.y);
polyline.translate(bb.min.x(), bb.min.y());
// clip pattern to boundaries
polylines = intersection_pl(polylines, (Polygons)expolygon);