OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::FakeWipeTower Struct Reference

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

Collaboration diagram for Slic3r::FakeWipeTower:

Public Member Functions

void set_fake_extrusion_data (Vec2f p, float w, float h, float lh, float d, float bd, Vec2d o)
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 (Vec2f p)
void set_pos_and_rotation (const Vec2f &p, float rotation)
std::vector< ExtrusionPaths > getFakeExtrusionPathsFromWipeTower () const
ExtrusionLayers getTrueExtrusionLayersFromWipeTower () const
std::vector< ExtrusionPaths > getFakeExtrusionPathsFromWipeTower2 () 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
Vec2f rib_offset {0.f,0.f}
std::map< float, Polylines > outer_wall

Detailed Description

Member Function Documentation

◆ getFakeExtrusionPathsFromWipeTower()

std::vector< ExtrusionPaths > Slic3r::FakeWipeTower::getFakeExtrusionPathsFromWipeTower ( ) const
inline
797 {
798 int d = scale_(depth);
799 int w = scale_(width);
800 int bd = scale_(brim_width);
801 Point minCorner = {scale_(pos.x()), scale_(pos.y())};
802 Point maxCorner = {minCorner.x() + w, minCorner.y() + d};
803
804 std::vector<ExtrusionPaths> paths;
805 for (float h = 0.f; h < height; h += layer_height) {
806 ExtrusionPath path(ExtrusionRole::erWipeTower, 0.0, 0.0, layer_height);
807 path.polyline = Polyline3(Polyline{{minCorner, {maxCorner.x(), minCorner.y()}, maxCorner, {minCorner.x(), maxCorner.y()}, minCorner}});
808 paths.push_back({path});
809
810 if (h == 0.f) { // add brim
811 ExtrusionPath fakeBrim(ExtrusionRole::erBrim, 0.0, 0.0, layer_height);
812 Point wtbminCorner = {minCorner - Point{bd, bd}};
813 Point wtbmaxCorner = {maxCorner + Point{bd, bd}};
814 fakeBrim.polyline = Polyline3(Polyline{{wtbminCorner, {wtbmaxCorner.x(), wtbminCorner.y()}, wtbmaxCorner, {wtbminCorner.x(), wtbmaxCorner.y()}, wtbminCorner}});
815 paths.back().push_back(fakeBrim);
816 }
817 }
818 return paths;
819 }
static const wxColour bd
Definition AxisCtrlButton.cpp:25
#define scale_(val)
Definition libslic3r.h:106
Kernel::Point_3 Point
Definition MeshRepair.cpp:81
@ erWipeTower
Definition ExtrusionEntity.hpp:44
@ erBrim
Definition ExtrusionEntity.hpp:40
float layer_height
Definition Print.hpp:759
Vec2f pos
Definition Print.hpp:756
float height
Definition Print.hpp:758
float width
Definition Print.hpp:757
float brim_width
Definition Print.hpp:762
float depth
Definition Print.hpp:760

References bd, brim_width, depth, Slic3r::erBrim, Slic3r::erWipeTower, height, layer_height, Slic3r::ExtrusionPath::polyline, pos, scale_, and width.

◆ getFakeExtrusionPathsFromWipeTower2()

std::vector< ExtrusionPaths > Slic3r::FakeWipeTower::getFakeExtrusionPathsFromWipeTower2 ( ) const
inline
824 {
825 float h = height;
826 float lh = layer_height;
827 int d = scale_(depth);
828 int w = scale_(width);
829 int bd = scale_(brim_width);
830 Point minCorner = { -bd, -bd };
831 Point maxCorner = { minCorner.x() + w + bd, minCorner.y() + d + bd };
832
833 const auto [cone_base_R, cone_scale_x] = WipeTower2::get_wipe_tower_cone_base(width, height, depth, cone_angle);
834
835 std::vector<ExtrusionPaths> paths;
836 for (float hh = 0.f; hh < h; hh += lh) {
837
838 if (hh != 0.f) {
839 // The wipe tower may be getting smaller. Find the depth for this layer.
840 size_t i = 0;
841 for (i=0; i<z_and_depth_pairs.size()-1; ++i)
842 if (hh >= z_and_depth_pairs[i].first && hh < z_and_depth_pairs[i+1].first)
843 break;
844 d = scale_(z_and_depth_pairs[i].second);
845 minCorner = {0.f, -d/2 + scale_(z_and_depth_pairs.front().second/2.f)};
846 maxCorner = { minCorner.x() + w, minCorner.y() + d };
847 }
848
849
850 ExtrusionPath path(ExtrusionRole::erWipeTower, 0.0, 0.0, lh);
851 path.polyline = Polyline3(Polyline{{ minCorner, {maxCorner.x(), minCorner.y()}, maxCorner, {minCorner.x(), maxCorner.y()}, minCorner }});
852 paths.push_back({ path });
853
854 // We added the border, now add several parallel lines so we can detect an object that is fully inside the tower.
855 // For now, simply use fixed spacing of 3mm.
856 for (coord_t y=minCorner.y()+scale_(3.); y<maxCorner.y(); y+=scale_(3.)) {
857 path.polyline = Polyline3(Polyline{{ {minCorner.x(), y}, {maxCorner.x(), y} }});
858 paths.back().emplace_back(path);
859 }
860
861 // And of course the stabilization cone and its base...
862 if (cone_base_R > 0.) {
863 path.polyline.clear();
864 double r = cone_base_R * (1 - hh/height);
865 for (double alpha=0; alpha<2.01*M_PI; alpha+=2*M_PI/20.)
866 path.polyline.points.emplace_back(Point::new_scale(width/2. + r * std::cos(alpha)/cone_scale_x, depth/2. + r * std::sin(alpha)));
867 paths.back().emplace_back(path);
868 if (hh == 0.f) { // Cone brim.
869 for (float bw=brim_width; bw>0.f; bw-=3.f) {
870 path.polyline.clear();
871 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
872 path.polyline.points.emplace_back(Point::new_scale(
873 width/2. + cone_base_R * std::cos(alpha)/cone_scale_x * (1. + cone_scale_x*bw/cone_base_R),
874 depth/2. + cone_base_R * std::sin(alpha) * (1. + bw/cone_base_R))
875 );
876 paths.back().emplace_back(path);
877 }
878 }
879 }
880
881 // Only the first layer has brim.
882 if (hh == 0.f) {
883 minCorner = minCorner + Point(bd, bd);
884 maxCorner = maxCorner - Point(bd, bd);
885 }
886 }
887
888 // Rotate and translate the tower into the final position.
889 for (ExtrusionPaths& ps : paths) {
890 for (ExtrusionPath& p : ps) {
891 p.polyline.rotate(Geometry::deg2rad(rotation_angle));
892 p.polyline.translate(scale_(pos.x()), scale_(pos.y()));
893 }
894 }
895
896 return paths;
897 }
#define M_PI
Definition ExtrusionSimulator.cpp:31
static Point new_scale(coordf_t x, coordf_t y)
Definition Point.hpp:214
static std::pair< double, double > get_wipe_tower_cone_base(double width, double height, double depth, double angle_deg)
Definition WipeTower2.cpp:2151
int64_t coord_t
Definition libslic3r.h:48
constexpr T deg2rad(const T angle)
Definition Geometry.hpp:312
std::vector< ExtrusionPath > ExtrusionPaths
Definition ExtrusionEntity.hpp:395
float cone_angle
Definition Print.hpp:764
float rotation_angle
Definition Print.hpp:763
std::vector< std::pair< float, float > > z_and_depth_pairs
Definition Print.hpp:761

References bd, brim_width, Slic3r::MultiPoint3::clear(), cone_angle, Slic3r::Geometry::deg2rad(), depth, Slic3r::erWipeTower, Slic3r::WipeTower2::get_wipe_tower_cone_base(), height, layer_height, M_PI, Slic3r::Point::new_scale(), Slic3r::MultiPoint3::points, Slic3r::ExtrusionPath::polyline, pos, rotation_angle, scale_, width, and z_and_depth_pairs.

Referenced by getTrueExtrusionLayersFromWipeTower().

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

◆ getTrueExtrusionLayersFromWipeTower()

ExtrusionLayers Slic3r::FakeWipeTower::getTrueExtrusionLayersFromWipeTower ( ) const
7154{
7155 ExtrusionLayers wtels;
7157
7158 //ORCA: Fallback for WipeTower2 if outer_wall is empty
7159 if (outer_wall.empty()) {
7160 auto fake_paths = getFakeExtrusionPathsFromWipeTower2();
7161 float current_z = 0.f;
7162 for (auto& layer_paths : fake_paths) {
7163 if (layer_paths.empty()) continue;
7164 ExtrusionLayer el;
7165 float lh = layer_paths.front().height;
7166 el.height = lh;
7167 el.bottom_z = current_z;
7168 el.layer = nullptr;
7169 el.paths = std::move(layer_paths);
7170 wtels.push_back(std::move(el));
7171 current_z += lh;
7172 }
7173 return wtels;
7174 }
7175
7176 std::vector<float> layer_heights;
7177 layer_heights.reserve(outer_wall.size());
7178 auto pre = outer_wall.begin();
7179 for (auto it = outer_wall.begin(); it != outer_wall.end(); ++it) {
7180 if (it == outer_wall.begin())
7181 layer_heights.push_back(it->first);
7182 else {
7183 layer_heights.push_back(it->first - pre->first);
7184 ++pre;
7185 }
7186 }
7187 Point trans = {scale_(pos.x()), scale_(pos.y())};
7188 for (auto it = outer_wall.begin(); it != outer_wall.end(); ++it) {
7189 int index = std::distance(outer_wall.begin(), it);
7190 ExtrusionLayer el;
7191 ExtrusionPaths paths;
7192 paths.reserve(it->second.size());
7193 for (auto &polyline : it->second) {
7194 ExtrusionPath path(ExtrusionRole::erWipeTower, 0.0, 0.0, layer_heights[index]);
7195 path.polyline = Polyline3(polyline);
7196 Point3 trans3(trans, 0);
7197 for (auto &p : path.polyline.points) p += trans3;
7198 paths.push_back(path);
7199 }
7200 el.paths = std::move(paths);
7201 el.bottom_z = it->first - layer_heights[index];
7202 el.layer = nullptr;
7203 wtels.push_back(el);
7204 }
7205 return wtels;
7206}
@ WIPE_TOWER
Definition ConflictChecker.hpp:43
std::vector< ExtrusionPaths > getFakeExtrusionPathsFromWipeTower2() const
Definition Print.hpp:823
std::map< float, Polylines > outer_wall
Definition Print.hpp:767

References Slic3r::ExtrusionLayer::bottom_z, Slic3r::erWipeTower, getFakeExtrusionPathsFromWipeTower2(), getTrueExtrusionLayersFromWipeTower(), Slic3r::ExtrusionLayer::height, Slic3r::ExtrusionLayer::layer, outer_wall, Slic3r::ExtrusionLayer::paths, Slic3r::MultiPoint3::points, Slic3r::ExtrusionPath::polyline, pos, scale_, Slic3r::ExtrusionLayers::type, and Slic3r::WIPE_TOWER.

Referenced by getTrueExtrusionLayersFromWipeTower().

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

◆ set_fake_extrusion_data() [1/2]

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
780 {
781 pos = p;
782 width = w;
783 height = h;
784 layer_height = lh;
785 depth = d;
786 z_and_depth_pairs = zad;
787 brim_width = bd;
788 rotation_angle = ra;
789 cone_angle = ca;
790 plate_origin = o;
791 }
Vec2d plate_origin
Definition Print.hpp:765

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

◆ set_fake_extrusion_data() [2/2]

void Slic3r::FakeWipeTower::set_fake_extrusion_data ( Vec2f p,
float w,
float h,
float lh,
float d,
float bd,
Vec2d o )
inline
770 {
771 pos = p;
772 width = w;
773 height = h;
774 layer_height = lh;
775 depth = d;
776 brim_width = bd;
777 plate_origin = o;
778 }

References bd, brim_width, depth, height, layer_height, plate_origin, pos, and width.

◆ set_pos()

void Slic3r::FakeWipeTower::set_pos ( Vec2f p)
inline
793{ pos = p+rib_offset; }
Vec2f rib_offset
Definition Print.hpp:766

References pos, and rib_offset.

◆ set_pos_and_rotation()

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

References pos, and rotation_angle.

Member Data Documentation

◆ brim_width

◆ cone_angle

float Slic3r::FakeWipeTower::cone_angle

◆ depth

◆ height

◆ layer_height

◆ outer_wall

std::map<float , Polylines> Slic3r::FakeWipeTower::outer_wall

◆ plate_origin

Vec2d Slic3r::FakeWipeTower::plate_origin

◆ pos

◆ rib_offset

Vec2f Slic3r::FakeWipeTower::rib_offset {0.f,0.f}
766{0.f,0.f};

Referenced by set_pos().

◆ rotation_angle

float Slic3r::FakeWipeTower::rotation_angle

◆ 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:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Print.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Print.cpp