OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Point3 Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Point.hpp>

Inheritance diagram for Slic3r::Point3:
Collaboration diagram for Slic3r::Point3:

Public Types

using coord_type = coord_t

Public Member Functions

 Point3 ()
 Point3 (int32_t x, int32_t y, int32_t z=0)
 Point3 (int64_t x, int64_t y, int64_t z=0)
 Point3 (double x, double y, double z=0.0)
 Point3 (const Vec2crd &vec2crd, coord_t z=0)
 Point3 (const Vec3crd &vec3crd)
template<typename OtherDerived>
 Point3 (const Eigen::MatrixBase< OtherDerived > &other)
template<typename OtherDerived>
Point3 & operator= (const Eigen::MatrixBase< OtherDerived > &other)
Point3 & operator+= (const Point3 &rhs)
Point3 & operator-= (const Point3 &rhs)
Point3 & operator*= (const double &rhs)
Point3 operator* (const double &rhs) const
bool both_comp (const Point3 &rhs, const std::string &op)
bool any_comp (const Point3 &rhs, const std::string &op)
bool any_comp (const coord_t val, const std::string &op)
void rotate (double angle)
void rotate (double cos_a, double sin_a)
void rotate (double angle, const Point3 &center)
Point3 rotated (double angle) const
Point3 rotated (double cos_a, double sin_a) const
Point3 rotated (double angle, const Point3 &center) const
Point3 rotate_90_degree_ccw () const
int nearest_point_index (const Points &points) const
bool nearest_point (const Points &points, Point3 *point) const
double ccw (const Point3 &p1, const Point3 &p2) const
double ccw (const Line3 &line) const
double ccw_angle (const Point3 &p1, const Point3 &p2) const
Point3 projection_onto (const MultiPoint3 &poly) const
Point3 projection_onto (const Line3 &line) const
Point to_point () const
double distance_to (const Point3 &point) const

Static Public Member Functions

static Point3 new_scale (coordf_t x, coordf_t y, coordf_t z)
static Point3 new_scale (const Vec3d &v)
static Point3 new_scale (const Vec3f &v)

Detailed Description

Member Typedef Documentation

◆ coord_type

Constructor & Destructor Documentation

◆ Point3() [1/7]

Slic3r::Point3::Point3 ( )
inline
287: Vec3crd(0, 0, 0) {}
Eigen::Matrix< coord_t, 3, 1, Eigen::DontAlign > Vec3crd
Definition Point.hpp:53

Referenced by any_comp(), both_comp(), ccw(), ccw_angle(), distance_to(), nearest_point(), new_scale(), new_scale(), new_scale(), operator*(), operator*=(), operator+=(), operator-=(), operator=(), projection_onto(), projection_onto(), rotate(), rotate_90_degree_ccw(), rotated(), rotated(), and rotated().

Here is the caller graph for this function:

◆ Point3() [2/7]

Slic3r::Point3::Point3 ( int32_t x,
int32_t y,
int32_t z = 0 )
inline
288: Vec3crd(coord_t(x), coord_t(y), coord_t(z)) {}
int64_t coord_t
Definition libslic3r.h:48

◆ Point3() [3/7]

Slic3r::Point3::Point3 ( int64_t x,
int64_t y,
int64_t z = 0 )
inline
289: Vec3crd(coord_t(x), coord_t(y), coord_t(z)) {}

◆ Point3() [4/7]

Slic3r::Point3::Point3 ( double x,
double y,
double z = 0.0 )
inline
290: Vec3crd(coord_t(std::round(x)), coord_t(std::round(y)), coord_t(std::round(z))) {}

◆ Point3() [5/7]

Slic3r::Point3::Point3 ( const Vec2crd & vec2crd,
coord_t z = 0 )
inlineexplicit
291: Vec3crd(vec2crd.x(), vec2crd.y(), z) {}

◆ Point3() [6/7]

Slic3r::Point3::Point3 ( const Vec3crd & vec3crd)
inlineexplicit
292: Vec3crd(vec3crd) {}

◆ Point3() [7/7]

template<typename OtherDerived>
Slic3r::Point3::Point3 ( const Eigen::MatrixBase< OtherDerived > & other)
inlineexplicit
295: Vec3crd(other) {}

Member Function Documentation

◆ any_comp() [1/2]

bool Slic3r::Point3::any_comp ( const coord_t val,
const std::string & op )
inline
341 {
342 if (op == ">")
343 return this->x() > val || this->y() > val;
344 else if (op == "<")
345 return this->x() < val || this->y() < val;
346 return false;
347 }

◆ any_comp() [2/2]

bool Slic3r::Point3::any_comp ( const Point3 & rhs,
const std::string & op )
inline
333 {
334 if (op == ">")
335 return this->x() > rhs.x() || this->y() > rhs.y();
336 else if (op == "<")
337 return this->x() < rhs.x() || this->y() < rhs.y();
338 return false;
339 }

References Point3().

Here is the call graph for this function:

◆ both_comp()

bool Slic3r::Point3::both_comp ( const Point3 & rhs,
const std::string & op )
inline
325 {
326 if (op == ">")
327 return this->x() > rhs.x() && this->y() > rhs.y();
328 else if (op == "<")
329 return this->x() < rhs.x() && this->y() < rhs.y();
330 return false;
331 }

References Point3().

Here is the call graph for this function:

◆ ccw() [1/2]

double Slic3r::Point3::ccw ( const Line3 & line) const
318 {
319 // Convert to 2D and use existing Point ccw implementation
320 Point a2d(line.a.x(), line.a.y());
321 Point b2d(line.b.x(), line.b.y());
322 return this->to_point().ccw(Line(a2d, b2d));
323}
Point to_point() const
Definition Point.hpp:372
double ccw(const Point &p1, const Point &p2) const
Definition Point.cpp:74
Kernel::Point_3 Point
Definition MeshRepair.cpp:81

References Slic3r::Line3::a, Slic3r::Line3::b, Slic3r::Point::ccw(), and to_point().

Here is the call graph for this function:

◆ ccw() [2/2]

double Slic3r::Point3::ccw ( const Point3 & p1,
const Point3 & p2 ) const
314 {
315 return this->to_point().ccw(p1.to_point(), p2.to_point());
316}

References Point3(), Slic3r::Point::ccw(), and to_point().

Here is the call graph for this function:

◆ ccw_angle()

double Slic3r::Point3::ccw_angle ( const Point3 & p1,
const Point3 & p2 ) const
325 {
326 return this->to_point().ccw_angle(p1.to_point(), p2.to_point());
327}
double ccw_angle(const Point &p1, const Point &p2) const
Definition Point.cpp:88

References Point3(), Slic3r::Point::ccw_angle(), and to_point().

Here is the call graph for this function:

◆ distance_to()

double Slic3r::Point3::distance_to ( const Point3 & point) const
inline
376{ return (point - *this).cast<double>().norm(); }

References Point3().

Here is the call graph for this function:

◆ nearest_point()

bool Slic3r::Point3::nearest_point ( const Points & points,
Point3 * point ) const
305 {
306 Point pt2d;
307 bool result = this->to_point().nearest_point(points, &pt2d);
308 if (result && point) {
309 *point = Point3(pt2d, this->z());
310 }
311 return result;
312}
Point3()
Definition Point.hpp:287
bool nearest_point(const Points &points, Point *point) const
Definition Point.cpp:240

References Point3(), Slic3r::Point::nearest_point(), and to_point().

Here is the call graph for this function:

◆ nearest_point_index()

int Slic3r::Point3::nearest_point_index ( const Points & points) const
301 {
302 return this->to_point().nearest_point_index(points);
303}
int nearest_point_index(const Points &points) const
Definition Point.cpp:197

References Slic3r::Point::nearest_point_index(), and to_point().

Here is the call graph for this function:

◆ new_scale() [1/3]

Point3 Slic3r::Point3::new_scale ( const Vec3d & v)
inlinestatic
300 {
301 return Point3(coord_t(scale_(v.x())), coord_t(scale_(v.y())), coord_t(scale_(v.z())));
302 }
#define scale_(val)
Definition libslic3r.h:106

References Point3(), and scale_.

Here is the call graph for this function:

◆ new_scale() [2/3]

Point3 Slic3r::Point3::new_scale ( const Vec3f & v)
inlinestatic
303 {
304 return Point3(coord_t(scale_(v.x())), coord_t(scale_(v.y())), coord_t(scale_(v.z())));
305 }

References Point3(), and scale_.

Here is the call graph for this function:

◆ new_scale() [3/3]

Point3 Slic3r::Point3::new_scale ( coordf_t x,
coordf_t y,
coordf_t z )
inlinestatic
297 {
298 return Point3(coord_t(scale_(x)), coord_t(scale_(y)), coord_t(scale_(z)));
299 }

References Point3(), and scale_.

Here is the call graph for this function:

◆ operator*()

Point3 Slic3r::Point3::operator* ( const double & rhs) const
inline
323{ return Point3(this->x() * rhs, this->y() * rhs, this->z() * rhs); }

References Point3().

Here is the call graph for this function:

◆ operator*=()

Point3 & Slic3r::Point3::operator*= ( const double & rhs)
inline
317 {
318 this->x() = coord_t(this->x() * rhs);
319 this->y() = coord_t(this->y() * rhs);
320 this->z() = coord_t(this->z() * rhs);
321 return *this;
322 }

References Point3().

Here is the call graph for this function:

◆ operator+=()

Point3 & Slic3r::Point3::operator+= ( const Point3 & rhs)
inline
315{ this->x() += rhs.x(); this->y() += rhs.y(); this->z() += rhs.z(); return *this; }

References Point3().

Here is the call graph for this function:

◆ operator-=()

Point3 & Slic3r::Point3::operator-= ( const Point3 & rhs)
inline
316{ this->x() -= rhs.x(); this->y() -= rhs.y(); this->z() -= rhs.z(); return *this; }

References Point3().

Here is the call graph for this function:

◆ operator=()

template<typename OtherDerived>
Point3 & Slic3r::Point3::operator= ( const Eigen::MatrixBase< OtherDerived > & other)
inline
310 {
311 this->Vec3crd::operator=(other);
312 return *this;
313 }

References Point3().

Here is the call graph for this function:

◆ projection_onto() [1/2]

Point3 Slic3r::Point3::projection_onto ( const Line3 & line) const
336 {
337 // Project in 2D plane and interpolate Z
338 Point pt2d = this->to_point();
339 Point line_a(line.a.x(), line.a.y());
340 Point line_b(line.b.x(), line.b.y());
341 Line line2d(line_a, line_b);
342 Point proj2d = pt2d.projection_onto(line2d);
343
344 // Interpolate Z coordinate
345 double line_len = line.length();
346 if (line_len < EPSILON) {
347 return Point3(proj2d, line.a.z());
348 }
349 double dist_from_a = (proj2d - line_a).cast<double>().norm();
350 double t = dist_from_a / line_len;
351 t = std::clamp(t, 0.0, 1.0);
352 coord_t z = coord_t(line.a.z() + t * (line.b.z() - line.a.z()));
353 return Point3(proj2d, z);
354}
#define EPSILON
Definition ColorUtils.cpp:64
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299

References Point3(), Slic3r::Line3::a, Slic3r::Line3::b, Slic3r::cast(), EPSILON, Slic3r::Line3::length(), Slic3r::Point::projection_onto(), and to_point().

Here is the call graph for this function:

◆ projection_onto() [2/2]

Point3 Slic3r::Point3::projection_onto ( const MultiPoint3 & poly) const
329 {
330 // TODO: Implement proper 3D projection when MultiPoint3 conversion methods are ready
331 // For now, stub implementation
332 throw RuntimeError("Point3::projection_onto(MultiPoint3) not implemented yet");
333 return *this;
334}
@ RuntimeError
Definition PluginStatus.hpp:14

References Point3().

Referenced by Slic3r::foot_pt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotate() [1/3]

void Slic3r::Point3::rotate ( double angle)
inline
349{ this->rotate(std::cos(angle), std::sin(angle)); }
void rotate(double angle)
Definition Point.hpp:349
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:138

References Slic3r::angle(), and rotate().

Referenced by rotate(), rotate(), rotated(), rotated(), and rotated().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotate() [2/3]

void Slic3r::Point3::rotate ( double angle,
const Point3 & center )
293 {
294 Vec3crd diff = *this - center;
295 Point3 temp(diff.x(), diff.y(), diff.z());
296 temp.rotate(angle);
297 Vec3crd sum = temp + center;
298 *this = Point3(sum.x(), sum.y(), sum.z());
299}
void center(ExPolygonsWithIds &e)
Definition Emboss.cpp:1382
Slic3r::Polygons diff(const Slic3r::Polygon &subject, const Slic3r::Polygon &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:731

References Point3(), Slic3r::angle(), Slic3r::center(), Slic3r::diff(), and rotate().

Here is the call graph for this function:

◆ rotate() [3/3]

void Slic3r::Point3::rotate ( double cos_a,
double sin_a )
inline
350 {
351 double cur_x = (double)this->x();
352 double cur_y = (double)this->y();
353 this->x() = (coord_t)round(cos_a * cur_x - sin_a * cur_y);
354 this->y() = (coord_t)round(cos_a * cur_y + sin_a * cur_x);
355 }

◆ rotate_90_degree_ccw()

Point3 Slic3r::Point3::rotate_90_degree_ccw ( ) const
inline
361{ return Point3(-this->y(), this->x(), this->z()); }

References Point3().

Here is the call graph for this function:

◆ rotated() [1/3]

Point3 Slic3r::Point3::rotated ( double angle) const
inline
358{ Point3 res(*this); res.rotate(angle); return res; }

References Point3(), Slic3r::angle(), and rotate().

Here is the call graph for this function:

◆ rotated() [2/3]

Point3 Slic3r::Point3::rotated ( double angle,
const Point3 & center ) const
inline
360{ Point3 res(*this); res.rotate(angle, center); return res; }

References Point3(), Slic3r::angle(), Slic3r::center(), and rotate().

Here is the call graph for this function:

◆ rotated() [3/3]

Point3 Slic3r::Point3::rotated ( double cos_a,
double sin_a ) const
inline
359{ Point3 res(*this); res.rotate(cos_a, sin_a); return res; }

References Point3(), and rotate().

Here is the call graph for this function:

◆ to_point()

Point Slic3r::Point3::to_point ( ) const
inline
372 {
373 return Point(this->x(), this->y());
374 }

Referenced by Slic3r::GCode::_extrude(), ccw(), ccw(), ccw_angle(), Slic3r::GCode::compute_farthest_point(), nearest_point(), nearest_point_index(), Slic3r::GCode::point_to_gcode(), projection_onto(), Slic3r::Polyline3::split_at(), and Slic3r::Polyline3::split_at().

Here is the caller graph for this function:

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Point.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Point.cpp