Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::ThickPolyline Struct Reference

#include <src/libslic3r/Polyline.hpp>

+ Collaboration diagram for Slic3r::ThickPolyline:

Public Member Functions

 ThickPolyline ()=default
 
ThickLines thicklines () const
 
const Pointfirst_point () const
 
const Pointlast_point () const
 
size_t size () const
 
bool is_valid () const
 
bool empty () const
 
double length () const
 
void clear ()
 
void reverse ()
 
void clip_end (double distance)
 
void start_at_index (int index)
 

Public Attributes

Points points
 
std::vector< coordf_twidth
 
std::pair< bool, bool > endpoints { false, false }
 

Detailed Description

Constructor & Destructor Documentation

◆ ThickPolyline()

Slic3r::ThickPolyline::ThickPolyline ( )
default

Member Function Documentation

◆ clear()

void Slic3r::ThickPolyline::clear ( )
inline
193{ this->points.clear(); this->width.clear(); }
std::vector< coordf_t > width
Definition Polyline.hpp:212
Points points
Definition Polyline.hpp:208

References points, and width.

Referenced by Slic3r::Geometry::MedialAxis::build().

+ Here is the caller graph for this function:

◆ clip_end()

void Slic3r::ThickPolyline::clip_end ( double  distance)
269{
270 if (! this->empty()) {
271 assert(this->width.size() == (this->points.size() - 1) * 2);
272 while (distance > 0) {
273 Vec2d last_point = this->last_point().cast<double>();
274 this->points.pop_back();
275 if (this->points.empty()) {
276 assert(this->width.empty());
277 break;
278 }
279 coordf_t last_width = this->width.back();
280 this->width.pop_back();
281
282 Vec2d vec = this->last_point().cast<double>() - last_point;
283 coordf_t width_diff = this->width.back() - last_width;
284 double vec_length_sqr = vec.squaredNorm();
285 if (vec_length_sqr > distance * distance) {
286 double t = (distance / std::sqrt(vec_length_sqr));
287 this->points.emplace_back((last_point + vec * t).cast<coord_t>());
288 this->width.emplace_back(last_width + width_diff * t);
289 assert(this->width.size() == (this->points.size() - 1) * 2);
290 return;
291 } else
292 this->width.pop_back();
293
294 distance -= std::sqrt(vec_length_sqr);
295 }
296 }
297 assert(this->points.empty() ? this->width.empty() : this->width.size() == (this->points.size() - 1) * 2);
298}
int32_t coord_t
Definition libslic3r.h:39
double coordf_t
Definition libslic3r.h:45
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:51
double distance(const P &p1, const P &p2)
Definition geometry_traits.hpp:329
const Point & last_point() const
Definition Polyline.hpp:187
size_t size() const
Definition Polyline.hpp:188
bool empty() const
Definition Polyline.hpp:190

References empty(), last_point(), points, and width.

+ Here is the call graph for this function:

◆ empty()

bool Slic3r::ThickPolyline::empty ( ) const
inline
190{ return this->points.empty(); }

References points.

Referenced by clip_end().

+ Here is the caller graph for this function:

◆ first_point()

const Point & Slic3r::ThickPolyline::first_point ( ) const
inline
186{ return this->points.front(); }

References points.

Referenced by Slic3r::Geometry::MedialAxis::build(), and Slic3r::ExPolygon::medial_axis().

+ Here is the caller graph for this function:

◆ is_valid()

bool Slic3r::ThickPolyline::is_valid ( ) const
inline
189{ return this->points.size() >= 2; }

References points.

◆ last_point()

const Point & Slic3r::ThickPolyline::last_point ( ) const
inline
187{ return this->points.back(); }

References points.

Referenced by Slic3r::Geometry::MedialAxis::build(), clip_end(), and Slic3r::ExPolygon::medial_axis().

+ Here is the caller graph for this function:

◆ length()

double Slic3r::ThickPolyline::length ( ) const
inline
191{ return Slic3r::length(this->points); }
double length(const Points &pts)
Definition MultiPoint.hpp:116

References Slic3r::length(), and points.

Referenced by Slic3r::ExPolygon::medial_axis().

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

◆ reverse()

void Slic3r::ThickPolyline::reverse ( )
inline
195 {
196 std::reverse(this->points.begin(), this->points.end());
197 std::reverse(this->width.begin(), this->width.end());
198 std::swap(this->endpoints.first, this->endpoints.second);
199 }
std::pair< bool, bool > endpoints
Definition Polyline.hpp:213

References endpoints, points, and width.

Referenced by Slic3r::ExPolygon::medial_axis().

+ Here is the caller graph for this function:

◆ size()

size_t Slic3r::ThickPolyline::size ( ) const
inline
188{ return this->points.size(); }

References points.

◆ start_at_index()

void Slic3r::ThickPolyline::start_at_index ( int  index)
301{
302 assert(index >= 0 && index < this->points.size());
303 assert(this->points.front() == this->points.back() && this->width.front() == this->width.back());
304 if (index != 0 && index + 1 != int(this->points.size()) && this->points.front() == this->points.back() && this->width.front() == this->width.back()) {
305 this->points.pop_back();
306 assert(this->points.size() * 2 == this->width.size());
307 std::rotate(this->points.begin(), this->points.begin() + index, this->points.end());
308 std::rotate(this->width.begin(), this->width.begin() + 2 * index, this->width.end());
309 this->points.emplace_back(this->points.front());
310 }
311}

References points, and width.

Referenced by Slic3r::FillConcentric::_fill_surface_single().

+ Here is the caller graph for this function:

◆ thicklines()

ThickLines Slic3r::ThickPolyline::thicklines ( ) const
257{
258 ThickLines lines;
259 if (this->points.size() >= 2) {
260 lines.reserve(this->points.size() - 1);
261 for (size_t i = 0; i + 1 < this->points.size(); ++ i)
262 lines.emplace_back(this->points[i], this->points[i + 1], this->width[2 * i], this->width[2 * i + 1]);
263 }
264 return lines;
265}
std::vector< ThickLine > ThickLines
Definition Line.hpp:19

References points.

Referenced by Slic3r::PerimeterGenerator::thick_polyline_to_multi_path().

+ Here is the caller graph for this function:

Member Data Documentation

◆ endpoints

◆ points

◆ width


The documentation for this struct was generated from the following files: