mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 11:17:51 -06:00
Removed the x(), y(), z() Point/Pointf/Point3/Pointf3 accessors.
This commit is contained in:
parent
1ba64da3fe
commit
65011f9382
60 changed files with 1083 additions and 1111 deletions
|
@ -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<double>(this->x() - (*it)->x());
|
||||
double d = sqr<double>((*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<double>(this->y() - (*it)->y());
|
||||
d += sqr<double>((*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<double>(lx) + sqr<double>(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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue