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

#include <src/libslic3r/Print.hpp>

+ Collaboration diagram for Slic3r::FakeWipeTower:

Public Member Functions

void set_fake_extrusion_data (const Vec2f &p, float w, float h, float lh, float d, const std::vector< std::pair< float, float > > &zad, float bd, float ra, float ca, const Vec2d &o)
 
void set_pos_and_rotation (const Vec2f &p, float rotation)
 
std::vector< ExtrusionPathsgetFakeExtrusionPathsFromWipeTower () const
 

Public Attributes

Vec2f pos
 
float width
 
float height
 
float layer_height
 
float depth
 
std::vector< std::pair< float, float > > z_and_depth_pairs
 
float brim_width
 
float rotation_angle
 
float cone_angle
 
Vec2d plate_origin
 

Detailed Description

Member Function Documentation

◆ getFakeExtrusionPathsFromWipeTower()

std::vector< ExtrusionPaths > Slic3r::FakeWipeTower::getFakeExtrusionPathsFromWipeTower ( ) const
1602 {
1603 float h = height;
1604 float lh = layer_height;
1605 int d = scale_(depth);
1606 int w = scale_(width);
1607 int bd = scale_(brim_width);
1608 Point minCorner = { -bd, -bd };
1609 Point maxCorner = { minCorner.x() + w + bd, minCorner.y() + d + bd };
1610
1611 const auto [cone_base_R, cone_scale_x] = WipeTower::get_wipe_tower_cone_base(width, height, depth, cone_angle);
1612
1613 std::vector<ExtrusionPaths> paths;
1614 for (float hh = 0.f; hh < h; hh += lh) {
1615
1616 if (hh != 0.f) {
1617 // The wipe tower may be getting smaller. Find the depth for this layer.
1618 size_t i = 0;
1619 for (i=0; i<z_and_depth_pairs.size()-1; ++i)
1620 if (hh >= z_and_depth_pairs[i].first && hh < z_and_depth_pairs[i+1].first)
1621 break;
1622 d = scale_(z_and_depth_pairs[i].second);
1623 minCorner = {0.f, -d/2 + scale_(z_and_depth_pairs.front().second/2.f)};
1624 maxCorner = { minCorner.x() + w, minCorner.y() + d };
1625 }
1626
1627
1628 ExtrusionPath path(ExtrusionRole::WipeTower, 0.0, 0.0, lh);
1629 path.polyline = { minCorner, {maxCorner.x(), minCorner.y()}, maxCorner, {minCorner.x(), maxCorner.y()}, minCorner };
1630 paths.push_back({ path });
1631
1632 // We added the border, now add several parallel lines so we can detect an object that is fully inside the tower.
1633 // For now, simply use fixed spacing of 3mm.
1634 for (coord_t y=minCorner.y()+scale_(3.); y<maxCorner.y(); y+=scale_(3.)) {
1635 path.polyline = { {minCorner.x(), y}, {maxCorner.x(), y} };
1636 paths.back().emplace_back(path);
1637 }
1638
1639 // And of course the stabilization cone and its base...
1640 if (cone_base_R > 0.) {
1641 path.polyline.clear();
1642 double r = cone_base_R * (1 - hh/height);
1643 for (double alpha=0; alpha<2.01*M_PI; alpha+=2*M_PI/20.)
1644 path.polyline.points.emplace_back(Point::new_scale(width/2. + r * std::cos(alpha)/cone_scale_x, depth/2. + r * std::sin(alpha)));
1645 paths.back().emplace_back(path);
1646 if (hh == 0.f) { // Cone brim.
1647 for (float bw=brim_width; bw>0.f; bw-=3.f) {
1648 path.polyline.clear();
1649 for (double alpha=0; alpha<2.01*M_PI; alpha+=2*M_PI/20.) // see load_wipe_tower_preview, where the same is a bit clearer
1650 path.polyline.points.emplace_back(Point::new_scale(
1651 width/2. + cone_base_R * std::cos(alpha)/cone_scale_x * (1. + cone_scale_x*bw/cone_base_R),
1652 depth/2. + cone_base_R * std::sin(alpha) * (1. + bw/cone_base_R))
1653 );
1654 paths.back().emplace_back(path);
1655 }
1656 }
1657 }
1658
1659 // Only the first layer has brim.
1660 if (hh == 0.f) {
1661 minCorner = minCorner + Point(bd, bd);
1662 maxCorner = maxCorner - Point(bd, bd);
1663 }
1664 }
1665
1666 // Rotate and translate the tower into the final position.
1667 for (ExtrusionPaths& ps : paths) {
1668 for (ExtrusionPath& p : ps) {
1669 p.polyline.rotate(Geometry::deg2rad(rotation_angle));
1670 p.polyline.translate(scale_(pos.x()), scale_(pos.y()));
1671 }
1672 }
1673
1674 return paths;
1675 }
#define M_PI
Definition ExtrusionSimulator.cpp:20
static std::pair< double, double > get_wipe_tower_cone_base(double width, double height, double depth, double angle_deg)
Definition WipeTower.cpp:1332
#define scale_(val)
Definition libslic3r.h:69
int32_t coord_t
Definition libslic3r.h:39
const Scalar & y
Definition MathFunctions.h:552
constexpr T deg2rad(const T angle)
Definition Geometry.hpp:289
std::vector< ExtrusionPath > ExtrusionPaths
Definition ExtrusionEntity.hpp:135
Kernel::Point_2 Point
Definition point_areas.cpp:20
static constexpr const ExtrusionRoleModifiers WipeTower
Definition ExtrusionRole.hpp:77
float layer_height
Definition Print.hpp:427
float cone_angle
Definition Print.hpp:432
float rotation_angle
Definition Print.hpp:431
Vec2f pos
Definition Print.hpp:424
float height
Definition Print.hpp:426
std::vector< std::pair< float, float > > z_and_depth_pairs
Definition Print.hpp:429
float width
Definition Print.hpp:425
float brim_width
Definition Print.hpp:430
float depth
Definition Print.hpp:428

References brim_width, Slic3r::MultiPoint::clear(), cone_angle, Slic3r::Geometry::deg2rad(), depth, Slic3r::WipeTower::get_wipe_tower_cone_base(), height, layer_height, M_PI, Slic3r::MultiPoint::points, Slic3r::ExtrusionPath::polyline, pos, rotation_angle, scale_, width, Slic3r::ExtrusionRole::WipeTower, and z_and_depth_pairs.

+ Here is the call graph for this function:

◆ set_fake_extrusion_data()

void Slic3r::FakeWipeTower::set_fake_extrusion_data ( const Vec2f p,
float  w,
float  h,
float  lh,
float  d,
const std::vector< std::pair< float, float > > &  zad,
float  bd,
float  ra,
float  ca,
const Vec2d o 
)
inline
436 {
437 pos = p;
438 width = w;
439 height = h;
440 layer_height = lh;
441 depth = d;
442 z_and_depth_pairs = zad;
443 brim_width = bd;
444 rotation_angle = ra;
445 cone_angle = ca;
446 plate_origin = o;
447 }
Vec2d plate_origin
Definition Print.hpp:433

References brim_width, cone_angle, depth, height, layer_height, plate_origin, pos, rotation_angle, width, and z_and_depth_pairs.

Referenced by Slic3r::Print::_make_wipe_tower().

+ Here is the caller graph for this function:

◆ set_pos_and_rotation()

void Slic3r::FakeWipeTower::set_pos_and_rotation ( const Vec2f p,
float  rotation 
)
inline
449{ pos = p; rotation_angle = rotation; }

References pos, and rotation_angle.

Referenced by Slic3r::Print::process().

+ Here is the caller graph for this function:

Member Data Documentation

◆ brim_width

float Slic3r::FakeWipeTower::brim_width

◆ cone_angle

float Slic3r::FakeWipeTower::cone_angle

◆ depth

float Slic3r::FakeWipeTower::depth

◆ height

float Slic3r::FakeWipeTower::height

◆ layer_height

float Slic3r::FakeWipeTower::layer_height

◆ plate_origin

Vec2d Slic3r::FakeWipeTower::plate_origin

Referenced by set_fake_extrusion_data().

◆ pos

◆ rotation_angle

float Slic3r::FakeWipeTower::rotation_angle

◆ width

float Slic3r::FakeWipeTower::width

◆ z_and_depth_pairs

std::vector<std::pair<float, float> > Slic3r::FakeWipeTower::z_and_depth_pairs

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