From 65011f93827a6e10757faef3d14ee068d9da8c94 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 17 Aug 2018 15:53:43 +0200 Subject: [PATCH] Removed the x(), y(), z() Point/Pointf/Point3/Pointf3 accessors. --- .../libnest2d/libnest2d/geometry_traits.hpp | 8 +- xs/src/libslic3r/BoundingBox.cpp | 98 +++--- xs/src/libslic3r/BoundingBox.hpp | 42 +-- xs/src/libslic3r/BridgeDetector.cpp | 10 +- xs/src/libslic3r/ClipperUtils.cpp | 4 +- xs/src/libslic3r/Config.hpp | 16 +- xs/src/libslic3r/EdgeGrid.cpp | 284 +++++++++--------- xs/src/libslic3r/ExPolygon.cpp | 44 +-- xs/src/libslic3r/ExtrusionSimulator.cpp | 2 +- xs/src/libslic3r/Fill/Fill3DHoneycomb.cpp | 12 +- xs/src/libslic3r/Fill/FillBase.hpp | 4 +- xs/src/libslic3r/Fill/FillConcentric.cpp | 2 +- xs/src/libslic3r/Fill/FillGyroid.cpp | 26 +- xs/src/libslic3r/Fill/FillHoneycomb.cpp | 6 +- xs/src/libslic3r/Fill/FillPlanePath.cpp | 20 +- xs/src/libslic3r/Fill/FillRectilinear.cpp | 18 +- xs/src/libslic3r/Fill/FillRectilinear2.cpp | 62 ++-- xs/src/libslic3r/Fill/FillRectilinear3.cpp | 70 ++--- xs/src/libslic3r/Format/3mf.cpp | 6 +- xs/src/libslic3r/Format/AMF.cpp | 8 +- xs/src/libslic3r/Format/PRUS.cpp | 4 +- xs/src/libslic3r/GCode.cpp | 62 ++-- xs/src/libslic3r/GCode/CoolingBuffer.cpp | 6 +- xs/src/libslic3r/GCode/PrintExtents.cpp | 24 +- xs/src/libslic3r/GCodeWriter.cpp | 48 +-- xs/src/libslic3r/Geometry.cpp | 122 ++++---- xs/src/libslic3r/Geometry.hpp | 30 +- xs/src/libslic3r/Layer.cpp | 8 +- xs/src/libslic3r/LayerRegion.cpp | 8 +- xs/src/libslic3r/Line.cpp | 8 +- xs/src/libslic3r/Line.hpp | 4 +- xs/src/libslic3r/Model.cpp | 118 ++++---- xs/src/libslic3r/Model.hpp | 2 +- xs/src/libslic3r/MultiPoint.cpp | 38 +-- xs/src/libslic3r/Point.cpp | 72 ++--- xs/src/libslic3r/Point.hpp | 77 ++--- xs/src/libslic3r/Polygon.cpp | 32 +- xs/src/libslic3r/Polygon.hpp | 2 +- xs/src/libslic3r/Polyline.cpp | 2 +- xs/src/libslic3r/Polyline.hpp | 2 +- xs/src/libslic3r/PolylineCollection.cpp | 10 +- xs/src/libslic3r/Print.cpp | 6 +- xs/src/libslic3r/PrintConfig.cpp | 2 +- xs/src/libslic3r/PrintObject.cpp | 12 +- xs/src/libslic3r/SVG.cpp | 50 +-- xs/src/libslic3r/Slicing.cpp | 24 +- xs/src/libslic3r/SupportMaterial.cpp | 42 +-- xs/src/libslic3r/Surface.cpp | 6 +- xs/src/libslic3r/SurfaceCollection.cpp | 4 +- xs/src/libslic3r/TriangleMesh.cpp | 93 +++--- xs/src/perlglue.cpp | 14 +- xs/src/slic3r/GUI/2DBed.cpp | 64 ++-- xs/src/slic3r/GUI/3DScene.cpp | 96 +++--- xs/src/slic3r/GUI/3DScene.hpp | 20 +- xs/src/slic3r/GUI/BedShapeDialog.cpp | 20 +- xs/src/slic3r/GUI/Field.cpp | 12 +- xs/src/slic3r/GUI/GLCanvas3D.cpp | 148 ++++----- xs/src/slic3r/GUI/GLGizmo.cpp | 68 ++--- xs/xsp/BoundingBox.xsp | 50 +-- xs/xsp/Point.xsp | 42 +-- 60 files changed, 1083 insertions(+), 1111 deletions(-) diff --git a/xs/src/libnest2d/libnest2d/geometry_traits.hpp b/xs/src/libnest2d/libnest2d/geometry_traits.hpp index dbd609201..9ba6b6826 100644 --- a/xs/src/libnest2d/libnest2d/geometry_traits.hpp +++ b/xs/src/libnest2d/libnest2d/geometry_traits.hpp @@ -137,25 +137,25 @@ struct PointLike { template static TCoord x(const RawPoint& p) { - return p.x(); + return p(0); } template static TCoord y(const RawPoint& p) { - return p.y(); + return p(1); } template static TCoord& x(RawPoint& p) { - return p.x(); + return p(0); } template static TCoord& y(RawPoint& p) { - return p.y(); + return p(1); } template diff --git a/xs/src/libslic3r/BoundingBox.cpp b/xs/src/libslic3r/BoundingBox.cpp index 5efc66c2e..68136b916 100644 --- a/xs/src/libslic3r/BoundingBox.cpp +++ b/xs/src/libslic3r/BoundingBox.cpp @@ -27,14 +27,14 @@ BoundingBox::polygon(Polygon* polygon) const { polygon->points.clear(); polygon->points.resize(4); - polygon->points[0].x() = this->min.x(); - polygon->points[0].y() = this->min.y(); - polygon->points[1].x() = this->max.x(); - polygon->points[1].y() = this->min.y(); - polygon->points[2].x() = this->max.x(); - polygon->points[2].y() = this->max.y(); - polygon->points[3].x() = this->min.x(); - polygon->points[3].y() = this->max.y(); + polygon->points[0](0) = this->min(0); + polygon->points[0](1) = this->min(1); + polygon->points[1](0) = this->max(0); + polygon->points[1](1) = this->min(1); + polygon->points[2](0) = this->max(0); + polygon->points[2](1) = this->max(1); + polygon->points[3](0) = this->min(0); + polygon->points[3](1) = this->max(1); } Polygon @@ -50,8 +50,8 @@ BoundingBox BoundingBox::rotated(double angle) const BoundingBox out; out.merge(this->min.rotated(angle)); out.merge(this->max.rotated(angle)); - out.merge(Point(this->min.x(), this->max.y()).rotated(angle)); - out.merge(Point(this->max.x(), this->min.y()).rotated(angle)); + out.merge(Point(this->min(0), this->max(1)).rotated(angle)); + out.merge(Point(this->max(0), this->min(1)).rotated(angle)); return out; } @@ -60,8 +60,8 @@ BoundingBox BoundingBox::rotated(double angle, const Point ¢er) const BoundingBox out; out.merge(this->min.rotated(angle, center)); out.merge(this->max.rotated(angle, center)); - out.merge(Point(this->min.x(), this->max.y()).rotated(angle, center)); - out.merge(Point(this->max.x(), this->min.y()).rotated(angle, center)); + out.merge(Point(this->min(0), this->max(1)).rotated(angle, center)); + out.merge(Point(this->max(0), this->min(1)).rotated(angle, center)); return out; } @@ -79,10 +79,10 @@ template void BoundingBoxBase::merge(const PointClass &point) { if (this->defined) { - this->min.x() = std::min(point.x(), this->min.x()); - this->min.y() = std::min(point.y(), this->min.y()); - this->max.x() = std::max(point.x(), this->max.x()); - this->max.y() = std::max(point.y(), this->max.y()); + this->min(0) = std::min(point(0), this->min(0)); + this->min(1) = std::min(point(1), this->min(1)); + this->max(0) = std::max(point(0), this->max(0)); + this->max(1) = std::max(point(1), this->max(1)); } else { this->min = this->max = point; this->defined = true; @@ -102,13 +102,13 @@ template void BoundingBoxBase::merge(const Pointfs &points); template void BoundingBoxBase::merge(const BoundingBoxBase &bb) { - assert(bb.defined || bb.min.x() >= bb.max.x() || bb.min.y() >= bb.max.y()); + assert(bb.defined || bb.min(0) >= bb.max(0) || bb.min(1) >= bb.max(1)); if (bb.defined) { if (this->defined) { - this->min.x() = std::min(bb.min.x(), this->min.x()); - this->min.y() = std::min(bb.min.y(), this->min.y()); - this->max.x() = std::max(bb.max.x(), this->max.x()); - this->max.y() = std::max(bb.max.y(), this->max.y()); + this->min(0) = std::min(bb.min(0), this->min(0)); + this->min(1) = std::min(bb.min(1), this->min(1)); + this->max(0) = std::max(bb.max(0), this->max(0)); + this->max(1) = std::max(bb.max(1), this->max(1)); } else { this->min = bb.min; this->max = bb.max; @@ -123,8 +123,8 @@ template void BoundingBox3Base::merge(const PointClass &point) { if (this->defined) { - this->min.z() = std::min(point.z(), this->min.z()); - this->max.z() = std::max(point.z(), this->max.z()); + this->min(2) = std::min(point(2), this->min(2)); + this->max(2) = std::max(point(2), this->max(2)); } BoundingBoxBase::merge(point); } @@ -140,11 +140,11 @@ template void BoundingBox3Base::merge(const Pointf3s &points); template void BoundingBox3Base::merge(const BoundingBox3Base &bb) { - assert(bb.defined || bb.min.x() >= bb.max.x() || bb.min.y() >= bb.max.y() || bb.min.z() >= bb.max.z()); + assert(bb.defined || bb.min(0) >= bb.max(0) || bb.min(1) >= bb.max(1) || bb.min(2) >= bb.max(2)); if (bb.defined) { if (this->defined) { - this->min.z() = std::min(bb.min.z(), this->min.z()); - this->max.z() = std::max(bb.max.z(), this->max.z()); + this->min(2) = std::min(bb.min(2), this->min(2)); + this->max(2) = std::max(bb.max(2), this->max(2)); } BoundingBoxBase::merge(bb); } @@ -154,7 +154,7 @@ template void BoundingBox3Base::merge(const BoundingBox3Base & template PointClass BoundingBoxBase::size() const { - return PointClass(this->max.x() - this->min.x(), this->max.y() - this->min.y()); + return PointClass(this->max(0) - this->min(0), this->max(1) - this->min(1)); } template Point BoundingBoxBase::size() const; template Pointf BoundingBoxBase::size() const; @@ -162,15 +162,15 @@ template Pointf BoundingBoxBase::size() const; template PointClass BoundingBox3Base::size() const { - return PointClass(this->max.x() - this->min.x(), this->max.y() - this->min.y(), this->max.z() - this->min.z()); + return PointClass(this->max(0) - this->min(0), this->max(1) - this->min(1), this->max(2) - this->min(2)); } template Pointf3 BoundingBox3Base::size() const; template double BoundingBoxBase::radius() const { assert(this->defined); - double x = this->max.x() - this->min.x(); - double y = this->max.y() - this->min.y(); + double x = this->max(0) - this->min(0); + double y = this->max(1) - this->min(1); return 0.5 * sqrt(x*x+y*y); } template double BoundingBoxBase::radius() const; @@ -178,9 +178,9 @@ template double BoundingBoxBase::radius() const; template double BoundingBox3Base::radius() const { - double x = this->max.x() - this->min.x(); - double y = this->max.y() - this->min.y(); - double z = this->max.z() - this->min.z(); + double x = this->max(0) - this->min(0); + double y = this->max(1) - this->min(1); + double z = this->max(2) - this->min(2); return 0.5 * sqrt(x*x+y*y+z*z); } template double BoundingBox3Base::radius() const; @@ -208,8 +208,8 @@ template PointClass BoundingBoxBase::center() const { return PointClass( - (this->max.x() + this->min.x())/2, - (this->max.y() + this->min.y())/2 + (this->max(0) + this->min(0))/2, + (this->max(1) + this->min(1))/2 ); } template Point BoundingBoxBase::center() const; @@ -219,9 +219,9 @@ template PointClass BoundingBox3Base::center() const { return PointClass( - (this->max.x() + this->min.x())/2, - (this->max.y() + this->min.y())/2, - (this->max.z() + this->min.z())/2 + (this->max(0) + this->min(0))/2, + (this->max(1) + this->min(1))/2, + (this->max(2) + this->min(2))/2 ); } template Pointf3 BoundingBox3Base::center() const; @@ -230,7 +230,7 @@ template coordf_t BoundingBox3Base::max_size() const { PointClass s = size(); - return std::max(s.x(), std::max(s.y(), s.z())); + return std::max(s(0), std::max(s(1), s(2))); } template coordf_t BoundingBox3Base::max_size() const; @@ -250,8 +250,8 @@ static inline coord_t _align_to_grid(const coord_t coord, const coord_t spacing) void BoundingBox::align_to_grid(const coord_t cell_size) { if (this->defined) { - min.x() = _align_to_grid(min.x(), cell_size); - min.y() = _align_to_grid(min.y(), cell_size); + min(0) = _align_to_grid(min(0), cell_size); + min(1) = _align_to_grid(min(1), cell_size); } } @@ -259,14 +259,14 @@ BoundingBoxf3 BoundingBoxf3::transformed(const Transform3f& matrix) const { Eigen::Matrix vertices; - vertices(0, 0) = (float)min.x(); vertices(1, 0) = (float)min.y(); vertices(2, 0) = (float)min.z(); - vertices(0, 1) = (float)max.x(); vertices(1, 1) = (float)min.y(); vertices(2, 1) = (float)min.z(); - vertices(0, 2) = (float)max.x(); vertices(1, 2) = (float)max.y(); vertices(2, 2) = (float)min.z(); - vertices(0, 3) = (float)min.x(); vertices(1, 3) = (float)max.y(); vertices(2, 3) = (float)min.z(); - vertices(0, 4) = (float)min.x(); vertices(1, 4) = (float)min.y(); vertices(2, 4) = (float)max.z(); - vertices(0, 5) = (float)max.x(); vertices(1, 5) = (float)min.y(); vertices(2, 5) = (float)max.z(); - vertices(0, 6) = (float)max.x(); vertices(1, 6) = (float)max.y(); vertices(2, 6) = (float)max.z(); - vertices(0, 7) = (float)min.x(); vertices(1, 7) = (float)max.y(); vertices(2, 7) = (float)max.z(); + vertices(0, 0) = (float)min(0); vertices(1, 0) = (float)min(1); vertices(2, 0) = (float)min(2); + vertices(0, 1) = (float)max(0); vertices(1, 1) = (float)min(1); vertices(2, 1) = (float)min(2); + vertices(0, 2) = (float)max(0); vertices(1, 2) = (float)max(1); vertices(2, 2) = (float)min(2); + vertices(0, 3) = (float)min(0); vertices(1, 3) = (float)max(1); vertices(2, 3) = (float)min(2); + vertices(0, 4) = (float)min(0); vertices(1, 4) = (float)min(1); vertices(2, 4) = (float)max(2); + vertices(0, 5) = (float)max(0); vertices(1, 5) = (float)min(1); vertices(2, 5) = (float)max(2); + vertices(0, 6) = (float)max(0); vertices(1, 6) = (float)max(1); vertices(2, 6) = (float)max(2); + vertices(0, 7) = (float)min(0); vertices(1, 7) = (float)max(1); vertices(2, 7) = (float)max(2); Eigen::Matrix transf_vertices = matrix * vertices.colwise().homogeneous(); diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp index d4c9fde88..d09658774 100644 --- a/xs/src/libslic3r/BoundingBox.hpp +++ b/xs/src/libslic3r/BoundingBox.hpp @@ -22,23 +22,23 @@ public: BoundingBoxBase() : defined(false) {}; BoundingBoxBase(const PointClass &pmin, const PointClass &pmax) : - min(pmin), max(pmax), defined(pmin.x() < pmax.x() && pmin.y() < pmax.y()) {} + min(pmin), max(pmax), defined(pmin(0) < pmax(0) && pmin(1) < pmax(1)) {} BoundingBoxBase(const std::vector& points) { if (points.empty()) CONFESS("Empty point set supplied to BoundingBoxBase constructor"); typename std::vector::const_iterator it = points.begin(); - this->min.x() = this->max.x() = it->x(); - this->min.y() = this->max.y() = it->y(); + this->min(0) = this->max(0) = (*it)(0); + this->min(1) = this->max(1) = (*it)(1); for (++it; it != points.end(); ++it) { - this->min.x() = std::min(it->x(), this->min.x()); - this->min.y() = std::min(it->y(), this->min.y()); - this->max.x() = std::max(it->x(), this->max.x()); - this->max.y() = std::max(it->y(), this->max.y()); + this->min(0) = std::min((*it)(0), this->min(0)); + this->min(1) = std::min((*it)(1), this->min(1)); + this->max(0) = std::max((*it)(0), this->max(0)); + this->max(1) = std::max((*it)(1), this->max(1)); } - this->defined = (this->min.x() < this->max.x()) && (this->min.y() < this->max.y()); + this->defined = (this->min(0) < this->max(0)) && (this->min(1) < this->max(1)); } void merge(const PointClass &point); void merge(const std::vector &points); @@ -51,12 +51,12 @@ public: void offset(coordf_t delta); PointClass center() const; bool contains(const PointClass &point) const { - return point.x() >= this->min.x() && point.x() <= this->max.x() - && point.y() >= this->min.y() && point.y() <= this->max.y(); + return point(0) >= this->min(0) && point(0) <= this->max(0) + && point(1) >= this->min(1) && point(1) <= this->max(1); } bool overlap(const BoundingBoxBase &other) const { - return ! (this->max.x() < other.min.x() || this->min.x() > other.max.x() || - this->max.y() < other.min.y() || this->min.y() > other.max.y()); + return ! (this->max(0) < other.min(0) || this->min(0) > other.max(0) || + this->max(1) < other.min(1) || this->min(1) > other.max(1)); } bool operator==(const BoundingBoxBase &rhs) { return this->min == rhs.min && this->max == rhs.max; } bool operator!=(const BoundingBoxBase &rhs) { return ! (*this == rhs); } @@ -69,7 +69,7 @@ public: BoundingBox3Base() : BoundingBoxBase() {}; BoundingBox3Base(const PointClass &pmin, const PointClass &pmax) : BoundingBoxBase(pmin, pmax) - { if (pmin.z() >= pmax.z()) BoundingBoxBase::defined = false; } + { if (pmin(2) >= pmax(2)) BoundingBoxBase::defined = false; } BoundingBox3Base(const std::vector& points) : BoundingBoxBase(points) { @@ -77,13 +77,13 @@ public: CONFESS("Empty point set supplied to BoundingBox3Base constructor"); typename std::vector::const_iterator it = points.begin(); - this->min.z() = this->max.z() = it->z(); + this->min(2) = this->max(2) = (*it)(2); for (++it; it != points.end(); ++it) { - this->min.z() = std::min(it->z(), this->min.z()); - this->max.z() = std::max(it->z(), this->max.z()); + this->min(2) = std::min((*it)(2), this->min(2)); + this->max(2) = std::max((*it)(2), this->max(2)); } - this->defined &= (this->min.z() < this->max.z()); + this->defined &= (this->min(2) < this->max(2)); } void merge(const PointClass &point); void merge(const std::vector &points); @@ -97,7 +97,7 @@ public: coordf_t max_size() const; bool contains(const PointClass &point) const { - return BoundingBoxBase::contains(point) && point.z() >= this->min.z() && point.z() <= this->max.z(); + return BoundingBoxBase::contains(point) && point(2) >= this->min(2) && point(2) <= this->max(2); } bool contains(const BoundingBox3Base& other) const { @@ -105,7 +105,7 @@ public: } bool intersects(const BoundingBox3Base& other) const { - return (this->min.x() < other.max.x()) && (this->max.x() > other.min.x()) && (this->min.y() < other.max.y()) && (this->max.y() > other.min.y()) && (this->min.z() < other.max.z()) && (this->max.z() > other.min.z()); + return (this->min(0) < other.max(0)) && (this->max(0) > other.min(0)) && (this->min(1) < other.max(1)) && (this->max(1) > other.min(1)) && (this->min(2) < other.max(2)) && (this->max(2) > other.min(2)); } }; @@ -159,13 +159,13 @@ public: template inline bool empty(const BoundingBoxBase &bb) { - return ! bb.defined || bb.min.x() >= bb.max.x() || bb.min.y() >= bb.max.y(); + return ! bb.defined || bb.min(0) >= bb.max(0) || bb.min(1) >= bb.max(1); } template inline bool empty(const BoundingBox3Base &bb) { - return ! bb.defined || bb.min.x() >= bb.max.x() || bb.min.y() >= bb.max.y() || bb.min.z() >= bb.max.z(); + return ! bb.defined || bb.min(0) >= bb.max(0) || bb.min(1) >= bb.max(1) || bb.min(2) >= bb.max(2); } } // namespace Slic3r diff --git a/xs/src/libslic3r/BridgeDetector.cpp b/xs/src/libslic3r/BridgeDetector.cpp index 622223a64..ccc3505ce 100644 --- a/xs/src/libslic3r/BridgeDetector.cpp +++ b/xs/src/libslic3r/BridgeDetector.cpp @@ -102,16 +102,16 @@ bool BridgeDetector::detect_angle(double bridge_direction_override) // Get an oriented bounding box around _anchor_regions. BoundingBox bbox = get_extents_rotated(this->_anchor_regions, - angle); // Cover the region with line segments. - lines.reserve((bbox.max.y() - bbox.min.y() + this->spacing) / this->spacing); + lines.reserve((bbox.max(1) - bbox.min(1) + this->spacing) / this->spacing); double s = sin(angle); double c = cos(angle); //FIXME Vojtech: The lines shall be spaced half the line width from the edge, but then // some of the test cases fail. Need to adjust the test cases then? -// for (coord_t y = bbox.min.y() + this->spacing / 2; y <= bbox.max.y(); y += this->spacing) - for (coord_t y = bbox.min.y(); y <= bbox.max.y(); y += this->spacing) +// for (coord_t y = bbox.min(1) + this->spacing / 2; y <= bbox.max(1); y += this->spacing) + for (coord_t y = bbox.min(1); y <= bbox.max(1); y += this->spacing) lines.push_back(Line( - Point((coord_t)round(c * bbox.min.x() - s * y), (coord_t)round(c * y + s * bbox.min.x())), - Point((coord_t)round(c * bbox.max.x() - s * y), (coord_t)round(c * y + s * bbox.max.x())))); + Point((coord_t)round(c * bbox.min(0) - s * y), (coord_t)round(c * y + s * bbox.min(0))), + Point((coord_t)round(c * bbox.max(0) - s * y), (coord_t)round(c * y + s * bbox.max(0))))); } double total_length = 0; diff --git a/xs/src/libslic3r/ClipperUtils.cpp b/xs/src/libslic3r/ClipperUtils.cpp index b18132733..f00e908ce 100644 --- a/xs/src/libslic3r/ClipperUtils.cpp +++ b/xs/src/libslic3r/ClipperUtils.cpp @@ -171,7 +171,7 @@ Slic3rMultiPoint_to_ClipperPath(const MultiPoint &input) { ClipperLib::Path retval; for (Points::const_iterator pit = input.points.begin(); pit != input.points.end(); ++pit) - retval.push_back(ClipperLib::IntPoint( (*pit).x(), (*pit).y() )); + retval.push_back(ClipperLib::IntPoint( (*pit)(0), (*pit)(1) )); return retval; } @@ -181,7 +181,7 @@ Slic3rMultiPoint_to_ClipperPath_reversed(const Slic3r::MultiPoint &input) ClipperLib::Path output; output.reserve(input.points.size()); for (Slic3r::Points::const_reverse_iterator pit = input.points.rbegin(); pit != input.points.rend(); ++pit) - output.push_back(ClipperLib::IntPoint( (*pit).x(), (*pit).y() )); + output.push_back(ClipperLib::IntPoint( (*pit)(0), (*pit)(1) )); return output; } diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 23ea3622f..ef54b1264 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -637,9 +637,9 @@ public: std::string serialize() const override { std::ostringstream ss; - ss << this->value.x(); + ss << this->value(0); ss << ","; - ss << this->value.y(); + ss << this->value(1); return ss.str(); } @@ -647,8 +647,8 @@ public: { UNUSED(append); char dummy; - return sscanf(str.data(), " %lf , %lf %c", &this->value.x(), &this->value.y(), &dummy) == 2 || - sscanf(str.data(), " %lf x %lf %c", &this->value.x(), &this->value.y(), &dummy) == 2; + return sscanf(str.data(), " %lf , %lf %c", &this->value(0), &this->value(1), &dummy) == 2 || + sscanf(str.data(), " %lf x %lf %c", &this->value(0), &this->value(1), &dummy) == 2; } }; @@ -671,9 +671,9 @@ public: std::ostringstream ss; for (Pointfs::const_iterator it = this->values.begin(); it != this->values.end(); ++it) { if (it - this->values.begin() != 0) ss << ","; - ss << it->x(); + ss << (*it)(0); ss << "x"; - ss << it->y(); + ss << (*it)(1); } return ss.str(); } @@ -700,9 +700,9 @@ public: std::istringstream iss(point_str); std::string coord_str; if (std::getline(iss, coord_str, 'x')) { - std::istringstream(coord_str) >> point.x(); + std::istringstream(coord_str) >> point(0); if (std::getline(iss, coord_str, 'x')) { - std::istringstream(coord_str) >> point.y(); + std::istringstream(coord_str) >> point(1); } } this->values.push_back(point); diff --git a/xs/src/libslic3r/EdgeGrid.cpp b/xs/src/libslic3r/EdgeGrid.cpp index 5a9363f40..50f424e6d 100644 --- a/xs/src/libslic3r/EdgeGrid.cpp +++ b/xs/src/libslic3r/EdgeGrid.cpp @@ -117,15 +117,15 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) m_bbox.merge(pts[j]); } coord_t eps = 16; - m_bbox.min.x() -= eps; - m_bbox.min.y() -= eps; - m_bbox.max.x() += eps; - m_bbox.max.y() += eps; + m_bbox.min(0) -= eps; + m_bbox.min(1) -= eps; + m_bbox.max(0) += eps; + m_bbox.max(1) += eps; // 2) Initialize the edge grid. m_resolution = resolution; - m_cols = (m_bbox.max.x() - m_bbox.min.x() + m_resolution - 1) / m_resolution; - m_rows = (m_bbox.max.y() - m_bbox.min.y() + m_resolution - 1) / m_resolution; + m_cols = (m_bbox.max(0) - m_bbox.min(0) + m_resolution - 1) / m_resolution; + m_rows = (m_bbox.max(1) - m_bbox.min(1) + m_resolution - 1) / m_resolution; m_cells.assign(m_rows * m_cols, Cell()); // 3) First round of contour rasterization, count the edges per grid cell. @@ -135,15 +135,15 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) // End points of the line segment. Slic3r::Point p1(pts[j]); Slic3r::Point p2 = pts[(j + 1 == pts.size()) ? 0 : j + 1]; - p1.x() -= m_bbox.min.x(); - p1.y() -= m_bbox.min.y(); - p2.x() -= m_bbox.min.x(); - p2.y() -= m_bbox.min.y(); + p1(0) -= m_bbox.min(0); + p1(1) -= m_bbox.min(1); + p2(0) -= m_bbox.min(0); + p2(1) -= m_bbox.min(1); // Get the cells of the end points. - coord_t ix = p1.x() / m_resolution; - coord_t iy = p1.y() / m_resolution; - coord_t ixb = p2.x() / m_resolution; - coord_t iyb = p2.y() / m_resolution; + coord_t ix = p1(0) / m_resolution; + coord_t iy = p1(1) / m_resolution; + coord_t ixb = p2(0) / m_resolution; + coord_t iyb = p2(1) / m_resolution; assert(ix >= 0 && ix < m_cols); assert(iy >= 0 && iy < m_rows); assert(ixb >= 0 && ixb < m_cols); @@ -154,13 +154,13 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) // Both ends fall into the same cell. continue; // Raster the centeral part of the line. - coord_t dx = std::abs(p2.x() - p1.x()); - coord_t dy = std::abs(p2.y() - p1.y()); - if (p1.x() < p2.x()) { - int64_t ex = int64_t((ix + 1)*m_resolution - p1.x()) * int64_t(dy); - if (p1.y() < p2.y()) { + coord_t dx = std::abs(p2(0) - p1(0)); + coord_t dy = std::abs(p2(1) - p1(1)); + if (p1(0) < p2(0)) { + int64_t ex = int64_t((ix + 1)*m_resolution - p1(0)) * int64_t(dy); + if (p1(1) < p2(1)) { // x positive, y positive - int64_t ey = int64_t((iy + 1)*m_resolution - p1.y()) * int64_t(dx); + int64_t ey = int64_t((iy + 1)*m_resolution - p1(1)) * int64_t(dx); do { assert(ix <= ixb && iy <= iyb); if (ex < ey) { @@ -185,7 +185,7 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) } else { // x positive, y non positive - int64_t ey = int64_t(p1.y() - iy*m_resolution) * int64_t(dx); + int64_t ey = int64_t(p1(1) - iy*m_resolution) * int64_t(dx); do { assert(ix <= ixb && iy >= iyb); if (ex <= ey) { @@ -203,10 +203,10 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) } } else { - int64_t ex = int64_t(p1.x() - ix*m_resolution) * int64_t(dy); - if (p1.y() < p2.y()) { + int64_t ex = int64_t(p1(0) - ix*m_resolution) * int64_t(dy); + if (p1(1) < p2(1)) { // x non positive, y positive - int64_t ey = int64_t((iy + 1)*m_resolution - p1.y()) * int64_t(dx); + int64_t ey = int64_t((iy + 1)*m_resolution - p1(1)) * int64_t(dx); do { assert(ix >= ixb && iy <= iyb); if (ex < ey) { @@ -225,7 +225,7 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) } else { // x non positive, y non positive - int64_t ey = int64_t(p1.y() - iy*m_resolution) * int64_t(dx); + int64_t ey = int64_t(p1(1) - iy*m_resolution) * int64_t(dx); do { assert(ix >= ixb && iy >= iyb); if (ex < ey) { @@ -279,15 +279,15 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) // End points of the line segment. Slic3r::Point p1(pts[j]); Slic3r::Point p2 = pts[(j + 1 == pts.size()) ? 0 : j + 1]; - p1.x() -= m_bbox.min.x(); - p1.y() -= m_bbox.min.y(); - p2.x() -= m_bbox.min.x(); - p2.y() -= m_bbox.min.y(); + p1(0) -= m_bbox.min(0); + p1(1) -= m_bbox.min(1); + p2(0) -= m_bbox.min(0); + p2(1) -= m_bbox.min(1); // Get the cells of the end points. - coord_t ix = p1.x() / m_resolution; - coord_t iy = p1.y() / m_resolution; - coord_t ixb = p2.x() / m_resolution; - coord_t iyb = p2.y() / m_resolution; + coord_t ix = p1(0) / m_resolution; + coord_t iy = p1(1) / m_resolution; + coord_t ixb = p2(0) / m_resolution; + coord_t iyb = p2(1) / m_resolution; assert(ix >= 0 && ix < m_cols); assert(iy >= 0 && iy < m_rows); assert(ixb >= 0 && ixb < m_cols); @@ -298,13 +298,13 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) // Both ends fall into the same cell. continue; // Raster the centeral part of the line. - coord_t dx = std::abs(p2.x() - p1.x()); - coord_t dy = std::abs(p2.y() - p1.y()); - if (p1.x() < p2.x()) { - int64_t ex = int64_t((ix + 1)*m_resolution - p1.x()) * int64_t(dy); - if (p1.y() < p2.y()) { + coord_t dx = std::abs(p2(0) - p1(0)); + coord_t dy = std::abs(p2(1) - p1(1)); + if (p1(0) < p2(0)) { + int64_t ex = int64_t((ix + 1)*m_resolution - p1(0)) * int64_t(dy); + if (p1(1) < p2(1)) { // x positive, y positive - int64_t ey = int64_t((iy + 1)*m_resolution - p1.y()) * int64_t(dx); + int64_t ey = int64_t((iy + 1)*m_resolution - p1(1)) * int64_t(dx); do { assert(ix <= ixb && iy <= iyb); if (ex < ey) { @@ -329,7 +329,7 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) } else { // x positive, y non positive - int64_t ey = int64_t(p1.y() - iy*m_resolution) * int64_t(dx); + int64_t ey = int64_t(p1(1) - iy*m_resolution) * int64_t(dx); do { assert(ix <= ixb && iy >= iyb); if (ex <= ey) { @@ -347,10 +347,10 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) } } else { - int64_t ex = int64_t(p1.x() - ix*m_resolution) * int64_t(dy); - if (p1.y() < p2.y()) { + int64_t ex = int64_t(p1(0) - ix*m_resolution) * int64_t(dy); + if (p1(1) < p2(1)) { // x non positive, y positive - int64_t ey = int64_t((iy + 1)*m_resolution - p1.y()) * int64_t(dx); + int64_t ey = int64_t((iy + 1)*m_resolution - p1(1)) * int64_t(dx); do { assert(ix >= ixb && iy <= iyb); if (ex < ey) { @@ -369,7 +369,7 @@ void EdgeGrid::Grid::create_from_m_contours(coord_t resolution) } else { // x non positive, y non positive - int64_t ey = int64_t(p1.y() - iy*m_resolution) * int64_t(dx); + int64_t ey = int64_t(p1(1) - iy*m_resolution) * int64_t(dx); do { assert(ix >= ixb && iy >= iyb); if (ex < ey) { @@ -429,15 +429,15 @@ bool EdgeGrid::Grid::intersect(const MultiPoint &polyline, bool closed) Point p1 = p1src; Point p2 = p2src; // Discretize the line segment p1, p2. - p1.x() -= m_bbox.min.x(); - p1.y() -= m_bbox.min.y(); - p2.x() -= m_bbox.min.x(); - p2.y() -= m_bbox.min.y(); + p1(0) -= m_bbox.min(0); + p1(1) -= m_bbox.min(1); + p2(0) -= m_bbox.min(0); + p2(1) -= m_bbox.min(1); // Get the cells of the end points. - coord_t ix = div_floor(p1.x(), m_resolution); - coord_t iy = div_floor(p1.y(), m_resolution); - coord_t ixb = div_floor(p2.x(), m_resolution); - coord_t iyb = div_floor(p2.y(), m_resolution); + coord_t ix = div_floor(p1(0), m_resolution); + coord_t iy = div_floor(p1(1), m_resolution); + coord_t ixb = div_floor(p2(0), m_resolution); + coord_t iyb = div_floor(p2(1), m_resolution); // assert(ix >= 0 && ix < m_cols); // assert(iy >= 0 && iy < m_rows); // assert(ixb >= 0 && ixb < m_cols); @@ -449,12 +449,12 @@ bool EdgeGrid::Grid::intersect(const MultiPoint &polyline, bool closed) // Both ends fall into the same cell. continue; // Raster the centeral part of the line. - coord_t dx = std::abs(p2.x() - p1.x()); - coord_t dy = std::abs(p2.y() - p1.y()); - if (p1.x() < p2.x()) { - int64_t ex = int64_t((ix + 1)*m_resolution - p1.x()) * int64_t(dy); - if (p1.y() < p2.y()) { - int64_t ey = int64_t((iy + 1)*m_resolution - p1.y()) * int64_t(dx); + coord_t dx = std::abs(p2(0) - p1(0)); + coord_t dy = std::abs(p2(1) - p1(1)); + if (p1(0) < p2(0)) { + int64_t ex = int64_t((ix + 1)*m_resolution - p1(0)) * int64_t(dy); + if (p1(1) < p2(1)) { + int64_t ey = int64_t((iy + 1)*m_resolution - p1(1)) * int64_t(dx); do { assert(ix <= ixb && iy <= iyb); if (ex < ey) { @@ -479,7 +479,7 @@ bool EdgeGrid::Grid::intersect(const MultiPoint &polyline, bool closed) } while (ix != ixb || iy != iyb); } else { - int64_t ey = int64_t(p1.y() - iy*m_resolution) * int64_t(dx); + int64_t ey = int64_t(p1(1) - iy*m_resolution) * int64_t(dx); do { assert(ix <= ixb && iy >= iyb); if (ex <= ey) { @@ -498,9 +498,9 @@ bool EdgeGrid::Grid::intersect(const MultiPoint &polyline, bool closed) } } else { - int64_t ex = int64_t(p1.x() - ix*m_resolution) * int64_t(dy); - if (p1.y() < p2.y()) { - int64_t ey = int64_t((iy + 1)*m_resolution - p1.y()) * int64_t(dx); + int64_t ex = int64_t(p1(0) - ix*m_resolution) * int64_t(dy); + if (p1(1) < p2(1)) { + int64_t ey = int64_t((iy + 1)*m_resolution - p1(1)) * int64_t(dx); do { assert(ix >= ixb && iy <= iyb); if (ex < ey) { @@ -519,7 +519,7 @@ bool EdgeGrid::Grid::intersect(const MultiPoint &polyline, bool closed) } while (ix != ixb || iy != iyb); } else { - int64_t ey = int64_t(p1.y() - iy*m_resolution) * int64_t(dx); + int64_t ey = int64_t(p1(1) - iy*m_resolution) * int64_t(dx); do { assert(ix >= ixb && iy >= iyb); if (ex < ey) { @@ -556,8 +556,8 @@ bool EdgeGrid::Grid::line_cell_intersect(const Point &p1a, const Point &p2a, con { BoundingBox bbox(p1a, p1a); bbox.merge(p2a); - int64_t va_x = p2a.x() - p1a.x(); - int64_t va_y = p2a.y() - p1a.y(); + int64_t va_x = p2a(0) - p1a(0); + int64_t va_y = p2a(1) - p1a(1); for (size_t i = cell.begin; i != cell.end; ++ i) { const std::pair &cell_data = m_cell_data[i]; // Contour indexed by the ith line of this cell. @@ -576,21 +576,21 @@ bool EdgeGrid::Grid::line_cell_intersect(const Point &p1a, const Point &p2a, con if (! bbox.overlap(bbox2)) continue; // Now intersect the two line segments using exact arithmetics. - int64_t w1_x = p1b.x() - p1a.x(); - int64_t w1_y = p1b.y() - p1a.y(); - int64_t w2_x = p2b.x() - p1a.x(); - int64_t w2_y = p2b.y() - p1a.y(); + int64_t w1_x = p1b(0) - p1a(0); + int64_t w1_y = p1b(1) - p1a(1); + int64_t w2_x = p2b(0) - p1a(0); + int64_t w2_y = p2b(1) - p1a(1); int64_t side1 = va_x * w1_y - va_y * w1_x; int64_t side2 = va_x * w2_y - va_y * w2_x; if (side1 == side2 && side1 != 0) // The line segments don't intersect. continue; - w1_x = p1a.x() - p1b.x(); - w1_y = p1a.y() - p1b.y(); - w2_x = p2a.x() - p1b.x(); - w2_y = p2a.y() - p1b.y(); - int64_t vb_x = p2b.x() - p1b.x(); - int64_t vb_y = p2b.y() - p1b.y(); + w1_x = p1a(0) - p1b(0); + w1_y = p1a(1) - p1b(1); + w2_x = p2a(0) - p1b(0); + w2_y = p2a(1) - p1b(1); + int64_t vb_x = p2b(0) - p1b(0); + int64_t vb_y = p2b(1) - p1b(1); side1 = vb_x * w1_y - vb_y * w1_x; side2 = vb_x * w2_y - vb_y * w2_x; if (side1 == side2 && side1 != 0) @@ -607,13 +607,13 @@ bool EdgeGrid::Grid::line_cell_intersect(const Point &p1a, const Point &p2a, con bool EdgeGrid::Grid::inside(const Point &pt_src) { Point p = pt_src; - p.x() -= m_bbox.min.x(); - p.y() -= m_bbox.min.y(); + p(0) -= m_bbox.min(0); + p(1) -= m_bbox.min(1); // Get the cell of the point. - if (p.x() < 0 || p.y() < 0) + if (p(0) < 0 || p(1) < 0) return false; - coord_t ix = p.x() / m_resolution; - coord_t iy = p.y() / m_resolution; + coord_t ix = p(0) / m_resolution; + coord_t iy = p(1) / m_resolution; if (ix >= this->m_cols || iy >= this->m_rows) return false; @@ -634,21 +634,21 @@ bool EdgeGrid::Grid::inside(const Point &pt_src) idx2 = 0; const Point &p1 = contour[idx1]; const Point &p2 = contour[idx2]; - if (p1.y() < p2.y()) { - if (p.y() < p1.y() || p.y() > p2.y()) + if (p1(1) < p2(1)) { + if (p(1) < p1(1) || p(1) > p2(1)) continue; //FIXME finish this! int64_t vx = 0;// pt_src //FIXME finish this! int64_t det = 0; - } else if (p1.y() != p2.y()) { - assert(p1.y() > p2.y()); - if (p.y() < p2.y() || p.y() > p1.y()) + } else if (p1(1) != p2(1)) { + assert(p1(1) > p2(1)); + if (p(1) < p2(1) || p(1) > p1(1)) continue; } else { - assert(p1.y() == p2.y()); - if (p1.y() == p.y()) { - if (p.x() >= p1.x() && p.x() <= p2.x()) + assert(p1(1) == p2(1)); + if (p1(1) == p(1)) { + if (p(0) >= p1(0) && p(0) <= p2(0)) // On the segment. return true; // Before or after the segment. @@ -769,7 +769,7 @@ void EdgeGrid::Grid::calculate_sdf() // Segment vector const Slic3r::Point v_seg = p2 - p1; // l2 of v_seg - const int64_t l2_seg = int64_t(v_seg.x()) * int64_t(v_seg.x()) + int64_t(v_seg.y()) * int64_t(v_seg.y()); + const int64_t l2_seg = int64_t(v_seg(0)) * int64_t(v_seg(0)) + int64_t(v_seg(1)) * int64_t(v_seg(1)); // For each corner of this cell and its 1 ring neighbours: for (int corner_y = -1; corner_y < 3; ++ corner_y) { coord_t corner_r = r + corner_y; @@ -780,28 +780,28 @@ void EdgeGrid::Grid::calculate_sdf() if (corner_c < 0 || corner_c >= ncols) continue; float &d_min = m_signed_distance_field[corner_r * ncols + corner_c]; - Slic3r::Point pt(m_bbox.min.x() + corner_c * m_resolution, m_bbox.min.y() + corner_r * m_resolution); + Slic3r::Point pt(m_bbox.min(0) + corner_c * m_resolution, m_bbox.min(1) + corner_r * m_resolution); Slic3r::Point v_pt = pt - p1; // dot(p2-p1, pt-p1) - int64_t t_pt = int64_t(v_seg.x()) * int64_t(v_pt.x()) + int64_t(v_seg.y()) * int64_t(v_pt.y()); + int64_t t_pt = int64_t(v_seg(0)) * int64_t(v_pt(0)) + int64_t(v_seg(1)) * int64_t(v_pt(1)); if (t_pt < 0) { // Closest to p1. - double dabs = sqrt(int64_t(v_pt.x()) * int64_t(v_pt.x()) + int64_t(v_pt.y()) * int64_t(v_pt.y())); + double dabs = sqrt(int64_t(v_pt(0)) * int64_t(v_pt(0)) + int64_t(v_pt(1)) * int64_t(v_pt(1))); if (dabs < d_min) { // Previous point. const Slic3r::Point &p0 = pts[(ipt == 0) ? (pts.size() - 1) : ipt - 1]; Slic3r::Point v_seg_prev = p1 - p0; - int64_t t2_pt = int64_t(v_seg_prev.x()) * int64_t(v_pt.x()) + int64_t(v_seg_prev.y()) * int64_t(v_pt.y()); + int64_t t2_pt = int64_t(v_seg_prev(0)) * int64_t(v_pt(0)) + int64_t(v_seg_prev(1)) * int64_t(v_pt(1)); if (t2_pt > 0) { // Inside the wedge between the previous and the next segment. // Set the signum depending on whether the vertex is convex or reflex. - int64_t det = int64_t(v_seg_prev.x()) * int64_t(v_seg.y()) - int64_t(v_seg_prev.y()) * int64_t(v_seg.x()); + int64_t det = int64_t(v_seg_prev(0)) * int64_t(v_seg(1)) - int64_t(v_seg_prev(1)) * int64_t(v_seg(0)); assert(det != 0); d_min = dabs; // Fill in an unsigned vector towards the zero iso surface. float *l = &L[(corner_r * ncols + corner_c) << 1]; - l[0] = std::abs(v_pt.x()); - l[1] = std::abs(v_pt.y()); + l[0] = std::abs(v_pt(0)); + l[1] = std::abs(v_pt(1)); #ifdef _DEBUG double dabs2 = sqrt(l[0]*l[0]+l[1]*l[1]); assert(std::abs(dabs-dabs2) < 1e-4 * std::max(dabs, dabs2)); @@ -816,7 +816,7 @@ void EdgeGrid::Grid::calculate_sdf() } else { // Closest to the segment. assert(t_pt >= 0 && t_pt <= l2_seg); - int64_t d_seg = int64_t(v_seg.y()) * int64_t(v_pt.x()) - int64_t(v_seg.x()) * int64_t(v_pt.y()); + int64_t d_seg = int64_t(v_seg(1)) * int64_t(v_pt(0)) - int64_t(v_seg(0)) * int64_t(v_pt(1)); double d = double(d_seg) / sqrt(double(l2_seg)); double dabs = std::abs(d); if (dabs < d_min) { @@ -824,8 +824,8 @@ void EdgeGrid::Grid::calculate_sdf() // Fill in an unsigned vector towards the zero iso surface. float *l = &L[(corner_r * ncols + corner_c) << 1]; float linv = float(d_seg) / float(l2_seg); - l[0] = std::abs(float(v_seg.y()) * linv); - l[1] = std::abs(float(v_seg.x()) * linv); + l[0] = std::abs(float(v_seg(1)) * linv); + l[1] = std::abs(float(v_seg(0)) * linv); #ifdef _DEBUG double dabs2 = sqrt(l[0]*l[0]+l[1]*l[1]); assert(std::abs(dabs-dabs2) <= 1e-4 * std::max(dabs, dabs2)); @@ -1059,8 +1059,8 @@ void EdgeGrid::Grid::calculate_sdf() float EdgeGrid::Grid::signed_distance_bilinear(const Point &pt) const { - coord_t x = pt.x() - m_bbox.min.x(); - coord_t y = pt.y() - m_bbox.min.y(); + coord_t x = pt(0) - m_bbox.min(0); + coord_t y = pt(1) - m_bbox.min(1); coord_t w = m_resolution * m_cols; coord_t h = m_resolution * m_rows; bool clamped = false; @@ -1124,39 +1124,39 @@ float EdgeGrid::Grid::signed_distance_bilinear(const Point &pt) const bool EdgeGrid::Grid::signed_distance_edges(const Point &pt, coord_t search_radius, coordf_t &result_min_dist, bool *pon_segment) const { BoundingBox bbox; - bbox.min = bbox.max = Point(pt.x() - m_bbox.min.x(), pt.y() - m_bbox.min.y()); + bbox.min = bbox.max = Point(pt(0) - m_bbox.min(0), pt(1) - m_bbox.min(1)); bbox.defined = true; // Upper boundary, round to grid and test validity. - bbox.max.x() += search_radius; - bbox.max.y() += search_radius; - if (bbox.max.x() < 0 || bbox.max.y() < 0) + bbox.max(0) += search_radius; + bbox.max(1) += search_radius; + if (bbox.max(0) < 0 || bbox.max(1) < 0) return false; - bbox.max.x() /= m_resolution; - bbox.max.y() /= m_resolution; - if (bbox.max.x() >= m_cols) - bbox.max.x() = m_cols - 1; - if (bbox.max.y() >= m_rows) - bbox.max.y() = m_rows - 1; + bbox.max(0) /= m_resolution; + bbox.max(1) /= m_resolution; + if (bbox.max(0) >= m_cols) + bbox.max(0) = m_cols - 1; + if (bbox.max(1) >= m_rows) + bbox.max(1) = m_rows - 1; // Lower boundary, round to grid and test validity. - bbox.min.x() -= search_radius; - bbox.min.y() -= search_radius; - if (bbox.min.x() < 0) - bbox.min.x() = 0; - if (bbox.min.y() < 0) - bbox.min.y() = 0; - bbox.min.x() /= m_resolution; - bbox.min.y() /= m_resolution; + bbox.min(0) -= search_radius; + bbox.min(1) -= search_radius; + if (bbox.min(0) < 0) + bbox.min(0) = 0; + if (bbox.min(1) < 0) + bbox.min(1) = 0; + bbox.min(0) /= m_resolution; + bbox.min(1) /= m_resolution; // Is the interval empty? - if (bbox.min.x() > bbox.max.x() || - bbox.min.y() > bbox.max.y()) + if (bbox.min(0) > bbox.max(0) || + bbox.min(1) > bbox.max(1)) return false; // Traverse all cells in the bounding box. float d_min = search_radius; // Signum of the distance field at pt. int sign_min = 0; bool on_segment = false; - for (int r = bbox.min.y(); r <= bbox.max.y(); ++ r) { - for (int c = bbox.min.x(); c <= bbox.max.x(); ++ c) { + for (int r = bbox.min(1); r <= bbox.max(1); ++ r) { + for (int c = bbox.min(0); c <= bbox.max(0); ++ c) { const Cell &cell = m_cells[r * m_cols + c]; for (size_t i = cell.begin; i < cell.end; ++ i) { const Slic3r::Points &pts = *m_contours[m_cell_data[i].first]; @@ -1167,22 +1167,22 @@ bool EdgeGrid::Grid::signed_distance_edges(const Point &pt, coord_t search_radiu Slic3r::Point v_seg = p2 - p1; Slic3r::Point v_pt = pt - p1; // dot(p2-p1, pt-p1) - int64_t t_pt = int64_t(v_seg.x()) * int64_t(v_pt.x()) + int64_t(v_seg.y()) * int64_t(v_pt.y()); + int64_t t_pt = int64_t(v_seg(0)) * int64_t(v_pt(0)) + int64_t(v_seg(1)) * int64_t(v_pt(1)); // l2 of seg - int64_t l2_seg = int64_t(v_seg.x()) * int64_t(v_seg.x()) + int64_t(v_seg.y()) * int64_t(v_seg.y()); + int64_t l2_seg = int64_t(v_seg(0)) * int64_t(v_seg(0)) + int64_t(v_seg(1)) * int64_t(v_seg(1)); if (t_pt < 0) { // Closest to p1. - double dabs = sqrt(int64_t(v_pt.x()) * int64_t(v_pt.x()) + int64_t(v_pt.y()) * int64_t(v_pt.y())); + double dabs = sqrt(int64_t(v_pt(0)) * int64_t(v_pt(0)) + int64_t(v_pt(1)) * int64_t(v_pt(1))); if (dabs < d_min) { // Previous point. const Slic3r::Point &p0 = pts[(ipt == 0) ? (pts.size() - 1) : ipt - 1]; Slic3r::Point v_seg_prev = p1 - p0; - int64_t t2_pt = int64_t(v_seg_prev.x()) * int64_t(v_pt.x()) + int64_t(v_seg_prev.y()) * int64_t(v_pt.y()); + int64_t t2_pt = int64_t(v_seg_prev(0)) * int64_t(v_pt(0)) + int64_t(v_seg_prev(1)) * int64_t(v_pt(1)); if (t2_pt > 0) { // Inside the wedge between the previous and the next segment. d_min = dabs; // Set the signum depending on whether the vertex is convex or reflex. - int64_t det = int64_t(v_seg_prev.x()) * int64_t(v_seg.y()) - int64_t(v_seg_prev.y()) * int64_t(v_seg.x()); + int64_t det = int64_t(v_seg_prev(0)) * int64_t(v_seg(1)) - int64_t(v_seg_prev(1)) * int64_t(v_seg(0)); assert(det != 0); sign_min = (det > 0) ? 1 : -1; on_segment = false; @@ -1195,7 +1195,7 @@ bool EdgeGrid::Grid::signed_distance_edges(const Point &pt, coord_t search_radiu } else { // Closest to the segment. assert(t_pt >= 0 && t_pt <= l2_seg); - int64_t d_seg = int64_t(v_seg.y()) * int64_t(v_pt.x()) - int64_t(v_seg.x()) * int64_t(v_pt.y()); + int64_t d_seg = int64_t(v_seg(1)) * int64_t(v_pt(0)) - int64_t(v_seg(0)) * int64_t(v_pt(1)); double d = double(d_seg) / sqrt(double(l2_seg)); double dabs = std::abs(d); if (dabs < d_min) { @@ -1307,7 +1307,7 @@ Polygons EdgeGrid::Grid::contours_simplified(coord_t offset) const const Line &line_next = lines[it->second]; const Vector v1 = line_current.vector(); const Vector v2 = line_next.vector(); - int64_t cross = int64_t(v1.x()) * int64_t(v2.y()) - int64_t(v2.x()) * int64_t(v1.y()); + int64_t cross = int64_t(v1(0)) * int64_t(v2(1)) - int64_t(v2(0)) * int64_t(v1(1)); if (cross > 0) { // This has to be a convex right angle. There is no better next line. i_next = it->second; @@ -1328,10 +1328,10 @@ Polygons EdgeGrid::Grid::contours_simplified(coord_t offset) const Polygon &poly = out[i]; for (size_t j = 0; j < poly.points.size(); ++ j) { Point &p = poly.points[j]; - p.x() *= m_resolution; - p.y() *= m_resolution; - p.x() += m_bbox.min.x(); - p.y() += m_bbox.min.y(); + p(0) *= m_resolution; + p(1) *= m_resolution; + p(0) += m_bbox.min(0); + p(1) += m_bbox.min(1); } // Shrink the contour slightly, so if the same contour gets discretized and simplified again, one will get the same result. // Remove collineaer points. @@ -1341,11 +1341,11 @@ Polygons EdgeGrid::Grid::contours_simplified(coord_t offset) const size_t j0 = (j == 0) ? poly.points.size() - 1 : j - 1; size_t j2 = (j + 1 == poly.points.size()) ? 0 : j + 1; Point v = poly.points[j2] - poly.points[j0]; - if (v.x() != 0 && v.y() != 0) { + if (v(0) != 0 && v(1) != 0) { // This is a corner point. Copy it to the output contour. Point p = poly.points[j]; - p.y() += (v.x() < 0) ? - offset : offset; - p.x() += (v.y() > 0) ? - offset : offset; + p(1) += (v(0) < 0) ? - offset : offset; + p(0) += (v(1) > 0) ? - offset : offset; pts.push_back(p); } } @@ -1357,8 +1357,8 @@ Polygons EdgeGrid::Grid::contours_simplified(coord_t offset) const #if 0 void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coord_t resolution, const char *path) { - unsigned int w = (bbox.max.x() - bbox.min.x() + resolution - 1) / resolution; - unsigned int h = (bbox.max.y() - bbox.min.y() + resolution - 1) / resolution; + unsigned int w = (bbox.max(0) - bbox.min(0) + resolution - 1) / resolution; + unsigned int h = (bbox.max(1) - bbox.min(1) + resolution - 1) / resolution; wxImage img(w, h); unsigned char *data = img.GetData(); memset(data, 0, w * h * 3); @@ -1371,7 +1371,7 @@ void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coo for (coord_t r = 0; r < h; ++r) { for (coord_t c = 0; c < w; ++ c) { unsigned char *pxl = data + (((h - r - 1) * w) + c) * 3; - Point pt(c * resolution + bbox.min.x(), r * resolution + bbox.min.y()); + Point pt(c * resolution + bbox.min(0), r * resolution + bbox.min(1)); coordf_t min_dist; bool on_segment = true; #if 0 @@ -1409,8 +1409,8 @@ void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coo pxl[2] = 0; } - float gridx = float(pt.x() - grid.bbox().min.x()) / float(grid.resolution()); - float gridy = float(pt.y() - grid.bbox().min.y()) / float(grid.resolution()); + float gridx = float(pt(0) - grid.bbox().min(0)) / float(grid.resolution()); + float gridy = float(pt(1) - grid.bbox().min(1)) / float(grid.resolution()); if (gridx >= -0.4f && gridy >= -0.4f && gridx <= grid.cols() + 0.4f && gridy <= grid.rows() + 0.4f) { int ix = int(floor(gridx + 0.5f)); int iy = int(floor(gridy + 0.5f)); diff --git a/xs/src/libslic3r/ExPolygon.cpp b/xs/src/libslic3r/ExPolygon.cpp index 57f56b089..c252b448e 100644 --- a/xs/src/libslic3r/ExPolygon.cpp +++ b/xs/src/libslic3r/ExPolygon.cpp @@ -355,14 +355,14 @@ ExPolygon::get_trapezoids2(Polygons* polygons) const // build rectangle Polygon poly; poly.points.resize(4); - poly[0].x() = *x; - poly[0].y() = bb.min.y(); - poly[1].x() = next_x; - poly[1].y() = bb.min.y(); - poly[2].x() = next_x; - poly[2].y() = bb.max.y(); - poly[3].x() = *x; - poly[3].y() = bb.max.y(); + poly[0](0) = *x; + poly[0](1) = bb.min(1); + poly[1](0) = next_x; + poly[1](1) = bb.min(1); + poly[2](0) = next_x; + poly[2](1) = bb.max(1); + poly[3](0) = *x; + poly[3](1) = bb.max(1); // intersect with this expolygon // append results to return value @@ -408,9 +408,10 @@ ExPolygon::triangulate_pp(Polygons* polygons) const TPPLPoly p; p.Init(int(ex->contour.points.size())); //printf(PRINTF_ZU "\n0\n", ex->contour.points.size()); - for (Points::const_iterator point = ex->contour.points.begin(); point != ex->contour.points.end(); ++point) { - p[ point-ex->contour.points.begin() ].x = point->x(); - p[ point-ex->contour.points.begin() ].y = point->y(); + for (const Point &point : ex->contour.points) { + size_t i = &point - &ex->contour.points.front(); + p[i].x = point(0); + p[i].y = point(1); //printf("%ld %ld\n", point->x(), point->y()); } p.SetHole(false); @@ -422,9 +423,10 @@ ExPolygon::triangulate_pp(Polygons* polygons) const TPPLPoly p; p.Init(hole->points.size()); //printf(PRINTF_ZU "\n1\n", hole->points.size()); - for (Points::const_iterator point = hole->points.begin(); point != hole->points.end(); ++point) { - p[ point-hole->points.begin() ].x = point->x(); - p[ point-hole->points.begin() ].y = point->y(); + for (const Point &point : hole->points) { + size_t i = &point - &hole->points.front(); + p[i].x = point(0); + p[i].y = point(1); //printf("%ld %ld\n", point->x(), point->y()); } p.SetHole(true); @@ -443,8 +445,8 @@ ExPolygon::triangulate_pp(Polygons* polygons) const Polygon p; p.points.resize(num_points); for (long i = 0; i < num_points; ++i) { - p.points[i].x() = coord_t((*poly)[i].x); - p.points[i].y() = coord_t((*poly)[i].y); + p.points[i](0) = coord_t((*poly)[i].x); + p.points[i](1) = coord_t((*poly)[i].y); } polygons->push_back(p); } @@ -460,19 +462,17 @@ ExPolygon::triangulate_p2t(Polygons* polygons) const // contour std::vector ContourPoints; - for (Points::const_iterator point = ex->contour.points.begin(); point != ex->contour.points.end(); ++point) { + for (const Point &pt : ex->contour.points) // We should delete each p2t::Point object - ContourPoints.push_back(new p2t::Point(point->x(), point->y())); - } + ContourPoints.push_back(new p2t::Point(pt(0), pt(1))); p2t::CDT cdt(ContourPoints); // holes for (Polygons::const_iterator hole = ex->holes.begin(); hole != ex->holes.end(); ++hole) { std::vector points; - for (Points::const_iterator point = hole->points.begin(); point != hole->points.end(); ++point) { + for (const Point &pt : hole->points) // will be destructed in SweepContext::~SweepContext - points.push_back(new p2t::Point(point->x(), point->y())); - } + points.push_back(new p2t::Point(pt(0), pt(1))); cdt.AddHole(points); } diff --git a/xs/src/libslic3r/ExtrusionSimulator.cpp b/xs/src/libslic3r/ExtrusionSimulator.cpp index 58531b7c5..fcb2fe825 100644 --- a/xs/src/libslic3r/ExtrusionSimulator.cpp +++ b/xs/src/libslic3r/ExtrusionSimulator.cpp @@ -965,7 +965,7 @@ void ExtrusionSimulator::extrude_to_accumulator(const ExtrusionPath &path, const for (Points::const_iterator it = path.polyline.points.begin(); it != path.polyline.points.end(); ++ it) { // printf("point %d,%d\n", it->x+shift.x(), it->y+shift.y); ExtrusionPoint ept; - ept.center = V2f(float(it->x()+shift.x()-bbox.min.x()) * scalex, float(it->y()+shift.y()-bbox.min.y()) * scaley); + ept.center = V2f(float((*it)(0)+shift.x()-bbox.min.x()) * scalex, float((*it)(1)+shift.y()-bbox.min.y()) * scaley); ept.radius = w/2.f; ept.height = 0.5f; polyline.push_back(ept.center); diff --git a/xs/src/libslic3r/Fill/Fill3DHoneycomb.cpp b/xs/src/libslic3r/Fill/Fill3DHoneycomb.cpp index 5c3697d3e..16ed12fb9 100644 --- a/xs/src/libslic3r/Fill/Fill3DHoneycomb.cpp +++ b/xs/src/libslic3r/Fill/Fill3DHoneycomb.cpp @@ -55,8 +55,8 @@ static std::vector 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); diff --git a/xs/src/libslic3r/Fill/FillBase.hpp b/xs/src/libslic3r/Fill/FillBase.hpp index 2b8a16b19..b67d14339 100644 --- a/xs/src/libslic3r/Fill/FillBase.hpp +++ b/xs/src/libslic3r/Fill/FillBase.hpp @@ -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 diff --git a/xs/src/libslic3r/Fill/FillConcentric.cpp b/xs/src/libslic3r/Fill/FillConcentric.cpp index 860f36777..d0f9510cc 100644 --- a/xs/src/libslic3r/Fill/FillConcentric.cpp +++ b/xs/src/libslic3r/Fill/FillConcentric.cpp @@ -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); } diff --git a/xs/src/libslic3r/Fill/FillGyroid.cpp b/xs/src/libslic3r/Fill/FillGyroid.cpp index bbac6f258..003893649 100644 --- a/xs/src/libslic3r/Fill/FillGyroid.cpp +++ b/xs/src/libslic3r/Fill/FillGyroid.cpp @@ -34,21 +34,21 @@ static inline Polyline make_wave( double z_cos, double z_sin, bool vertical) { std::vector 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()); } @@ -73,12 +73,12 @@ static std::vector 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); diff --git a/xs/src/libslic3r/Fill/FillHoneycomb.cpp b/xs/src/libslic3r/Fill/FillHoneycomb.cpp index ce7ac4a19..6f26167a2 100644 --- a/xs/src/libslic3r/Fill/FillHoneycomb.cpp +++ b/xs/src/libslic3r/Fill/FillHoneycomb.cpp @@ -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)); diff --git a/xs/src/libslic3r/Fill/FillPlanePath.cpp b/xs/src/libslic3r/Fill/FillPlanePath.cpp index f872c1ef8..bb7d5ac80 100644 --- a/xs/src/libslic3r/Fill/FillPlanePath.cpp +++ b/xs/src/libslic3r/Fill/FillPlanePath.cpp @@ -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; } diff --git a/xs/src/libslic3r/Fill/FillRectilinear.cpp b/xs/src/libslic3r/Fill/FillRectilinear.cpp index 5826abdb9..2209d219e 100644 --- a/xs/src/libslic3r/Fill/FillRectilinear.cpp +++ b/xs/src/libslic3r/Fill/FillRectilinear.cpp @@ -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); } } diff --git a/xs/src/libslic3r/Fill/FillRectilinear2.cpp b/xs/src/libslic3r/Fill/FillRectilinear2.cpp index a9ccdb0fb..f18ab0f62 100644 --- a/xs/src/libslic3r/Fill/FillRectilinear2.cpp +++ b/xs/src/libslic3r/Fill/FillRectilinear2.cpp @@ -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? diff --git a/xs/src/libslic3r/Fill/FillRectilinear3.cpp b/xs/src/libslic3r/Fill/FillRectilinear3.cpp index d2ba3d237..d80bbfe6e 100644 --- a/xs/src/libslic3r/Fill/FillRectilinear3.cpp +++ b/xs/src/libslic3r/Fill/FillRectilinear3.cpp @@ -223,24 +223,24 @@ Point SegmentIntersection::pos() const const Pointf p2(line->pos.cast()); const Pointf v2(line->dir.cast()); // 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(), vec_b); Vec2i64 vx_a = (seg_start_a - this->line->pos).cast(); Vec2i64 vx_b = (seg_start_b - this->line->pos).cast(); - 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(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 . 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? diff --git a/xs/src/libslic3r/Format/3mf.cpp b/xs/src/libslic3r/Format/3mf.cpp index 6b81fc9c0..ca063b882 100644 --- a/xs/src/libslic3r/Format/3mf.cpp +++ b/xs/src/libslic3r/Format/3mf.cpp @@ -1352,8 +1352,8 @@ namespace Slic3r { double angle_z = (rotation.axis() == Eigen::Vector3d::UnitZ()) ? rotation.angle() : -rotation.angle(); #endif - instance.offset.x() = offset_x; - instance.offset.y() = offset_y; + instance.offset(0) = offset_x; + instance.offset(1) = offset_y; instance.scaling_factor = sx; instance.rotation = angle_z; } @@ -1801,7 +1801,7 @@ namespace Slic3r { } Eigen::Affine3f transform; - transform = Eigen::Translation3f((float)instance->offset.x(), (float)instance->offset.y(), 0.0f) * Eigen::AngleAxisf((float)instance->rotation, Eigen::Vector3f::UnitZ()) * Eigen::Scaling((float)instance->scaling_factor); + transform = Eigen::Translation3f((float)instance->offset(0), (float)instance->offset(1), 0.0f) * Eigen::AngleAxisf((float)instance->rotation, Eigen::Vector3f::UnitZ()) * Eigen::Scaling((float)instance->scaling_factor); build_items.emplace_back(instance_id, transform.matrix()); stream << " \n"; diff --git a/xs/src/libslic3r/Format/AMF.cpp b/xs/src/libslic3r/Format/AMF.cpp index 3dc0418ae..2f245d98d 100644 --- a/xs/src/libslic3r/Format/AMF.cpp +++ b/xs/src/libslic3r/Format/AMF.cpp @@ -496,8 +496,8 @@ void AMFParserContext::endDocument() for (const Instance &instance : object.second.instances) if (instance.deltax_set && instance.deltay_set) { ModelInstance *mi = m_model.objects[object.second.idx]->add_instance(); - mi->offset.x() = instance.deltax; - mi->offset.y() = instance.deltay; + mi->offset(0) = instance.deltax; + mi->offset(1) = instance.deltay; mi->rotation = instance.rz_set ? instance.rz : 0.f; mi->scaling_factor = instance.scale_set ? instance.scale : 1.f; } @@ -829,8 +829,8 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c " %lf\n" " \n", object_id, - instance->offset.x(), - instance->offset.y(), + instance->offset(0), + instance->offset(1), instance->rotation, instance->scaling_factor); //FIXME missing instance->scaling_factor diff --git a/xs/src/libslic3r/Format/PRUS.cpp b/xs/src/libslic3r/Format/PRUS.cpp index b73a71352..b817f8305 100644 --- a/xs/src/libslic3r/Format/PRUS.cpp +++ b/xs/src/libslic3r/Format/PRUS.cpp @@ -207,8 +207,8 @@ bool load_prus(const char *path, Model *model) for (size_t c = 0; c < 3; ++ c) trafo[r][c] += mat_trafo(r, c); } - instance_offset.x() = position[0] - zero[0]; - instance_offset.y() = position[1] - zero[1]; + instance_offset(0) = position[0] - zero[0]; + instance_offset(1) = position[1] - zero[1]; trafo[2][3] = position[2] / instance_scaling_factor; trafo_set = true; } diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index d3441a565..42d05e138 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -49,7 +49,7 @@ Polyline AvoidCrossingPerimeters::travel_to(const GCode &gcodegen, const Point & // If use_external, then perform the path planning in the world coordinate system (correcting for the gcodegen offset). // Otherwise perform the path planning in the coordinate system of the active object. bool use_external = this->use_external_mp || this->use_external_mp_once; - Point scaled_origin = use_external ? Point::new_scale(gcodegen.origin().x(), gcodegen.origin().y()) : Point(0, 0); + Point scaled_origin = use_external ? Point::new_scale(gcodegen.origin()(0), gcodegen.origin()(1)) : Point(0, 0); Polyline result = (use_external ? m_external_mp.get() : m_layer_mp.get())-> shortest_path(gcodegen.last_pos() + scaled_origin, point + scaled_origin); if (use_external) @@ -65,7 +65,7 @@ std::string OozePrevention::pre_toolchange(GCode &gcodegen) if (!this->standby_points.empty()) { // get current position in print coordinates Pointf3 writer_pos = gcodegen.writer().get_position(); - Point pos = Point::new_scale(writer_pos.x(), writer_pos.y()); + Point pos = Point::new_scale(writer_pos(0), writer_pos(1)); // find standby point Point standby_point; @@ -160,7 +160,7 @@ Wipe::wipe(GCode &gcodegen, bool toolchange) static inline Point wipe_tower_point_to_object_point(GCode &gcodegen, const WipeTower::xy &wipe_tower_pt) { - return Point(scale_(wipe_tower_pt.x - gcodegen.origin().x()), scale_(wipe_tower_pt.y - gcodegen.origin().y())); + return Point(scale_(wipe_tower_pt.x - gcodegen.origin()(0)), scale_(wipe_tower_pt.y - gcodegen.origin()(1))); } std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::ToolChangeResult &tcr, int new_extruder_id) const @@ -262,7 +262,7 @@ std::string WipeTowerIntegration::tool_change(GCode &gcodegen, int extruder_id, std::string WipeTowerIntegration::finalize(GCode &gcodegen) { std::string gcode; - if (std::abs(gcodegen.writer().get_position().z() - m_final_purge.print_z) > EPSILON) + if (std::abs(gcodegen.writer().get_position()(2) - m_final_purge.print_z) > EPSILON) gcode += gcodegen.change_layer(m_final_purge.print_z); gcode += append_tcr(gcodegen, m_final_purge, -1); return gcode; @@ -699,7 +699,7 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data) for (unsigned int extruder_id : print.extruders()) { const Pointf &extruder_offset = print.config.extruder_offset.get_at(extruder_id); Polygon s(outer_skirt); - s.translate(Point::new_scale(- extruder_offset.x(), - extruder_offset.y())); + s.translate(Point::new_scale(- extruder_offset(0), - extruder_offset(1))); skirts.emplace_back(std::move(s)); } m_ooze_prevention.enable = true; @@ -725,7 +725,7 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data) // Print objects from the smallest to the tallest to avoid collisions // when moving onto next object starting point. std::vector objects(print.objects); - std::sort(objects.begin(), objects.end(), [](const PrintObject* po1, const PrintObject* po2) { return po1->size.z() < po2->size.z(); }); + std::sort(objects.begin(), objects.end(), [](const PrintObject* po1, const PrintObject* po2) { return po1->size(2) < po2->size(2); }); size_t finished_objects = 0; for (size_t object_id = initial_print_object_id; object_id < objects.size(); ++ object_id) { const PrintObject &object = *objects[object_id]; @@ -742,7 +742,7 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data) final_extruder_id = tool_ordering.last_extruder(); assert(final_extruder_id != (unsigned int)-1); } - this->set_origin(unscale(copy.x()), unscale(copy.y())); + this->set_origin(unscale(copy(0)), unscale(copy(1))); if (finished_objects > 0) { // Move to the origin position for the copy we're going to print. // This happens before Z goes down to layer 0 again, so that no collision happens hopefully. @@ -849,7 +849,7 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data) { DynamicConfig config; config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index)); - config.set_key_value("layer_z", new ConfigOptionFloat(m_writer.get_position().z() - m_config.z_offset.value)); + config.set_key_value("layer_z", new ConfigOptionFloat(m_writer.get_position()(2) - m_config.z_offset.value)); if (print.config.single_extruder_multi_material) { // Process the end_filament_gcode for the active filament only. _writeln(file, this->placeholder_parser_process("end_filament_gcode", print.config.end_filament_gcode.get_at(m_writer.extruder()->id()), m_writer.extruder()->id(), &config)); @@ -1304,8 +1304,8 @@ void GCode::process_layer( layer_surface_bboxes.push_back(get_extents(expoly.contour)); auto point_inside_surface = [&layer, &layer_surface_bboxes](const size_t i, const Point &point) { const BoundingBox &bbox = layer_surface_bboxes[i]; - return point.x() >= bbox.min.x() && point.x() < bbox.max.x() && - point.y() >= bbox.min.y() && point.y() < bbox.max.y() && + return point(0) >= bbox.min(0) && point(0) < bbox.max(0) && + point(1) >= bbox.min(1) && point(1) < bbox.max(1) && layer.slices.expolygons[i].contour.contains(point); }; @@ -1455,7 +1455,7 @@ void GCode::process_layer( if (m_last_obj_copy != this_object_copy) m_avoid_crossing_perimeters.use_external_mp_once = true; m_last_obj_copy = this_object_copy; - this->set_origin(unscale(copy.x()), unscale(copy.y())); + this->set_origin(unscale(copy(0)), unscale(copy(1))); if (object_by_extruder.support != nullptr && !print_wipe_extrusions) { m_layer = layers[layer_id].support_layer; gcode += this->extrude_support( @@ -1544,8 +1544,8 @@ void GCode::set_origin(const Pointf &pointf) { // if origin increases (goes towards right), last_pos decreases because it goes towards left const Point translate( - scale_(m_origin.x() - pointf.x()), - scale_(m_origin.y() - pointf.y()) + scale_(m_origin(0) - pointf(0)), + scale_(m_origin(1) - pointf(1)) ); m_last_pos += translate; m_wipe.path.translate(translate); @@ -1680,11 +1680,11 @@ static Points::iterator project_point_to_polygon_and_insert(Polygon &polygon, co const Point &p2 = polygon.points[j]; const Slic3r::Point v_seg = p2 - p1; const Slic3r::Point v_pt = pt - p1; - const int64_t l2_seg = int64_t(v_seg.x()) * int64_t(v_seg.x()) + int64_t(v_seg.y()) * int64_t(v_seg.y()); - int64_t t_pt = int64_t(v_seg.x()) * int64_t(v_pt.x()) + int64_t(v_seg.y()) * int64_t(v_pt.y()); + const int64_t l2_seg = int64_t(v_seg(0)) * int64_t(v_seg(0)) + int64_t(v_seg(1)) * int64_t(v_seg(1)); + int64_t t_pt = int64_t(v_seg(0)) * int64_t(v_pt(0)) + int64_t(v_seg(1)) * int64_t(v_pt(1)); if (t_pt < 0) { // Closest to p1. - double dabs = sqrt(int64_t(v_pt.x()) * int64_t(v_pt.x()) + int64_t(v_pt.y()) * int64_t(v_pt.y())); + double dabs = sqrt(int64_t(v_pt(0)) * int64_t(v_pt(0)) + int64_t(v_pt(1)) * int64_t(v_pt(1))); if (dabs < d_min) { d_min = dabs; i_min = i; @@ -1697,7 +1697,7 @@ static Points::iterator project_point_to_polygon_and_insert(Polygon &polygon, co } else { // Closest to the segment. assert(t_pt >= 0 && t_pt <= l2_seg); - int64_t d_seg = int64_t(v_seg.y()) * int64_t(v_pt.x()) - int64_t(v_seg.x()) * int64_t(v_pt.y()); + int64_t d_seg = int64_t(v_seg(1)) * int64_t(v_pt(0)) - int64_t(v_seg(0)) * int64_t(v_pt(1)); double d = double(d_seg) / sqrt(double(l2_seg)); double dabs = std::abs(d); if (dabs < d_min) { @@ -1706,8 +1706,8 @@ static Points::iterator project_point_to_polygon_and_insert(Polygon &polygon, co // Evaluate the foot point. pt_min = p1; double linv = double(d_seg) / double(l2_seg); - pt_min.x() = pt.x() - coord_t(floor(double(v_seg.y()) * linv + 0.5)); - pt_min.y() = pt.y() + coord_t(floor(double(v_seg.x()) * linv + 0.5)); + pt_min(0) = pt(0) - coord_t(floor(double(v_seg(1)) * linv + 0.5)); + pt_min(1) = pt(1) + coord_t(floor(double(v_seg(0)) * linv + 0.5)); assert(Line(p1, p2).distance_to(pt_min) < scale_(1e-5)); } } @@ -1777,8 +1777,8 @@ std::vector polygon_angles_at_vertices(const Polygon &polygon, const std: const Point &p2 = polygon.points[idx_next]; const Point v1 = p1 - p0; const Point v2 = p2 - p1; - int64_t dot = int64_t(v1.x())*int64_t(v2.x()) + int64_t(v1.y())*int64_t(v2.y()); - int64_t cross = int64_t(v1.x())*int64_t(v2.y()) - int64_t(v1.y())*int64_t(v2.x()); + int64_t dot = int64_t(v1(0))*int64_t(v2(0)) + int64_t(v1(1))*int64_t(v2(1)); + int64_t cross = int64_t(v1(0))*int64_t(v2(1)) - int64_t(v1(1))*int64_t(v2(0)); float angle = float(atan2(double(cross), double(dot))); angles[idx_curr] = angle; } @@ -1802,10 +1802,10 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou { static int iRun = 0; BoundingBox bbox = (*lower_layer_edge_grid)->bbox(); - bbox.min.x() -= scale_(5.f); - bbox.min.y() -= scale_(5.f); - bbox.max.x() += scale_(5.f); - bbox.max.y() += scale_(5.f); + bbox.min(0) -= scale_(5.f); + bbox.min(1) -= scale_(5.f); + bbox.max(0) += scale_(5.f); + bbox.max(1) += scale_(5.f); EdgeGrid::save_png(*(*lower_layer_edge_grid), bbox, scale_(0.1f), debug_out_path("GCode_extrude_loop_edge_grid-%d.png", iRun++)); } #endif @@ -1841,7 +1841,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou break; case spRear: last_pos = m_layer->object()->bounding_box().center(); - last_pos.y() += coord_t(3. * m_layer->object()->bounding_box().radius()); + last_pos(1) += coord_t(3. * m_layer->object()->bounding_box().radius()); last_pos_weight = 5.f; break; } @@ -1974,7 +1974,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou //FIXME Better parametrize the loop by its length. Polygon polygon = loop.polygon(); Point centroid = polygon.centroid(); - last_pos = Point(polygon.bounding_box().max.x(), centroid.y()); + last_pos = Point(polygon.bounding_box().max(0), centroid(1)); last_pos.rotate(fmod((float)rand()/16.0, 2.0*PI), centroid); } // Find the closest point, avoid overhangs. @@ -2530,8 +2530,8 @@ Pointf GCode::point_to_gcode(const Point &point) const { Pointf extruder_offset = EXTRUDER_CONFIG(extruder_offset); return Pointf( - unscale(point.x()) + m_origin.x() - extruder_offset.x(), - unscale(point.y()) + m_origin.y() - extruder_offset.y()); + unscale(point(0)) + m_origin(0) - extruder_offset(0), + unscale(point(1)) + m_origin(1) - extruder_offset(1)); } // convert a model-space scaled point into G-code coordinates @@ -2539,8 +2539,8 @@ Point GCode::gcode_to_point(const Pointf &point) const { Pointf extruder_offset = EXTRUDER_CONFIG(extruder_offset); return Point( - scale_(point.x() - m_origin.x() + extruder_offset.x()), - scale_(point.y() - m_origin.y() + extruder_offset.y())); + scale_(point(0) - m_origin(0) + extruder_offset(0)), + scale_(point(1) - m_origin(1) + extruder_offset(1))); } diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.cpp b/xs/src/libslic3r/GCode/CoolingBuffer.cpp index 78855ec4a..0f361b250 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.cpp @@ -24,9 +24,9 @@ void CoolingBuffer::reset() { m_current_pos.assign(5, 0.f); Pointf3 pos = m_gcodegen.writer().get_position(); - m_current_pos[0] = float(pos.x()); - m_current_pos[1] = float(pos.y()); - m_current_pos[2] = float(pos.z()); + m_current_pos[0] = float(pos(0)); + m_current_pos[1] = float(pos(1)); + m_current_pos[2] = float(pos(2)); m_current_pos[4] = float(m_gcodegen.config().travel_speed.value); } diff --git a/xs/src/libslic3r/GCode/PrintExtents.cpp b/xs/src/libslic3r/GCode/PrintExtents.cpp index a943f1b23..4467c737a 100644 --- a/xs/src/libslic3r/GCode/PrintExtents.cpp +++ b/xs/src/libslic3r/GCode/PrintExtents.cpp @@ -19,10 +19,10 @@ static inline BoundingBox extrusion_polyline_extents(const Polyline &polyline, c if (! polyline.points.empty()) bbox.merge(polyline.points.front()); for (const Point &pt : polyline.points) { - bbox.min.x() = std::min(bbox.min.x(), pt.x() - radius); - bbox.min.y() = std::min(bbox.min.y(), pt.y() - radius); - bbox.max.x() = std::max(bbox.max.x(), pt.x() + radius); - bbox.max.y() = std::max(bbox.max.y(), pt.y() + radius); + bbox.min(0) = std::min(bbox.min(0), pt(0) - radius); + bbox.min(1) = std::min(bbox.min(1), pt(1) - radius); + bbox.max(0) = std::max(bbox.max(0), pt(0) + radius); + bbox.max(1) = std::max(bbox.max(1), pt(1) + radius); } return bbox; } @@ -146,10 +146,10 @@ BoundingBoxf get_wipe_tower_extrusions_extents(const Print &print, const coordf_ Pointf p2(e.pos.x, e.pos.y); bbox.merge(p1); coordf_t radius = 0.5 * e.width; - bbox.min.x() = std::min(bbox.min.x(), std::min(p1.x(), p2.x()) - radius); - bbox.min.y() = std::min(bbox.min.y(), std::min(p1.y(), p2.y()) - radius); - bbox.max.x() = std::max(bbox.max.x(), std::max(p1.x(), p2.x()) + radius); - bbox.max.y() = std::max(bbox.max.y(), std::max(p1.y(), p2.y()) + radius); + bbox.min(0) = std::min(bbox.min(0), std::min(p1(0), p2(0)) - radius); + bbox.min(1) = std::min(bbox.min(1), std::min(p1(1), p2(1)) - radius); + bbox.max(0) = std::max(bbox.max(0), std::max(p1(0), p2(0)) + radius); + bbox.max(1) = std::max(bbox.max(1), std::max(p1(1), p2(1)) + radius); } } } @@ -170,10 +170,10 @@ BoundingBoxf get_wipe_tower_priming_extrusions_extents(const Print &print) Pointf p2(e.pos.x, e.pos.y); bbox.merge(p1); coordf_t radius = 0.5 * e.width; - bbox.min.x() = std::min(bbox.min.x(), std::min(p1.x(), p2.x()) - radius); - bbox.min.y() = std::min(bbox.min.y(), std::min(p1.y(), p2.y()) - radius); - bbox.max.x() = std::max(bbox.max.x(), std::max(p1.x(), p2.x()) + radius); - bbox.max.y() = std::max(bbox.max.y(), std::max(p1.y(), p2.y()) + radius); + bbox.min(0) = std::min(bbox.min(0), std::min(p1(0), p2(0)) - radius); + bbox.min(1) = std::min(bbox.min(1), std::min(p1(1), p2(1)) - radius); + bbox.max(0) = std::max(bbox.max(0), std::max(p1(0), p2(0)) + radius); + bbox.max(1) = std::max(bbox.max(1), std::max(p1(1), p2(1)) + radius); } } } diff --git a/xs/src/libslic3r/GCodeWriter.cpp b/xs/src/libslic3r/GCodeWriter.cpp index 6ebb181f5..cefbdad2e 100644 --- a/xs/src/libslic3r/GCodeWriter.cpp +++ b/xs/src/libslic3r/GCodeWriter.cpp @@ -278,12 +278,12 @@ std::string GCodeWriter::set_speed(double F, const std::string &comment, const s std::string GCodeWriter::travel_to_xy(const Pointf &point, const std::string &comment) { - m_pos.x() = point.x(); - m_pos.y() = point.y(); + m_pos(0) = point(0); + m_pos(1) = point(1); std::ostringstream gcode; - gcode << "G1 X" << XYZF_NUM(point.x()) - << " Y" << XYZF_NUM(point.y()) + gcode << "G1 X" << XYZF_NUM(point(0)) + << " Y" << XYZF_NUM(point(1)) << " F" << XYZF_NUM(this->config.travel_speed.value * 60.0); COMMENT(comment); gcode << "\n"; @@ -296,9 +296,9 @@ std::string GCodeWriter::travel_to_xyz(const Pointf3 &point, const std::string & don't perform the Z move but we only move in the XY plane and adjust the nominal Z by reducing the lift amount that will be used for unlift. */ - if (!this->will_move_z(point.z())) { - double nominal_z = m_pos.z() - m_lifted; - m_lifted = m_lifted - (point.z() - nominal_z); + if (!this->will_move_z(point(2))) { + double nominal_z = m_pos(2) - m_lifted; + m_lifted = m_lifted - (point(2) - nominal_z); return this->travel_to_xy(point.xy()); } @@ -308,9 +308,9 @@ std::string GCodeWriter::travel_to_xyz(const Pointf3 &point, const std::string & m_pos = point; std::ostringstream gcode; - gcode << "G1 X" << XYZF_NUM(point.x()) - << " Y" << XYZF_NUM(point.y()) - << " Z" << XYZF_NUM(point.z()) + gcode << "G1 X" << XYZF_NUM(point(0)) + << " Y" << XYZF_NUM(point(1)) + << " Z" << XYZF_NUM(point(2)) << " F" << XYZF_NUM(this->config.travel_speed.value * 60.0); COMMENT(comment); gcode << "\n"; @@ -323,7 +323,7 @@ std::string GCodeWriter::travel_to_z(double z, const std::string &comment) we don't perform the move but we only adjust the nominal Z by reducing the lift amount that will be used for unlift. */ if (!this->will_move_z(z)) { - double nominal_z = m_pos.z() - m_lifted; + double nominal_z = m_pos(2) - m_lifted; m_lifted = m_lifted - (z - nominal_z); return ""; } @@ -336,7 +336,7 @@ std::string GCodeWriter::travel_to_z(double z, const std::string &comment) std::string GCodeWriter::_travel_to_z(double z, const std::string &comment) { - m_pos.z() = z; + m_pos(2) = z; std::ostringstream gcode; gcode << "G1 Z" << XYZF_NUM(z) @@ -351,8 +351,8 @@ bool GCodeWriter::will_move_z(double z) const /* If target Z is lower than current Z but higher than nominal Z we don't perform an actual Z move. */ if (m_lifted > 0) { - double nominal_z = m_pos.z() - m_lifted; - if (z >= nominal_z && z <= m_pos.z()) + double nominal_z = m_pos(2) - m_lifted; + if (z >= nominal_z && z <= m_pos(2)) return false; } return true; @@ -360,13 +360,13 @@ bool GCodeWriter::will_move_z(double z) const std::string GCodeWriter::extrude_to_xy(const Pointf &point, double dE, const std::string &comment) { - m_pos.x() = point.x(); - m_pos.y() = point.y(); + m_pos(0) = point(0); + m_pos(1) = point(1); m_extruder->extrude(dE); std::ostringstream gcode; - gcode << "G1 X" << XYZF_NUM(point.x()) - << " Y" << XYZF_NUM(point.y()) + gcode << "G1 X" << XYZF_NUM(point(0)) + << " Y" << XYZF_NUM(point(1)) << " " << m_extrusion_axis << E_NUM(m_extruder->E()); COMMENT(comment); gcode << "\n"; @@ -380,9 +380,9 @@ std::string GCodeWriter::extrude_to_xyz(const Pointf3 &point, double dE, const s m_extruder->extrude(dE); std::ostringstream gcode; - gcode << "G1 X" << XYZF_NUM(point.x()) - << " Y" << XYZF_NUM(point.y()) - << " Z" << XYZF_NUM(point.z()) + gcode << "G1 X" << XYZF_NUM(point(0)) + << " Y" << XYZF_NUM(point(1)) + << " Z" << XYZF_NUM(point(2)) << " " << m_extrusion_axis << E_NUM(m_extruder->E()); COMMENT(comment); gcode << "\n"; @@ -486,12 +486,12 @@ std::string GCodeWriter::lift() { double above = this->config.retract_lift_above.get_at(m_extruder->id()); double below = this->config.retract_lift_below.get_at(m_extruder->id()); - if (m_pos.z() >= above && (below == 0 || m_pos.z() <= below)) + if (m_pos(2) >= above && (below == 0 || m_pos(2) <= below)) target_lift = this->config.retract_lift.get_at(m_extruder->id()); } if (m_lifted == 0 && target_lift > 0) { m_lifted = target_lift; - return this->_travel_to_z(m_pos.z() + target_lift, "lift Z"); + return this->_travel_to_z(m_pos(2) + target_lift, "lift Z"); } return ""; } @@ -500,7 +500,7 @@ std::string GCodeWriter::unlift() { std::string gcode; if (m_lifted > 0) { - gcode += this->_travel_to_z(m_pos.z() - m_lifted, "restore layer Z"); + gcode += this->_travel_to_z(m_pos(2) - m_lifted, "restore layer Z"); m_lifted = 0; } return gcode; diff --git a/xs/src/libslic3r/Geometry.cpp b/xs/src/libslic3r/Geometry.cpp index eb206ce62..b4813be14 100644 --- a/xs/src/libslic3r/Geometry.cpp +++ b/xs/src/libslic3r/Geometry.cpp @@ -198,7 +198,7 @@ namespace Slic3r { namespace Geometry { static bool sort_points (Point a, Point b) { - return (a.x() < b.x()) || (a.x() == b.x() && a.y() < b.y()); + return (a(0) < b(0)) || (a(0) == b(0) && a(1) < b(1)); } /* This implementation is based on Andrew's monotone chain 2D convex hull algorithm */ @@ -349,30 +349,30 @@ struct ArrangeItem { coordf_t weight; bool operator<(const ArrangeItem &other) const { return weight < other.weight || - ((weight == other.weight) && (pos.y() < other.pos.y() || (pos.y() == other.pos.y() && pos.x() < other.pos.x()))); + ((weight == other.weight) && (pos(1) < other.pos(1) || (pos(1) == other.pos(1) && pos(0) < other.pos(0)))); } }; Pointfs arrange(size_t num_parts, const Pointf &part_size, coordf_t gap, const BoundingBoxf* bed_bounding_box) { // Use actual part size (the largest) plus separation distance (half on each side) in spacing algorithm. - const Pointf cell_size(part_size.x() + gap, part_size.y() + gap); + const Pointf cell_size(part_size(0) + gap, part_size(1) + gap); const BoundingBoxf bed_bbox = (bed_bounding_box != NULL && bed_bounding_box->defined) ? *bed_bounding_box : // Bogus bed size, large enough not to trigger the unsufficient bed size error. BoundingBoxf( Pointf(0, 0), - Pointf(cell_size.x() * num_parts, cell_size.y() * num_parts)); + Pointf(cell_size(0) * num_parts, cell_size(1) * num_parts)); // This is how many cells we have available into which to put parts. - size_t cellw = size_t(floor((bed_bbox.size().x() + gap) / cell_size.x())); - size_t cellh = size_t(floor((bed_bbox.size().y() + gap) / cell_size.y())); + size_t cellw = size_t(floor((bed_bbox.size()(0) + gap) / cell_size(0))); + size_t cellh = size_t(floor((bed_bbox.size()(1) + gap) / cell_size(1))); if (num_parts > cellw * cellh) CONFESS(PRINTF_ZU " parts won't fit in your print area!\n", num_parts); // Get a bounding box of cellw x cellh cells, centered at the center of the bed. - Pointf cells_size(cellw * cell_size.x() - gap, cellh * cell_size.y() - gap); + Pointf cells_size(cellw * cell_size(0) - gap, cellh * cell_size(1) - gap); Pointf cells_offset(bed_bbox.center() - 0.5 * cells_size); BoundingBoxf cells_bb(cells_offset, cells_size + cells_offset); @@ -380,19 +380,19 @@ Pointfs arrange(size_t num_parts, const Pointf &part_size, coordf_t gap, const B std::vector cellsorder(cellw * cellh, ArrangeItem()); for (size_t j = 0; j < cellh; ++ j) { // Center of the jth row on the bed. - coordf_t cy = linint(j + 0.5, 0., double(cellh), cells_bb.min.y(), cells_bb.max.y()); + coordf_t cy = linint(j + 0.5, 0., double(cellh), cells_bb.min(1), cells_bb.max(1)); // Offset from the bed center. - coordf_t yd = cells_bb.center().y() - cy; + coordf_t yd = cells_bb.center()(1) - cy; for (size_t i = 0; i < cellw; ++ i) { // Center of the ith column on the bed. - coordf_t cx = linint(i + 0.5, 0., double(cellw), cells_bb.min.x(), cells_bb.max.x()); + coordf_t cx = linint(i + 0.5, 0., double(cellw), cells_bb.min(0), cells_bb.max(0)); // Offset from the bed center. - coordf_t xd = cells_bb.center().x() - cx; + coordf_t xd = cells_bb.center()(0) - cx; // Cell with a distance from the bed center. ArrangeItem &ci = cellsorder[j * cellw + i]; // Cell center - ci.pos.x() = cx; - ci.pos.y() = cy; + ci.pos(0) = cx; + ci.pos(1) = cy; // Square distance of the cell center to the bed center. ci.weight = xd * xd + yd * yd; } @@ -405,7 +405,7 @@ Pointfs arrange(size_t num_parts, const Pointf &part_size, coordf_t gap, const B Pointfs positions; positions.reserve(num_parts); for (std::vector::const_iterator it = cellsorder.begin(); it != cellsorder.end(); ++ it) - positions.push_back(Pointf(it->pos.x() - 0.5 * part_size.x(), it->pos.y() - 0.5 * part_size.y())); + positions.push_back(Pointf(it->pos(0) - 0.5 * part_size(0), it->pos(1) - 0.5 * part_size(1))); return positions; } #else @@ -430,26 +430,26 @@ arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const Boundi Pointf part = part_size; // use actual part size (the largest) plus separation distance (half on each side) in spacing algorithm - part.x() += dist; - part.y() += dist; + part(0) += dist; + part(1) += dist; Pointf area; if (bb != NULL && bb->defined) { area = bb->size(); } else { // bogus area size, large enough not to trigger the error below - area.x() = part.x() * total_parts; - area.y() = part.y() * total_parts; + area(0) = part(0) * total_parts; + area(1) = part(1) * total_parts; } // this is how many cells we have available into which to put parts - size_t cellw = floor((area.x() + dist) / part.x()); - size_t cellh = floor((area.y() + dist) / part.y()); + size_t cellw = floor((area(0) + dist) / part(0)); + size_t cellh = floor((area(1) + dist) / part(1)); if (total_parts > (cellw * cellh)) return false; // total space used by cells - Pointf cells(cellw * part.x(), cellh * part.y()); + Pointf cells(cellw * part(0), cellh * part(1)); // bounding box of total space used by cells BoundingBoxf cells_bb; @@ -458,8 +458,8 @@ arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const Boundi // center bounding box to area cells_bb.translate( - (area.x() - cells.x()) / 2, - (area.y() - cells.y()) / 2 + (area(0) - cells(0)) / 2, + (area(1) - cells(1)) / 2 ); // list of cells, sorted by distance from center @@ -468,15 +468,15 @@ arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const Boundi // work out distance for all cells, sort into list for (size_t i = 0; i <= cellw-1; ++i) { for (size_t j = 0; j <= cellh-1; ++j) { - coordf_t cx = linint(i + 0.5, 0, cellw, cells_bb.min.x(), cells_bb.max.x()); - coordf_t cy = linint(j + 0.5, 0, cellh, cells_bb.min.y(), cells_bb.max.y()); + coordf_t cx = linint(i + 0.5, 0, cellw, cells_bb.min(0), cells_bb.max(0)); + coordf_t cy = linint(j + 0.5, 0, cellh, cells_bb.min(1), cells_bb.max(1)); - coordf_t xd = fabs((area.x() / 2) - cx); - coordf_t yd = fabs((area.y() / 2) - cy); + coordf_t xd = fabs((area(0) / 2) - cx); + coordf_t yd = fabs((area(1) / 2) - cy); ArrangeItem c; - c.pos.x() = cx; - c.pos.y() = cy; + c.pos(0) = cx; + c.pos(1) = cy; c.index_x = i; c.index_y = j; c.dist = xd * xd + yd * yd - fabs((cellw / 2) - (i + 0.5)); @@ -533,13 +533,13 @@ arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const Boundi coordf_t cx = c.item.index_x - lx; coordf_t cy = c.item.index_y - ty; - positions.push_back(Pointf(cx * part.x(), cy * part.y())); + positions.push_back(Pointf(cx * part(0), cy * part(1))); } if (bb != NULL && bb->defined) { for (Pointfs::iterator p = positions.begin(); p != positions.end(); ++p) { - p->x() += bb->min.x(); - p->y() += bb->min.y(); + p->x() += bb->min(0); + p->y() += bb->min(1); } } @@ -608,15 +608,15 @@ namespace Voronoi { namespace Internal { if (cell1.contains_point() && cell2.contains_point()) { point_type p1 = retrieve_point(segments, cell1); point_type p2 = retrieve_point(segments, cell2); - origin.x((p1.x() + p2.x()) * 0.5); - origin.y((p1.y() + p2.y()) * 0.5); - direction.x(p1.y() - p2.y()); - direction.y(p2.x() - p1.x()); + origin.x((p1(0) + p2(0)) * 0.5); + origin.y((p1(1) + p2(1)) * 0.5); + direction.x(p1(1) - p2(1)); + direction.y(p2(0) - p1(0)); } else { origin = cell1.contains_segment() ? retrieve_point(segments, cell2) : retrieve_point(segments, cell1); segment_type segment = cell1.contains_segment() ? segments[cell1.source_index()] : segments[cell2.source_index()]; - coordinate_type dx = high(segment).x() - low(segment).x(); - coordinate_type dy = high(segment).y() - low(segment).y(); + coordinate_type dx = high(segment)(0) - low(segment)(0); + coordinate_type dy = high(segment)(1) - low(segment)(1); if ((low(segment) == origin) ^ cell1.contains_point()) { direction.x(dy); direction.y(-dx); @@ -625,19 +625,19 @@ namespace Voronoi { namespace Internal { direction.y(dx); } } - coordinate_type koef = bbox_max_size / (std::max)(fabs(direction.x()), fabs(direction.y())); + coordinate_type koef = bbox_max_size / (std::max)(fabs(direction(0)), fabs(direction(1))); if (edge.vertex0() == NULL) { clipped_edge->push_back(point_type( - origin.x() - direction.x() * koef, - origin.y() - direction.y() * koef)); + origin(0) - direction(0) * koef, + origin(1) - direction(1) * koef)); } else { clipped_edge->push_back( point_type(edge.vertex0()->x(), edge.vertex0()->y())); } if (edge.vertex1() == NULL) { clipped_edge->push_back(point_type( - origin.x() + direction.x() * koef, - origin.y() + direction.y() * koef)); + origin(0) + direction(0) * koef, + origin(1) + direction(1) * koef)); } else { clipped_edge->push_back( point_type(edge.vertex1()->x(), edge.vertex1()->y())); @@ -676,10 +676,10 @@ static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ voronoi_d const bool primaryEdgesOnly = false; BoundingBox bbox = BoundingBox(lines); - bbox.min.x() -= coord_t(1. / SCALING_FACTOR); - bbox.min.y() -= coord_t(1. / SCALING_FACTOR); - bbox.max.x() += coord_t(1. / SCALING_FACTOR); - bbox.max.y() += coord_t(1. / SCALING_FACTOR); + bbox.min(0) -= coord_t(1. / SCALING_FACTOR); + bbox.min(1) -= coord_t(1. / SCALING_FACTOR); + bbox.max(0) += coord_t(1. / SCALING_FACTOR); + bbox.max(1) += coord_t(1. / SCALING_FACTOR); ::Slic3r::SVG svg(path, bbox); @@ -689,7 +689,7 @@ static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ voronoi_d // bbox.scale(1.2); // For clipping of half-lines to some reasonable value. // The line will then be clipped by the SVG viewer anyway. - const double bbox_dim_max = double(bbox.max.x() - bbox.min.x()) + double(bbox.max.y() - bbox.min.y()); + const double bbox_dim_max = double(bbox.max(0) - bbox.min(0)) + double(bbox.max(1) - bbox.min(1)); // For the discretization of the Voronoi parabolic segments. const double discretization_step = 0.0005 * bbox_dim_max; @@ -697,8 +697,8 @@ static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ voronoi_d std::vector segments; for (Lines::const_iterator it = lines.begin(); it != lines.end(); ++ it) segments.push_back(Voronoi::Internal::segment_type( - Voronoi::Internal::point_type(double(it->a.x()), double(it->a.y())), - Voronoi::Internal::point_type(double(it->b.x()), double(it->b.y())))); + Voronoi::Internal::point_type(double(it->a(0)), double(it->a(1))), + Voronoi::Internal::point_type(double(it->b(0)), double(it->b(1))))); // Color exterior edges. for (voronoi_diagram::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it) @@ -712,13 +712,13 @@ static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ voronoi_d } // Draw the input polygon. for (Lines::const_iterator it = lines.begin(); it != lines.end(); ++it) - svg.draw(Line(Point(coord_t(it->a.x()), coord_t(it->a.y())), Point(coord_t(it->b.x()), coord_t(it->b.y()))), inputSegmentColor, inputSegmentLineWidth); + svg.draw(Line(Point(coord_t(it->a(0)), coord_t(it->a(1))), Point(coord_t(it->b(0)), coord_t(it->b(1)))), inputSegmentColor, inputSegmentLineWidth); #if 1 // Draw voronoi vertices. for (voronoi_diagram::const_vertex_iterator it = vd.vertices().begin(); it != vd.vertices().end(); ++it) if (! internalEdgesOnly || it->color() != Voronoi::Internal::EXTERNAL_COLOR) - svg.draw(Point(coord_t(it->x()), coord_t(it->y())), voronoiPointColor, voronoiPointRadius); + svg.draw(Point(coord_t((*it)(0)), coord_t((*it)(1))), voronoiPointColor, voronoiPointRadius); for (voronoi_diagram::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it) { if (primaryEdgesOnly && !it->is_primary()) @@ -743,7 +743,7 @@ static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ voronoi_d color = voronoiLineColorSecondary; } for (std::size_t i = 0; i + 1 < samples.size(); ++i) - svg.draw(Line(Point(coord_t(samples[i].x()), coord_t(samples[i].y())), Point(coord_t(samples[i+1].x()), coord_t(samples[i+1].y()))), color, voronoiLineWidth); + svg.draw(Line(Point(coord_t(samples[i](0)), coord_t(samples[i](1))), Point(coord_t(samples[i+1](0)), coord_t(samples[i+1](1)))), color, voronoiLineWidth); } #endif @@ -758,8 +758,8 @@ static inline void dump_voronoi_to_svg(const Lines &lines, /* const */ voronoi_d template T dist(const boost::polygon::point_data &p1,const boost::polygon::point_data &p2) { - T dx = p2.x() - p1.x(); - T dy = p2.y() - p1.y(); + T dx = p2(0) - p1(0); + T dy = p2(1) - p1(1); return sqrt(dx*dx+dy*dy); } @@ -770,11 +770,11 @@ inline point_type project_point_to_segment(segment_type &seg, point_type &px) typedef typename point_type::coordinate_type T; const point_type &p0 = low(seg); const point_type &p1 = high(seg); - const point_type dir(p1.x()-p0.x(), p1.y()-p0.y()); - const point_type dproj(px.x()-p0.x(), px.y()-p0.y()); - const T t = (dir.x()*dproj.x() + dir.y()*dproj.y()) / (dir.x()*dir.x() + dir.y()*dir.y()); + const point_type dir(p1(0)-p0(0), p1(1)-p0(1)); + const point_type dproj(px(0)-p0(0), px(1)-p0(1)); + const T t = (dir(0)*dproj(0) + dir(1)*dproj(1)) / (dir(0)*dir(0) + dir(1)*dir(1)); assert(t >= T(-1e-6) && t <= T(1. + 1e-6)); - return point_type(p0.x() + t*dir.x(), p0.y() + t*dir.y()); + return point_type(p0(0) + t*dir(0), p0(1) + t*dir(1)); } template @@ -828,8 +828,8 @@ public: Lines2VDSegments(const Lines &alines) : lines(alines) {} typename VD::segment_type operator[](size_t idx) const { return typename VD::segment_type( - typename VD::point_type(typename VD::coord_type(lines[idx].a.x()), typename VD::coord_type(lines[idx].a.y())), - typename VD::point_type(typename VD::coord_type(lines[idx].b.x()), typename VD::coord_type(lines[idx].b.y()))); + typename VD::point_type(typename VD::coord_type(lines[idx].a(0)), typename VD::coord_type(lines[idx].a(1))), + typename VD::point_type(typename VD::coord_type(lines[idx].b(0)), typename VD::coord_type(lines[idx].b(1)))); } private: const Lines &lines; diff --git a/xs/src/libslic3r/Geometry.hpp b/xs/src/libslic3r/Geometry.hpp index 1ac0ce59f..95c13fcdb 100644 --- a/xs/src/libslic3r/Geometry.hpp +++ b/xs/src/libslic3r/Geometry.hpp @@ -30,9 +30,9 @@ enum Orientation static inline Orientation orient(const Point &a, const Point &b, const Point &c) { // BOOST_STATIC_ASSERT(sizeof(coord_t) * 2 == sizeof(int64_t)); - int64_t u = int64_t(b.x()) * int64_t(c.y()) - int64_t(b.y()) * int64_t(c.x()); - int64_t v = int64_t(a.x()) * int64_t(c.y()) - int64_t(a.y()) * int64_t(c.x()); - int64_t w = int64_t(a.x()) * int64_t(b.y()) - int64_t(a.y()) * int64_t(b.x()); + int64_t u = int64_t(b(0)) * int64_t(c(1)) - int64_t(b(1)) * int64_t(c(0)); + int64_t v = int64_t(a(0)) * int64_t(c(1)) - int64_t(a(1)) * int64_t(c(0)); + int64_t w = int64_t(a(0)) * int64_t(b(1)) - int64_t(a(1)) * int64_t(b(0)); int64_t d = u - v + w; return (d > 0) ? ORIENTATION_CCW : ((d == 0) ? ORIENTATION_COLINEAR : ORIENTATION_CW); } @@ -52,7 +52,7 @@ static inline bool is_ccw(const Polygon &poly) for (unsigned int i = 1; i < poly.points.size(); ++ i) { const Point &pmin = poly.points[imin]; const Point &p = poly.points[i]; - if (p.x() < pmin.x() || (p.x() == pmin.x() && p.y() < pmin.y())) + if (p(0) < pmin(0) || (p(0) == pmin(0) && p(1) < pmin(1))) imin = i; } @@ -68,24 +68,24 @@ static inline bool is_ccw(const Polygon &poly) inline bool ray_ray_intersection(const Pointf &p1, const Vectorf &v1, const Pointf &p2, const Vectorf &v2, Pointf &res) { - double denom = v1.x() * v2.y() - v2.x() * v1.y(); + double denom = v1(0) * v2(1) - v2(0) * v1(1); if (std::abs(denom) < EPSILON) return false; - double t = (v2.x() * (p1.y() - p2.y()) - v2.y() * (p1.x() - p2.x())) / denom; - res.x() = p1.x() + t * v1.x(); - res.y() = p1.y() + t * v1.y(); + double t = (v2(0) * (p1(1) - p2(1)) - v2(1) * (p1(0) - p2(0))) / denom; + res(0) = p1(0) + t * v1(0); + res(1) = p1(1) + t * v1(1); return true; } inline bool segment_segment_intersection(const Pointf &p1, const Vectorf &v1, const Pointf &p2, const Vectorf &v2, Pointf &res) { - double denom = v1.x() * v2.y() - v2.x() * v1.y(); + double denom = v1(0) * v2(1) - v2(0) * v1(1); if (std::abs(denom) < EPSILON) // Lines are collinear. return false; - double s12_x = p1.x() - p2.x(); - double s12_y = p1.y() - p2.y(); - double s_numer = v1.x() * s12_y - v1.y() * s12_x; + double s12_x = p1(0) - p2(0); + double s12_y = p1(1) - p2(1); + double s_numer = v1(0) * s12_y - v1(1) * s12_x; bool denom_is_positive = false; if (denom < 0.) { denom_is_positive = true; @@ -95,7 +95,7 @@ inline bool segment_segment_intersection(const Pointf &p1, const Vectorf &v1, co if (s_numer < 0.) // Intersection outside of the 1st segment. return false; - double t_numer = v2.x() * s12_y - v2.y() * s12_x; + double t_numer = v2(0) * s12_y - v2(1) * s12_x; if (! denom_is_positive) t_numer = - t_numer; if (t_numer < 0. || s_numer > denom || t_numer > denom) @@ -103,8 +103,8 @@ inline bool segment_segment_intersection(const Pointf &p1, const Vectorf &v1, co return false; // Intersection inside both of the segments. double t = t_numer / denom; - res.x() = p1.x() + t * v1.x(); - res.y() = p1.y() + t * v1.y(); + res(0) = p1(0) + t * v1(0); + res(1) = p1(1) + t * v1(1); return true; } diff --git a/xs/src/libslic3r/Layer.cpp b/xs/src/libslic3r/Layer.cpp index a83267346..20e8f8ae1 100644 --- a/xs/src/libslic3r/Layer.cpp +++ b/xs/src/libslic3r/Layer.cpp @@ -168,8 +168,8 @@ void Layer::export_region_slices_to_svg(const char *path) const for (Surfaces::const_iterator surface = (*region)->slices.surfaces.begin(); surface != (*region)->slices.surfaces.end(); ++surface) bbox.merge(get_extents(surface->expolygon)); Point legend_size = export_surface_type_legend_to_svg_box_size(); - Point legend_pos(bbox.min.x(), bbox.max.y()); - bbox.merge(Point(std::max(bbox.min.x() + legend_size.x(), bbox.max.x()), bbox.max.y() + legend_size.y())); + Point legend_pos(bbox.min(0), bbox.max(1)); + bbox.merge(Point(std::max(bbox.min(0) + legend_size(0), bbox.max(0)), bbox.max(1) + legend_size(1))); SVG svg(path, bbox); const float transparency = 0.5f; @@ -194,8 +194,8 @@ void Layer::export_region_fill_surfaces_to_svg(const char *path) const for (Surfaces::const_iterator surface = (*region)->fill_surfaces.surfaces.begin(); surface != (*region)->fill_surfaces.surfaces.end(); ++surface) bbox.merge(get_extents(surface->expolygon)); Point legend_size = export_surface_type_legend_to_svg_box_size(); - Point legend_pos(bbox.min.x(), bbox.max.y()); - bbox.merge(Point(std::max(bbox.min.x() + legend_size.x(), bbox.max.x()), bbox.max.y() + legend_size.y())); + Point legend_pos(bbox.min(0), bbox.max(1)); + bbox.merge(Point(std::max(bbox.min(0) + legend_size(0), bbox.max(0)), bbox.max(1) + legend_size(1))); SVG svg(path, bbox); const float transparency = 0.5f; diff --git a/xs/src/libslic3r/LayerRegion.cpp b/xs/src/libslic3r/LayerRegion.cpp index fe3e91f50..afdc9c5a2 100644 --- a/xs/src/libslic3r/LayerRegion.cpp +++ b/xs/src/libslic3r/LayerRegion.cpp @@ -395,8 +395,8 @@ void LayerRegion::export_region_slices_to_svg(const char *path) const for (Surfaces::const_iterator surface = this->slices.surfaces.begin(); surface != this->slices.surfaces.end(); ++surface) bbox.merge(get_extents(surface->expolygon)); Point legend_size = export_surface_type_legend_to_svg_box_size(); - Point legend_pos(bbox.min.x(), bbox.max.y()); - bbox.merge(Point(std::max(bbox.min.x() + legend_size.x(), bbox.max.x()), bbox.max.y() + legend_size.y())); + Point legend_pos(bbox.min(0), bbox.max(1)); + bbox.merge(Point(std::max(bbox.min(0) + legend_size(0), bbox.max(0)), bbox.max(1) + legend_size(1))); SVG svg(path, bbox); const float transparency = 0.5f; @@ -422,8 +422,8 @@ void LayerRegion::export_region_fill_surfaces_to_svg(const char *path) const for (Surfaces::const_iterator surface = this->fill_surfaces.surfaces.begin(); surface != this->fill_surfaces.surfaces.end(); ++surface) bbox.merge(get_extents(surface->expolygon)); Point legend_size = export_surface_type_legend_to_svg_box_size(); - Point legend_pos(bbox.min.x(), bbox.max.y()); - bbox.merge(Point(std::max(bbox.min.x() + legend_size.x(), bbox.max.x()), bbox.max.y() + legend_size.y())); + Point legend_pos(bbox.min(0), bbox.max(1)); + bbox.merge(Point(std::max(bbox.min(0) + legend_size(0), bbox.max(0)), bbox.max(1) + legend_size(1))); SVG svg(path, bbox); const float transparency = 0.5f; diff --git a/xs/src/libslic3r/Line.cpp b/xs/src/libslic3r/Line.cpp index cd1a0dbe1..9007754fe 100644 --- a/xs/src/libslic3r/Line.cpp +++ b/xs/src/libslic3r/Line.cpp @@ -10,8 +10,8 @@ namespace Slic3r { std::string Line::wkt() const { std::ostringstream ss; - ss << "LINESTRING(" << this->a.x() << " " << this->a.y() << "," - << this->b.x() << " " << this->b.y() << ")"; + ss << "LINESTRING(" << this->a(0) << " " << this->a(1) << "," + << this->b(0) << " " << this->b(1) << ")"; return ss.str(); } @@ -108,8 +108,8 @@ bool Line::intersection(const Line &l2, Point *intersection) const Pointf3 Linef3::intersect_plane(double z) const { auto v = (this->b - this->a).cast(); - double t = (z - this->a.z()) / v.z(); - return Pointf3(this->a.x() + v.x() * t, this->a.y() + v.y() * t, z); + double t = (z - this->a(2)) / v(2); + return Pointf3(this->a(0) + v(0) * t, this->a(1) + v(1) * t, z); } } diff --git a/xs/src/libslic3r/Line.hpp b/xs/src/libslic3r/Line.hpp index a38810f71..feeb1d266 100644 --- a/xs/src/libslic3r/Line.hpp +++ b/xs/src/libslic3r/Line.hpp @@ -34,11 +34,11 @@ public: double perp_distance_to(const Point &point) const; bool parallel_to(double angle) const; bool parallel_to(const Line &line) const { return this->parallel_to(line.direction()); } - double atan2_() const { return atan2(this->b.y() - this->a.y(), this->b.x() - this->a.x()); } + double atan2_() const { return atan2(this->b(1) - this->a(1), this->b(0) - this->a(0)); } double orientation() const; double direction() const; Vector vector() const { return this->b - this->a; } - Vector normal() const { return Vector((this->b.y() - this->a.y()), -(this->b.x() - this->a.x())); } + Vector normal() const { return Vector((this->b(1) - this->a(1)), -(this->b(0) - this->a(0))); } bool intersection(const Line& line, Point* intersection) const; double ccw(const Point& point) const { return point.ccw(*this); } diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index e22f87f65..dc0a462c0 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -335,11 +335,11 @@ std::string toString(const Model& model, bool holes = true) { ss << "\t\t{\n"; for(auto v : expoly.contour.points) ss << "\t\t\t{" - << v.x() << ", " - << v.y() << "},\n"; + << v(0) << ", " + << v(1) << "},\n"; { auto v = expoly.contour.points.front(); - ss << "\t\t\t{" << v.x() << ", " << v.y() << "},\n"; + ss << "\t\t\t{" << v(0) << ", " << v(1) << "},\n"; } ss << "\t\t},\n"; @@ -348,11 +348,11 @@ std::string toString(const Model& model, bool holes = true) { if(holes) for(auto h : expoly.holes) { ss << "\t\t\t{\n"; for(auto v : h.points) ss << "\t\t\t\t{" - << v.x() << ", " - << v.y() << "},\n"; + << v(0) << ", " + << v(1) << "},\n"; { auto v = h.points.front(); - ss << "\t\t\t\t{" << v.x() << ", " << v.y() << "},\n"; + ss << "\t\t\t\t{" << v(0) << ", " << v(1) << "},\n"; } ss << "\t\t\t},\n"; } @@ -427,8 +427,8 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model) { if(item.vertexCount() > 3) { item.rotation(objinst->rotation); item.translation( { - ClipperLib::cInt(objinst->offset.x()/SCALING_FACTOR), - ClipperLib::cInt(objinst->offset.y()/SCALING_FACTOR) + ClipperLib::cInt(objinst->offset(0)/SCALING_FACTOR), + ClipperLib::cInt(objinst->offset(1)/SCALING_FACTOR) }); ret.emplace_back(objinst, item); } @@ -499,12 +499,12 @@ bool arrange(Model &model, coordf_t dist, const Slic3r::BoundingBoxf* bb, bbb.scale(1.0/SCALING_FACTOR); bin = Box({ - static_cast(bbb.min.x()), - static_cast(bbb.min.y()) + static_cast(bbb.min(0)), + static_cast(bbb.min(1)) }, { - static_cast(bbb.max.x()), - static_cast(bbb.max.y()) + static_cast(bbb.max(0)), + static_cast(bbb.max(1)) }); } @@ -718,8 +718,8 @@ void Model::duplicate_objects_grid(size_t x, size_t y, coordf_t dist) for (size_t x_copy = 1; x_copy <= x; ++x_copy) { for (size_t y_copy = 1; y_copy <= y; ++y_copy) { ModelInstance* instance = object->add_instance(); - instance->offset.x() = (size.x() + dist) * (x_copy-1); - instance->offset.y() = (size.y() + dist) * (y_copy-1); + instance->offset(0) = (size(0) + dist) * (x_copy-1); + instance->offset(1) = (size(1) + dist) * (y_copy-1); } } } @@ -733,7 +733,7 @@ bool Model::looks_like_multipart_object() const if (obj->volumes.size() > 1 || obj->config.keys().size() > 1) return false; for (const ModelVolume *vol : obj->volumes) { - double zmin_this = vol->mesh.bounding_box().min.z(); + double zmin_this = vol->mesh.bounding_box().min(2); if (zmin == std::numeric_limits::max()) zmin = zmin_this; else if (std::abs(zmin - zmin_this) > EPSILON) @@ -777,13 +777,13 @@ void Model::adjust_min_z() if (objects.empty()) return; - if (bounding_box().min.z() < 0.0) + if (bounding_box().min(2) < 0.0) { for (ModelObject* obj : objects) { if (obj != nullptr) { - coordf_t obj_min_z = obj->bounding_box().min.z(); + coordf_t obj_min_z = obj->bounding_box().min(2); if (obj_min_z < 0.0) obj->translate(0.0, 0.0, -obj_min_z); } @@ -983,19 +983,19 @@ BoundingBoxf3 ModelObject::tight_bounding_box(bool include_modifiers) const Pointf3 p((double)v.x, (double)v.y, (double)v.z); // scale - p.x() *= inst->scaling_factor; - p.y() *= inst->scaling_factor; - p.z() *= inst->scaling_factor; + p(0) *= inst->scaling_factor; + p(1) *= inst->scaling_factor; + p(2) *= inst->scaling_factor; // rotate Z - double x = p.x(); - double y = p.y(); - p.x() = c * x - s * y; - p.y() = s * x + c * y; + double x = p(0); + double y = p(1); + p(0) = c * x - s * y; + p(1) = s * x + c * y; // translate - p.x() += inst->offset.x(); - p.y() += inst->offset.y(); + p(0) += inst->offset(0); + p(1) += inst->offset(1); bb.merge(p); } @@ -1065,12 +1065,12 @@ void ModelObject::center_around_origin() bb.merge(v->mesh.bounding_box()); // first align to origin on XYZ - Vectorf3 vector(-bb.min.x(), -bb.min.y(), -bb.min.z()); + Vectorf3 vector(-bb.min(0), -bb.min(1), -bb.min(2)); // then center it on XY Sizef3 size = bb.size(); - vector.x() -= size.x()/2; - vector.y() -= size.y()/2; + vector(0) -= size(0)/2; + vector(1) -= size(1)/2; this->translate(vector); this->origin_translation += vector; @@ -1256,19 +1256,19 @@ void ModelObject::check_instances_print_volume_state(const BoundingBoxf3& print_ Pointf3 p((double)v.x, (double)v.y, (double)v.z); // scale - p.x() *= inst->scaling_factor; - p.y() *= inst->scaling_factor; - p.z() *= inst->scaling_factor; + p(0) *= inst->scaling_factor; + p(1) *= inst->scaling_factor; + p(2) *= inst->scaling_factor; // rotate Z - double x = p.x(); - double y = p.y(); - p.x() = c * x - s * y; - p.y() = s * x + c * y; + double x = p(0); + double y = p(1); + p(0) = c * x - s * y; + p(1) = s * x + c * y; // translate - p.x() += inst->offset.x(); - p.y() += inst->offset.y(); + p(0) += inst->offset(0); + p(1) += inst->offset(1); bb.merge(p); } @@ -1295,15 +1295,15 @@ void ModelObject::print_info() const mesh.check_topology(); BoundingBoxf3 bb = mesh.bounding_box(); Sizef3 size = bb.size(); - cout << "size_x = " << size.x() << endl; - cout << "size_y = " << size.y() << endl; - cout << "size_z = " << size.z() << endl; - cout << "min_x = " << bb.min.x() << endl; - cout << "min_y = " << bb.min.y() << endl; - cout << "min_z = " << bb.min.z() << endl; - cout << "max_x = " << bb.max.x() << endl; - cout << "max_y = " << bb.max.y() << endl; - cout << "max_z = " << bb.max.z() << endl; + cout << "size_x = " << size(0) << endl; + cout << "size_y = " << size(1) << endl; + cout << "size_z = " << size(2) << endl; + cout << "min_x = " << bb.min(0) << endl; + cout << "min_y = " << bb.min(1) << endl; + cout << "min_z = " << bb.min(2) << endl; + cout << "max_x = " << bb.max(0) << endl; + cout << "max_y = " << bb.max(1) << endl; + cout << "max_z = " << bb.max(2) << endl; cout << "number_of_facets = " << mesh.stl.stats.number_of_facets << endl; cout << "manifold = " << (mesh.is_manifold() ? "yes" : "no") << endl; @@ -1394,7 +1394,7 @@ void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) cons mesh->rotate_z(this->rotation); // rotate around mesh origin mesh->scale(this->scaling_factor); // scale around mesh origin if (!dont_translate) - mesh->translate(this->offset.x(), this->offset.y(), 0); + mesh->translate(this->offset(0), this->offset(1), 0); } BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mesh, bool dont_translate) const @@ -1417,19 +1417,19 @@ BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mes if (! empty(bbox)) { // Scale the bounding box uniformly. if (std::abs(this->scaling_factor - 1.) > EPSILON) { - bbox.min.x() *= float(this->scaling_factor); - bbox.min.y() *= float(this->scaling_factor); - bbox.min.z() *= float(this->scaling_factor); - bbox.max.x() *= float(this->scaling_factor); - bbox.max.y() *= float(this->scaling_factor); - bbox.max.z() *= float(this->scaling_factor); + bbox.min(0) *= float(this->scaling_factor); + bbox.min(1) *= float(this->scaling_factor); + bbox.min(2) *= float(this->scaling_factor); + bbox.max(0) *= float(this->scaling_factor); + bbox.max(1) *= float(this->scaling_factor); + bbox.max(2) *= float(this->scaling_factor); } // Translate the bounding box. if (! dont_translate) { - bbox.min.x() += float(this->offset.x()); - bbox.min.y() += float(this->offset.y()); - bbox.max.x() += float(this->offset.x()); - bbox.max.y() += float(this->offset.y()); + bbox.min(0) += float(this->offset(0)); + bbox.min(1) += float(this->offset(1)); + bbox.max(0) += float(this->offset(0)); + bbox.max(1) += float(this->offset(1)); } } return bbox; @@ -1439,7 +1439,7 @@ BoundingBoxf3 ModelInstance::transform_bounding_box(const BoundingBoxf3 &bbox, b { auto matrix = Transform3f::Identity(); if (!dont_translate) - matrix.translate(Vec3f((float)offset.x(), (float)offset.y(), 0.0f)); + matrix.translate(Vec3f((float)offset(0), (float)offset(1), 0.0f)); matrix.rotate(Eigen::AngleAxisf(rotation, Vec3f::UnitZ())); matrix.scale(scaling_factor); return bbox.transformed(matrix); diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index 6c299fc4c..06f727ccf 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -120,7 +120,7 @@ public: // A snug bounding box around the transformed non-modifier object volumes. BoundingBoxf3 instance_bounding_box(size_t instance_idx, bool dont_translate = false) const; void center_around_origin(); - void translate(const Vectorf3 &vector) { this->translate(vector.x(), vector.y(), vector.z()); } + void translate(const Vectorf3 &vector) { this->translate(vector(0), vector(1), vector(2)); } void translate(coordf_t x, coordf_t y, coordf_t z); void scale(const Pointf3 &versor); void rotate(float angle, const Axis &axis); diff --git a/xs/src/libslic3r/MultiPoint.cpp b/xs/src/libslic3r/MultiPoint.cpp index b9fc70967..0fbad58c2 100644 --- a/xs/src/libslic3r/MultiPoint.cpp +++ b/xs/src/libslic3r/MultiPoint.cpp @@ -30,10 +30,10 @@ void MultiPoint::translate(const Point &v) void MultiPoint::rotate(double cos_angle, double sin_angle) { for (Point &pt : this->points) { - double cur_x = double(pt.x()); - double cur_y = double(pt.y()); - pt.x() = coord_t(round(cos_angle * cur_x - sin_angle * cur_y)); - pt.y() = coord_t(round(cos_angle * cur_y + sin_angle * cur_x)); + double cur_x = double(pt(0)); + double cur_y = double(pt(1)); + pt(0) = coord_t(round(cos_angle * cur_x - sin_angle * cur_y)); + pt(1) = coord_t(round(cos_angle * cur_y + sin_angle * cur_x)); } } @@ -43,8 +43,8 @@ void MultiPoint::rotate(double angle, const Point ¢er) double c = cos(angle); for (Point &pt : points) { Vec2crd v(pt - center); - pt.x() = (coord_t)round(double(center.x()) + c * v[0] - s * v[1]); - pt.y() = (coord_t)round(double(center.y()) + c * v[1] + s * v[0]); + pt(0) = (coord_t)round(double(center(0)) + c * v[0] - s * v[1]); + pt(1) = (coord_t)round(double(center(1)) + c * v[1] + s * v[0]); } } @@ -210,14 +210,14 @@ MultiPoint::_douglas_peucker(const Points &points, const double tolerance) void MultiPoint3::translate(double x, double y) { for (Point3 &p : points) { - p.x() += x; - p.y() += y; + p(0) += x; + p(1) += y; } } void MultiPoint3::translate(const Point& vector) { - this->translate(vector.x(), vector.y()); + this->translate(vector(0), vector(1)); } double MultiPoint3::length() const @@ -267,19 +267,19 @@ BoundingBox get_extents_rotated(const Points &points, double angle) double s = sin(angle); double c = cos(angle); Points::const_iterator it = points.begin(); - double cur_x = (double)it->x(); - double cur_y = (double)it->y(); - bbox.min.x() = bbox.max.x() = (coord_t)round(c * cur_x - s * cur_y); - bbox.min.y() = bbox.max.y() = (coord_t)round(c * cur_y + s * cur_x); + double cur_x = (double)(*it)(0); + double cur_y = (double)(*it)(1); + bbox.min(0) = bbox.max(0) = (coord_t)round(c * cur_x - s * cur_y); + bbox.min(1) = bbox.max(1) = (coord_t)round(c * cur_y + s * cur_x); for (++it; it != points.end(); ++it) { - double cur_x = (double)it->x(); - double cur_y = (double)it->y(); + double cur_x = (double)(*it)(0); + double cur_y = (double)(*it)(1); coord_t x = (coord_t)round(c * cur_x - s * cur_y); coord_t y = (coord_t)round(c * cur_y + s * cur_x); - bbox.min.x() = std::min(x, bbox.min.x()); - bbox.min.y() = std::min(y, bbox.min.y()); - bbox.max.x() = std::max(x, bbox.max.x()); - bbox.max.y() = std::max(y, bbox.max.y()); + bbox.min(0) = std::min(x, bbox.min(0)); + bbox.min(1) = std::min(y, bbox.min(1)); + bbox.max(0) = std::max(x, bbox.max(0)); + bbox.max(1) = std::max(y, bbox.max(1)); } bbox.defined = true; } diff --git a/xs/src/libslic3r/Point.cpp b/xs/src/libslic3r/Point.cpp index 670643a2c..4b49106df 100644 --- a/xs/src/libslic3r/Point.cpp +++ b/xs/src/libslic3r/Point.cpp @@ -9,42 +9,42 @@ namespace Slic3r { std::string Point::wkt() const { std::ostringstream ss; - ss << "POINT(" << this->x() << " " << this->y() << ")"; + ss << "POINT(" << (*this)(0) << " " << (*this)(1) << ")"; return ss.str(); } std::string Point::dump_perl() const { std::ostringstream ss; - ss << "[" << this->x() << "," << this->y() << "]"; + ss << "[" << (*this)(0) << "," << (*this)(1) << "]"; return ss.str(); } void Point::rotate(double angle) { - double cur_x = (double)this->x(); - double cur_y = (double)this->y(); + double cur_x = (double)(*this)(0); + double cur_y = (double)(*this)(1); double s = ::sin(angle); double c = ::cos(angle); - this->x() = (coord_t)round(c * cur_x - s * cur_y); - this->y() = (coord_t)round(c * cur_y + s * cur_x); + (*this)(0) = (coord_t)round(c * cur_x - s * cur_y); + (*this)(1) = (coord_t)round(c * cur_y + s * cur_x); } void Point::rotate(double angle, const Point ¢er) { - double cur_x = (double)this->x(); - double cur_y = (double)this->y(); + double cur_x = (double)(*this)(0); + double cur_y = (double)(*this)(1); double s = ::sin(angle); double c = ::cos(angle); - double dx = cur_x - (double)center.x(); - double dy = cur_y - (double)center.y(); - this->x() = (coord_t)round( (double)center.x() + c * dx - s * dy ); - this->y() = (coord_t)round( (double)center.y() + c * dy + s * dx ); + double dx = cur_x - (double)center(0); + double dy = cur_y - (double)center(1); + (*this)(0) = (coord_t)round( (double)center(0) + c * dx - s * dy ); + (*this)(1) = (coord_t)round( (double)center(1) + c * dy + s * dx ); } bool Point::coincides_with_epsilon(const Point &point) const { - return std::abs(this->x() - point.x()) < SCALED_EPSILON && std::abs(this->y() - point.y()) < SCALED_EPSILON; + return std::abs((*this)(0) - point(0)) < SCALED_EPSILON && std::abs((*this)(1) - point(1)) < SCALED_EPSILON; } int Point::nearest_point_index(const Points &points) const @@ -64,12 +64,12 @@ int Point::nearest_point_index(const PointConstPtrs &points) const for (PointConstPtrs::const_iterator it = points.begin(); it != points.end(); ++it) { /* If the X distance of the candidate is > than the total distance of the best previous candidate, we know we don't want it */ - double d = sqr(this->x() - (*it)->x()); + double d = sqr((*this)(0) - (*it)->x()); if (distance != -1 && d > distance) continue; /* If the Y distance of the candidate is > than the total distance of the best previous candidate, we know we don't want it */ - d += sqr(this->y() - (*it)->y()); + d += sqr((*this)(1) - (*it)->y()); if (distance != -1 && d > distance) continue; idx = it - points.begin(); @@ -107,7 +107,7 @@ bool Point::nearest_point(const Points &points, Point* point) const */ double Point::ccw(const Point &p1, const Point &p2) const { - return (double)(p2.x() - p1.x())*(double)(this->y() - p1.y()) - (double)(p2.y() - p1.y())*(double)(this->x() - p1.x()); + return (double)(p2(0) - p1(0))*(double)((*this)(1) - p1(1)) - (double)(p2(1) - p1(1))*(double)((*this)(0) - p1(0)); } double Point::ccw(const Line &line) const @@ -119,8 +119,8 @@ double Point::ccw(const Line &line) const // i.e. this assumes a CCW rotation from p1 to p2 around this double Point::ccw_angle(const Point &p1, const Point &p2) const { - double angle = atan2(p1.x() - this->x(), p1.y() - this->y()) - - atan2(p2.x() - this->x(), p2.y() - this->y()); + double angle = atan2(p1(0) - (*this)(0), p1(1) - (*this)(1)) + - atan2(p2(0) - (*this)(0), p2(1) - (*this)(1)); // we only want to return only positive angles return angle <= 0 ? angle + 2*PI : angle; @@ -155,9 +155,9 @@ Point Point::projection_onto(const Line &line) const If theta is outside the interval [0,1], then one of the Line_Segment's endpoints must be closest to calling Point. */ - double lx = (double)(line.b.x() - line.a.x()); - double ly = (double)(line.b.y() - line.a.y()); - double theta = ( (double)(line.b.x() - this->x())*lx + (double)(line.b.y()- this->y())*ly ) + double lx = (double)(line.b(0) - line.a(0)); + double ly = (double)(line.b(1) - line.a(1)); + double theta = ( (double)(line.b(0) - (*this)(0))*lx + (double)(line.b(1)- (*this)(1))*ly ) / ( sqr(lx) + sqr(ly) ); if (0.0 <= theta && theta <= 1.0) @@ -169,43 +169,43 @@ Point Point::projection_onto(const Line &line) const std::ostream& operator<<(std::ostream &stm, const Pointf &pointf) { - return stm << pointf.x() << "," << pointf.y(); + return stm << pointf(0) << "," << pointf(1); } std::string Pointf::wkt() const { std::ostringstream ss; - ss << "POINT(" << this->x() << " " << this->y() << ")"; + ss << "POINT(" << (*this)(0) << " " << (*this)(1) << ")"; return ss.str(); } std::string Pointf::dump_perl() const { std::ostringstream ss; - ss << "[" << this->x() << "," << this->y() << "]"; + ss << "[" << (*this)(0) << "," << (*this)(1) << "]"; return ss.str(); } void Pointf::rotate(double angle) { - double cur_x = this->x(); - double cur_y = this->y(); + double cur_x = (*this)(0); + double cur_y = (*this)(1); double s = ::sin(angle); double c = ::cos(angle); - this->x() = c * cur_x - s * cur_y; - this->y() = c * cur_y + s * cur_x; + (*this)(0) = c * cur_x - s * cur_y; + (*this)(1) = c * cur_y + s * cur_x; } void Pointf::rotate(double angle, const Pointf ¢er) { - double cur_x = this->x(); - double cur_y = this->y(); + double cur_x = (*this)(0); + double cur_y = (*this)(1); double s = ::sin(angle); double c = ::cos(angle); - double dx = cur_x - center.x(); - double dy = cur_y - center.y(); - this->x() = center.x() + c * dx - s * dy; - this->y() = center.y() + c * dy + s * dx; + double dx = cur_x - center(0); + double dy = cur_y - center(1); + (*this)(0) = center(0) + c * dx - s * dy; + (*this)(1) = center(1) + c * dy + s * dx; } namespace int128 { @@ -214,12 +214,12 @@ int orient(const Point &p1, const Point &p2, const Point &p3) { Slic3r::Vector v1(p2 - p1); Slic3r::Vector v2(p3 - p1); - return Int128::sign_determinant_2x2_filtered(v1.x(), v1.y(), v2.x(), v2.y()); + return Int128::sign_determinant_2x2_filtered(v1(0), v1(1), v2(0), v2(1)); } int cross(const Point &v1, const Point &v2) { - return Int128::sign_determinant_2x2_filtered(v1.x(), v1.y(), v2.x(), v2.y()); + return Int128::sign_determinant_2x2_filtered(v1(0), v1(1), v2(0), v2(1)); } } diff --git a/xs/src/libslic3r/Point.hpp b/xs/src/libslic3r/Point.hpp index affe1e80e..60e053f16 100644 --- a/xs/src/libslic3r/Point.hpp +++ b/xs/src/libslic3r/Point.hpp @@ -49,10 +49,10 @@ typedef Eigen::Transform Transform2d typedef Eigen::Transform Transform3f; typedef Eigen::Transform Transform3d; -inline int64_t cross2(const Vec2i64 &v1, const Vec2i64 &v2) { return v1.x() * v2.y() - v1.y() * v2.x(); } -inline coord_t cross2(const Vec2crd &v1, const Vec2crd &v2) { return v1.x() * v2.y() - v1.y() * v2.x(); } -inline float cross2(const Vec2f &v1, const Vec2f &v2) { return v1.x() * v2.y() - v1.y() * v2.x(); } -inline double cross2(const Vec2d &v1, const Vec2d &v2) { return v1.x() * v2.y() - v1.y() * v2.x(); } +inline int64_t cross2(const Vec2i64 &v1, const Vec2i64 &v2) { return v1(0) * v2(1) - v1(1) * v2(0); } +inline coord_t cross2(const Vec2crd &v1, const Vec2crd &v2) { return v1(0) * v2(1) - v1(1) * v2(0); } +inline float cross2(const Vec2f &v1, const Vec2f &v2) { return v1(0) * v2(1) - v1(1) * v2(0); } +inline double cross2(const Vec2d &v1, const Vec2d &v2) { return v1(0) * v2(1) - v1(1) * v2(0); } class Point : public Vec2crd { @@ -77,18 +77,13 @@ public: return *this; } - const coord_t& x() const { return (*this)(0); } - coord_t& x() { return (*this)(0); } - const coord_t& y() const { return (*this)(1); } - coord_t& y() { return (*this)(1); } - - bool operator==(const Point& rhs) const { return this->x() == rhs.x() && this->y() == rhs.y(); } + bool operator==(const Point& rhs) const { return (*this)(0) == rhs(0) && (*this)(1) == rhs(1); } bool operator!=(const Point& rhs) const { return ! (*this == rhs); } - bool operator< (const Point& rhs) const { return this->x() < rhs.x() || (this->x() == rhs.x() && this->y() < rhs.y()); } + bool operator< (const Point& rhs) const { return (*this)(0) < rhs(0) || ((*this)(0) == rhs(0) && (*this)(1) < rhs(1)); } - Point& operator+=(const Point& rhs) { this->x() += rhs.x(); this->y() += rhs.y(); return *this; } - Point& operator-=(const Point& rhs) { this->x() -= rhs.x(); this->y() -= rhs.y(); return *this; } - Point& operator*=(const double &rhs) { this->x() *= rhs; this->y() *= rhs; return *this; } + Point& operator+=(const Point& rhs) { (*this)(0) += rhs(0); (*this)(1) += rhs(1); return *this; } + Point& operator-=(const Point& rhs) { (*this)(0) -= rhs(0); (*this)(1) -= rhs(1); return *this; } + Point& operator*=(const double &rhs) { (*this)(0) *= rhs; (*this)(1) *= rhs; return *this; } std::string wkt() const; std::string dump_perl() const; @@ -120,7 +115,7 @@ namespace int128 { // To be used by std::unordered_map, std::unordered_multimap and friends. struct PointHash { size_t operator()(const Point &pt) const { - return std::hash()(pt.x()) ^ std::hash()(pt.y()); + return std::hash()(pt(0)) ^ std::hash()(pt(1)); } }; @@ -182,12 +177,12 @@ public: const ValueType *value_min = nullptr; double dist_min = std::numeric_limits::max(); // Round pt to a closest grid_cell corner. - Point grid_corner((pt.x()+(m_grid_resolution>>1))>>m_grid_log2, (pt.y()+(m_grid_resolution>>1))>>m_grid_log2); + Point grid_corner((pt(0)+(m_grid_resolution>>1))>>m_grid_log2, (pt(1)+(m_grid_resolution>>1))>>m_grid_log2); // For four neighbors of grid_corner: for (coord_t neighbor_y = -1; neighbor_y < 1; ++ neighbor_y) { for (coord_t neighbor_x = -1; neighbor_x < 1; ++ neighbor_x) { // Range of fragment starts around grid_corner, close to pt. - auto range = m_map.equal_range(Point(grid_corner.x() + neighbor_x, grid_corner.y() + neighbor_y)); + auto range = m_map.equal_range(Point(grid_corner(0) + neighbor_x, grid_corner(1) + neighbor_y)); // Find the map entry closest to pt. for (auto it = range.first; it != range.second; ++it) { const ValueType &value = it->second; @@ -236,17 +231,10 @@ public: return *this; } - const coord_t& x() const { return (*this)(0); } - coord_t& x() { return (*this)(0); } - const coord_t& y() const { return (*this)(1); } - coord_t& y() { return (*this)(1); } - const coord_t& z() const { return (*this)(2); } - coord_t& z() { return (*this)(2); } - - bool operator==(const Point3 &rhs) const { return this->x() == rhs.x() && this->y() == rhs.y() && this->z() == rhs.z(); } + bool operator==(const Point3 &rhs) const { return (*this)(0) == rhs(0) && (*this)(1) == rhs(1) && (*this)(2) == rhs(2); } bool operator!=(const Point3 &rhs) const { return ! (*this == rhs); } - Point xy() const { return Point(this->x(), this->y()); } + Point xy() const { return Point((*this)(0), (*this)(1)); } }; std::ostream& operator<<(std::ostream &stm, const Pointf &pointf); @@ -262,7 +250,7 @@ public: template Pointf(const Eigen::MatrixBase &other) : Vec2d(other) {} static Pointf new_unscale(coord_t x, coord_t y) { return Pointf(unscale(x), unscale(y)); } - static Pointf new_unscale(const Point &p) { return Pointf(unscale(p.x()), unscale(p.y())); } + static Pointf new_unscale(const Point &p) { return Pointf(unscale(p(0)), unscale(p(1))); } // This method allows you to assign Eigen expressions to MyVectorType template @@ -272,22 +260,14 @@ public: return *this; } - const coordf_t& x() const { return (*this)(0); } - coordf_t& x() { return (*this)(0); } - const coordf_t& y() const { return (*this)(1); } - coordf_t& y() { return (*this)(1); } - std::string wkt() const; std::string dump_perl() const; void rotate(double angle); void rotate(double angle, const Pointf ¢er); - Pointf& operator+=(const Pointf& rhs) { this->x() += rhs.x(); this->y() += rhs.y(); return *this; } - Pointf& operator-=(const Pointf& rhs) { this->x() -= rhs.x(); this->y() -= rhs.y(); return *this; } - Pointf& operator*=(const coordf_t& rhs) { this->x() *= rhs; this->y() *= rhs; return *this; } - bool operator==(const Pointf &rhs) const { return this->x() == rhs.x() && this->y() == rhs.y(); } + bool operator==(const Pointf &rhs) const { return (*this)(0) == rhs(0) && (*this)(1) == rhs(1); } bool operator!=(const Pointf &rhs) const { return ! (*this == rhs); } - bool operator< (const Pointf& rhs) const { return this->x() < rhs.x() || (this->x() == rhs.x() && this->y() < rhs.y()); } + bool operator< (const Pointf& rhs) const { return (*this)(0) < rhs(0) || ((*this)(0) == rhs(0) && (*this)(1) < rhs(1)); } }; class Pointf3 : public Vec3d @@ -302,7 +282,7 @@ public: template Pointf3(const Eigen::MatrixBase &other) : Vec3d(other) {} static Pointf3 new_unscale(coord_t x, coord_t y, coord_t z) { return Pointf3(unscale(x), unscale(y), unscale(z)); } - static Pointf3 new_unscale(const Point3& p) { return Pointf3(unscale(p.x()), unscale(p.y()), unscale(p.z())); } + static Pointf3 new_unscale(const Point3& p) { return Pointf3(unscale(p(0)), unscale(p(1)), unscale(p(2))); } // This method allows you to assign Eigen expressions to MyVectorType template @@ -312,17 +292,10 @@ public: return *this; } - const coordf_t& x() const { return (*this)(0); } - coordf_t& x() { return (*this)(0); } - const coordf_t& y() const { return (*this)(1); } - coordf_t& y() { return (*this)(1); } - const coordf_t& z() const { return (*this)(2); } - coordf_t& z() { return (*this)(2); } - - bool operator==(const Pointf3 &rhs) const { return this->x() == rhs.x() && this->y() == rhs.y() && this->z() == rhs.z(); } + bool operator==(const Pointf3 &rhs) const { return (*this)(0) == rhs(0) && (*this)(1) == rhs(1) && (*this)(2) == rhs(2); } bool operator!=(const Pointf3 &rhs) const { return ! (*this == rhs); } - Pointf xy() const { return Pointf(this->x(), this->y()); } + Pointf xy() const { return Pointf((*this)(0), (*this)(1)); } }; } // namespace Slic3r @@ -339,7 +312,7 @@ namespace boost { namespace polygon { typedef coord_t coordinate_type; static inline coordinate_type get(const Slic3r::Point& point, orientation_2d orient) { - return (orient == HORIZONTAL) ? (coordinate_type)point.x() : (coordinate_type)point.y(); + return (orient == HORIZONTAL) ? (coordinate_type)point(0) : (coordinate_type)point(1); } }; @@ -348,14 +321,14 @@ namespace boost { namespace polygon { typedef coord_t coordinate_type; static inline void set(Slic3r::Point& point, orientation_2d orient, coord_t value) { if (orient == HORIZONTAL) - point.x() = value; + point(0) = value; else - point.y() = value; + point(1) = value; } static inline Slic3r::Point construct(coord_t x_value, coord_t y_value) { Slic3r::Point retval; - retval.x() = x_value; - retval.y() = y_value; + retval(0) = x_value; + retval(1) = y_value; return retval; } }; diff --git a/xs/src/libslic3r/Polygon.cpp b/xs/src/libslic3r/Polygon.cpp index 83aea58d9..ce9cc66dc 100644 --- a/xs/src/libslic3r/Polygon.cpp +++ b/xs/src/libslic3r/Polygon.cpp @@ -86,7 +86,7 @@ int64_t Polygon::area2x() const int64_t a = 0; for (size_t i = 0, j = n - 1; i < n; ++i) - a += int64_t(poly[j].x() + poly[i].x()) * int64_t(poly[j].y() - poly[i].y()); + a += int64_t(poly[j](0) + poly[i](0)) * int64_t(poly[j](1) - poly[i](1)); j = i; } return -a * 0.5; @@ -101,7 +101,7 @@ double Polygon::area() const double a = 0.; for (size_t i = 0, j = n - 1; i < n; ++i) { - a += ((double)points[j].x() + (double)points[i].x()) * ((double)points[i].y() - (double)points[j].y()); + a += ((double)points[j](0) + (double)points[i](0)) * ((double)points[i](1) - (double)points[j](1)); j = i; } return 0.5 * a; @@ -155,17 +155,17 @@ Polygon::contains(const Point &point) const Points::const_iterator i = this->points.begin(); Points::const_iterator j = this->points.end() - 1; for (; i != this->points.end(); j = i++) { - //FIXME this test is not numerically robust. Particularly, it does not handle horizontal segments at y == point.y() well. - // Does the ray with y == point.y() intersect this line segment? + //FIXME this test is not numerically robust. Particularly, it does not handle horizontal segments at y == point(1) well. + // Does the ray with y == point(1) intersect this line segment? #if 1 - if ( ((i->y() > point.y()) != (j->y() > point.y())) - && ((double)point.x() < (double)(j->x() - i->x()) * (double)(point.y() - i->y()) / (double)(j->y() - i->y()) + (double)i->x()) ) + if ( (((*i)(1) > point(1)) != ((*j)(1) > point(1))) + && ((double)point(0) < (double)((*j)(0) - (*i)(0)) * (double)(point(1) - (*i)(1)) / (double)((*j)(1) - (*i)(1)) + (double)(*i)(0)) ) result = !result; #else - if ((i->y() > point.y()) != (j->y() > point.y())) { + if (((*i)(1) > point(1)) != ((*j)(1) > point(1))) { // Orientation predicated relative to i-th point. - double orient = (double)(point.x() - i->x()) * (double)(j->y() - i->y()) - (double)(point.y() - i->y()) * (double)(j->x() - i->x()); - if ((i->y() > j->y()) ? (orient > 0.) : (orient < 0.)) + double orient = (double)(point(0) - (*i)(0)) * (double)((*j)(1) - (*i)(1)) - (double)(point(1) - (*i)(1)) * (double)((*j)(0) - (*i)(0)); + if (((*i)(1) > (*j)(1)) ? (orient > 0.) : (orient < 0.)) result = !result; } #endif @@ -310,13 +310,13 @@ Point Polygon::point_projection(const Point &point) const dmin = d; proj = pt1; } - Pointf v1(coordf_t(pt1.x() - pt0.x()), coordf_t(pt1.y() - pt0.y())); + Pointf v1(coordf_t(pt1(0) - pt0(0)), coordf_t(pt1(1) - pt0(1))); coordf_t div = v1.squaredNorm(); if (div > 0.) { - Pointf v2(coordf_t(point.x() - pt0.x()), coordf_t(point.y() - pt0.y())); + Pointf v2(coordf_t(point(0) - pt0(0)), coordf_t(point(1) - pt0(1))); coordf_t t = v1.dot(v2) / div; if (t > 0. && t < 1.) { - Point foot(coord_t(floor(coordf_t(pt0.x()) + t * v1.x() + 0.5)), coord_t(floor(coordf_t(pt0.y()) + t * v1.y() + 0.5))); + Point foot(coord_t(floor(coordf_t(pt0(0)) + t * v1(0) + 0.5)), coord_t(floor(coordf_t(pt0(1)) + t * v1(1) + 0.5))); d = (point - foot).cast().norm(); if (d < dmin) { dmin = d; @@ -374,12 +374,12 @@ static inline bool is_stick(const Point &p1, const Point &p2, const Point &p3) { Point v1 = p2 - p1; Point v2 = p3 - p2; - int64_t dir = int64_t(v1.x()) * int64_t(v2.x()) + int64_t(v1.y()) * int64_t(v2.y()); + int64_t dir = int64_t(v1(0)) * int64_t(v2(0)) + int64_t(v1(1)) * int64_t(v2(1)); if (dir > 0) // p3 does not turn back to p1. Do not remove p2. return false; - double l2_1 = double(v1.x()) * double(v1.x()) + double(v1.y()) * double(v1.y()); - double l2_2 = double(v2.x()) * double(v2.x()) + double(v2.y()) * double(v2.y()); + double l2_1 = double(v1(0)) * double(v1(0)) + double(v1(1)) * double(v1(1)); + double l2_2 = double(v2(0)) * double(v2(0)) + double(v2(1)) * double(v2(1)); if (dir == 0) // p1, p2, p3 may make a perpendicular corner, or there is a zero edge length. // Remove p2 if it is coincident with p1 or p2. @@ -387,7 +387,7 @@ static inline bool is_stick(const Point &p1, const Point &p2, const Point &p3) // p3 turns back to p1 after p2. Are p1, p2, p3 collinear? // Calculate distance from p3 to a segment (p1, p2) or from p1 to a segment(p2, p3), // whichever segment is longer - double cross = double(v1.x()) * double(v2.y()) - double(v2.x()) * double(v1.y()); + double cross = double(v1(0)) * double(v2(1)) - double(v2(0)) * double(v1(1)); double dist2 = cross * cross / std::max(l2_1, l2_2); return dist2 < EPSILON * EPSILON; } diff --git a/xs/src/libslic3r/Polygon.hpp b/xs/src/libslic3r/Polygon.hpp index 6d0b148ef..d618644e9 100644 --- a/xs/src/libslic3r/Polygon.hpp +++ b/xs/src/libslic3r/Polygon.hpp @@ -27,7 +27,7 @@ public: static Polygon new_scale(std::vector points) { Points int_points; for (auto pt : points) - int_points.push_back(Point::new_scale(pt.x(), pt.y())); + int_points.push_back(Point::new_scale(pt(0), pt(1))); return Polygon(int_points); } Polygon& operator=(const Polygon &other) { points = other.points; return *this; } diff --git a/xs/src/libslic3r/Polyline.cpp b/xs/src/libslic3r/Polyline.cpp index 16275c346..75c6203e1 100644 --- a/xs/src/libslic3r/Polyline.cpp +++ b/xs/src/libslic3r/Polyline.cpp @@ -33,7 +33,7 @@ Polyline::leftmost_point() const { Point p = this->points.front(); for (Points::const_iterator it = this->points.begin() + 1; it != this->points.end(); ++it) { - if (it->x() < p.x()) p = *it; + if ((*it)(0) < p(0)) p = *it; } return p; } diff --git a/xs/src/libslic3r/Polyline.hpp b/xs/src/libslic3r/Polyline.hpp index 9d6cf91ee..d977c771e 100644 --- a/xs/src/libslic3r/Polyline.hpp +++ b/xs/src/libslic3r/Polyline.hpp @@ -27,7 +27,7 @@ public: Polyline pl; Points int_points; for (auto pt : points) - int_points.push_back(Point::new_scale(pt.x(), pt.y())); + int_points.push_back(Point::new_scale(pt(0), pt(1))); pl.append(int_points); return pl; } diff --git a/xs/src/libslic3r/PolylineCollection.cpp b/xs/src/libslic3r/PolylineCollection.cpp index dcec43c81..3f65ea699 100644 --- a/xs/src/libslic3r/PolylineCollection.cpp +++ b/xs/src/libslic3r/PolylineCollection.cpp @@ -15,9 +15,9 @@ inline int nearest_point_index(const std::vector &pairs, const Point & T dmin = std::numeric_limits::max(); int idx = 0; for (std::vector::const_iterator it = pairs.begin(); it != pairs.end(); ++it) { - T d = sqr(T(start_near.x() - it->first.x())); + T d = sqr(T(start_near(0) - it->first(0))); if (d <= dmin) { - d += sqr(T(start_near.y() - it->first.y())); + d += sqr(T(start_near(1) - it->first(1))); if (d < dmin) { idx = (it - pairs.begin()) * 2; dmin = d; @@ -26,9 +26,9 @@ inline int nearest_point_index(const std::vector &pairs, const Point & } } if (! no_reverse) { - d = sqr(T(start_near.x() - it->last.x())); + d = sqr(T(start_near(0) - it->last(0))); if (d <= dmin) { - d += sqr(T(start_near.y() - it->last.y())); + d += sqr(T(start_near(1) - it->last(1))); if (d < dmin) { idx = (it - pairs.begin()) * 2 + 1; dmin = d; @@ -82,7 +82,7 @@ Point PolylineCollection::leftmost_point(const Polylines &polylines) Point p = it->leftmost_point(); for (++ it; it != polylines.end(); ++it) { Point p2 = it->leftmost_point(); - if (p2.x() < p.x()) + if (p2(0) < p(0)) p = p2; } return p; diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 353d8ace5..958ad3fa7 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -538,9 +538,9 @@ bool Print::has_skirt() const std::string Print::validate() const { BoundingBox bed_box_2D = get_extents(Polygon::new_scale(config.bed_shape.values)); - BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x()), unscale(bed_box_2D.min.y()), 0.0), Pointf3(unscale(bed_box_2D.max.x()), unscale(bed_box_2D.max.y()), config.max_print_height)); + BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min(0)), unscale(bed_box_2D.min(1)), 0.0), Pointf3(unscale(bed_box_2D.max(0)), unscale(bed_box_2D.max(1)), config.max_print_height)); // Allow the objects to protrude below the print bed, only the part of the object above the print bed will be sliced. - print_volume.min.z() = -1e10; + print_volume.min(2) = -1e10; unsigned int printable_count = 0; for (PrintObject *po : this->objects) { po->model_object()->check_instances_print_volume_state(print_volume); @@ -585,7 +585,7 @@ std::string Print::validate() const { std::vector object_height; for (const PrintObject *object : this->objects) - object_height.insert(object_height.end(), object->copies().size(), object->size.z()); + object_height.insert(object_height.end(), object->copies().size(), object->size(2)); std::sort(object_height.begin(), object_height.end()); // Ignore the tallest *copy* (this is why we repeat height for all of them): // it will be printed as last one so its height doesn't matter. diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 624ac59e4..c79625313 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -2067,7 +2067,7 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va ConfigOptionPoint p; p.deserialize(value); std::ostringstream oss; - oss << "0x0," << p.value.x() << "x0," << p.value.x() << "x" << p.value.y() << ",0x" << p.value.y(); + oss << "0x0," << p.value(0) << "x0," << p.value(0) << "x" << p.value(1) << ",0x" << p.value(1); value = oss.str(); // Maybe one day we will rename octoprint_host to print_host as it has been done in the upstream Slic3r. // Commenting this out fixes github issue #869 for now. diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index a8404c0ed..b79e1fdf1 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -48,10 +48,10 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Bounding // don't assume it's already aligned and we don't alter the original position in model. // We store the XY translation so that we can place copies correctly in the output G-code // (copies are expressed in G-code coordinates and this translation is not publicly exposed). - this->_copies_shift = Point::new_scale(modobj_bbox.min.x(), modobj_bbox.min.y()); + this->_copies_shift = Point::new_scale(modobj_bbox.min(0), modobj_bbox.min(1)); // Scale the object size and store it Pointf3 size = modobj_bbox.size(); - this->size = Point3::new_scale(size.x(), size.y(), size.z()); + this->size = Point3::new_scale(size(0), size(1), size(2)); } this->reload_model_instances(); @@ -62,7 +62,7 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Bounding bool PrintObject::add_copy(const Pointf &point) { Points points = this->_copies; - points.push_back(Point::new_scale(point.x(), point.y())); + points.push_back(Point::new_scale(point(0), point(1))); return this->set_copies(points); } @@ -101,7 +101,7 @@ bool PrintObject::reload_model_instances() for (const ModelInstance *mi : this->_model_object->instances) { if (mi->is_printable()) - copies.emplace_back(Point::new_scale(mi->offset.x(), mi->offset.y())); + copies.emplace_back(Point::new_scale(mi->offset(0), mi->offset(1))); } return this->set_copies(copies); } @@ -1119,7 +1119,7 @@ SlicingParameters PrintObject::slicing_parameters() const { return SlicingParameters::create_from_config( this->print()->config, this->config, - unscale(this->size.z()), this->print()->object_extruders()); + unscale(this->size(2)), this->print()->object_extruders()); } bool PrintObject::update_layer_height_profile(std::vector &layer_height_profile) const @@ -1333,7 +1333,7 @@ std::vector PrintObject::_slice_region(size_t region_id, const std:: // consider the first one this->model_object()->instances.front()->transform_mesh(&mesh, true); // align mesh to Z = 0 (it should be already aligned actually) and apply XY shift - mesh.translate(- float(unscale(this->_copies_shift.x())), - float(unscale(this->_copies_shift.y())), -float(this->model_object()->bounding_box().min.z())); + mesh.translate(- float(unscale(this->_copies_shift(0))), - float(unscale(this->_copies_shift(1))), -float(this->model_object()->bounding_box().min(2))); // perform actual slicing TriangleMeshSlicer mslicer(&mesh); mslicer.slice(z, &layers); diff --git a/xs/src/libslic3r/SVG.cpp b/xs/src/libslic3r/SVG.cpp index 1d683a030..d3a0eed36 100644 --- a/xs/src/libslic3r/SVG.cpp +++ b/xs/src/libslic3r/SVG.cpp @@ -32,8 +32,8 @@ bool SVG::open(const char* afilename, const BoundingBox &bbox, const coord_t bbo this->f = boost::nowide::fopen(afilename, "w"); if (f == NULL) return false; - float w = COORD(bbox.max.x() - bbox.min.x() + 2 * bbox_offset); - float h = COORD(bbox.max.y() - bbox.min.y() + 2 * bbox_offset); + float w = COORD(bbox.max(0) - bbox.min(0) + 2 * bbox_offset); + float h = COORD(bbox.max(1) - bbox.min(1) + 2 * bbox_offset); fprintf(this->f, "\n" "\n" @@ -50,7 +50,7 @@ SVG::draw(const Line &line, std::string stroke, coordf_t stroke_width) { fprintf(this->f, " arrows) fprintf(this->f, " marker-end=\"url(#endArrow)\""); fprintf(this->f, "/>\n"); @@ -58,21 +58,21 @@ SVG::draw(const Line &line, std::string stroke, coordf_t stroke_width) void SVG::draw(const ThickLine &line, const std::string &fill, const std::string &stroke, coordf_t stroke_width) { - Pointf dir(line.b.x()-line.a.x(), line.b.y()-line.a.y()); - Pointf perp(-dir.y(), dir.x()); - coordf_t len = sqrt(perp.x()*perp.x() + perp.y()*perp.y()); + Pointf dir(line.b(0)-line.a(0), line.b(1)-line.a(1)); + Pointf perp(-dir(1), dir(0)); + coordf_t len = sqrt(perp(0)*perp(0) + perp(1)*perp(1)); coordf_t da = coordf_t(0.5)*line.a_width/len; coordf_t db = coordf_t(0.5)*line.b_width/len; fprintf(this->f, " \n", - COORD(line.a.x()-da*perp.x()-origin.x()), - COORD(line.a.y()-da*perp.y()-origin.y()), - COORD(line.b.x()-db*perp.x()-origin.x()), - COORD(line.b.y()-db*perp.y()-origin.y()), - COORD(line.b.x()+db*perp.x()-origin.x()), - COORD(line.b.y()+db*perp.y()-origin.y()), - COORD(line.a.x()+da*perp.x()-origin.x()), - COORD(line.a.y()+da*perp.y()-origin.y()), + COORD(line.a(0)-da*perp(0)-origin(0)), + COORD(line.a(1)-da*perp(1)-origin(1)), + COORD(line.b(0)-db*perp(0)-origin(0)), + COORD(line.b(1)-db*perp(1)-origin(1)), + COORD(line.b(0)+db*perp(0)-origin(0)), + COORD(line.b(1)+db*perp(1)-origin(1)), + COORD(line.a(0)+da*perp(0)-origin(0)), + COORD(line.a(1)+da*perp(1)-origin(1)), fill.c_str(), stroke.c_str(), (stroke_width == 0) ? 1.f : COORD(stroke_width)); } @@ -220,7 +220,7 @@ SVG::draw(const Point &point, std::string fill, coord_t iradius) { float radius = (iradius == 0) ? 3.f : COORD(iradius); std::ostringstream svg; - svg << " "; @@ -287,8 +287,8 @@ SVG::get_path_d(const MultiPoint &mp, bool closed) const std::ostringstream d; d << "M "; for (Points::const_iterator p = mp.points.begin(); p != mp.points.end(); ++p) { - d << COORD(p->x() - origin.x()) << " "; - d << COORD(p->y() - origin.y()) << " "; + d << COORD((*p)(0) - origin(0)) << " "; + d << COORD((*p)(1) - origin(1)) << " "; } if (closed) d << "z"; return d.str(); @@ -300,8 +300,8 @@ SVG::get_path_d(const ClipperLib::Path &path, double scale, bool closed) const std::ostringstream d; d << "M "; for (ClipperLib::Path::const_iterator p = path.begin(); p != path.end(); ++p) { - d << COORD(scale * p->X - origin.x()) << " "; - d << COORD(scale * p->Y - origin.y()) << " "; + d << COORD(scale * p->X - origin(0)) << " "; + d << COORD(scale * p->Y - origin(1)) << " "; } if (closed) d << "z"; return d.str(); @@ -311,8 +311,8 @@ void SVG::draw_text(const Point &pt, const char *text, const char *color) { fprintf(this->f, "%s", - COORD(pt.x()-origin.x()), - COORD(pt.y()-origin.y()), + COORD(pt(0)-origin(0)), + COORD(pt(1)-origin(1)), color, text); } @@ -320,13 +320,13 @@ void SVG::draw_legend(const Point &pt, const char *text, const char *color) { fprintf(this->f, "", - COORD(pt.x()-origin.x()), - COORD(pt.y()-origin.y()), + COORD(pt(0)-origin(0)), + COORD(pt(1)-origin(1)), color); fprintf(this->f, "%s", - COORD(pt.x()-origin.x()) + 20.f, - COORD(pt.y()-origin.y()), + COORD(pt(0)-origin(0)) + 20.f, + COORD(pt(1)-origin(1)), "black", text); } diff --git a/xs/src/libslic3r/Slicing.cpp b/xs/src/libslic3r/Slicing.cpp index f38c97cb7..d745a803c 100644 --- a/xs/src/libslic3r/Slicing.cpp +++ b/xs/src/libslic3r/Slicing.cpp @@ -608,17 +608,17 @@ int generate_layer_height_texture( coordf_t intensity = cos(M_PI * 0.7 * (mid - z) / h); // Color mapping from layer height to RGB. Pointf3 color( - intensity * lerp(coordf_t(color1.x()), coordf_t(color2.x()), t), - intensity * lerp(coordf_t(color1.y()), coordf_t(color2.y()), t), - intensity * lerp(coordf_t(color1.z()), coordf_t(color2.z()), t)); + intensity * lerp(coordf_t(color1(0)), coordf_t(color2(0)), t), + intensity * lerp(coordf_t(color1(1)), coordf_t(color2(1)), t), + intensity * lerp(coordf_t(color1(2)), coordf_t(color2(2)), t)); int row = cell / (cols - 1); int col = cell - row * (cols - 1); assert(row >= 0 && row < rows); assert(col >= 0 && col < cols); unsigned char *ptr = (unsigned char*)data + (row * cols + col) * 4; - ptr[0] = (unsigned char)clamp(0, 255, int(floor(color.x() + 0.5))); - ptr[1] = (unsigned char)clamp(0, 255, int(floor(color.y() + 0.5))); - ptr[2] = (unsigned char)clamp(0, 255, int(floor(color.z() + 0.5))); + ptr[0] = (unsigned char)clamp(0, 255, int(floor(color(0) + 0.5))); + ptr[1] = (unsigned char)clamp(0, 255, int(floor(color(1) + 0.5))); + ptr[2] = (unsigned char)clamp(0, 255, int(floor(color(2) + 0.5))); ptr[3] = 255; if (col == 0 && row > 0) { // Duplicate the first value in a row as a last value of the preceding row. @@ -640,17 +640,17 @@ int generate_layer_height_texture( const Point3 &color2 = palette_raw[idx2]; // Color mapping from layer height to RGB. Pointf3 color( - lerp(coordf_t(color1.x()), coordf_t(color2.x()), t), - lerp(coordf_t(color1.y()), coordf_t(color2.y()), t), - lerp(coordf_t(color1.z()), coordf_t(color2.z()), t)); + lerp(coordf_t(color1(0)), coordf_t(color2(0)), t), + lerp(coordf_t(color1(1)), coordf_t(color2(1)), t), + lerp(coordf_t(color1(2)), coordf_t(color2(2)), t)); int row = cell / (cols1 - 1); int col = cell - row * (cols1 - 1); assert(row >= 0 && row < rows/2); assert(col >= 0 && col < cols/2); unsigned char *ptr = data1 + (row * cols1 + col) * 4; - ptr[0] = (unsigned char)clamp(0, 255, int(floor(color.x() + 0.5))); - ptr[1] = (unsigned char)clamp(0, 255, int(floor(color.y() + 0.5))); - ptr[2] = (unsigned char)clamp(0, 255, int(floor(color.z() + 0.5))); + ptr[0] = (unsigned char)clamp(0, 255, int(floor(color(0) + 0.5))); + ptr[1] = (unsigned char)clamp(0, 255, int(floor(color(1) + 0.5))); + ptr[2] = (unsigned char)clamp(0, 255, int(floor(color(2) + 0.5))); ptr[3] = 255; if (col == 0 && row > 0) { // Duplicate the first value in a row as a last value of the preceding row. diff --git a/xs/src/libslic3r/SupportMaterial.cpp b/xs/src/libslic3r/SupportMaterial.cpp index cf272eaa7..98f41a663 100644 --- a/xs/src/libslic3r/SupportMaterial.cpp +++ b/xs/src/libslic3r/SupportMaterial.cpp @@ -67,9 +67,9 @@ Point export_support_surface_type_legend_to_svg_box_size() void export_support_surface_type_legend_to_svg(SVG &svg, const Point &pos) { // 1st row - coord_t pos_x0 = pos.x() + scale_(1.); + coord_t pos_x0 = pos(0) + scale_(1.); coord_t pos_x = pos_x0; - coord_t pos_y = pos.y() + scale_(1.5); + coord_t pos_y = pos(1) + scale_(1.5); coord_t step_x = scale_(10.); svg.draw_legend(Point(pos_x, pos_y), "top contact" , support_surface_type_to_color_name(PrintObjectSupportMaterial::sltTopContact)); pos_x += step_x; @@ -82,7 +82,7 @@ void export_support_surface_type_legend_to_svg(SVG &svg, const Point &pos) svg.draw_legend(Point(pos_x, pos_y), "bottom contact" , support_surface_type_to_color_name(PrintObjectSupportMaterial::sltBottomContact)); // 2nd row pos_x = pos_x0; - pos_y = pos.y()+scale_(2.8); + pos_y = pos(1)+scale_(2.8); svg.draw_legend(Point(pos_x, pos_y), "raft interface" , support_surface_type_to_color_name(PrintObjectSupportMaterial::sltRaftInterface)); pos_x += step_x; svg.draw_legend(Point(pos_x, pos_y), "raft base" , support_surface_type_to_color_name(PrintObjectSupportMaterial::sltRaftBase)); @@ -98,8 +98,8 @@ void export_print_z_polygons_to_svg(const char *path, PrintObjectSupportMaterial for (int i = 0; i < n_layers; ++ i) bbox.merge(get_extents(layers[i]->polygons)); Point legend_size = export_support_surface_type_legend_to_svg_box_size(); - Point legend_pos(bbox.min.x(), bbox.max.y()); - bbox.merge(Point(std::max(bbox.min.x() + legend_size.x(), bbox.max.x()), bbox.max.y() + legend_size.y())); + Point legend_pos(bbox.min(0), bbox.max(1)); + bbox.merge(Point(std::max(bbox.min(0) + legend_size(0), bbox.max(0)), bbox.max(1) + legend_size(1))); SVG svg(path, bbox); const float transparency = 0.5f; for (int i = 0; i < n_layers; ++ i) @@ -120,8 +120,8 @@ void export_print_z_polygons_and_extrusions_to_svg( for (int i = 0; i < n_layers; ++ i) bbox.merge(get_extents(layers[i]->polygons)); Point legend_size = export_support_surface_type_legend_to_svg_box_size(); - Point legend_pos(bbox.min.x(), bbox.max.y()); - bbox.merge(Point(std::max(bbox.min.x() + legend_size.x(), bbox.max.x()), bbox.max.y() + legend_size.y())); + Point legend_pos(bbox.min(0), bbox.max(1)); + bbox.merge(Point(std::max(bbox.min(0) + legend_size(0), bbox.max(0)), bbox.max(1) + legend_size(1))); SVG svg(path, bbox); const float transparency = 0.5f; for (int i = 0; i < n_layers; ++ i) @@ -519,12 +519,12 @@ public: Points::const_iterator i = contour.points.begin(); Points::const_iterator j = contour.points.end() - 1; for (; i != contour.points.end(); j = i ++) { - //FIXME this test is not numerically robust. Particularly, it does not handle horizontal segments at y == point.y() well. - // Does the ray with y == point.y() intersect this line segment? + //FIXME this test is not numerically robust. Particularly, it does not handle horizontal segments at y == point(1) well. + // Does the ray with y == point(1) intersect this line segment? for (auto &sample_inside : samples_inside) { - if ((i->y() > sample_inside.first.y()) != (j->y() > sample_inside.first.y())) { - double x1 = (double)sample_inside.first.x(); - double x2 = (double)i->x() + (double)(j->x() - i->x()) * (double)(sample_inside.first.y() - i->y()) / (double)(j->y() - i->y()); + if (((*i)(1) > sample_inside.first(1)) != ((*j)(1) > sample_inside.first(1))) { + double x1 = (double)sample_inside.first(0); + double x2 = (double)(*i)(0) + (double)((*j)(0) - (*i)(0)) * (double)(sample_inside.first(1) - (*i)(1)) / (double)((*j)(1) - (*i)(1)); if (x1 < x2) sample_inside.second = !sample_inside.second; } @@ -585,11 +585,11 @@ private: const Point &p3 = (pt_min == &expoly.contour.points.back()) ? expoly.contour.points.front() : *(pt_min + 1); Vector v = (p3 - p2) + (p1 - p2); - double l2 = double(v.x())*double(v.x())+double(v.y())*double(v.y()); + double l2 = double(v(0))*double(v(0))+double(v(1))*double(v(1)); if (l2 == 0.) return p2; double coef = 20. / sqrt(l2); - return Point(p2.x() + coef * v.x(), p2.y() + coef * v.y()); + return Point(p2(0) + coef * v(0), p2(1) + coef * v(1)); } static Points island_samples(const ExPolygons &expolygons) @@ -789,7 +789,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_ // workaround for Clipper bug, see Slic3r::Polygon::clip_as_polyline() for (Polyline &polyline : overhang_perimeters) - polyline.points[0].x() += 1; + polyline.points[0](0) += 1; // Trim the perimeters of this layer by the lower layer to get the unsupported pieces of perimeters. overhang_perimeters = diff_pl(overhang_perimeters, lower_grown_slices); @@ -2057,8 +2057,8 @@ void LoopInterfaceProcessor::generate(MyLayerExtruded &top_contact_layer, const const Point &p1 = *(it-1); const Point &p2 = *it; // Intersection of a ray (p1, p2) with a circle placed at center_last, with radius of circle_distance. - const Pointf v_seg(coordf_t(p2.x()) - coordf_t(p1.x()), coordf_t(p2.y()) - coordf_t(p1.y())); - const Pointf v_cntr(coordf_t(p1.x() - center_last.x()), coordf_t(p1.y() - center_last.y())); + const Pointf v_seg(coordf_t(p2(0)) - coordf_t(p1(0)), coordf_t(p2(1)) - coordf_t(p1(1))); + const Pointf v_cntr(coordf_t(p1(0) - center_last(0)), coordf_t(p1(1) - center_last(1))); coordf_t a = v_seg.squaredNorm(); coordf_t b = 2. * v_seg.dot(v_cntr); coordf_t c = v_cntr.squaredNorm() - circle_distance * circle_distance; @@ -2081,7 +2081,7 @@ void LoopInterfaceProcessor::generate(MyLayerExtruded &top_contact_layer, const } seg_current_pt = &p1; seg_current_t = t; - center_last = Point(p1.x() + coord_t(v_seg.x() * t), p1.y() + coord_t(v_seg.y() * t)); + center_last = Point(p1(0) + coord_t(v_seg(0) * t), p1(1) + coord_t(v_seg(1) * t)); // It has been verified that the new point is far enough from center_last. // Ensure, that it is far enough from all the centers. std::pair circle_closest = circle_centers_lookup.find(center_last); @@ -2887,9 +2887,9 @@ void PrintObjectSupportMaterial::clip_by_pillars( BoundingBox bbox; for (LayersPtr::const_iterator it = top_contacts.begin(); it != top_contacts.end(); ++ it) bbox.merge(get_extents((*it)->polygons)); - grid.reserve(size_t(ceil(bb.size().x() / pillar_spacing)) * size_t(ceil(bb.size().y() / pillar_spacing))); - for (coord_t x = bb.min.x(); x <= bb.max.x() - pillar_size; x += pillar_spacing) { - for (coord_t y = bb.min.y(); y <= bb.max.y() - pillar_size; y += pillar_spacing) { + grid.reserve(size_t(ceil(bb.size()(0) / pillar_spacing)) * size_t(ceil(bb.size()(1) / pillar_spacing))); + for (coord_t x = bb.min(0); x <= bb.max(0) - pillar_size; x += pillar_spacing) { + for (coord_t y = bb.min(1); y <= bb.max(1) - pillar_size; y += pillar_spacing) { grid.push_back(pillar); for (size_t i = 0; i < pillar.points.size(); ++ i) grid.back().points[i].translate(Point(x, y)); diff --git a/xs/src/libslic3r/Surface.cpp b/xs/src/libslic3r/Surface.cpp index d3474e4a7..0e9eca7fd 100644 --- a/xs/src/libslic3r/Surface.cpp +++ b/xs/src/libslic3r/Surface.cpp @@ -106,9 +106,9 @@ Point export_surface_type_legend_to_svg_box_size() void export_surface_type_legend_to_svg(SVG &svg, const Point &pos) { // 1st row - coord_t pos_x0 = pos.x() + scale_(1.); + coord_t pos_x0 = pos(0) + scale_(1.); coord_t pos_x = pos_x0; - coord_t pos_y = pos.y() + scale_(1.5); + coord_t pos_y = pos(1) + scale_(1.5); coord_t step_x = scale_(10.); svg.draw_legend(Point(pos_x, pos_y), "perimeter" , surface_type_to_color_name(stPerimeter)); pos_x += step_x; @@ -121,7 +121,7 @@ void export_surface_type_legend_to_svg(SVG &svg, const Point &pos) svg.draw_legend(Point(pos_x, pos_y), "invalid" , surface_type_to_color_name(SurfaceType(-1))); // 2nd row pos_x = pos_x0; - pos_y = pos.y()+scale_(2.8); + pos_y = pos(1)+scale_(2.8); svg.draw_legend(Point(pos_x, pos_y), "internal" , surface_type_to_color_name(stInternal)); pos_x += step_x; svg.draw_legend(Point(pos_x, pos_y), "internal solid" , surface_type_to_color_name(stInternalSolid)); diff --git a/xs/src/libslic3r/SurfaceCollection.cpp b/xs/src/libslic3r/SurfaceCollection.cpp index a7fc4a648..6db599306 100644 --- a/xs/src/libslic3r/SurfaceCollection.cpp +++ b/xs/src/libslic3r/SurfaceCollection.cpp @@ -170,8 +170,8 @@ void SurfaceCollection::export_to_svg(const char *path, bool show_labels) for (Surfaces::const_iterator surface = this->surfaces.begin(); surface != this->surfaces.end(); ++surface) bbox.merge(get_extents(surface->expolygon)); Point legend_size = export_surface_type_legend_to_svg_box_size(); - Point legend_pos(bbox.min.x(), bbox.max.y()); - bbox.merge(Point(std::max(bbox.min.x() + legend_size.x(), bbox.max.x()), bbox.max.y() + legend_size.y())); + Point legend_pos(bbox.min(0), bbox.max(1)); + bbox.merge(Point(std::max(bbox.min(0) + legend_size(0), bbox.max(0)), bbox.max(1) + legend_size(1))); SVG svg(path, bbox); const float transparency = 0.5f; diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp index 9d4edc352..30ef637e5 100644 --- a/xs/src/libslic3r/TriangleMesh.cpp +++ b/xs/src/libslic3r/TriangleMesh.cpp @@ -52,20 +52,20 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector& fa for (int i = 0; i < stl.stats.number_of_facets; i++) { stl_facet facet; - const Pointf3& ref_f1 = points[facets[i].x()]; - facet.vertex[0].x = ref_f1.x(); - facet.vertex[0].y = ref_f1.y(); - facet.vertex[0].z = ref_f1.z(); + const Pointf3& ref_f1 = points[facets[i](0)]; + facet.vertex[0].x = ref_f1(0); + facet.vertex[0].y = ref_f1(1); + facet.vertex[0].z = ref_f1(2); - const Pointf3& ref_f2 = points[facets[i].y()]; - facet.vertex[1].x = ref_f2.x(); - facet.vertex[1].y = ref_f2.y(); - facet.vertex[1].z = ref_f2.z(); + const Pointf3& ref_f2 = points[facets[i](1)]; + facet.vertex[1].x = ref_f2(0); + facet.vertex[1].y = ref_f2(1); + facet.vertex[1].z = ref_f2(2); - const Pointf3& ref_f3 = points[facets[i].z()]; - facet.vertex[2].x = ref_f3.x(); - facet.vertex[2].y = ref_f3.y(); - facet.vertex[2].z = ref_f3.z(); + const Pointf3& ref_f3 = points[facets[i](2)]; + facet.vertex[2].x = ref_f3(0); + facet.vertex[2].y = ref_f3(1); + facet.vertex[2].z = ref_f3(2); facet.extra[0] = 0; facet.extra[1] = 0; @@ -303,9 +303,9 @@ void TriangleMesh::scale(float factor) void TriangleMesh::scale(const Pointf3 &versor) { float fversor[3]; - fversor[0] = versor.x(); - fversor[1] = versor.y(); - fversor[2] = versor.z(); + fversor[0] = versor(0); + fversor[1] = versor(1); + fversor[2] = versor(2); stl_scale_versor(&this->stl, fversor); stl_invalidate_shared_vertices(&this->stl); } @@ -400,9 +400,10 @@ void TriangleMesh::rotate(double angle, Point* center) { if (angle == 0.) return; - this->translate(float(-center->x()), float(-center->y()), 0); + Vec2f c = center->cast(); + this->translate(-c(0), -c(1), 0); stl_rotate_z(&(this->stl), (float)angle); - this->translate(float(+center->x()), float(+center->y()), 0); + this->translate(c(0), c(1), 0); } bool TriangleMesh::has_multiple_patches() const @@ -588,12 +589,12 @@ TriangleMesh::bounding_box() const { BoundingBoxf3 bb; bb.defined = true; - bb.min.x() = this->stl.stats.min.x; - bb.min.y() = this->stl.stats.min.y; - bb.min.z() = this->stl.stats.min.z; - bb.max.x() = this->stl.stats.max.x; - bb.max.y() = this->stl.stats.max.y; - bb.max.z() = this->stl.stats.max.z; + bb.min(0) = this->stl.stats.min.x; + bb.min(1) = this->stl.stats.min.y; + bb.min(2) = this->stl.stats.min.z; + bb.max(0) = this->stl.stats.max.x; + bb.max(1) = this->stl.stats.max.y; + bb.max(2) = this->stl.stats.max.z; return bb; } @@ -813,10 +814,10 @@ void TriangleMeshSlicer::_slice_do(size_t facet_idx, std::vectorv_scaled_shared[a_id]; const stl_vertex *b = &this->v_scaled_shared[b_id]; - il.a.x() = a->x; - il.a.y() = a->y; - il.b.x() = b->x; - il.b.y() = b->y; + il.a(0) = a->x; + il.a(1) = a->y; + il.b(0) = b->x; + il.b(1) = b->y; il.a_id = a_id; il.b_id = b_id; (*lines)[layer_idx].emplace_back(il); @@ -894,10 +895,10 @@ bool TriangleMeshSlicer::slice_facet( // Two vertices are aligned with the cutting plane, the third vertex is above the cutting plane. line_out->edge_type = feBottom; } - line_out->a.x() = a->x; - line_out->a.y() = a->y; - line_out->b.x() = b->x; - line_out->b.y() = b->y; + line_out->a(0) = a->x; + line_out->a(1) = a->y; + line_out->b(0) = b->x; + line_out->b(1) = b->y; line_out->a_id = a_id; line_out->b_id = b_id; return true; @@ -907,21 +908,21 @@ bool TriangleMeshSlicer::slice_facet( // Only point a alings with the cutting plane. points_on_layer[num_points_on_layer ++] = num_points; IntersectionPoint &point = points[num_points ++]; - point.x() = a->x; - point.y() = a->y; + point(0) = a->x; + point(1) = a->y; point.point_id = a_id; } else if (b->z == slice_z) { // Only point b alings with the cutting plane. points_on_layer[num_points_on_layer ++] = num_points; IntersectionPoint &point = points[num_points ++]; - point.x() = b->x; - point.y() = b->y; + point(0) = b->x; + point(1) = b->y; point.point_id = b_id; } else if ((a->z < slice_z && b->z > slice_z) || (b->z < slice_z && a->z > slice_z)) { // A general case. The face edge intersects the cutting plane. Calculate the intersection point. IntersectionPoint &point = points[num_points ++]; - point.x() = b->x + (a->x - b->x) * (slice_z - b->z) / (a->z - b->z); - point.y() = b->y + (a->y - b->y) * (slice_z - b->z) / (a->z - b->z); + point(0) = b->x + (a->x - b->x) * (slice_z - b->z) / (a->z - b->z); + point(1) = b->y + (a->y - b->y) * (slice_z - b->z) / (a->z - b->z); point.edge_id = edge_id; } } @@ -1202,7 +1203,7 @@ void TriangleMeshSlicer::make_loops(std::vector &lines, Polygo // Orient the patched up polygons CCW. This heuristic may close some holes and cavities. double area = 0.; for (size_t i = 0, j = opl.points.size() - 1; i < opl.points.size(); j = i ++) - area += double(opl.points[j].x() + opl.points[i].x()) * double(opl.points[i].y() - opl.points[j].y()); + area += double(opl.points[j](0) + opl.points[i](0)) * double(opl.points[i](1) - opl.points[j](1)); if (area < 0) std::reverse(opl.points.begin(), opl.points.end()); loops->emplace_back(std::move(opl.points)); @@ -1492,8 +1493,8 @@ void TriangleMeshSlicer::cut(float z, TriangleMesh* upper, TriangleMesh* lower) facet.normal.y = 0; facet.normal.z = -1; for (size_t i = 0; i <= 2; ++i) { - facet.vertex[i].x = unscale(p.points[i].x()); - facet.vertex[i].y = unscale(p.points[i].y()); + facet.vertex[i].x = unscale(p.points[i](0)); + facet.vertex[i].y = unscale(p.points[i](1)); facet.vertex[i].z = z; } stl_add_facet(&upper->stl, &facet); @@ -1518,8 +1519,8 @@ void TriangleMeshSlicer::cut(float z, TriangleMesh* upper, TriangleMesh* lower) facet.normal.y = 0; facet.normal.z = 1; for (size_t i = 0; i <= 2; ++i) { - facet.vertex[i].x = unscale(polygon->points[i].x()); - facet.vertex[i].y = unscale(polygon->points[i].y()); + facet.vertex[i].x = unscale(polygon->points[i](0)); + facet.vertex[i].y = unscale(polygon->points[i](1)); facet.vertex[i].z = z; } stl_add_facet(&lower->stl, &facet); @@ -1576,8 +1577,8 @@ TriangleMesh make_cylinder(double r, double h, double fa) { for (double i = 0; i < 2*PI; i+=angle) { Pointf p(0, r); p.rotate(i); - vertices.emplace_back(Pointf3(p.x(), p.y(), 0.)); - vertices.emplace_back(Pointf3(p.x(), p.y(), h)); + vertices.emplace_back(Pointf3(p(0), p(1), 0.)); + vertices.emplace_back(Pointf3(p(0), p(1), h)); id = vertices.size() - 1; facets.emplace_back(Point3( 0, id - 1, id - 3)); // top facets.emplace_back(Point3(id, 1, id - 2)); // bottom @@ -1627,7 +1628,7 @@ TriangleMesh make_sphere(double rho, double fa) { const double r = sqrt(abs(rho*rho - z*z)); Pointf b(0, r); b.rotate(ring[i]); - vertices.emplace_back(Pointf3(b.x(), b.y(), z)); + vertices.emplace_back(Pointf3(b(0), b(1), z)); facets.emplace_back((i == 0) ? Point3(1, 0, ring.size()) : Point3(id, 0, id - 1)); ++ id; } @@ -1640,7 +1641,7 @@ TriangleMesh make_sphere(double rho, double fa) { for (size_t i = 0; i < ring.size(); i++) { Pointf b(0, r); b.rotate(ring[i]); - vertices.emplace_back(Pointf3(b.x(), b.y(), z)); + vertices.emplace_back(Pointf3(b(0), b(1), z)); if (i == 0) { // wrap around facets.emplace_back(Point3(id + ring.size() - 1 , id, id - 1)); diff --git a/xs/src/perlglue.cpp b/xs/src/perlglue.cpp index 5665f6c0f..9813f02d5 100644 --- a/xs/src/perlglue.cpp +++ b/xs/src/perlglue.cpp @@ -485,8 +485,8 @@ SV* to_SV_pureperl(const Point* THIS) { AV* av = newAV(); av_fill(av, 1); - av_store(av, 0, newSViv(THIS->x())); - av_store(av, 1, newSViv(THIS->y())); + av_store(av, 0, newSViv((*THIS)(0))); + av_store(av, 1, newSViv((*THIS)(1))); return newRV_noinc((SV*)av); } @@ -495,8 +495,7 @@ void from_SV(SV* point_sv, Point* point) AV* point_av = (AV*)SvRV(point_sv); // get a double from Perl and round it, otherwise // it would get truncated - point->x() = lrint(SvNV(*av_fetch(point_av, 0, 0))); - point->y() = lrint(SvNV(*av_fetch(point_av, 1, 0))); + (*point) = Point(lrint(SvNV(*av_fetch(point_av, 0, 0))), lrint(SvNV(*av_fetch(point_av, 1, 0)))); } void from_SV_check(SV* point_sv, Point* point) @@ -514,8 +513,8 @@ SV* to_SV_pureperl(const Pointf* point) { AV* av = newAV(); av_fill(av, 1); - av_store(av, 0, newSVnv(point->x())); - av_store(av, 1, newSVnv(point->y())); + av_store(av, 0, newSVnv((*point)(0))); + av_store(av, 1, newSVnv((*point)(1))); return newRV_noinc((SV*)av); } @@ -526,8 +525,7 @@ bool from_SV(SV* point_sv, Pointf* point) SV* sv_y = *av_fetch(point_av, 1, 0); if (!looks_like_number(sv_x) || !looks_like_number(sv_y)) return false; - point->x() = SvNV(sv_x); - point->y() = SvNV(sv_y); + *point = Pointf(SvNV(sv_x), SvNV(sv_y)); return true; } diff --git a/xs/src/slic3r/GUI/2DBed.cpp b/xs/src/slic3r/GUI/2DBed.cpp index 03791bdb2..5f087a881 100644 --- a/xs/src/slic3r/GUI/2DBed.cpp +++ b/xs/src/slic3r/GUI/2DBed.cpp @@ -34,15 +34,15 @@ void Bed_2D::repaint() auto cbb = BoundingBoxf(Pointf(0, 0),Pointf(cw, ch)); // leave space for origin point - cbb.min.x() += 4; + cbb.min(0) += 4; cbb.max -= Vec2d(4., 4.); // leave space for origin label - cbb.max.y() -= 13; + cbb.max(1) -= 13; // read new size - cw = cbb.size().x(); - ch = cbb.size().y(); + cw = cbb.size()(0); + ch = cbb.size()(1); auto ccenter = cbb.center(); @@ -51,19 +51,19 @@ void Bed_2D::repaint() auto bed_polygon = Polygon::new_scale(m_bed_shape); auto bb = BoundingBoxf(m_bed_shape); bb.merge(Pointf(0, 0)); // origin needs to be in the visible area - auto bw = bb.size().x(); - auto bh = bb.size().y(); + auto bw = bb.size()(0); + auto bh = bb.size()(1); auto bcenter = bb.center(); // calculate the scaling factor for fitting bed shape in canvas area auto sfactor = std::min(cw/bw, ch/bh); auto shift = Pointf( - ccenter.x() - bcenter.x() * sfactor, - ccenter.y() - bcenter.y() * sfactor + ccenter(0) - bcenter(0) * sfactor, + ccenter(1) - bcenter(1) * sfactor ); m_scale_factor = sfactor; - m_shift = Pointf(shift.x() + cbb.min.x(), - shift.y() - (cbb.max.y() - GetSize().GetHeight())); + m_shift = Pointf(shift(0) + cbb.min(0), + shift(1) - (cbb.max(1) - GetSize().GetHeight())); // draw bed fill dc.SetBrush(wxBrush(wxColour(255, 255, 255), wxSOLID)); @@ -71,19 +71,19 @@ void Bed_2D::repaint() for (auto pt: m_bed_shape) { Point pt_pix = to_pixels(pt); - pt_list.push_back(new wxPoint(pt_pix.x(), pt_pix.y())); + pt_list.push_back(new wxPoint(pt_pix(0), pt_pix(1))); } dc.DrawPolygon(&pt_list, 0, 0); // draw grid auto step = 10; // 1cm grid Polylines polylines; - for (auto x = bb.min.x() - fmod(bb.min.x(), step) + step; x < bb.max.x(); x += step) { - Polyline pl = Polyline::new_scale({ Pointf(x, bb.min.y()), Pointf(x, bb.max.y()) }); + for (auto x = bb.min(0) - fmod(bb.min(0), step) + step; x < bb.max(0); x += step) { + Polyline pl = Polyline::new_scale({ Pointf(x, bb.min(1)), Pointf(x, bb.max(1)) }); polylines.push_back(pl); } - for (auto y = bb.min.y() - fmod(bb.min.y(), step) + step; y < bb.max.y(); y += step) { - polylines.push_back(Polyline::new_scale({ Pointf(bb.min.x(), y), Pointf(bb.max.x(), y) })); + for (auto y = bb.min(1) - fmod(bb.min(1), step) + step; y < bb.max(1); y += step) { + polylines.push_back(Polyline::new_scale({ Pointf(bb.min(0), y), Pointf(bb.max(0), y) })); } polylines = intersection_pl(polylines, bed_polygon); @@ -93,7 +93,7 @@ void Bed_2D::repaint() for (size_t i = 0; i < pl.points.size()-1; i++){ Point pt1 = to_pixels(Pointf::new_unscale(pl.points[i])); Point pt2 = to_pixels(Pointf::new_unscale(pl.points[i+1])); - dc.DrawLine(pt1.x(), pt1.y(), pt2.x(), pt2.y()); + dc.DrawLine(pt1(0), pt1(1), pt2(0), pt2(1)); } } @@ -109,36 +109,36 @@ void Bed_2D::repaint() auto arrow_len = 6; auto arrow_angle = Geometry::deg2rad(45.0); dc.SetPen(wxPen(wxColour(255, 0, 0), 2, wxSOLID)); // red - auto x_end = Pointf(origin_px.x() + axes_len, origin_px.y()); - dc.DrawLine(wxPoint(origin_px.x(), origin_px.y()), wxPoint(x_end.x(), x_end.y())); + auto x_end = Pointf(origin_px(0) + axes_len, origin_px(1)); + dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(x_end(0), x_end(1))); for (auto angle : { -arrow_angle, arrow_angle }){ auto end = x_end; - end.x() -= arrow_len; + end(0) -= arrow_len; end.rotate(angle, x_end); - dc.DrawLine(wxPoint(x_end.x(), x_end.y()), wxPoint(end.x(), end.y())); + dc.DrawLine(wxPoint(x_end(0), x_end(1)), wxPoint(end(0), end(1))); } dc.SetPen(wxPen(wxColour(0, 255, 0), 2, wxSOLID)); // green - auto y_end = Pointf(origin_px.x(), origin_px.y() - axes_len); - dc.DrawLine(wxPoint(origin_px.x(), origin_px.y()), wxPoint(y_end.x(), y_end.y())); + auto y_end = Pointf(origin_px(0), origin_px(1) - axes_len); + dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(y_end(0), y_end(1))); for (auto angle : { -arrow_angle, arrow_angle }) { auto end = y_end; - end.y() += arrow_len; + end(1) += arrow_len; end.rotate(angle, y_end); - dc.DrawLine(wxPoint(y_end.x(), y_end.y()), wxPoint(end.x(), end.y())); + dc.DrawLine(wxPoint(y_end(0), y_end(1)), wxPoint(end(0), end(1))); } // draw origin dc.SetPen(wxPen(wxColour(0, 0, 0), 1, wxSOLID)); dc.SetBrush(wxBrush(wxColour(0, 0, 0), wxSOLID)); - dc.DrawCircle(origin_px.x(), origin_px.y(), 3); + dc.DrawCircle(origin_px(0), origin_px(1), 3); static const auto origin_label = wxString("(0,0)"); dc.SetTextForeground(wxColour(0, 0, 0)); dc.SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL)); auto extent = dc.GetTextExtent(origin_label); - const auto origin_label_x = origin_px.x() <= cw / 2 ? origin_px.x() + 1 : origin_px.x() - 1 - extent.GetWidth(); - const auto origin_label_y = origin_px.y() <= ch / 2 ? origin_px.y() + 1 : origin_px.y() - 1 - extent.GetHeight(); + const auto origin_label_x = origin_px(0) <= cw / 2 ? origin_px(0) + 1 : origin_px(0) - 1 - extent.GetWidth(); + const auto origin_label_y = origin_px(1) <= ch / 2 ? origin_px(1) + 1 : origin_px(1) - 1 - extent.GetHeight(); dc.DrawText(origin_label, origin_label_x, origin_label_y); // draw current position @@ -146,10 +146,10 @@ void Bed_2D::repaint() auto pos_px = to_pixels(m_pos); dc.SetPen(wxPen(wxColour(200, 0, 0), 2, wxSOLID)); dc.SetBrush(wxBrush(wxColour(200, 0, 0), wxTRANSPARENT)); - dc.DrawCircle(pos_px.x(), pos_px.y(), 5); + dc.DrawCircle(pos_px(0), pos_px(1), 5); - dc.DrawLine(pos_px.x() - 15, pos_px.y(), pos_px.x() + 15, pos_px.y()); - dc.DrawLine(pos_px.x(), pos_px.y() - 15, pos_px.x(), pos_px.y() + 15); + dc.DrawLine(pos_px(0) - 15, pos_px(1), pos_px(0) + 15, pos_px(1)); + dc.DrawLine(pos_px(0), pos_px(1) - 15, pos_px(0), pos_px(1) + 15); } m_painted = true; @@ -158,7 +158,7 @@ void Bed_2D::repaint() // convert G - code coordinates into pixels Point Bed_2D::to_pixels(Pointf point){ auto p = point * m_scale_factor + m_shift; - return Point(p.x(), GetSize().GetHeight() - p.y()); + return Point(p(0), GetSize().GetHeight() - p(1)); } void Bed_2D::mouse_event(wxMouseEvent event){ @@ -176,7 +176,7 @@ void Bed_2D::mouse_event(wxMouseEvent event){ // convert pixels into G - code coordinates Pointf Bed_2D::to_units(Point point){ - return (Pointf(point.x(), GetSize().GetHeight() - point.y()) - m_shift) * (1. / m_scale_factor); + return (Pointf(point(0), GetSize().GetHeight() - point(1)) - m_shift) * (1. / m_scale_factor); } void Bed_2D::set_pos(Pointf pos){ diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 68e11e378..03d997ae6 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -279,7 +279,7 @@ const Transform3f& GLVolume::world_matrix() const if (m_dirty) { m_world_mat = Transform3f::Identity(); - m_world_mat.translate(Vec3f(m_origin.x(), m_origin.y(), 0)); + m_world_mat.translate(Vec3f(m_origin(0), m_origin(1), 0)); m_world_mat.rotate(Eigen::AngleAxisf(m_angle_z, Vec3f::UnitZ())); m_world_mat.scale(m_scale_factor); m_dirty = false; @@ -338,7 +338,7 @@ void GLVolume::render() const ::glCullFace(GL_BACK); ::glPushMatrix(); - ::glTranslated(m_origin.x(), m_origin.y(), m_origin.z()); + ::glTranslated(m_origin(0), m_origin(1), m_origin(2)); ::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f); ::glScalef(m_scale_factor, m_scale_factor, m_scale_factor); if (this->indexed_vertex_array.indexed()) @@ -372,7 +372,7 @@ void GLVolume::render_using_layer_height() const glUniform1f(z_texture_row_to_normalized_id, (GLfloat)(1.0f / layer_height_texture_height())); if (z_cursor_id >= 0) - glUniform1f(z_cursor_id, (GLfloat)(layer_height_texture_data.print_object->model_object()->bounding_box().max.z() * layer_height_texture_data.z_cursor_relative)); + glUniform1f(z_cursor_id, (GLfloat)(layer_height_texture_data.print_object->model_object()->bounding_box().max(2) * layer_height_texture_data.z_cursor_relative)); if (z_cursor_band_width_id >= 0) glUniform1f(z_cursor_band_width_id, (GLfloat)layer_height_texture_data.edit_band_width); @@ -464,7 +464,7 @@ void GLVolume::render_VBOs(int color_id, int detection_id, int worldmatrix_id) c ::glNormalPointer(GL_FLOAT, 6 * sizeof(float), nullptr); ::glPushMatrix(); - ::glTranslated(m_origin.x(), m_origin.y(), m_origin.z()); + ::glTranslated(m_origin(0), m_origin(1), m_origin(2)); ::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f); ::glScalef(m_scale_factor, m_scale_factor, m_scale_factor); @@ -509,7 +509,7 @@ void GLVolume::render_legacy() const ::glNormalPointer(GL_FLOAT, 6 * sizeof(float), indexed_vertex_array.vertices_and_normals_interleaved.data()); ::glPushMatrix(); - ::glTranslated(m_origin.x(), m_origin.y(), m_origin.z()); + ::glTranslated(m_origin(0), m_origin(1), m_origin(2)); ::glRotatef(m_angle_z * 180.0f / PI, 0.0f, 0.0f, 1.0f); ::glScalef(m_scale_factor, m_scale_factor, m_scale_factor); @@ -524,7 +524,7 @@ void GLVolume::render_legacy() const double GLVolume::layer_height_texture_z_to_row_id() const { - return (this->layer_height_texture.get() == nullptr) ? 0.0 : double(this->layer_height_texture->cells - 1) / (double(this->layer_height_texture->width) * this->layer_height_texture_data.print_object->model_object()->bounding_box().max.z()); + return (this->layer_height_texture.get() == nullptr) ? 0.0 : double(this->layer_height_texture->cells - 1) / (double(this->layer_height_texture->width) * this->layer_height_texture_data.print_object->model_object()->bounding_box().max(2)); } void GLVolume::generate_layer_height_texture(PrintObject *print_object, bool force) @@ -628,7 +628,7 @@ std::vector GLVolumeCollection::load_object( } v.is_modifier = model_volume->modifier; v.outside_printer_detection_enabled = !model_volume->modifier; - v.set_origin(Pointf3(instance->offset.x(), instance->offset.y(), 0.0)); + v.set_origin(Pointf3(instance->offset(0), instance->offset(1), 0.0)); v.set_angle_z(instance->rotation); v.set_scale_factor(instance->scaling_factor); } @@ -742,9 +742,9 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M return false; BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); - BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x()), unscale(bed_box_2D.min.y()), 0.0), Pointf3(unscale(bed_box_2D.max.x()), unscale(bed_box_2D.max.y()), config->opt_float("max_print_height"))); + BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min(0)), unscale(bed_box_2D.min(1)), 0.0), Pointf3(unscale(bed_box_2D.max(0)), unscale(bed_box_2D.max(1)), config->opt_float("max_print_height"))); // Allow the objects to protrude below the print bed - print_volume.min.z() = -1e10; + print_volume.min(2) = -1e10; ModelInstance::EPrintVolumeState state = ModelInstance::PVS_Inside; bool all_contained = true; @@ -939,8 +939,8 @@ static void thick_lines_to_indexed_vertex_array( Pointf b2 = b; { double dist = 0.5 * width; // scaled - double dx = dist * v.x(); - double dy = dist * v.y(); + double dx = dist * v(0); + double dy = dist * v(1); a1 += Vectorf(+dy, -dx); a2 += Vectorf(-dy, +dx); b1 += Vectorf(+dy, -dx); @@ -949,7 +949,7 @@ static void thick_lines_to_indexed_vertex_array( // calculate new XY normals Vector n = line.normal(); - Vectorf3 xy_right_normal = Vectorf3::new_unscale(n.x(), n.y(), 0); + Vectorf3 xy_right_normal = Vectorf3::new_unscale(n(0), n(1), 0); xy_right_normal *= inv_len; int idx_a[4]; @@ -968,7 +968,7 @@ static void thick_lines_to_indexed_vertex_array( // Share top / bottom vertices if possible. if (is_first) { idx_a[TOP] = idx_last++; - volume.push_geometry(a.x(), a.y(), top_z , 0., 0., 1.); + volume.push_geometry(a(0), a(1), top_z , 0., 0., 1.); } else { idx_a[TOP] = idx_prev[TOP]; } @@ -976,11 +976,11 @@ static void thick_lines_to_indexed_vertex_array( if (is_first || bottom_z_different) { // Start of the 1st line segment or a change of the layer thickness while maintaining the print_z. idx_a[BOTTOM] = idx_last ++; - volume.push_geometry(a.x(), a.y(), bottom_z, 0., 0., -1.); + volume.push_geometry(a(0), a(1), bottom_z, 0., 0., -1.); idx_a[LEFT ] = idx_last ++; - volume.push_geometry(a2.x(), a2.y(), middle_z, -xy_right_normal.x(), -xy_right_normal.y(), -xy_right_normal.z()); + volume.push_geometry(a2(0), a2(1), middle_z, -xy_right_normal(0), -xy_right_normal(1), -xy_right_normal(2)); idx_a[RIGHT] = idx_last ++; - volume.push_geometry(a1.x(), a1.y(), middle_z, xy_right_normal.x(), xy_right_normal.y(), xy_right_normal.z()); + volume.push_geometry(a1(0), a1(1), middle_z, xy_right_normal(0), xy_right_normal(1), xy_right_normal(2)); } else { idx_a[BOTTOM] = idx_prev[BOTTOM]; @@ -1001,9 +1001,9 @@ static void thick_lines_to_indexed_vertex_array( { // Allocate new left / right points for the start of this segment as these points will receive their own normals to indicate a sharp turn. idx_a[RIGHT] = idx_last++; - volume.push_geometry(a1.x(), a1.y(), middle_z, xy_right_normal.x(), xy_right_normal.y(), xy_right_normal.z()); + volume.push_geometry(a1(0), a1(1), middle_z, xy_right_normal(0), xy_right_normal(1), xy_right_normal(2)); idx_a[LEFT] = idx_last++; - volume.push_geometry(a2.x(), a2.y(), middle_z, -xy_right_normal.x(), -xy_right_normal.y(), -xy_right_normal.z()); + volume.push_geometry(a2(0), a2(1), middle_z, -xy_right_normal(0), -xy_right_normal(1), -xy_right_normal(2)); } } if (v_dot > 0.9) { @@ -1029,17 +1029,17 @@ static void thick_lines_to_indexed_vertex_array( float *p_left_prev = n_left_prev + 3; float *n_right_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[RIGHT] * 6; float *p_right_prev = n_right_prev + 3; - p_left_prev [0] = float(a2.x()); - p_left_prev [1] = float(a2.y()); - p_right_prev[0] = float(a1.x()); - p_right_prev[1] = float(a1.y()); - xy_right_normal.x() += n_right_prev[0]; - xy_right_normal.y() += n_right_prev[1]; + p_left_prev [0] = float(a2(0)); + p_left_prev [1] = float(a2(1)); + p_right_prev[0] = float(a1(0)); + p_right_prev[1] = float(a1(1)); + xy_right_normal(0) += n_right_prev[0]; + xy_right_normal(1) += n_right_prev[1]; xy_right_normal *= 1. / xy_right_normal.norm(); - n_left_prev [0] = float(-xy_right_normal.x()); - n_left_prev [1] = float(-xy_right_normal.y()); - n_right_prev[0] = float( xy_right_normal.x()); - n_right_prev[1] = float( xy_right_normal.y()); + n_left_prev [0] = float(-xy_right_normal(0)); + n_left_prev [1] = float(-xy_right_normal(1)); + n_right_prev[0] = float( xy_right_normal(0)); + n_right_prev[1] = float( xy_right_normal(1)); idx_a[LEFT ] = idx_prev[LEFT ]; idx_a[RIGHT] = idx_prev[RIGHT]; } @@ -1080,20 +1080,20 @@ static void thick_lines_to_indexed_vertex_array( idx_b[TOP] = idx_initial[TOP]; } else { idx_b[TOP] = idx_last ++; - volume.push_geometry(b.x(), b.y(), top_z , 0., 0., 1.); + volume.push_geometry(b(0), b(1), top_z , 0., 0., 1.); } if (is_closing && (width == width_initial) && (bottom_z == bottom_z_initial)) { idx_b[BOTTOM] = idx_initial[BOTTOM]; } else { idx_b[BOTTOM] = idx_last ++; - volume.push_geometry(b.x(), b.y(), bottom_z, 0., 0., -1.); + volume.push_geometry(b(0), b(1), bottom_z, 0., 0., -1.); } // Generate new vertices for the end of this line segment. idx_b[LEFT ] = idx_last ++; - volume.push_geometry(b2.x(), b2.y(), middle_z, -xy_right_normal.x(), -xy_right_normal.y(), -xy_right_normal.z()); + volume.push_geometry(b2(0), b2(1), middle_z, -xy_right_normal(0), -xy_right_normal(1), -xy_right_normal(2)); idx_b[RIGHT ] = idx_last ++; - volume.push_geometry(b1.x(), b1.y(), middle_z, xy_right_normal.x(), xy_right_normal.y(), xy_right_normal.z()); + volume.push_geometry(b1(0), b1(1), middle_z, xy_right_normal(0), xy_right_normal(1), xy_right_normal(2)); memcpy(idx_prev, idx_b, 4 * sizeof(int)); bottom_z_prev = bottom_z; @@ -1178,10 +1178,10 @@ static void thick_lines_to_indexed_vertex_array(const Lines3& lines, Vectorf3 n_right; Vectorf3 unit_positive_z(0.0, 0.0, 1.0); - if ((line.a.x() == line.b.x()) && (line.a.y() == line.b.y())) + if ((line.a(0) == line.b(0)) && (line.a(1) == line.b(1))) { // vertical segment - n_right = (line.a.z() < line.b.z()) ? Vectorf3(-1.0, 0.0, 0.0) : Vectorf3(1.0, 0.0, 0.0); + n_right = (line.a(2) < line.b(2)) ? Vectorf3(-1.0, 0.0, 0.0) : Vectorf3(1.0, 0.0, 0.0); n_top = Vectorf3(0.0, 1.0, 0.0); } else @@ -1212,8 +1212,8 @@ static void thick_lines_to_indexed_vertex_array(const Lines3& lines, int idx_b[4]; int idx_last = int(volume.vertices_and_normals_interleaved.size() / 6); - bool z_different = (z_prev != l_a.z()); - z_prev = l_b.z(); + bool z_different = (z_prev != l_a(2)); + z_prev = l_b(2); // Share top / bottom vertices if possible. if (ii == 0) @@ -1282,25 +1282,25 @@ static void thick_lines_to_indexed_vertex_array(const Lines3& lines, // updates previous line normals float* normal_left_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[LEFT] * 6; - normal_left_prev[0] = float(average_n_left.x()); - normal_left_prev[1] = float(average_n_left.y()); - normal_left_prev[2] = float(average_n_left.z()); + normal_left_prev[0] = float(average_n_left(0)); + normal_left_prev[1] = float(average_n_left(1)); + normal_left_prev[2] = float(average_n_left(2)); float* normal_right_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[RIGHT] * 6; - normal_right_prev[0] = float(average_n_right.x()); - normal_right_prev[1] = float(average_n_right.y()); - normal_right_prev[2] = float(average_n_right.z()); + normal_right_prev[0] = float(average_n_right(0)); + normal_right_prev[1] = float(average_n_right(1)); + normal_right_prev[2] = float(average_n_right(2)); // updates previous line's vertices around b float* b_left_prev = normal_left_prev + 3; - b_left_prev[0] = float(a[LEFT].x()); - b_left_prev[1] = float(a[LEFT].y()); - b_left_prev[2] = float(a[LEFT].z()); + b_left_prev[0] = float(a[LEFT](0)); + b_left_prev[1] = float(a[LEFT](1)); + b_left_prev[2] = float(a[LEFT](2)); float* b_right_prev = normal_right_prev + 3; - b_right_prev[0] = float(a[RIGHT].x()); - b_right_prev[1] = float(a[RIGHT].y()); - b_right_prev[2] = float(a[RIGHT].z()); + b_right_prev[0] = float(a[RIGHT](0)); + b_right_prev[1] = float(a[RIGHT](1)); + b_right_prev[2] = float(a[RIGHT](2)); idx_a[LEFT] = idx_prev[LEFT]; idx_a[RIGHT] = idx_prev[RIGHT]; diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 1d56f2f73..d0e78b9b7 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -120,7 +120,7 @@ public: } inline void push_geometry(const Pointf3& p, const Vectorf3& n) { - push_geometry(p.x(), p.y(), p.z(), n.x(), n.y(), n.z()); + push_geometry(p(0), p(1), p(2), n(0), n(1), n(2)); } inline void push_triangle(int idx1, int idx2, int idx3) { @@ -176,17 +176,17 @@ public: BoundingBoxf3 bbox; if (! this->vertices_and_normals_interleaved.empty()) { bbox.defined = true; - bbox.min.x() = bbox.max.x() = this->vertices_and_normals_interleaved[3]; - bbox.min.y() = bbox.max.y() = this->vertices_and_normals_interleaved[4]; - bbox.min.z() = bbox.max.z() = this->vertices_and_normals_interleaved[5]; + bbox.min(0) = bbox.max(0) = this->vertices_and_normals_interleaved[3]; + bbox.min(1) = bbox.max(1) = this->vertices_and_normals_interleaved[4]; + bbox.min(2) = bbox.max(2) = this->vertices_and_normals_interleaved[5]; for (size_t i = 9; i < this->vertices_and_normals_interleaved.size(); i += 6) { const float *verts = this->vertices_and_normals_interleaved.data() + i; - bbox.min.x() = std::min(bbox.min.x(), verts[0]); - bbox.min.y() = std::min(bbox.min.y(), verts[1]); - bbox.min.z() = std::min(bbox.min.z(), verts[2]); - bbox.max.x() = std::max(bbox.max.x(), verts[0]); - bbox.max.y() = std::max(bbox.max.y(), verts[1]); - bbox.max.z() = std::max(bbox.max.z(), verts[2]); + bbox.min(0) = std::min(bbox.min(0), verts[0]); + bbox.min(1) = std::min(bbox.min(1), verts[1]); + bbox.min(2) = std::min(bbox.min(2), verts[2]); + bbox.max(0) = std::max(bbox.max(0), verts[0]); + bbox.max(1) = std::max(bbox.max(1), verts[1]); + bbox.max(2) = std::max(bbox.max(2), verts[2]); } } return bbox; diff --git a/xs/src/slic3r/GUI/BedShapeDialog.cpp b/xs/src/slic3r/GUI/BedShapeDialog.cpp index 0cdc1df43..0f2e84754 100644 --- a/xs/src/slic3r/GUI/BedShapeDialog.cpp +++ b/xs/src/slic3r/GUI/BedShapeDialog.cpp @@ -148,13 +148,13 @@ void BedShapePanel::set_shape(ConfigOptionPoints* points) // find origin // the || 0 hack prevents "-0" which might confuse the user int x_min, x_max, y_min, y_max; - x_max = x_min = points->values[0].x(); - y_max = y_min = points->values[0].y(); + x_max = x_min = points->values[0](0); + y_max = y_min = points->values[0](1); for (auto pt : points->values){ - if (x_min > pt.x()) x_min = pt.x(); - if (x_max < pt.x()) x_max = pt.x(); - if (y_min > pt.y()) y_min = pt.y(); - if (y_max < pt.y()) y_max = pt.y(); + if (x_min > pt(0)) x_min = pt(0); + if (x_max < pt(0)) x_max = pt(0); + if (y_min > pt(1)) y_min = pt(1); + if (y_max < pt(1)) y_max = pt(1); } if (x_min < 0) x_min = 0; if (x_max < 0) x_max = 0; @@ -242,8 +242,8 @@ void BedShapePanel::update_shape() catch (const std::exception &e){ return;} - auto x = rect_size.x(); - auto y = rect_size.y(); + auto x = rect_size(0); + auto y = rect_size(1); // empty strings or '-' or other things if (x == 0 || y == 0) return; double x0 = 0.0; @@ -251,8 +251,8 @@ void BedShapePanel::update_shape() double x1 = x; double y1 = y; - auto dx = rect_origin.x(); - auto dy = rect_origin.y(); + auto dx = rect_origin(0); + auto dy = rect_origin(1); x0 -= dx; x1 -= dx; diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 4efda6398..8892583a2 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -629,9 +629,9 @@ void PointCtrl::BUILD() wxSize field_size(40, -1); auto default_pt = static_cast(m_opt.default_value)->values.at(0); - double val = default_pt.x(); + double val = default_pt(0); wxString X = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None); - val = default_pt.y(); + val = default_pt(1); wxString Y = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None); x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size); @@ -656,9 +656,9 @@ void PointCtrl::set_value(const Pointf& value, bool change_event) { m_disable_change_event = !change_event; - double val = value.x(); + double val = value(0); x_textctrl->SetValue(val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None)); - val = value.y(); + val = value(1); y_textctrl->SetValue(val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None)); m_disable_change_event = false; @@ -683,9 +683,9 @@ boost::any& PointCtrl::get_value() Pointf ret_point; double val; x_textctrl->GetValue().ToDouble(&val); - ret_point.x() = val; + ret_point(0) = val; y_textctrl->GetValue().ToDouble(&val); - ret_point.y() = val; + ret_point(1) = val; return m_value = ret_point; } diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 91a8ea890..8d82d1111 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -68,8 +68,8 @@ bool GeometryBuffer::set_from_triangles(const Polygons& triangles, float z, bool if (generate_tex_coords) m_tex_coords = std::vector(t_size, 0.0f); - float min_x = (float)unscale(triangles[0].points[0].x()); - float min_y = (float)unscale(triangles[0].points[0].y()); + float min_x = (float)unscale(triangles[0].points[0](0)); + float min_y = (float)unscale(triangles[0].points[0](1)); float max_x = min_x; float max_y = min_y; @@ -80,8 +80,8 @@ bool GeometryBuffer::set_from_triangles(const Polygons& triangles, float z, bool for (unsigned int v = 0; v < 3; ++v) { const Point& p = t.points[v]; - float x = (float)unscale(p.x()); - float y = (float)unscale(p.y()); + float x = (float)unscale(p(0)); + float y = (float)unscale(p(1)); m_vertices[v_coord++] = x; m_vertices[v_coord++] = y; @@ -134,11 +134,11 @@ bool GeometryBuffer::set_from_lines(const Lines& lines, float z) unsigned int coord = 0; for (const Line& l : lines) { - m_vertices[coord++] = (float)unscale(l.a.x()); - m_vertices[coord++] = (float)unscale(l.a.y()); + m_vertices[coord++] = (float)unscale(l.a(0)); + m_vertices[coord++] = (float)unscale(l.a(1)); m_vertices[coord++] = z; - m_vertices[coord++] = (float)unscale(l.b.x()); - m_vertices[coord++] = (float)unscale(l.b.y()); + m_vertices[coord++] = (float)unscale(l.b(0)); + m_vertices[coord++] = (float)unscale(l.b(1)); m_vertices[coord++] = z; } @@ -312,7 +312,7 @@ void GLCanvas3D::Bed::set_shape(const Pointfs& shape) ExPolygon poly; for (const Pointf& p : m_shape) { - poly.contour.append(Point(scale_(p.x()), scale_(p.y()))); + poly.contour.append(Point(scale_(p(0)), scale_(p(1)))); } _calc_triangles(poly); @@ -366,7 +366,7 @@ void GLCanvas3D::Bed::_calc_bounding_box() m_bounding_box = BoundingBoxf3(); for (const Pointf& p : m_shape) { - m_bounding_box.merge(Pointf3(p.x(), p.y(), 0.0)); + m_bounding_box.merge(Pointf3(p(0), p(1), 0.0)); } } @@ -382,18 +382,18 @@ void GLCanvas3D::Bed::_calc_triangles(const ExPolygon& poly) void GLCanvas3D::Bed::_calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox) { Polylines axes_lines; - for (coord_t x = bed_bbox.min.x(); x <= bed_bbox.max.x(); x += scale_(10.0)) + for (coord_t x = bed_bbox.min(0); x <= bed_bbox.max(0); x += scale_(10.0)) { Polyline line; - line.append(Point(x, bed_bbox.min.y())); - line.append(Point(x, bed_bbox.max.y())); + line.append(Point(x, bed_bbox.min(1))); + line.append(Point(x, bed_bbox.max(1))); axes_lines.push_back(line); } - for (coord_t y = bed_bbox.min.y(); y <= bed_bbox.max.y(); y += scale_(10.0)) + for (coord_t y = bed_bbox.min(1); y <= bed_bbox.max(1); y += scale_(10.0)) { Polyline line; - line.append(Point(bed_bbox.min.x(), y)); - line.append(Point(bed_bbox.max.x(), y)); + line.append(Point(bed_bbox.min(0), y)); + line.append(Point(bed_bbox.max(0), y)); axes_lines.push_back(line); } @@ -597,12 +597,12 @@ void GLCanvas3D::Axes::render(bool depth_test) const ::glBegin(GL_LINES); // draw line for x axis ::glColor3f(1.0f, 0.0f, 0.0f); - ::glVertex3f((GLfloat)origin.x(), (GLfloat)origin.y(), (GLfloat)origin.z()); - ::glVertex3f((GLfloat)origin.x() + length, (GLfloat)origin.y(), (GLfloat)origin.z()); + ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2)); + ::glVertex3f((GLfloat)origin(0) + length, (GLfloat)origin(1), (GLfloat)origin(2)); // draw line for y axis ::glColor3f(0.0f, 1.0f, 0.0f); - ::glVertex3f((GLfloat)origin.x(), (GLfloat)origin.y(), (GLfloat)origin.z()); - ::glVertex3f((GLfloat)origin.x(), (GLfloat)origin.y() + length, (GLfloat)origin.z()); + ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2)); + ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1) + length, (GLfloat)origin(2)); ::glEnd(); // draw line for Z axis // (re-enable depth test so that axis is correctly shown when objects are behind it) @@ -611,8 +611,8 @@ void GLCanvas3D::Axes::render(bool depth_test) const ::glBegin(GL_LINES); ::glColor3f(0.0f, 0.0f, 1.0f); - ::glVertex3f((GLfloat)origin.x(), (GLfloat)origin.y(), (GLfloat)origin.z()); - ::glVertex3f((GLfloat)origin.x(), (GLfloat)origin.y(), (GLfloat)origin.z() + length); + ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2)); + ::glVertex3f((GLfloat)origin(0), (GLfloat)origin(1), (GLfloat)origin(2) + length); ::glEnd(); } @@ -646,10 +646,10 @@ void GLCanvas3D::CuttingPlane::_render_plane(const BoundingBoxf3& bb) const ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); float margin = 20.0f; - float min_x = bb.min.x() - margin; - float max_x = bb.max.x() + margin; - float min_y = bb.min.y() - margin; - float max_y = bb.max.y() + margin; + float min_x = bb.min(0) - margin; + float max_x = bb.max(0) + margin; + float min_y = bb.min(1) - margin; + float max_y = bb.max(1) + margin; ::glBegin(GL_QUADS); ::glColor4f(0.8f, 0.8f, 0.8f, 0.5f); @@ -860,8 +860,8 @@ float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas) { const Point& mouse_pos = canvas.get_local_mouse_position(); const Rect& rect = get_bar_rect_screen(canvas); - float x = (float)mouse_pos.x(); - float y = (float)mouse_pos.y(); + float x = (float)mouse_pos(0); + float y = (float)mouse_pos(1); float t = rect.get_top(); float b = rect.get_bottom(); @@ -970,7 +970,7 @@ void GLCanvas3D::LayersEditing::_render_reset_texture(const Rect& reset_rect) co void GLCanvas3D::LayersEditing::_render_active_object_annotations(const GLCanvas3D& canvas, const GLVolume& volume, const PrintObject& print_object, const Rect& bar_rect) const { - float max_z = print_object.model_object()->bounding_box().max.z(); + float max_z = print_object.model_object()->bounding_box().max(2); m_shader.start_using(); @@ -1031,7 +1031,7 @@ void GLCanvas3D::LayersEditing::_render_profile(const PrintObject& print_object, // Make the vertical bar a bit wider so the layer height curve does not touch the edge of the bar region. layer_height_max *= 1.12; - coordf_t max_z = unscale(print_object.size.z()); + coordf_t max_z = unscale(print_object.size(2)); double layer_height = dynamic_cast(print_object.config.option("layer_height"))->value; float l = bar_rect.get_left(); float w = bar_rect.get_right() - l; @@ -1951,15 +1951,15 @@ void GLCanvas3D::set_auto_bed_shape() Pointfs bed_shape; bed_shape.reserve(4); - bed_shape.emplace_back(center.x() - max_size, center.y() - max_size); - bed_shape.emplace_back(center.x() + max_size, center.y() - max_size); - bed_shape.emplace_back(center.x() + max_size, center.y() + max_size); - bed_shape.emplace_back(center.x() - max_size, center.y() + max_size); + bed_shape.emplace_back(center(0) - max_size, center(1) - max_size); + bed_shape.emplace_back(center(0) + max_size, center(1) - max_size); + bed_shape.emplace_back(center(0) + max_size, center(1) + max_size); + bed_shape.emplace_back(center(0) - max_size, center(1) + max_size); set_bed_shape(bed_shape); // Set the origin for painting of the coordinate system axes. - m_axes.origin = Pointf3(center.x(), center.y(), (coordf_t)GROUND_Z); + m_axes.origin = Pointf3(center(0), center(1), (coordf_t)GROUND_Z); } void GLCanvas3D::set_axes_length(float length) @@ -2283,7 +2283,7 @@ void GLCanvas3D::reload_scene(bool force) if ((extruders_count > 1) && semm && wt && !co) { // Height of a print (Show at least a slab) - coordf_t height = std::max(m_model->bounding_box().max.z(), 10.0); + coordf_t height = std::max(m_model->bounding_box().max(2), 10.0); float x = dynamic_cast(m_config->option("wipe_tower_x"))->value; float y = dynamic_cast(m_config->option("wipe_tower_y"))->value; @@ -3031,14 +3031,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // on a volume or not. int volume_idx = m_hover_volume_id; m_layers_editing.state = LayersEditing::Unknown; - if ((layer_editing_object_idx != -1) && m_layers_editing.bar_rect_contains(*this, pos.x(), pos.y())) + if ((layer_editing_object_idx != -1) && m_layers_editing.bar_rect_contains(*this, pos(0), pos(1))) { // A volume is selected and the mouse is inside the layer thickness bar. // Start editing the layer height. m_layers_editing.state = LayersEditing::Editing; _perform_layer_editing_action(&evt); } - else if ((layer_editing_object_idx != -1) && m_layers_editing.reset_rect_contains(*this, pos.x(), pos.y())) + else if ((layer_editing_object_idx != -1) && m_layers_editing.reset_rect_contains(*this, pos(0), pos(1))) { if (evt.LeftDown()) { @@ -3121,7 +3121,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) { // if right clicking on volume, propagate event through callback if (m_volumes.volumes[volume_idx]->hover) - m_on_right_click_callback.call(pos.x(), pos.y()); + m_on_right_click_callback.call(pos(0), pos(1)); } } } @@ -3133,16 +3133,16 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // Get new position at the same Z of the initial click point. float z0 = 0.0f; float z1 = 1.0f; - Pointf3 cur_pos = Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D.z()); + Pointf3 cur_pos = Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D(2)); // Clip the new position, so the object center remains close to the bed. cur_pos += m_mouse.drag.volume_center_offset; - Point cur_pos2(scale_(cur_pos.x()), scale_(cur_pos.y())); + Point cur_pos2(scale_(cur_pos(0)), scale_(cur_pos(1))); if (!m_bed.contains(cur_pos2)) { Point ip = m_bed.point_projection(cur_pos2); - cur_pos.x() = unscale(ip.x()); - cur_pos.y() = unscale(ip.y()); + cur_pos(0) = unscale(ip(0)); + cur_pos(1) = unscale(ip(1)); } cur_pos -= m_mouse.drag.volume_center_offset; @@ -3169,7 +3169,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // Apply new temporary volume origin and ignore Z. for (GLVolume* v : volumes) - v->set_origin(v->get_origin() + Vectorf3(vector.x(), vector.y(), 0.0)); + v->set_origin(v->get_origin() + Vectorf3(vector(0), vector(1), 0.0)); m_mouse.drag.start_position_3D = cur_pos; m_gizmos.refresh(); @@ -3181,7 +3181,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_mouse.dragging = true; const Pointf3& cur_pos = _mouse_to_bed_3d(pos); - m_gizmos.update(Pointf(cur_pos.x(), cur_pos.y())); + m_gizmos.update(Pointf(cur_pos(0), cur_pos(1))); std::vector volumes; if (m_mouse.drag.gizmo_volume_idx != -1) @@ -3230,7 +3230,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) { const BoundingBoxf3& bb = volumes[0]->transformed_bounding_box(); const Pointf3& size = bb.size(); - m_on_update_geometry_info_callback.call(size.x(), size.y(), size.z(), m_gizmos.get_scale()); + m_on_update_geometry_info_callback.call(size(0), size(1), size(2), m_gizmos.get_scale()); } if ((m_gizmos.get_current_type() != Gizmos::Rotate) && (volumes.size() > 1)) @@ -3253,14 +3253,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (m_mouse.is_start_position_3D_defined()) { const Pointf3& orig = m_mouse.drag.start_position_3D; - m_camera.phi += (((float)pos.x() - (float)orig.x()) * TRACKBALLSIZE); - m_camera.set_theta(m_camera.get_theta() - ((float)pos.y() - (float)orig.y()) * TRACKBALLSIZE); + m_camera.phi += (((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE); + m_camera.set_theta(m_camera.get_theta() - ((float)pos(1) - (float)orig(1)) * TRACKBALLSIZE); m_on_viewport_changed_callback.call(); m_dirty = true; } - m_mouse.drag.start_position_3D = Pointf3((coordf_t)pos.x(), (coordf_t)pos.y(), 0.0); + m_mouse.drag.start_position_3D = Pointf3((coordf_t)pos(0), (coordf_t)pos(1), 0.0); } else if (evt.MiddleIsDown() || evt.RightIsDown()) { @@ -3349,7 +3349,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } else if (evt.Moving()) { - m_mouse.position = Pointf((coordf_t)pos.x(), (coordf_t)pos.y()); + m_mouse.position = Pointf((coordf_t)pos(0), (coordf_t)pos(1)); // Only refresh if picking is enabled, in that case the objects may get highlighted if the mouse cursor hovers over. if (m_picking_enabled) m_dirty = true; @@ -3547,13 +3547,13 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co std::vector vertices; vertices.reserve(8); vertices.push_back(bb_min); - vertices.emplace_back(bb_max.x(), bb_min.y(), bb_min.z()); - vertices.emplace_back(bb_max.x(), bb_max.y(), bb_min.z()); - vertices.emplace_back(bb_min.x(), bb_max.y(), bb_min.z()); - vertices.emplace_back(bb_min.x(), bb_min.y(), bb_max.z()); - vertices.emplace_back(bb_max.x(), bb_min.y(), bb_max.z()); + vertices.emplace_back(bb_max(0), bb_min(1), bb_min(2)); + vertices.emplace_back(bb_max(0), bb_max(1), bb_min(2)); + vertices.emplace_back(bb_min(0), bb_max(1), bb_min(2)); + vertices.emplace_back(bb_min(0), bb_min(1), bb_max(2)); + vertices.emplace_back(bb_max(0), bb_min(1), bb_max(2)); vertices.push_back(bb_max); - vertices.emplace_back(bb_min.x(), bb_max.y(), bb_max.z()); + vertices.emplace_back(bb_min(0), bb_max(1), bb_max(2)); coordf_t max_x = 0.0; coordf_t max_y = 0.0; @@ -3564,7 +3564,7 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co for (const Pointf3 v : vertices) { // project vertex on the plane perpendicular to camera forward axis - Pointf3 pos(v.x() - bb_center.x(), v.y() - bb_center.y(), v.z() - bb_center.z()); + Pointf3 pos(v(0) - bb_center(0), v(1) - bb_center(1), v(2) - bb_center(2)); Pointf3 proj_on_plane = pos - pos.dot(forward) * forward; // calculates vertex coordinate along camera xy axes @@ -3648,7 +3648,7 @@ void GLCanvas3D::_camera_tranform() const ::glRotatef(m_camera.phi, 0.0f, 0.0f, 1.0f); // yaw Pointf3 neg_target = - m_camera.target; - ::glTranslatef((GLfloat)neg_target.x(), (GLfloat)neg_target.y(), (GLfloat)neg_target.z()); + ::glTranslatef((GLfloat)neg_target(0), (GLfloat)neg_target(1), (GLfloat)neg_target(2)); } void GLCanvas3D::_picking_pass() const @@ -3678,7 +3678,7 @@ void GLCanvas3D::_picking_pass() const const Size& cnv_size = get_canvas_size(); GLubyte color[4]; - ::glReadPixels(pos.x(), cnv_size.get_height() - pos.y() - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color); + ::glReadPixels(pos(0), cnv_size.get_height() - pos(1) - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color); int volume_id = color[0] + color[1] * 256 + color[2] * 256 * 256; m_hover_volume_id = -1; @@ -3773,7 +3773,7 @@ void GLCanvas3D::_render_objects() const if (m_config != nullptr) { const BoundingBoxf3& bed_bb = m_bed.get_bounding_box(); - m_volumes.set_print_box((float)bed_bb.min.x(), (float)bed_bb.min.y(), 0.0f, (float)bed_bb.max.x(), (float)bed_bb.max.y(), (float)m_config->opt_float("max_print_height")); + m_volumes.set_print_box((float)bed_bb.min(0), (float)bed_bb.min(1), 0.0f, (float)bed_bb.max(0), (float)bed_bb.max(1), (float)m_config->opt_float("max_print_height")); m_volumes.check_outside_state(m_config, nullptr); } // do not cull backfaces to show broken geometry, if any @@ -3980,7 +3980,7 @@ void GLCanvas3D::_perform_layer_editing_action(wxMouseEvent* evt) { const Rect& rect = LayersEditing::get_bar_rect_screen(*this); float b = rect.get_bottom(); - m_layers_editing.last_z = unscale(selected_obj->size.z()) * (b - evt->GetY() - 1.0f) / (b - rect.get_top()); + m_layers_editing.last_z = unscale(selected_obj->size(2)) * (b - evt->GetY() - 1.0f) / (b - rect.get_top()); m_layers_editing.last_action = evt->ShiftDown() ? (evt->RightIsDown() ? 3 : 2) : (evt->RightIsDown() ? 0 : 1); } @@ -4024,15 +4024,15 @@ Pointf3 GLCanvas3D::_mouse_to_3d(const Point& mouse_pos, float* z) GLdouble projection_matrix[16]; ::glGetDoublev(GL_PROJECTION_MATRIX, projection_matrix); - GLint y = viewport[3] - (GLint)mouse_pos.y(); + GLint y = viewport[3] - (GLint)mouse_pos(1); GLfloat mouse_z; if (z == nullptr) - ::glReadPixels((GLint)mouse_pos.x(), y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, (void*)&mouse_z); + ::glReadPixels((GLint)mouse_pos(0), y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, (void*)&mouse_z); else mouse_z = *z; GLdouble out_x, out_y, out_z; - ::gluUnProject((GLdouble)mouse_pos.x(), (GLdouble)y, (GLdouble)mouse_z, modelview_matrix, projection_matrix, viewport, &out_x, &out_y, &out_z); + ::gluUnProject((GLdouble)mouse_pos(0), (GLdouble)y, (GLdouble)mouse_z, modelview_matrix, projection_matrix, viewport, &out_x, &out_y, &out_z); return Pointf3((coordf_t)out_x, (coordf_t)out_y, (coordf_t)out_z); } @@ -4383,7 +4383,7 @@ bool GLCanvas3D::_travel_paths_by_type(const GCodePreviewData& preview_data) TypesList::iterator type = std::find(types.begin(), types.end(), Type(polyline.type)); if (type != types.end()) { - type->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min.z())); + type->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min(2))); type->volume->offsets.push_back(type->volume->indexed_vertex_array.quad_indices.size()); type->volume->offsets.push_back(type->volume->indexed_vertex_array.triangle_indices.size()); @@ -4449,7 +4449,7 @@ bool GLCanvas3D::_travel_paths_by_feedrate(const GCodePreviewData& preview_data) FeedratesList::iterator feedrate = std::find(feedrates.begin(), feedrates.end(), Feedrate(polyline.feedrate)); if (feedrate != feedrates.end()) { - feedrate->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min.z())); + feedrate->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min(2))); feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.quad_indices.size()); feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.triangle_indices.size()); @@ -4515,7 +4515,7 @@ bool GLCanvas3D::_travel_paths_by_tool(const GCodePreviewData& preview_data, con ToolsList::iterator tool = std::find(tools.begin(), tools.end(), Tool(polyline.extruder_id)); if (tool != tools.end()) { - tool->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min.z())); + tool->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().min(2))); tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.quad_indices.size()); tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.triangle_indices.size()); @@ -4540,11 +4540,11 @@ void GLCanvas3D::_load_gcode_retractions(const GCodePreviewData& preview_data) m_volumes.volumes.emplace_back(volume); GCodePreviewData::Retraction::PositionsList copy(preview_data.retraction.positions); - std::sort(copy.begin(), copy.end(), [](const GCodePreviewData::Retraction::Position& p1, const GCodePreviewData::Retraction::Position& p2){ return p1.position.z() < p2.position.z(); }); + std::sort(copy.begin(), copy.end(), [](const GCodePreviewData::Retraction::Position& p1, const GCodePreviewData::Retraction::Position& p2){ return p1.position(2) < p2.position(2); }); for (const GCodePreviewData::Retraction::Position& position : copy) { - volume->print_zs.push_back(unscale(position.position.z())); + volume->print_zs.push_back(unscale(position.position(2))); volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size()); volume->offsets.push_back(volume->indexed_vertex_array.triangle_indices.size()); @@ -4571,11 +4571,11 @@ void GLCanvas3D::_load_gcode_unretractions(const GCodePreviewData& preview_data) m_volumes.volumes.emplace_back(volume); GCodePreviewData::Retraction::PositionsList copy(preview_data.unretraction.positions); - std::sort(copy.begin(), copy.end(), [](const GCodePreviewData::Retraction::Position& p1, const GCodePreviewData::Retraction::Position& p2){ return p1.position.z() < p2.position.z(); }); + std::sort(copy.begin(), copy.end(), [](const GCodePreviewData::Retraction::Position& p1, const GCodePreviewData::Retraction::Position& p2){ return p1.position(2) < p2.position(2); }); for (const GCodePreviewData::Retraction::Position& position : copy) { - volume->print_zs.push_back(unscale(position.position.z())); + volume->print_zs.push_back(unscale(position.position(2))); volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size()); volume->offsets.push_back(volume->indexed_vertex_array.triangle_indices.size()); @@ -4615,7 +4615,7 @@ void GLCanvas3D::_load_shells() } // adds wipe tower's volume - coordf_t max_z = m_print->objects[0]->model_object()->get_model()->bounding_box().max.z(); + coordf_t max_z = m_print->objects[0]->model_object()->get_model()->bounding_box().max(2); const PrintConfig& config = m_print->config; unsigned int extruders_count = config.nozzle_diameter.size(); if ((extruders_count > 1) && config.single_extruder_multi_material && config.wipe_tower && !config.complete_objects) { @@ -4710,7 +4710,7 @@ void GLCanvas3D::_on_move(const std::vector& volume_idxs) // Move a regular object. ModelObject* model_object = m_model->objects[obj_idx]; const Pointf3& origin = volume->get_origin(); - model_object->instances[instance_idx]->offset = Pointf(origin.x(), origin.y()); + model_object->instances[instance_idx]->offset = Pointf(origin(0), origin(1)); model_object->invalidate_bounding_box(); object_moved = true; } @@ -4723,7 +4723,7 @@ void GLCanvas3D::_on_move(const std::vector& volume_idxs) m_on_instance_moved_callback.call(); if (wipe_tower_origin != Pointf3(0.0, 0.0, 0.0)) - m_on_wipe_tower_moved_callback.call(wipe_tower_origin.x(), wipe_tower_origin.y()); + m_on_wipe_tower_moved_callback.call(wipe_tower_origin(0), wipe_tower_origin(1)); } void GLCanvas3D::_on_select(int volume_idx) diff --git a/xs/src/slic3r/GUI/GLGizmo.cpp b/xs/src/slic3r/GUI/GLGizmo.cpp index c52230c61..f4f947d9c 100644 --- a/xs/src/slic3r/GUI/GLGizmo.cpp +++ b/xs/src/slic3r/GUI/GLGizmo.cpp @@ -35,7 +35,7 @@ void GLGizmoBase::Grabber::render(bool hover) const float angle_z_in_deg = angle_z * 180.0f / (float)PI; ::glPushMatrix(); - ::glTranslatef((GLfloat)center.x(), (GLfloat)center.y(), 0.0f); + ::glTranslatef((GLfloat)center(0), (GLfloat)center(1), 0.0f); ::glRotatef((GLfloat)angle_z_in_deg, 0.0f, 0.0f, 1.0f); ::glDisable(GL_CULL_FACE); @@ -266,7 +266,7 @@ void GLGizmoRotate::on_render(const BoundingBoxf3& box) const m_center = box.center().xy(); if (!m_keep_radius) { - m_radius = Offset + ::sqrt(sqr(0.5f * size.x()) + sqr(0.5f * size.y())); + m_radius = Offset + ::sqrt(sqr(0.5f * size(0)) + sqr(0.5f * size(1))); m_keep_radius = true; } @@ -299,8 +299,8 @@ void GLGizmoRotate::_render_circle() const for (unsigned int i = 0; i < ScaleStepsCount; ++i) { float angle = (float)i * ScaleStepRad; - float x = m_center.x() + ::cos(angle) * m_radius; - float y = m_center.y() + ::sin(angle) * m_radius; + float x = m_center(0) + ::cos(angle) * m_radius; + float y = m_center(1) + ::sin(angle) * m_radius; ::glVertex3f((GLfloat)x, (GLfloat)y, 0.0f); } ::glEnd(); @@ -317,10 +317,10 @@ void GLGizmoRotate::_render_scale() const float angle = (float)i * ScaleStepRad; float cosa = ::cos(angle); float sina = ::sin(angle); - float in_x = m_center.x() + cosa * m_radius; - float in_y = m_center.y() + sina * m_radius; - float out_x = (i % ScaleLongEvery == 0) ? m_center.x() + cosa * out_radius_long : m_center.x() + cosa * out_radius_short; - float out_y = (i % ScaleLongEvery == 0) ? m_center.y() + sina * out_radius_long : m_center.y() + sina * out_radius_short; + float in_x = m_center(0) + cosa * m_radius; + float in_y = m_center(1) + sina * m_radius; + float out_x = (i % ScaleLongEvery == 0) ? m_center(0) + cosa * out_radius_long : m_center(0) + cosa * out_radius_short; + float out_y = (i % ScaleLongEvery == 0) ? m_center(1) + sina * out_radius_long : m_center(1) + sina * out_radius_short; ::glVertex3f((GLfloat)in_x, (GLfloat)in_y, 0.0f); ::glVertex3f((GLfloat)out_x, (GLfloat)out_y, 0.0f); } @@ -340,10 +340,10 @@ void GLGizmoRotate::_render_snap_radii() const float angle = (float)i * step; float cosa = ::cos(angle); float sina = ::sin(angle); - float in_x = m_center.x() + cosa * in_radius; - float in_y = m_center.y() + sina * in_radius; - float out_x = m_center.x() + cosa * out_radius; - float out_y = m_center.y() + sina * out_radius; + float in_x = m_center(0) + cosa * in_radius; + float in_y = m_center(1) + sina * in_radius; + float out_x = m_center(0) + cosa * out_radius; + float out_y = m_center(1) + sina * out_radius; ::glVertex3f((GLfloat)in_x, (GLfloat)in_y, 0.0f); ::glVertex3f((GLfloat)out_x, (GLfloat)out_y, 0.0f); } @@ -353,8 +353,8 @@ void GLGizmoRotate::_render_snap_radii() const void GLGizmoRotate::_render_reference_radius() const { ::glBegin(GL_LINES); - ::glVertex3f((GLfloat)m_center.x(), (GLfloat)m_center.y(), 0.0f); - ::glVertex3f((GLfloat)m_center.x() + m_radius + GrabberOffset, (GLfloat)m_center.y(), 0.0f); + ::glVertex3f((GLfloat)m_center(0), (GLfloat)m_center(1), 0.0f); + ::glVertex3f((GLfloat)m_center(0) + m_radius + GrabberOffset, (GLfloat)m_center(1), 0.0f); ::glEnd(); } @@ -367,8 +367,8 @@ void GLGizmoRotate::_render_angle_z() const for (unsigned int i = 0; i <= AngleResolution; ++i) { float angle = (float)i * step_angle; - float x = m_center.x() + ::cos(angle) * ex_radius; - float y = m_center.y() + ::sin(angle) * ex_radius; + float x = m_center(0) + ::cos(angle) * ex_radius; + float y = m_center(1) + ::sin(angle) * ex_radius; ::glVertex3f((GLfloat)x, (GLfloat)y, 0.0f); } ::glEnd(); @@ -377,14 +377,14 @@ void GLGizmoRotate::_render_angle_z() const void GLGizmoRotate::_render_grabber() const { float grabber_radius = m_radius + GrabberOffset; - m_grabbers[0].center.x() = m_center.x() + ::cos(m_angle_z) * grabber_radius; - m_grabbers[0].center.y() = m_center.y() + ::sin(m_angle_z) * grabber_radius; + m_grabbers[0].center(0) = m_center(0) + ::cos(m_angle_z) * grabber_radius; + m_grabbers[0].center(1) = m_center(1) + ::sin(m_angle_z) * grabber_radius; m_grabbers[0].angle_z = m_angle_z; ::glColor3fv(BaseColor); ::glBegin(GL_LINES); - ::glVertex3f((GLfloat)m_center.x(), (GLfloat)m_center.y(), 0.0f); - ::glVertex3f((GLfloat)m_grabbers[0].center.x(), (GLfloat)m_grabbers[0].center.y(), 0.0f); + ::glVertex3f((GLfloat)m_center(0), (GLfloat)m_center(1), 0.0f); + ::glVertex3f((GLfloat)m_grabbers[0].center(0), (GLfloat)m_grabbers[0].center(1), 0.0f); ::glEnd(); ::memcpy((void*)m_grabbers[0].color, (const void*)HighlightColor, 3 * sizeof(float)); @@ -442,7 +442,7 @@ void GLGizmoScale::on_start_dragging() void GLGizmoScale::on_update(const Pointf& mouse_pos) { - Pointf center(0.5 * (m_grabbers[1].center.x() + m_grabbers[0].center.x()), 0.5 * (m_grabbers[3].center.y() + m_grabbers[0].center.y())); + Pointf center(0.5 * (m_grabbers[1].center(0) + m_grabbers[0].center(0)), 0.5 * (m_grabbers[3].center(1) + m_grabbers[0].center(1))); coordf_t orig_len = (m_starting_drag_position - center).norm(); coordf_t new_len = (mouse_pos - center).norm(); @@ -455,19 +455,19 @@ void GLGizmoScale::on_render(const BoundingBoxf3& box) const { ::glDisable(GL_DEPTH_TEST); - coordf_t min_x = box.min.x() - (coordf_t)Offset; - coordf_t max_x = box.max.x() + (coordf_t)Offset; - coordf_t min_y = box.min.y() - (coordf_t)Offset; - coordf_t max_y = box.max.y() + (coordf_t)Offset; + coordf_t min_x = box.min(0) - (coordf_t)Offset; + coordf_t max_x = box.max(0) + (coordf_t)Offset; + coordf_t min_y = box.min(1) - (coordf_t)Offset; + coordf_t max_y = box.max(1) + (coordf_t)Offset; - m_grabbers[0].center.x() = min_x; - m_grabbers[0].center.y() = min_y; - m_grabbers[1].center.x() = max_x; - m_grabbers[1].center.y() = min_y; - m_grabbers[2].center.x() = max_x; - m_grabbers[2].center.y() = max_y; - m_grabbers[3].center.x() = min_x; - m_grabbers[3].center.y() = max_y; + m_grabbers[0].center(0) = min_x; + m_grabbers[0].center(1) = min_y; + m_grabbers[1].center(0) = max_x; + m_grabbers[1].center(1) = min_y; + m_grabbers[2].center(0) = max_x; + m_grabbers[2].center(1) = max_y; + m_grabbers[3].center(0) = min_x; + m_grabbers[3].center(1) = max_y; ::glLineWidth(2.0f); ::glColor3fv(BaseColor); @@ -475,7 +475,7 @@ void GLGizmoScale::on_render(const BoundingBoxf3& box) const ::glBegin(GL_LINE_LOOP); for (unsigned int i = 0; i < 4; ++i) { - ::glVertex3f((GLfloat)m_grabbers[i].center.x(), (GLfloat)m_grabbers[i].center.y(), 0.0f); + ::glVertex3f((GLfloat)m_grabbers[i].center(0), (GLfloat)m_grabbers[i].center(1), 0.0f); } ::glEnd(); diff --git a/xs/xsp/BoundingBox.xsp b/xs/xsp/BoundingBox.xsp index cfc11b40f..d65f8a523 100644 --- a/xs/xsp/BoundingBox.xsp +++ b/xs/xsp/BoundingBox.xsp @@ -25,15 +25,15 @@ double radius(); Clone min_point() %code{% RETVAL = THIS->min; %}; Clone max_point() %code{% RETVAL = THIS->max; %}; - int x_min() %code{% RETVAL = THIS->min.x(); %}; - int x_max() %code{% RETVAL = THIS->max.x(); %}; - int y_min() %code{% RETVAL = THIS->min.y(); %}; - int y_max() %code{% RETVAL = THIS->max.y(); %}; - void set_x_min(double val) %code{% THIS->min.x() = val; %}; - void set_x_max(double val) %code{% THIS->max.x() = val; %}; - void set_y_min(double val) %code{% THIS->min.y() = val; %}; - void set_y_max(double val) %code{% THIS->max.y() = val; %}; - std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min.x(), THIS->min.y(), THIS->max.x(), THIS->max.y()); RETVAL = buf; %}; + int x_min() %code{% RETVAL = THIS->min(0); %}; + int x_max() %code{% RETVAL = THIS->max(0); %}; + int y_min() %code{% RETVAL = THIS->min(1); %}; + int y_max() %code{% RETVAL = THIS->max(1); %}; + void set_x_min(double val) %code{% THIS->min(0) = val; %}; + void set_x_max(double val) %code{% THIS->max(0) = val; %}; + void set_y_min(double val) %code{% THIS->min(1) = val; %}; + void set_y_max(double val) %code{% THIS->max(1) = val; %}; + std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min(0), THIS->min(1), THIS->max(0), THIS->max(1)); RETVAL = buf; %}; bool defined() %code{% RETVAL = THIS->defined; %}; %{ @@ -65,15 +65,15 @@ new_from_points(CLASS, points) bool empty() %code{% RETVAL = empty(*THIS); %}; Clone min_point() %code{% RETVAL = THIS->min; %}; Clone max_point() %code{% RETVAL = THIS->max; %}; - double x_min() %code{% RETVAL = THIS->min.x(); %}; - double x_max() %code{% RETVAL = THIS->max.x(); %}; - double y_min() %code{% RETVAL = THIS->min.y(); %}; - double y_max() %code{% RETVAL = THIS->max.y(); %}; - void set_x_min(double val) %code{% THIS->min.x() = val; %}; - void set_x_max(double val) %code{% THIS->max.x() = val; %}; - void set_y_min(double val) %code{% THIS->min.y() = val; %}; - void set_y_max(double val) %code{% THIS->max.y() = val; %}; - std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf;%lf,%lf", THIS->min.x(), THIS->min.y(), THIS->max.x(), THIS->max.y()); RETVAL = buf; %}; + double x_min() %code{% RETVAL = THIS->min(0); %}; + double x_max() %code{% RETVAL = THIS->max(0); %}; + double y_min() %code{% RETVAL = THIS->min(1); %}; + double y_max() %code{% RETVAL = THIS->max(1); %}; + void set_x_min(double val) %code{% THIS->min(0) = val; %}; + void set_x_max(double val) %code{% THIS->max(0) = val; %}; + void set_y_min(double val) %code{% THIS->min(1) = val; %}; + void set_y_max(double val) %code{% THIS->max(1) = val; %}; + std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf;%lf,%lf", THIS->min(0), THIS->min(1), THIS->max(0), THIS->max(1)); RETVAL = buf; %}; bool defined() %code{% RETVAL = THIS->defined; %}; %{ @@ -107,12 +107,12 @@ new_from_points(CLASS, points) bool empty() %code{% RETVAL = empty(*THIS); %}; Clone min_point() %code{% RETVAL = THIS->min; %}; Clone max_point() %code{% RETVAL = THIS->max; %}; - double x_min() %code{% RETVAL = THIS->min.x(); %}; - double x_max() %code{% RETVAL = THIS->max.x(); %}; - double y_min() %code{% RETVAL = THIS->min.y(); %}; - double y_max() %code{% RETVAL = THIS->max.y(); %}; - double z_min() %code{% RETVAL = THIS->min.z(); %}; - double z_max() %code{% RETVAL = THIS->max.z(); %}; - std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf;%lf,%lf,%lf", THIS->min.x(), THIS->min.y(), THIS->min.z(), THIS->max.x(), THIS->max.y(), THIS->max.z()); RETVAL = buf; %}; + double x_min() %code{% RETVAL = THIS->min(0); %}; + double x_max() %code{% RETVAL = THIS->max(0); %}; + double y_min() %code{% RETVAL = THIS->min(1); %}; + double y_max() %code{% RETVAL = THIS->max(1); %}; + double z_min() %code{% RETVAL = THIS->min(2); %}; + double z_max() %code{% RETVAL = THIS->max(2); %}; + std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf;%lf,%lf,%lf", THIS->min(0), THIS->min(1), THIS->min(2), THIS->max(0), THIS->max(1), THIS->max(2)); RETVAL = buf; %}; bool defined() %code{% RETVAL = THIS->defined; %}; }; diff --git a/xs/xsp/Point.xsp b/xs/xsp/Point.xsp index 1d569c4f3..0c3dae321 100644 --- a/xs/xsp/Point.xsp +++ b/xs/xsp/Point.xsp @@ -22,13 +22,13 @@ SV* pp() %code{% RETVAL = to_SV_pureperl(THIS); %}; int x() - %code{% RETVAL = THIS->x(); %}; + %code{% RETVAL = (*THIS)(0); %}; int y() - %code{% RETVAL = THIS->y(); %}; + %code{% RETVAL = (*THIS)(1); %}; void set_x(int val) - %code{% THIS->x() = val; %}; + %code{% (*THIS)(0) = val; %}; void set_y(int val) - %code{% THIS->y() = val; %}; + %code{% (*THIS)(1) = val; %}; int nearest_point_index(Points points); Clone nearest_point(Points points) %code{% Point p; THIS->nearest_point(points, &p); RETVAL = p; %}; @@ -52,7 +52,7 @@ %code{% RETVAL = new Point(- *THIS); %}; bool coincides_with_epsilon(Point* point) %code{% RETVAL = (*THIS) == *point; %}; - std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld", THIS->x(), THIS->y()); RETVAL = buf; %}; + std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld", (*THIS)(0), (*THIS)(1)); RETVAL = buf; %}; %{ @@ -85,12 +85,12 @@ Point::coincides_with(point_sv) Clone clone() %code{% RETVAL = THIS; %}; int x() - %code{% RETVAL = THIS->x(); %}; + %code{% RETVAL = (*THIS)(0); %}; int y() - %code{% RETVAL = THIS->y(); %}; + %code{% RETVAL = (*THIS)(1); %}; int z() - %code{% RETVAL = THIS->z(); %}; - std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld,%ld", THIS->x(), THIS->y(), THIS->z()); RETVAL = buf; %}; + %code{% RETVAL = (*THIS)(2); %}; + std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld,%ld", (*THIS)(0), (*THIS)(1), (*THIS)(2)); RETVAL = buf; %}; }; %name{Slic3r::Pointf} class Pointf { @@ -103,13 +103,13 @@ Point::coincides_with(point_sv) SV* pp() %code{% RETVAL = to_SV_pureperl(THIS); %}; double x() - %code{% RETVAL = THIS->x(); %}; + %code{% RETVAL = (*THIS)(0); %}; double y() - %code{% RETVAL = THIS->y(); %}; + %code{% RETVAL = (*THIS)(1); %}; void set_x(double val) - %code{% THIS->x() = val; %}; + %code{% (*THIS)(0) = val; %}; void set_y(double val) - %code{% THIS->y() = val; %}; + %code{% (*THIS)(1) = val; %}; void translate(double x, double y) %code{% *THIS += Pointf(x, y); %}; void scale(double factor) @@ -120,7 +120,7 @@ Point::coincides_with(point_sv) %code{% RETVAL = new Pointf(- *THIS); %}; Pointf* vector_to(Pointf* point) %code{% RETVAL = new Pointf(*point - *THIS); %}; - std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf", THIS->x(), THIS->y()); RETVAL = buf; %}; + std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf", (*THIS)(0), (*THIS)(1)); RETVAL = buf; %}; }; %name{Slic3r::Pointf3} class Pointf3 { @@ -129,17 +129,17 @@ Point::coincides_with(point_sv) Clone clone() %code{% RETVAL = THIS; %}; double x() - %code{% RETVAL = THIS->x(); %}; + %code{% RETVAL = (*THIS)(0); %}; double y() - %code{% RETVAL = THIS->y(); %}; + %code{% RETVAL = (*THIS)(1); %}; double z() - %code{% RETVAL = THIS->z(); %}; + %code{% RETVAL = (*THIS)(2); %}; void set_x(double val) - %code{% THIS->x() = val; %}; + %code{% (*THIS)(0) = val; %}; void set_y(double val) - %code{% THIS->y() = val; %}; + %code{% (*THIS)(1) = val; %}; void set_z(double val) - %code{% THIS->z() = val; %}; + %code{% (*THIS)(2) = val; %}; void translate(double x, double y, double z) %code{% *THIS += Pointf3(x, y, z); %}; void scale(double factor) @@ -150,5 +150,5 @@ Point::coincides_with(point_sv) %code{% RETVAL = new Pointf3(- *THIS); %}; Pointf3* vector_to(Pointf3* point) %code{% RETVAL = new Pointf3(*point - *THIS); %}; - std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf", THIS->x(), THIS->y(), THIS->z()); RETVAL = buf; %}; + std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf", (*THIS)(0), (*THIS)(1), (*THIS)(2)); RETVAL = buf; %}; };