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

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/3DScene.hpp>

Collaboration diagram for Slic3r::GLVolumeCollection:

Classes

struct  PrintVolume
struct  Slope

Public Types

enum class  ERenderType : unsigned char { Opaque , Transparent , All }

Public Member Functions

 GLVolumeCollection ()
 ~GLVolumeCollection ()
std::vector< int > load_object (const ModelObject *model_object, int obj_idx, const std::vector< int > &instance_idxs, const std::string &color_by, bool opengl_initialized, bool need_raycaster=true)
int load_object_volume (const ModelObject *model_object, int obj_idx, int volume_idx, int instance_idx, const std::string &color_by, bool opengl_initialized, bool in_assemble_view=false, bool use_loaded_id=false, bool need_raycaster=true)
void load_object_auxiliary (const SLAPrintObject *print_object, int obj_idx, const std::vector< std::pair< size_t, size_t > > &instances, SLAPrintObjectStep milestone, size_t timestamp)
int load_wipe_tower_preview (int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool size_unknown, float brim_width)
int load_real_wipe_tower_preview (int obj_idx, float pos_x, float pos_y, const TriangleMesh &wt_mesh, const TriangleMesh &brim_mesh, bool render_brim, float rotation_angle, bool size_unknown, bool opengl_initialized)
GLVolume * new_toolpath_volume (const ColorRGBA &rgba)
GLVolume * new_nontoolpath_volume (const ColorRGBA &rgba)
float get_selection_support_normal_z () const
void render (ERenderType type, bool disable_cullface, const Transform3d &view_matrix, const Transform3d &projection_matrix, const GUI::Size &cnv_size, std::function< bool(const GLVolume &)> filter_func=std::function< bool(const GLVolume &)>(), bool partly_inside_enable=true, std::vector< double > *printable_heights=nullptr) const
void clear ()
bool empty () const
void set_range (double low, double high)
void set_print_volume (const PrintVolume &print_volume)
void set_z_range (float min_z, float max_z)
void set_clipping_plane (const std::array< double, 4 > &coeffs)
const std::array< float, 2 > & get_z_range () const
const std::array< double, 4 > & get_clipping_plane () const
void set_use_color_clip_plane (bool use)
void set_color_clip_plane (const Vec3d &cp_normal, double offset)
void set_color_clip_plane_colors (const std::array< ColorRGBA, 2 > &colors)
bool is_slope_GlobalActive () const
bool is_slope_active () const
void set_slope_active (bool active)
void set_slope_GlobalActive (bool active)
float get_slope_normal_z () const
void set_slope_normal_z (float normal_z)
void set_default_slope_normal_z ()
void set_show_sinking_contours (bool show)
bool check_outside_state (const Slic3r::BuildVolume &build_volume, ModelInstanceEPrintVolumeState *out_state, ObjectFilamentResults *object_results) const
void reset_outside_state ()
bool check_wipe_tower_outside_state (const Slic3r::BuildVolume &build_volume, int plate_id) const
void update_colors_by_extruder (const DynamicPrintConfig *config, bool is_update_alpha=true)
std::vector< double > get_current_print_zs (bool active_only) const
size_t cpu_memory_used () const
size_t gpu_memory_used () const
size_t total_memory_used () const
std::string log_memory_info () const
void set_transparency (float alpha)

Public Attributes

GLVolumePtrs volumes

Private Member Functions

 GLVolumeCollection (const GLVolumeCollection &other)
GLVolumeCollection & operator= (const GLVolumeCollection &)

Private Attributes

PrintVolume m_print_volume
PrintVolume m_render_volume
std::array< float, 2 > m_z_range
std::array< double, 4 > m_clipping_plane
std::array< double, 4 > m_color_clip_plane
bool m_use_color_clip_plane { false }
std::array< ColorRGBA, 2 > m_color_clip_plane_colors { ColorRGBA::RED(), ColorRGBA::BLUE() }
Slope m_slope
bool m_show_sinking_contours = false

Detailed Description


Class Documentation

◆ Slic3r::GLVolumeCollection::PrintVolume

struct Slic3r::GLVolumeCollection::PrintVolume
Collaboration diagram for Slic3r::GLVolumeCollection::PrintVolume:
Class Members
array< float, 4 > data
int type { 0 }
array< float, 2 > zs

◆ Slic3r::GLVolumeCollection::Slope

struct Slic3r::GLVolumeCollection::Slope
Class Members
bool active { false }
bool isGlobalActive {false}
float normal_z

Member Enumeration Documentation

◆ ERenderType

enum class Slic3r::GLVolumeCollection::ERenderType : unsigned char
strong
Enumerator
Opaque 
Transparent 
All 
420 {
421 Opaque,
422 Transparent,
423 All
424 };
@ All
Definition GeometryEngine.hpp:16

Constructor & Destructor Documentation

◆ GLVolumeCollection() [1/2]

Slic3r::GLVolumeCollection::GLVolumeCollection ( )
inline
470 {
472
473 //BBS init render volume
474 m_render_volume.type = -1;
475 }
void set_default_slope_normal_z()
Definition 3DScene.hpp:557
PrintVolume m_render_volume
Definition 3DScene.hpp:442

References m_render_volume, and set_default_slope_normal_z().

Referenced by GLVolumeCollection(), and operator=().

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

◆ ~GLVolumeCollection()

Slic3r::GLVolumeCollection::~GLVolumeCollection ( )
inline
476{ clear(); }
void clear()
Definition 3DScene.hpp:529

References clear().

Here is the call graph for this function:

◆ GLVolumeCollection() [2/2]

Slic3r::GLVolumeCollection::GLVolumeCollection ( const GLVolumeCollection & other)
private

References GLVolumeCollection().

Here is the call graph for this function:

Member Function Documentation

◆ check_outside_state()

bool Slic3r::GLVolumeCollection::check_outside_state ( const Slic3r::BuildVolume & build_volume,
ModelInstanceEPrintVolumeState * out_state,
ObjectFilamentResults * object_results ) const
1441{
1442 if (GUI::wxGetApp().plater() == NULL)
1443 {
1444 if (out_state != nullptr)
1445 *out_state = ModelInstancePVS_Inside;
1446 return false;
1447 }
1448
1449 const Model& model = GUI::wxGetApp().plater()->model();
1450 auto volume_below = [](GLVolume& volume) -> bool
1451 { return volume.object_idx() != -1 && volume.volume_idx() != -1 && volume.is_below_printbed(); };
1452 // Volume is partially below the print bed, thus a pre-calculated convex hull cannot be used.
1453 auto volume_sinking = [](GLVolume& volume) -> bool
1454 { return volume.object_idx() != -1 && volume.volume_idx() != -1 && volume.is_sinking(); };
1455 // Cached bounding box of a volume above the print bed.
1456 auto volume_bbox = [volume_sinking](GLVolume& volume) -> BoundingBoxf3
1457 { return volume_sinking(volume) ? volume.transformed_non_sinking_bounding_box() : volume.transformed_convex_hull_bounding_box(); };
1458 // Cached 3D convex hull of a volume above the print bed.
1459 auto volume_convex_mesh = [volume_sinking, &model](GLVolume& volume) -> const TriangleMesh&
1460 { return volume_sinking(volume) ? model.objects[volume.object_idx()]->volumes[volume.volume_idx()]->mesh() : *volume.convex_hull(); };
1461
1463 bool contained_min_one = false;
1464
1465 //BBS: add instance judge logic, besides to original volume judge logic
1466 //std::map<int64_t, ModelInstanceEPrintVolumeState> model_state;
1467
1468 GUI::PartPlate* curr_plate = GUI::wxGetApp().plater()->get_partplate_list().get_selected_plate();
1469 const Pointfs& pp_bed_shape = curr_plate->get_shape();
1470 BuildVolume plate_build_volume(pp_bed_shape, build_volume.printable_height(), build_volume.extruder_areas(), build_volume.extruder_heights());
1471 const std::vector<BoundingBoxf3>& exclude_areas = curr_plate->get_exclude_areas();
1472
1473 const DynamicPrintConfig *plater_config = GUI::wxGetApp().plater()->config();
1474 std::vector<std::vector<BedExcludeRegion>> exclusion_regions;
1475 // Legacy bed-exclude areas retain Orca's existing 2D presentation. The
1476 // per-extruder 3D state is needed only after collision volumes are enabled.
1477 if (has_bed_exclude_volumes(*plater_config)) {
1478 exclusion_regions = get_bed_excluded_regions_by_extruder(*plater_config);
1479 // The native BuildVolume path below already presents the shared legacy
1480 // area. Merge only opt-in collision volumes into nozzle-specific state.
1481 for (std::vector<BedExcludeRegion> &regions : exclusion_regions)
1482 regions.erase(std::remove_if(regions.begin(), regions.end(),
1483 [](const BedExcludeRegion &region) { return !region.is_collision_volume(); }), regions.end());
1484 }
1485 const Vec3d plate_origin = curr_plate->get_origin();
1486 const Point exclusion_offset(scale_(plate_origin.x()), scale_(plate_origin.y()));
1487 for (std::vector<BedExcludeRegion> &regions : exclusion_regions)
1488 for (BedExcludeRegion &region : regions)
1489 region.polygon.translate(exclusion_offset);
1490
1491 std::map<ModelObject*, std::map<int, std::set<int>>> objects_unprintable_filaments;
1492 const DynamicPrintConfig &plate_project_config = GUI::wxGetApp().preset_bundle->project_config;
1493 const int build_volume_extruder_count = build_volume.get_extruder_area_count();
1494 const int extruder_count = std::max<int>(build_volume_extruder_count, int(exclusion_regions.size()));
1495 std::vector<std::set<int>> unprintable_filament_ids(extruder_count, std::set<int>());
1496 std::set<ModelObject*> partly_objects_set;
1497 std::map<std::pair<int, int>, std::vector<bool>> instance_inside_exclusion_regions;
1498 const ModelObjectPtrs &model_objects = model.objects;
1499 for (GLVolume* volume : this->volumes)
1500 {
1501 std::vector<bool> inside_extruders;
1502 if (! volume->is_modifier && (volume->shader_outside_printer_detection_enabled || (! volume->is_wipe_tower && volume->composite_id.volume_id >= 0))) {
1504 if (volume_below(*volume))
1506 else {
1507 switch (plate_build_volume.type()) {
1509 //FIXME this test does not evaluate collision of a build volume bounding box with non-convex objects.
1510 const BoundingBoxf3& bb = volume_bbox(*volume);
1511 state = plate_build_volume.volume_state_bbox(bb);
1512 if ((state == BuildVolume::ObjectState::Inside) && (build_volume_extruder_count > 1))
1513 {
1514 state = plate_build_volume.check_volume_bbox_state_with_extruder_areas(bb, inside_extruders);
1515 }
1516 break;
1517 }
1520 //FIXME doing test on convex hull until we learn to do test on non-convex polygons efficiently.
1522 {
1523 const indexed_triangle_set& convex_mesh_it = volume_convex_mesh(*volume).its;
1524 const Transform3f trafo = volume->world_matrix().cast<float>();
1525 state = plate_build_volume.object_state(convex_mesh_it, trafo, volume_sinking(*volume));
1526 if ((state == BuildVolume::ObjectState::Inside) && (build_volume_extruder_count > 1))
1527 {
1528 state = plate_build_volume.check_object_state_with_extruder_areas(convex_mesh_it, trafo, inside_extruders);
1529 }
1530 break;
1531 }
1532 default:
1533 // Ignore, don't produce any collision.
1535 break;
1536 }
1537 assert(state != BuildVolume::ObjectState::Below);
1538
1539 // Preserve Orca's native printable-area result separately.
1540 // Exclusion collisions have current-map semantics and must not
1541 // leak into the later "unprintable on every possible nozzle"
1542 // aggregation used by automatic printable-area assignment.
1543 const std::vector<bool> printable_area_inside_extruders = inside_extruders;
1544
1545 // Newer Orca resolves live multi-nozzle placement through this
1546 // per-extruder state vector. Merge exclusion-volume collisions
1547 // into the same source of truth instead of relying only on the
1548 // legacy PartPlate::check_outside() path.
1550 volume->object_idx() >= 0 && volume->object_idx() < int(model_objects.size()) &&
1551 volume->instance_idx() >= 0 &&
1552 volume->instance_idx() < int(model_objects[volume->object_idx()]->instances.size())) {
1553 inside_extruders.resize(extruder_count, true);
1554
1555 const std::pair<int, int> instance_key{ volume->object_idx(), volume->instance_idx() };
1556 auto [cache_it, inserted] = instance_inside_exclusion_regions.emplace(
1557 instance_key, std::vector<bool>(extruder_count, true));
1558 if (inserted) {
1559 const ModelInstance *instance = model_objects[volume->object_idx()]->instances[volume->instance_idx()];
1560 for (size_t extruder_id = 0; extruder_id < exclusion_regions.size(); ++extruder_id) {
1561 if (instance->intersects_bed_exclude_regions(exclusion_regions[extruder_id]))
1562 cache_it->second[extruder_id] = false;
1563 }
1564 }
1565
1566 bool exclusion_limited = false;
1567 for (size_t extruder_id = 0; extruder_id < cache_it->second.size(); ++extruder_id) {
1568 if (!cache_it->second[extruder_id]) {
1569 inside_extruders[extruder_id] = false;
1570 exclusion_limited = true;
1571 }
1572 }
1573
1574 if (exclusion_limited && state == BuildVolume::ObjectState::Inside)
1576
1577 }
1578
1579 if (state == BuildVolume::ObjectState::Limited) {
1580 //unprintable_filament_ids.resize(inside_extruders.size());
1581 ModelObject *model_object = model_objects[volume->object_idx()];
1582 ModelVolume *model_volume = model_object->volumes[volume->volume_idx()];
1583 for (size_t i = 0; i < printable_area_inside_extruders.size(); ++i) {
1584 if (!printable_area_inside_extruders[i]) {
1585 std::vector<int> filaments = model_volume->get_extruders();
1586 unprintable_filament_ids[i].insert(filaments.begin(), filaments.end());
1587 if (object_results) {
1588 std::map<int, std::set<int>>& obj_extruder_filament_maps = objects_unprintable_filaments[model_object];
1589 std::set<int>& obj_extruder_filaments = obj_extruder_filament_maps[i+1];
1590 obj_extruder_filaments.insert(filaments.begin(), filaments.end());
1591 }
1592 }
1593 }
1594 }
1595 }
1596
1597 //int64_t comp_id = ((int64_t)volume->composite_id.object_id << 32) | ((int64_t)volume->composite_id.instance_id);
1598 volume->is_outside = (state != BuildVolume::ObjectState::Inside && state != BuildVolume::ObjectState::Limited);
1599 volume->partly_inside = (state == BuildVolume::ObjectState::Colliding);
1600 if (volume->printable) {
1602 {
1603 overall_state = ModelInstancePVS_Partly_Outside;
1604 partly_objects_set.emplace(model_objects[volume->object_idx()]);
1605 }
1606 else if ((state == BuildVolume::ObjectState::Limited) && (overall_state != ModelInstancePVS_Partly_Outside))
1607 overall_state = ModelInstancePVS_Limited;
1608 else if ((state == BuildVolume::ObjectState::Inside) && (overall_state == ModelInstancePVS_Fully_Outside)) {
1609 overall_state = ModelInstancePVS_Fully_Outside;
1610 }
1611 contained_min_one |= !volume->is_outside;
1612 }
1613
1614 /*ModelInstanceEPrintVolumeState volume_state;
1615 //if (volume->is_outside && (plate_build_volume.bounding_volume().intersects(volume->bounding_box())))
1616 if (volume->is_outside && (state == BuildVolume::ObjectState::Colliding))
1617 volume_state = ModelInstancePVS_Partly_Outside;
1618 else if (volume->is_outside)
1619 volume_state = ModelInstancePVS_Fully_Outside;
1620 else
1621 volume_state = ModelInstancePVS_Inside;
1622
1623 if (model_state.find(comp_id) != model_state.end())
1624 {
1625 if (model_state[comp_id] != ModelInstancePVS_Partly_Outside)
1626 {
1627 if (volume_state == ModelInstancePVS_Partly_Outside)
1628 model_state[comp_id] = ModelInstancePVS_Partly_Outside;
1629 else if (model_state[comp_id] != volume_state)
1630 {
1631 model_state[comp_id] = ModelInstancePVS_Partly_Outside;
1632 }
1633 }
1634 }
1635 else
1636 {
1637 model_state[comp_id] = volume_state;
1638 }
1639
1640 if (model_state[comp_id] == ModelInstancePVS_Partly_Outside) {
1641 overall_state = ModelInstancePVS_Partly_Outside;
1642 BOOST_LOG_TRIVIAL(debug) << "instance includes " << volume->name << " is partially outside of bed";
1643 }*/
1644 }
1645 }
1646
1647 std::vector<std::vector<int>> unprintable_filament_vec;
1648 for (const std::set<int>& filamnt_ids : unprintable_filament_ids) {
1649 unprintable_filament_vec.emplace_back(std::vector<int>(filamnt_ids.begin(), filamnt_ids.end()));
1650 }
1651
1652 if (object_results && !partly_objects_set.empty()) {
1653 object_results->partly_outside_objects = std::vector<ModelObject*>(partly_objects_set.begin(), partly_objects_set.end());
1654 }
1655
1656 //check per-object error for extruder areas
1657 if (object_results && (extruder_count > 1))
1658 {
1659 object_results->mode = curr_plate->get_real_filament_map_mode(plate_project_config);
1660 if (object_results->mode < FilamentMapMode::fmmManual)
1661 {
1662 std::vector<int> conflict_filament_vector;
1663 for (int index = 0; index < extruder_count; index++ )
1664 {
1665 if (!unprintable_filament_vec[index].empty())
1666 {
1667 std::sort (unprintable_filament_vec[index].begin(), unprintable_filament_vec[index].end());
1668 if (index == 0)
1669 conflict_filament_vector = unprintable_filament_vec[index];
1670 else
1671 {
1672 std::vector<int> result_filaments;
1673 //result_filaments.reserve(conflict_filaments.size());
1674 std::set_intersection (conflict_filament_vector.begin(), conflict_filament_vector.end(), unprintable_filament_vec[index].begin(), unprintable_filament_vec[index].end(), std::insert_iterator<std::vector<int>>(result_filaments, result_filaments.begin()));
1675 conflict_filament_vector = result_filaments;
1676 }
1677 }
1678 else
1679 {
1680 conflict_filament_vector.clear();
1681 break;
1682 }
1683 }
1684
1685 if (!conflict_filament_vector.empty())
1686 {
1687 std::set<int> conflict_filaments_set(conflict_filament_vector.begin(), conflict_filament_vector.end());
1688 object_results->filaments = conflict_filament_vector;
1689
1690 for (auto& object_map: objects_unprintable_filaments)
1691 {
1692 ModelObject *model_object = object_map.first;
1693 std::map<int, std::set<int>>& obj_extruder_filament_maps = object_map.second;
1694 std::set<int> obj_filaments_set;
1695 ObjectFilamentInfo object_filament_info;
1696 object_filament_info.object = model_object;
1697
1698 for (std::map<int, std::set<int>>::iterator extruder_map_iter = obj_extruder_filament_maps.begin(); extruder_map_iter != obj_extruder_filament_maps.end(); extruder_map_iter++ )
1699 {
1700 int extruder_id = extruder_map_iter->first;
1701 std::set<int>& filaments_set = extruder_map_iter->second;
1702
1703 for (int filament: filaments_set)
1704 {
1705 if (conflict_filaments_set.find(filament) != conflict_filaments_set.end())
1706 {
1707 obj_filaments_set.emplace(filament);
1708 }
1709 }
1710 }
1711 if (!obj_filaments_set.empty()) {
1712 object_filament_info.auto_filaments = std::vector<int>(obj_filaments_set.begin(), obj_filaments_set.end());
1713 object_results->object_filaments.push_back(std::move(object_filament_info));
1714 }
1715 }
1716 }
1717 }
1718 else
1719 {
1720 std::set<int> conflict_filaments_set;
1721 std::vector<int> filament_maps = curr_plate->get_real_filament_maps(plate_project_config);
1722 for (auto& object_map: objects_unprintable_filaments)
1723 {
1724 ModelObject *model_object = object_map.first;
1725 std::map<int, std::set<int>>& obj_extruder_filament_maps = object_map.second;
1726 ObjectFilamentInfo object_filament_info;
1727 object_filament_info.object = model_object;
1728
1729 for (std::map<int, std::set<int>>::iterator extruder_map_iter = obj_extruder_filament_maps.begin(); extruder_map_iter != obj_extruder_filament_maps.end(); extruder_map_iter++ )
1730 {
1731 int extruder_id = extruder_map_iter->first;
1732 std::set<int>& filaments_set = extruder_map_iter->second;
1733
1734 for (int filament: filaments_set)
1735 {
1736 if (filament > 0 && size_t(filament) <= filament_maps.size() &&
1737 filament_maps[filament - 1] == extruder_id)
1738 {
1739 object_filament_info.manual_filaments.emplace(filament, extruder_id);
1740 object_results->filament_maps[filament] = extruder_id;
1741 conflict_filaments_set.emplace(filament);
1742 }
1743 }
1744 }
1745 if (!object_filament_info.manual_filaments.empty())
1746 {
1747 object_results->object_filaments.push_back(std::move(object_filament_info));
1748 }
1749 }
1750 if (!conflict_filaments_set.empty()) {
1751 object_results->filaments = std::vector<int>(conflict_filaments_set.begin(), conflict_filaments_set.end());
1752 }
1753 }
1754
1755 }
1756
1757 /*for (GLVolume* volume : this->volumes)
1758 {
1759 if (! volume->is_modifier && (volume->shader_outside_printer_detection_enabled || (! volume->is_wipe_tower && volume->composite_id.volume_id >= 0)))
1760 {
1761 int64_t comp_id = ((int64_t)volume->composite_id.object_id << 32) | ((int64_t)volume->composite_id.instance_id);
1762 if (model_state.find(comp_id) != model_state.end())
1763 {
1764 if (model_state[comp_id] == ModelInstancePVS_Partly_Outside) {
1765 volume->partly_inside = true;
1766 }
1767 else
1768 volume->partly_inside = false;
1769 }
1770 }
1771 }*/
1772
1773 if (out_state != nullptr)
1774 *out_state = overall_state;
1775
1776 return contained_min_one;
1777}
const std::vector< double > & extruder_heights() const
Definition BuildVolume.hpp:68
const std::vector< std::vector< Vec2d > > & extruder_areas() const
Definition BuildVolume.hpp:67
int get_extruder_area_count() const
Definition BuildVolume.hpp:126
ObjectState
Definition BuildVolume.hpp:94
@ Limited
Definition BuildVolume.hpp:105
@ Inside
Definition BuildVolume.hpp:96
@ Colliding
Definition BuildVolume.hpp:98
@ Below
Definition BuildVolume.hpp:103
double printable_height() const
Definition BuildVolume.hpp:66
GLVolumePtrs volumes
Definition 3DScene.hpp:468
bool empty() const
Definition 3DScene.hpp:531
#define scale_(val)
Definition libslic3r.h:106
T * begin(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:838
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
Kernel::Point_3 Point
Definition MeshRepair.cpp:81
bool has_bed_exclude_volumes(const DynamicPrintConfig &cfg)
Definition PrintConfig.cpp:14346
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
std::vector< Vec2d > Pointfs
Definition Point.hpp:77
Eigen::Transform< float, 3, Eigen::Affine, Eigen::DontAlign > Transform3f
Definition Point.hpp:95
@ Circle
Definition BuildVolume.hpp:25
@ Convex
Definition BuildVolume.hpp:27
@ Custom
Definition BuildVolume.hpp:29
@ Rectangle
Definition BuildVolume.hpp:23
std::vector< std::vector< BedExcludeRegion > > get_bed_excluded_regions_by_extruder(const DynamicPrintConfig &cfg)
Definition PrintConfig.cpp:14211
@ fmmManual
Definition PrintConfig.hpp:635
ModelInstanceEPrintVolumeState
Definition Model.hpp:1410
@ ModelInstancePVS_Limited
Definition Model.hpp:1412
@ ModelInstancePVS_Inside
Definition Model.hpp:1411
@ ModelInstancePVS_Partly_Outside
Definition Model.hpp:1413
@ ModelInstancePVS_Fully_Outside
Definition Model.hpp:1414
std::vector< ModelObject * > ModelObjectPtrs
Definition CutUtils.hpp:13

References Slic3r::ObjectFilamentInfo::auto_filaments, Slic3r::BuildVolume::Below, Slic3r::BuildVolume::check_object_state_with_extruder_areas(), Slic3r::BuildVolume::check_volume_bbox_state_with_extruder_areas(), Slic3r::Circle, Slic3r::BuildVolume::Colliding, Slic3r::Convex, Slic3r::Custom, empty(), Slic3r::BuildVolume::extruder_areas(), Slic3r::BuildVolume::extruder_heights(), Slic3r::ObjectFilamentResults::filament_maps, Slic3r::ObjectFilamentResults::filaments, Slic3r::fmmManual, Slic3r::get_bed_excluded_regions_by_extruder(), Slic3r::GUI::PartPlate::get_exclude_areas(), Slic3r::BuildVolume::get_extruder_area_count(), Slic3r::ModelVolume::get_extruders(), Slic3r::GUI::PartPlate::get_origin(), Slic3r::GUI::PartPlate::get_real_filament_map_mode(), Slic3r::GUI::PartPlate::get_real_filament_maps(), Slic3r::GUI::PartPlate::get_shape(), Slic3r::has_bed_exclude_volumes(), Slic3r::BuildVolume::Inside, Slic3r::ModelInstance::intersects_bed_exclude_regions(), Slic3r::BuildVolume::Limited, Slic3r::ObjectFilamentInfo::manual_filaments, Slic3r::ObjectFilamentResults::mode, Slic3r::ModelInstancePVS_Fully_Outside, Slic3r::ModelInstancePVS_Inside, Slic3r::ModelInstancePVS_Limited, Slic3r::ModelInstancePVS_Partly_Outside, Slic3r::ObjectFilamentInfo::object, Slic3r::ObjectFilamentResults::object_filaments, Slic3r::BuildVolume::object_state(), Slic3r::Model::objects, Slic3r::ObjectFilamentResults::partly_outside_objects, Slic3r::BuildVolume::printable_height(), Slic3r::Rectangle, scale_, Slic3r::BuildVolume::type(), Slic3r::BuildVolume::volume_state_bbox(), and Slic3r::ModelObject::volumes.

Here is the call graph for this function:

◆ check_wipe_tower_outside_state()

bool Slic3r::GLVolumeCollection::check_wipe_tower_outside_state ( const Slic3r::BuildVolume & build_volume,
int plate_id ) const
1407{
1408 for (GLVolume *volume : this->volumes) {
1409 if (volume->is_wipe_tower) {
1410 int wipe_tower_plate_id = volume->composite_id.object_id - 1000;
1411 if (wipe_tower_plate_id != plate_id)
1412 continue;
1413 const std::vector<Vec2d>& printable_area = build_volume.printable_area();
1414 Polygon printable_poly = Polygon::new_scale(printable_area);
1415
1416 // multi-extruder
1417 Polygons extruder_polys;
1418 const std::vector<std::vector<Vec2d>> & extruder_areas = build_volume.extruder_areas();
1419 if (!extruder_areas.empty()) {
1420 for (size_t i = 0; i < extruder_areas.size(); ++i) {
1421 extruder_polys.emplace_back(Polygon::new_scale(extruder_areas[i]));
1422 }
1423 extruder_polys = union_(extruder_polys);
1424 if (extruder_polys.empty())
1425 return false;
1426
1427 printable_poly = extruder_polys[0];
1428 }
1429
1430 const BoundingBoxf3 &bbox = volume->transformed_convex_hull_bounding_box();
1431 Polygon wipe_tower_polygon = bbox.polygon(true);
1432
1433 Polygons diff_res = diff(wipe_tower_polygon, printable_poly);
1434 return diff_res.empty();
1435 }
1436 }
1437 return true;
1438}
const std::vector< Vec2d > & printable_area() const
Definition BuildVolume.hpp:65
static Polygon new_scale(const std::vector< Vec2d > &points)
Definition Polygon.hpp:38
Slic3r::Polygons union_(const Slic3r::Polygons &subject)
Definition ClipperUtils.cpp:801
zaa_minimize_perimeter_height printable_area((ConfigOptionPointsGroups, extruder_printable_area))((ConfigOptionBool
std::vector< Polygon, PointsAllocator< Polygon > > Polygons
Definition Polygon.hpp:22
Slic3r::Polygons diff(const Slic3r::Polygon &subject, const Slic3r::Polygon &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:731
Slic3r::Polygon Polygon
Definition Emboss.cpp:101

References Slic3r::diff(), Slic3r::BuildVolume::extruder_areas(), Slic3r::Polygon::new_scale(), Slic3r::BoundingBox3Base< PointType >::polygon(), Slic3r::BuildVolume::printable_area(), Slic3r::printable_area(), and Slic3r::union_().

Here is the call graph for this function:

◆ clear()

void Slic3r::GLVolumeCollection::clear ( )
inline
529{ for (auto *v : volumes) delete v; volumes.clear(); }

References volumes.

Referenced by ~GLVolumeCollection().

Here is the caller graph for this function:

◆ cpu_memory_used()

size_t Slic3r::GLVolumeCollection::cpu_memory_used ( ) const
1884{
1885 size_t memsize = sizeof(*this) + this->volumes.capacity() * sizeof(GLVolume);
1886 for (const GLVolume *volume : this->volumes)
1887 memsize += volume->cpu_memory_used();
1888 return memsize;
1889}

Referenced by log_memory_info(), and total_memory_used().

Here is the caller graph for this function:

◆ empty()

bool Slic3r::GLVolumeCollection::empty ( ) const
inline
531{ return volumes.empty(); }

References volumes.

Referenced by check_outside_state().

Here is the caller graph for this function:

◆ get_clipping_plane()

const std::array< double, 4 > & Slic3r::GLVolumeCollection::get_clipping_plane ( ) const
inline
540{ return m_clipping_plane; }
std::array< double, 4 > m_clipping_plane
Definition 3DScene.hpp:448

References m_clipping_plane.

◆ get_current_print_zs()

std::vector< double > Slic3r::GLVolumeCollection::get_current_print_zs ( bool active_only) const
1857{
1858 // Collect layer top positions of all volumes.
1859 std::vector<double> print_zs;
1860 for (GLVolume *vol : this->volumes)
1861 {
1862 if (!active_only || vol->is_active)
1863 append(print_zs, vol->print_zs);
1864 }
1865 std::sort(print_zs.begin(), print_zs.end());
1866
1867 // Replace intervals of layers with similar top positions with their average value.
1868 int n = int(print_zs.size());
1869 int k = 0;
1870 for (int i = 0; i < n;) {
1871 int j = i + 1;
1872 coordf_t zmax = print_zs[i] + EPSILON;
1873 for (; j < n && print_zs[j] <= zmax; ++ j) ;
1874 print_zs[k ++] = (j > i + 1) ? (0.5 * (print_zs[i] + print_zs[j - 1])) : print_zs[i];
1875 i = j;
1876 }
1877 if (k < n)
1878 print_zs.erase(print_zs.begin() + k, print_zs.end());
1879
1880 return print_zs;
1881}
#define EPSILON
Definition ColorUtils.cpp:64
double coordf_t
Definition GUI_ObjectList.hpp:46
void append(std::vector< T, Alloc > &dest, const std::vector< T, Alloc2 > &src)
Definition libslic3r.h:157

References Slic3r::append(), and EPSILON.

Here is the call graph for this function:

◆ get_selection_support_normal_z()

float Slic3r::GLVolumeCollection::get_selection_support_normal_z ( ) const
1160{
1161 const DynamicPrintConfig& glb_cfg = GUI::wxGetApp().preset_bundle->prints.get_edited_preset().config;
1162 const auto& full_cfg = GUI::wxGetApp().preset_bundle->full_config();
1163 const auto support_type = glb_cfg.opt_enum<SupportType>("support_type");
1164 const int support_threshold_angle = glb_cfg.opt_int("support_threshold_angle");
1165 double angle_rad;
1166
1167 if (support_threshold_angle > 0) {
1168 // Match support generation: explicit threshold angles are treated as inclusive.
1169 const int effective_support_threshold_angle = std::min(support_threshold_angle + 1, 89);
1170 angle_rad = Geometry::deg2rad(static_cast<double>(effective_support_threshold_angle));
1171 } else if (is_tree(support_type)) {
1172 angle_rad = Geometry::deg2rad(30.0); // fallback value for tree supports
1173 } else { // For normal supports, if the angle is set to 0, calculate normal_z from overlap.
1174 const double layer_height = full_cfg.opt_float("layer_height");
1175 const auto* nozzle_diameter_opt = full_cfg.option<ConfigOptionFloats>("nozzle_diameter");
1176 const int wall_filament_id = full_cfg.opt_int("outer_wall_filament_id");
1177 const size_t nozzle_count = nozzle_diameter_opt->values.size();
1178 const size_t wall_extruder_idx = (wall_filament_id > 0 && wall_filament_id <= static_cast<int>(nozzle_count))
1179 ? static_cast<size_t>(wall_filament_id - 1)
1180 : 0; // Invalid extruder index falls back to extruder 1.
1181
1182 // Use wall extruder's nozzle diameter for better estimation of external perimeter width,
1183 // which is more relevant to overhang printing than the default nozzle diameter.
1184 const double nozzle_diameter = nozzle_diameter_opt->values[wall_extruder_idx];
1185
1186 double external_perimeter_width = full_cfg.get_abs_value("outer_wall_line_width", nozzle_diameter);
1187 if (external_perimeter_width <= 0.0) {
1188 external_perimeter_width = full_cfg.get_abs_value("line_width", nozzle_diameter);
1189
1190 if (external_perimeter_width <= 0.0)
1191 external_perimeter_width = nozzle_diameter;
1192 }
1193
1194 const double overlap_width = full_cfg.get_abs_value("support_threshold_overlap", external_perimeter_width);
1195 const double lower_layer_offset = std::max(0.0, external_perimeter_width - overlap_width);
1196
1197 angle_rad = lower_layer_offset <= EPSILON ? Geometry::deg2rad(89.0) : std::atan(layer_height / lower_layer_offset);
1198 }
1199
1200 return static_cast<float>(-std::cos(std::clamp(angle_rad, 0.0, Geometry::deg2rad(89.0))));
1201}
std::vector< double > values
Definition Config.hpp:418
constexpr T deg2rad(const T angle)
Definition Geometry.hpp:312
zaa_minimize_perimeter_height nozzle_diameter((ConfigOptionBool, reduce_infill_retraction))((ConfigOptionBool
layer_height((ConfigOptionInt, faded_layers))((ConfigOptionFloat
bool is_tree(SupportType stype)
Definition PrintConfig.hpp:381
SupportType
Definition PrintConfig.hpp:378
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:1015

References Slic3r::Geometry::deg2rad(), EPSILON, Slic3r::is_tree(), Slic3r::layer_height(), Slic3r::nozzle_diameter(), Slic3r::DynamicConfig::opt_enum(), and Slic3r::DynamicConfig::opt_int().

Referenced by render().

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

◆ get_slope_normal_z()

float Slic3r::GLVolumeCollection::get_slope_normal_z ( ) const
inline
555{ return m_slope.normal_z; }
Slope m_slope
Definition 3DScene.hpp:464

References m_slope.

◆ get_z_range()

const std::array< float, 2 > & Slic3r::GLVolumeCollection::get_z_range ( ) const
inline
539{ return m_z_range; }
std::array< float, 2 > m_z_range
Definition 3DScene.hpp:445

References m_z_range.

◆ gpu_memory_used()

size_t Slic3r::GLVolumeCollection::gpu_memory_used ( ) const
1892{
1893 size_t memsize = 0;
1894 for (const GLVolume *volume : this->volumes)
1895 memsize += volume->gpu_memory_used();
1896 return memsize;
1897}

Referenced by log_memory_info(), and total_memory_used().

Here is the caller graph for this function:

◆ is_slope_active()

bool Slic3r::GLVolumeCollection::is_slope_active ( ) const
inline
551{ return m_slope.active; }

References m_slope.

◆ is_slope_GlobalActive()

bool Slic3r::GLVolumeCollection::is_slope_GlobalActive ( ) const
inline
550{ return m_slope.isGlobalActive; }

References m_slope.

◆ load_object()

std::vector< int > Slic3r::GLVolumeCollection::load_object ( const ModelObject * model_object,
int obj_idx,
const std::vector< int > & instance_idxs,
const std::string & color_by,
bool opengl_initialized,
bool need_raycaster = true )
884{
885 std::vector<int> volumes_idx;
886 for (int volume_idx = 0; volume_idx < int(model_object->volumes.size()); ++volume_idx)
887 for (int instance_idx : instance_idxs)
888 volumes_idx.emplace_back(this->GLVolumeCollection::load_object_volume(model_object, obj_idx, volume_idx, instance_idx, color_by, opengl_initialized, false, false, need_raycaster));
889 return volumes_idx;
890}
int load_object_volume(const ModelObject *model_object, int obj_idx, int volume_idx, int instance_idx, const std::string &color_by, bool opengl_initialized, bool in_assemble_view=false, bool use_loaded_id=false, bool need_raycaster=true)
Definition 3DScene.cpp:893

References load_object_volume(), and Slic3r::ModelObject::volumes.

Here is the call graph for this function:

◆ load_object_auxiliary()

void Slic3r::GLVolumeCollection::load_object_auxiliary ( const SLAPrintObject * print_object,
int obj_idx,
const std::vector< std::pair< size_t, size_t > > & instances,
SLAPrintObjectStep milestone,
size_t timestamp )
956{
957 assert(print_object->is_step_done(milestone));
958 Transform3d mesh_trafo_inv = print_object->trafo().inverse();
959 // Get the support mesh.
960 TriangleMesh mesh = print_object->get_mesh(milestone);
961 mesh.transform(mesh_trafo_inv);
962 // Convex hull is required for out of print bed detection.
963 TriangleMesh convex_hull = mesh.convex_hull_3d();
964 for (const std::pair<size_t, size_t>& instance_idx : instances) {
965 const ModelInstance& model_instance = *print_object->model_object()->instances[instance_idx.first];
966 this->volumes.emplace_back(new GLVolume((milestone == slaposPad) ? GLVolume::SLA_PAD_COLOR : GLVolume::SLA_SUPPORT_COLOR));
967 GLVolume& v = *this->volumes.back();
968 v.model.init_from(mesh);
969 v.model.set_color((milestone == slaposPad) ? GLVolume::SLA_PAD_COLOR : GLVolume::SLA_SUPPORT_COLOR);
970 v.mesh_raycaster = std::make_unique<GUI::MeshRaycaster>(std::make_shared<const TriangleMesh>(mesh));
971 v.composite_id = GLVolume::CompositeID(obj_idx, -int(milestone), (int)instance_idx.first);
972 v.geometry_id = std::pair<size_t, size_t>(timestamp, model_instance.id().id);
973 // Create a copy of the convex hull mesh for each instance. Use a move operator on the last instance.
974 if (&instance_idx == &instances.back())
975 v.set_convex_hull(std::move(convex_hull));
976 else
977 v.set_convex_hull(convex_hull);
978 v.is_modifier = false;
979 v.shader_outside_printer_detection_enabled = (milestone == slaposSupportTree);
980 v.set_instance_transformation(model_instance.get_transformation());
981 // Leave the volume transformation at identity.
982 // v.set_volume_transformation(model_volume->get_transformation());
983 }
984}
static ColorRGBA SLA_PAD_COLOR
Definition 3DScene.hpp:96
static ColorRGBA SLA_SUPPORT_COLOR
Definition 3DScene.hpp:95
Polygon convex_hull(Points pts)
Definition ConvexHull.cpp:21
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:96
@ slaposPad
Definition SLAPrint.hpp:48
@ slaposSupportTree
Definition SLAPrint.hpp:47

References Slic3r::GLVolume::composite_id, Slic3r::Geometry::convex_hull(), Slic3r::TriangleMesh::convex_hull_3d(), Slic3r::GLVolume::geometry_id, Slic3r::SLAPrintObject::get_mesh(), Slic3r::ModelInstance::get_transformation(), Slic3r::ObjectBase::id(), Slic3r::ObjectID::id, Slic3r::GUI::GLModel::init_from(), Slic3r::ModelObject::instances, Slic3r::PrintObjectBaseWithState< PrintType, PrintObjectStepEnum, COUNT >::is_step_done(), Slic3r::GLVolume::mesh_raycaster, Slic3r::GLVolume::model, Slic3r::PrintObjectBase::model_object(), Slic3r::GUI::GLModel::set_color(), Slic3r::GLVolume::set_convex_hull(), Slic3r::GLVolume::set_instance_transformation(), Slic3r::GLVolume::SLA_PAD_COLOR, Slic3r::GLVolume::SLA_SUPPORT_COLOR, Slic3r::slaposPad, Slic3r::slaposSupportTree, Slic3r::SLAPrintObject::trafo(), Slic3r::TriangleMesh::transform(), and volumes.

Here is the call graph for this function:

◆ load_object_volume()

int Slic3r::GLVolumeCollection::load_object_volume ( const ModelObject * model_object,
int obj_idx,
int volume_idx,
int instance_idx,
const std::string & color_by,
bool opengl_initialized,
bool in_assemble_view = false,
bool use_loaded_id = false,
bool need_raycaster = true )
903{
904 const ModelVolume *model_volume = model_object->volumes[volume_idx];
905 const int extruder_id = model_volume->extruder_id();
906 const ModelInstance *instance = model_object->instances[instance_idx];
907 auto color = GLVolume::MODEL_COLOR[((color_by == "volume") ? volume_idx : obj_idx) % 4];
908 color.a(model_volume->is_model_part() ? 0.7f : 0.4f);
909
910 std::shared_ptr<const TriangleMesh> mesh = model_volume->mesh_ptr();
911 this->volumes.emplace_back(new GLVolume(color));
912 GLVolume& v = *this->volumes.back();
913 v.set_color(color_from_model_volume(*model_volume));
914 v.name = model_volume->name;
915
916 v.model.init_from(*mesh);
917 if (need_raycaster) { v.mesh_raycaster = std::make_unique<GUI::MeshRaycaster>(mesh); }
918 v.composite_id = GLVolume::CompositeID(obj_idx, volume_idx, instance_idx);
919
920 if (model_volume->is_model_part())
921 {
922 // GLVolume will reference a convex hull from model_volume!
923 v.set_convex_hull(model_volume->get_convex_hull_shared_ptr());
924 if (extruder_id != -1)
925 v.extruder_id = extruder_id;
926 }
927 v.is_modifier = !model_volume->is_model_part();
928 v.shader_outside_printer_detection_enabled = model_volume->is_model_part();
929 if (in_assemble_view) {
930 v.set_instance_transformation(instance->get_assemble_transformation());
931 v.set_offset_to_assembly(instance->get_offset_to_assembly());
932 }
933 else
934 v.set_instance_transformation(instance->get_transformation());
935 v.set_volume_transformation(model_volume->get_transformation());
936 //use object's instance id
937 if (use_loaded_id && (instance->loaded_id > 0))
938 v.model_object_ID = instance->loaded_id;
939 else
940 v.model_object_ID = instance->id().id;
941
942 return int(this->volumes.size() - 1);
943}
static std::array< ColorRGBA, 5 > MODEL_COLOR
Definition 3DScene.hpp:99
ColorRGBA color_from_model_volume(const ModelVolume &model_volume)
Definition 3DScene.cpp:407

References Slic3r::color_from_model_volume(), Slic3r::GLVolume::composite_id, Slic3r::GLVolume::extruder_id, Slic3r::ModelVolume::extruder_id(), Slic3r::ModelInstance::get_assemble_transformation(), Slic3r::ModelVolume::get_convex_hull_shared_ptr(), Slic3r::ModelInstance::get_offset_to_assembly(), Slic3r::ModelInstance::get_transformation(), Slic3r::ModelVolume::get_transformation(), Slic3r::ObjectBase::id(), Slic3r::ObjectID::id, Slic3r::GUI::GLModel::init_from(), Slic3r::ModelObject::instances, Slic3r::ModelVolume::is_model_part(), Slic3r::ModelInstance::loaded_id, Slic3r::ModelVolume::mesh_ptr(), Slic3r::GLVolume::mesh_raycaster, Slic3r::GLVolume::model, Slic3r::GLVolume::MODEL_COLOR, Slic3r::GLVolume::model_object_ID, Slic3r::GLVolume::name, Slic3r::ModelVolume::name, Slic3r::GLVolume::set_color(), Slic3r::GLVolume::set_convex_hull(), Slic3r::GLVolume::set_instance_transformation(), Slic3r::GLVolume::set_offset_to_assembly(), Slic3r::GLVolume::set_volume_transformation(), volumes, and Slic3r::ModelObject::volumes.

Referenced by load_object(), Slic3r::GUI::CalibUtils::process_and_store_3mf(), Slic3r::CLI::run(), and Slic3r::GUI::Plater::update_obj_preview_thumbnail().

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

◆ load_real_wipe_tower_preview()

int Slic3r::GLVolumeCollection::load_real_wipe_tower_preview ( int obj_idx,
float pos_x,
float pos_y,
const TriangleMesh & wt_mesh,
const TriangleMesh & brim_mesh,
bool render_brim,
float rotation_angle,
bool size_unknown,
bool opengl_initialized )
1055{
1056 int plate_idx = obj_idx - 1000;
1057 if (wt_mesh.its.vertices.empty()) return int(this->volumes.size() - 1);
1058
1059 std::vector<Slic3r::ColorRGBA> extruder_colors = GUI::wxGetApp().plater()->get_extruders_colors();
1060 GUI::PartPlateList &ppl = GUI::wxGetApp().plater()->get_partplate_list();
1061 std::vector<int> plate_extruders = ppl.get_plate(plate_idx)->get_extruders(true);
1062 std::vector<Slic3r::ColorRGBA> colors;
1063 if (!plate_extruders.empty()) {
1064 if (plate_extruders.front() <= extruder_colors.size())
1065 colors.push_back(extruder_colors[plate_extruders.front() - 1]);
1066 else
1067 colors.push_back(extruder_colors[0]);
1068 }
1069 if (colors.empty()) return int(this->volumes.size() - 1);
1070 volumes.emplace_back(new GLWipeTowerVolume({colors}));
1071 GLWipeTowerVolume &v = *dynamic_cast<GLWipeTowerVolume *>(volumes.back());
1072 auto mesh = wt_mesh;
1073 if (render_brim) {
1074 mesh.merge(brim_mesh);
1075 }
1076 if (!colors.empty()) {
1077 v.model_per_colors.resize(1);
1078 v.model_per_colors[0].init_from(mesh);
1079 }
1080 TriangleMesh wipe_tower_shell = mesh.convex_hull_3d();
1081 v.model.init_from(wipe_tower_shell);
1082 v.mesh_raycaster = std::make_unique<GUI::MeshRaycaster>(std::make_shared<const TriangleMesh>(wipe_tower_shell));
1083 v.set_convex_hull(wipe_tower_shell);
1084 v.set_volume_offset(Vec3d(pos_x, pos_y, 0.0));
1085 v.set_volume_rotation(Vec3d(0., 0., (M_PI / 180.) * rotation_angle));
1086 v.composite_id = GLVolume::CompositeID(obj_idx, 0, 0);
1087 v.geometry_id.first = 0;
1088 v.geometry_id.second = wipe_tower_instance_id().id + (obj_idx - 1000);
1089 v.is_wipe_tower = true;
1090 v.shader_outside_printer_detection_enabled = !size_unknown;
1091 return int(volumes.size() - 1);
1092}
#define M_PI
Definition ExtrusionSimulator.cpp:31
size_t id
Definition ObjectID.hpp:39
ObjectID wipe_tower_instance_id()
Definition ObjectID.cpp:15

References Slic3r::GLVolume::composite_id, Slic3r::TriangleMesh::convex_hull_3d(), Slic3r::GLVolume::geometry_id, Slic3r::GUI::PartPlate::get_extruders(), Slic3r::GUI::PartPlateList::get_plate(), Slic3r::ObjectID::id, Slic3r::GUI::GLModel::init_from(), Slic3r::TriangleMesh::its, M_PI, Slic3r::GLVolume::mesh_raycaster, Slic3r::GLVolume::model, Slic3r::GLWipeTowerVolume::model_per_colors, Slic3r::GLVolume::set_convex_hull(), Slic3r::GLVolume::set_volume_offset(), Slic3r::GLVolume::set_volume_rotation(), volumes, and Slic3r::wipe_tower_instance_id().

Here is the call graph for this function:

◆ load_wipe_tower_preview()

int Slic3r::GLVolumeCollection::load_wipe_tower_preview ( int obj_idx,
float pos_x,
float pos_y,
float width,
float depth,
float height,
float rotation_angle,
bool size_unknown,
float brim_width )
989{
990 int plate_idx = obj_idx - 1000;
991
992 if (depth < 0.01f)
993 return int(this->volumes.size() - 1);
994 if (height == 0.0f)
995 height = 0.1f;
996
997 std::vector<ColorRGBA> extruder_colors = GUI::wxGetApp().plater()->get_extruders_colors();
998 std::vector<ColorRGBA> colors;
999 GUI::PartPlateList& ppl = GUI::wxGetApp().plater()->get_partplate_list();
1000 std::vector<int> plate_extruders = ppl.get_plate(plate_idx)->get_extruders(true);
1001 TriangleMesh wipe_tower_shell = make_cube(width, depth, height);
1002 // The brim is part of the printed footprint: draw it and fold it into the shell so the
1003 // outside-bed shader and the drag clamp react to the true first-layer extent.
1004 const bool show_brim = brim_width > 0.f;
1005 const float brim_height = 0.2f; // one first layer, visual only
1006 TriangleMesh brim_slab;
1007 if (show_brim) {
1008 // The brim follows the real first-layer outline: a Type2 cone-wall tower's base bulges
1009 // past the body box. The wall type and angle are print settings, the planner a printer one.
1010 const DynamicPrintConfig &print_cfg = GUI::wxGetApp().preset_bundle->prints.get_edited_preset().config;
1011 const DynamicPrintConfig &printer_cfg = GUI::wxGetApp().preset_bundle->printers.get_edited_preset().config;
1012 const Polygon outline = estimate_wipe_tower_first_layer_outline(print_cfg, resolve_wipe_tower_type(printer_cfg), width, depth, height);
1013 const Polygons brim_outline = offset(outline, scaled(brim_width));
1014 brim_slab = WipeTower::its_make_rib_brim(brim_outline.empty() ? outline : brim_outline.front(), brim_height);
1015 wipe_tower_shell.merge(brim_slab);
1016 }
1017 for (int extruder_id : plate_extruders) {
1018 if (extruder_id <= extruder_colors.size())
1019 colors.push_back(extruder_colors[extruder_id - 1]);
1020 else
1021 colors.push_back(extruder_colors[0]);
1022 }
1023
1024 // Orca: make it transparent
1025 for(auto& color : colors)
1026 color.a(0.66f);
1027 const size_t slab_count = colors.size(); // per-filament body slabs; the brim part comes after
1028 if (show_brim && !colors.empty())
1029 colors.push_back(colors.front());
1030 volumes.emplace_back(new GLWipeTowerVolume(colors));
1031 GLWipeTowerVolume& v = *dynamic_cast<GLWipeTowerVolume*>(volumes.back());
1032 v.model_per_colors.resize(colors.size());
1033 for (size_t i = 0; i < slab_count; i++) {
1034 TriangleMesh color_part = make_cube(width, depth / slab_count, height);
1035 color_part.translate({ 0.f, depth * i / slab_count, 0. });
1036 v.model_per_colors[i].init_from(color_part);
1037 }
1038 if (show_brim && !colors.empty())
1039 v.model_per_colors[slab_count].init_from(brim_slab);
1040 v.model.init_from(wipe_tower_shell);
1041 v.mesh_raycaster = std::make_unique<GUI::MeshRaycaster>(std::make_shared<const TriangleMesh>(wipe_tower_shell));
1042 v.set_convex_hull(wipe_tower_shell);
1043 v.set_volume_offset(Vec3d(pos_x, pos_y, 0.0));
1044 v.set_volume_rotation(Vec3d(0., 0., (M_PI / 180.) * rotation_angle));
1045 v.composite_id = GLVolume::CompositeID(obj_idx, 0, 0);
1046 v.geometry_id.first = 0;
1047 v.geometry_id.second = wipe_tower_instance_id().id + (obj_idx - 1000);
1048 v.is_wipe_tower = true;
1049 v.shader_outside_printer_detection_enabled = !size_unknown;
1050 return int(volumes.size() - 1);
1051}
static TriangleMesh its_make_rib_brim(const Polygon &brim, float layer_height)
Definition WipeTower.cpp:1950
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185
TriangleMesh make_cube(double x, double y, double z)
Definition TriangleMesh.hpp:378
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:284
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582
Polygon estimate_wipe_tower_first_layer_outline(const ConfigBase &config, WipeTowerType tower_type, double width, double depth, double height)
Definition WipeTowerEstimate.cpp:75
WipeTowerType resolve_wipe_tower_type(const ConfigBase &config)
Definition WipeTowerEstimate.cpp:62

References Slic3r::GLVolume::composite_id, Slic3r::estimate_wipe_tower_first_layer_outline(), Slic3r::GLVolume::geometry_id, Slic3r::GUI::PartPlate::get_extruders(), Slic3r::GUI::PartPlateList::get_plate(), Slic3r::ObjectID::id, Slic3r::GUI::GLModel::init_from(), Slic3r::WipeTower::its_make_rib_brim(), M_PI, Slic3r::make_cube(), Slic3r::TriangleMesh::merge(), Slic3r::GLVolume::mesh_raycaster, Slic3r::GLVolume::model, Slic3r::GLWipeTowerVolume::model_per_colors, Slic3r::offset(), Slic3r::resolve_wipe_tower_type(), Slic3r::scaled(), Slic3r::GLVolume::set_convex_hull(), Slic3r::GLVolume::set_volume_offset(), Slic3r::GLVolume::set_volume_rotation(), Slic3r::TriangleMesh::translate(), volumes, and Slic3r::wipe_tower_instance_id().

Here is the call graph for this function:

◆ log_memory_info()

std::string Slic3r::GLVolumeCollection::log_memory_info ( ) const
1900{
1901 return " (GLVolumeCollection RAM: " + format_memsize_MB(this->cpu_memory_used()) + " GPU: " + format_memsize_MB(this->gpu_memory_used()) + " Both: " + format_memsize_MB(this->gpu_memory_used()) + ")";
1902}
size_t cpu_memory_used() const
Definition 3DScene.cpp:1883
size_t gpu_memory_used() const
Definition 3DScene.cpp:1891
std::string format_memsize_MB(size_t n)
Definition utils.cpp:1677

References cpu_memory_used(), Slic3r::format_memsize_MB(), and gpu_memory_used().

Here is the call graph for this function:

◆ new_nontoolpath_volume()

GLVolume * Slic3r::GLVolumeCollection::new_nontoolpath_volume ( const ColorRGBA & rgba)
1103{
1104 GLVolume* out = new GLVolume(rgba);
1105 out->is_extrusion_path = false;
1106 this->volumes.emplace_back(out);
1107 return out;
1108}

References volumes.

Referenced by new_toolpath_volume().

Here is the caller graph for this function:

◆ new_toolpath_volume()

GLVolume * Slic3r::GLVolumeCollection::new_toolpath_volume ( const ColorRGBA & rgba)
1096{
1097 GLVolume* out = new_nontoolpath_volume(rgba);
1098 out->is_extrusion_path = true;
1099 return out;
1100}
GLVolume * new_nontoolpath_volume(const ColorRGBA &rgba)
Definition 3DScene.cpp:1102

References new_nontoolpath_volume().

Here is the call graph for this function:

◆ operator=()

GLVolumeCollection & Slic3r::GLVolumeCollection::operator= ( const GLVolumeCollection & )
private

References GLVolumeCollection().

Here is the call graph for this function:

◆ render()

void Slic3r::GLVolumeCollection::render ( GLVolumeCollection::ERenderType type,
bool disable_cullface,
const Transform3d & view_matrix,
const Transform3d & projection_matrix,
const GUI::Size & cnv_size,
std::function< bool(const GLVolume &)> filter_func = std::function<bool(const GLVolume &)>(),
bool partly_inside_enable = true,
std::vector< double > * printable_heights = nullptr ) const
1212{
1213 GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func);
1214 if (to_render.empty())
1215 return;
1216
1217 GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
1218 if (shader == nullptr)
1219 return;
1220
1221 GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat");
1222#if SLIC3R_OPENGL_ES
1223 GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("dashed_lines");
1224#else
1225 GLShaderProgram* edges_shader = GUI::OpenGLManager::get_gl_info().is_core_profile() ? GUI::wxGetApp().get_shader("dashed_thick_lines") : GUI::wxGetApp().get_shader("flat");
1226#endif // SLIC3R_OPENGL_ES
1227
1228 if (type == ERenderType::Transparent) {
1231 }
1232
1234 if (disable_cullface)
1236
1237 const float support_normal_z = get_selection_support_normal_z();
1238
1239 // The outline passes below are driven by is_outline, which only the object shaders have; with an
1240 // overlay one (wireframe, x-ray) bound they would just draw the volume again.
1241 const bool shader_can_outline = shader->get_uniform_location("is_outline") >= 0;
1242 // ORCA: the object shaders that know how draw a part of a translucent filament as its print would
1243 // show, in premultiplied color, see translucent_filament_color() in gouraud.fs
1244 const bool shade_translucent_filaments = type == ERenderType::Transparent && shader->get_uniform_location("translucent_filament") >= 0;
1245
1246 // Prime depth_tex on every frame so non-outline draws do not keep the
1247 // default sampler unit 0, which can conflict with other sampler types.
1248 shader->set_uniform("depth_tex", OUTLINE_DEPTH_TEX_UNIT);
1249
1250 // Compute up direction accounting for build plate tilt. This is frame-invariant
1251 // (config cannot change mid-render), so compute it once before the volume loop.
1252 const Vec3f up_direction = GUI::build_plate_tilt_up_direction().cast<float>();
1253
1254 for (GLVolumeWithIdAndZ& volume : to_render) {
1255#if ENABLE_MODIFIERS_ALWAYS_TRANSPARENT
1256 if (type == ERenderType::Transparent) {
1257 volume.first->force_transparent = true;
1258 //BOOST_LOG_TRIVIAL(info) << boost::format("transparent rendering...");
1259 }
1260 //else
1261 // BOOST_LOG_TRIVIAL(info) << boost::format("opaque rendering...");
1262#endif // ENABLE_MODIFIERS_ALWAYS_TRANSPARENT
1263 volume.first->set_render_color();
1264#if ENABLE_MODIFIERS_ALWAYS_TRANSPARENT
1265 if (type == ERenderType::Transparent)
1266 volume.first->force_transparent = false;
1267#endif // ENABLE_MODIFIERS_ALWAYS_TRANSPARENT
1268
1269 // render sinking contours of non-hovered volumes
1270 shader->stop_using();
1271 if (sink_shader != nullptr) {
1272 sink_shader->start_using();
1274 if (volume.first->is_sinking() && !volume.first->is_below_printbed() &&
1275 volume.first->hover == GLVolume::HS_None && !volume.first->force_sinking_contours) {
1276 volume.first->render_sinking_contours();
1277 }
1278 }
1279 sink_shader->stop_using();
1280 }
1281 shader->start_using();
1282
1283 if (!volume.first->model.is_initialized())
1284 shader->set_uniform("uniform_color", volume.first->render_color);
1285 shader->set_uniform("z_range", m_z_range);
1286 shader->set_uniform("clipping_plane", m_clipping_plane);
1287 shader->set_uniform("use_color_clip_plane", m_use_color_clip_plane);
1288 shader->set_uniform("color_clip_plane", m_color_clip_plane);
1289 shader->set_uniform("uniform_color_clip_plane_1", m_color_clip_plane_colors[0]);
1290 shader->set_uniform("uniform_color_clip_plane_2", m_color_clip_plane_colors[1]);
1291 //BOOST_LOG_TRIVIAL(info) << boost::format("set uniform_color to {%1%, %2%, %3%, %4%}, with_outline=%5%, selected %6%")
1292 // %volume.first->render_color[0]%volume.first->render_color[1]%volume.first->render_color[2]%volume.first->render_color[3]
1293 // %with_outline%volume.first->selected;
1294
1295 //BBS set print_volume to render volume
1296 //shader->set_uniform("print_volume.type", static_cast<int>(m_render_volume.type));
1297 //shader->set_uniform("print_volume.xy_data", m_render_volume.data);
1298 //shader->set_uniform("print_volume.z_data", m_render_volume.zs);
1299
1300 if (volume.first->partly_inside && partly_inside_enable) {
1301 //only partly inside volume need to be painted with boundary check
1302 shader->set_uniform("print_volume.type", static_cast<int>(m_print_volume.type));
1303 shader->set_uniform("print_volume.xy_data", m_print_volume.data);
1304 shader->set_uniform("print_volume.z_data", m_print_volume.zs);
1305 }
1306 else {
1307 //use -1 ad a invalid type
1308 shader->set_uniform("print_volume.type", -1);
1309 }
1310
1311 // Per-extruder printable-height shading. The flag is set to
1312 // 2.0 only for multi-extruder printers (two per-extruder heights); otherwise it is forced to 0.0
1313 // on every render so no stale flag survives a multi->single-extruder plate switch, keeping the
1314 // shared gouraud shader pixel-identical for single-extruder printers. When active the height
1315 // branch reads print_volume.xy_data (the bed rect), so set it explicitly here.
1316 std::array<float, 3> extruder_printable_heights = {0.0f, 0.0f, 0.0f};
1317 if (printable_heights != nullptr && printable_heights->size() > 1) {
1318 extruder_printable_heights[0] = 2.0f;
1319 extruder_printable_heights[1] = static_cast<float>((*printable_heights)[0]);
1320 extruder_printable_heights[2] = static_cast<float>((*printable_heights)[1]);
1321 shader->set_uniform("extruder_printable_heights", extruder_printable_heights);
1322 shader->set_uniform("print_volume.xy_data", m_print_volume.data);
1323 }
1324 else {
1325 shader->set_uniform("extruder_printable_heights", extruder_printable_heights);
1326 }
1327
1328 shader->set_uniform("volume_world_matrix", volume.first->world_matrix());
1329 shader->set_uniform("slope.actived", m_slope.isGlobalActive && !volume.first->is_modifier && !volume.first->is_wipe_tower);
1330 shader->set_uniform("slope.volume_world_normal_matrix", static_cast<Matrix3f>(volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>()));
1331 shader->set_uniform("slope.normal_z", support_normal_z);
1332 shader->set_uniform("slope.up_direction", up_direction);
1333
1334#if ENABLE_ENVIRONMENT_MAP
1335 unsigned int environment_texture_id = GUI::wxGetApp().plater()->get_environment_texture_id();
1336 bool use_environment_texture = environment_texture_id > 0 && GUI::wxGetApp().app_config->get("use_environment_map") == "1";
1337 shader->set_uniform("use_environment_tex", use_environment_texture);
1338 if (use_environment_texture)
1339 glsafe(::glBindTexture(GL_TEXTURE_2D, environment_texture_id));
1340#endif // ENABLE_ENVIRONMENT_MAP
1341 glcheck();
1342
1343 auto red_color = ColorRGBA{1.0f, 0.0f, 0.0f, 1.0f};//slice_error
1344 volume.first->model.set_color(volume.first->slice_error ? red_color : volume.first->render_color);
1345 const Transform3d model_matrix = volume.first->world_matrix();
1346 shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
1347 shader->set_uniform("projection_matrix", projection_matrix);
1348 const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
1349 shader->set_uniform("view_normal_matrix", view_normal_matrix);
1350 if (shade_translucent_filaments) {
1351 const bool translucent_filament = volume.first->visible && !volume.first->is_modifier && volume.first->color.is_transparent();
1352 shader->set_uniform("translucent_filament", translucent_filament);
1354 }
1355 if (volume.first->depth_bias) {
1357 glsafe(::glPolygonOffset(1.0f, 1.0f));
1358 }
1359 //BBS: add outline related logic
1360 if (volume.first->selected && shader_can_outline && GUI::wxGetApp().show_outline())
1361 volume.first->render_with_outline(cnv_size);
1362 else
1363 volume.first->render();
1364 if (volume.first->depth_bias)
1366
1367#if ENABLE_ENVIRONMENT_MAP
1368 if (use_environment_texture)
1370#endif // ENABLE_ENVIRONMENT_MAP
1371
1374 }
1375
1377 shader->stop_using();
1378 if (sink_shader != nullptr) {
1379 sink_shader->start_using();
1380 for (GLVolumeWithIdAndZ& volume : to_render) {
1381 // render sinking contours of hovered/displaced volumes
1382 if (volume.first->is_sinking() && !volume.first->is_below_printbed() &&
1383 (volume.first->hover != GLVolume::HS_None || volume.first->force_sinking_contours)) {
1385 volume.first->render_sinking_contours();
1387 }
1388 }
1389 sink_shader->start_using();
1390 }
1391 shader->start_using();
1392 }
1393
1394 if (disable_cullface)
1396
1397 if (shade_translucent_filaments) {
1398 // the program is shared, so leave it as the other users expect
1399 shader->set_uniform("translucent_filament", false);
1401 }
1402 if (type == ERenderType::Transparent)
1404}
static constexpr int OUTLINE_DEPTH_TEX_UNIT
Definition 3DScene.cpp:110
#define glcheck()
Definition OpenGLUtils.hpp:26
#define glsafe(cmd)
Definition OpenGLUtils.hpp:25
PrintVolume m_print_volume
Definition 3DScene.hpp:441
float get_selection_support_normal_z() const
Definition 3DScene.cpp:1159
std::array< double, 4 > m_color_clip_plane
Definition 3DScene.hpp:452
bool m_show_sinking_contours
Definition 3DScene.hpp:465
std::array< ColorRGBA, 2 > m_color_clip_plane_colors
Definition 3DScene.hpp:454
@ Transparent
Definition 3DScene.hpp:422
bool m_use_color_clip_plane
Definition 3DScene.hpp:453
@ HS_None
Definition 3DScene.hpp:122
bool is_core_profile() const
Definition OpenGLManager.hpp:53
static const GLInfo & get_gl_info()
Definition OpenGLManager.hpp:106
#define GL_ALWAYS
Definition gl.h:230
#define GL_LESS
Definition gl.h:914
#define glCullFace
Definition gl.h:3555
#define glBindBuffer
Definition gl.h:3267
#define GL_POLYGON_OFFSET_FILL
Definition gl.h:1318
#define glEnable
Definition gl.h:3667
#define glPolygonOffset
Definition gl.h:4471
#define GL_SRC_ALPHA
Definition gl.h:1621
#define glDepthFunc
Definition gl.h:3593
#define GL_BACK
Definition gl.h:266
#define GL_ARRAY_BUFFER
Definition gl.h:238
#define GL_CULL_FACE
Definition gl.h:500
#define glBindTexture
Definition gl.h:3299
#define GL_BLEND
Definition gl.h:275
#define GL_ONE_MINUS_SRC_ALPHA
Definition gl.h:1239
#define GL_ONE
Definition gl.h:1232
#define GL_ELEMENT_ARRAY_BUFFER
Definition gl.h:636
#define GL_TEXTURE_2D
Definition gl.h:1739
#define glDisable
Definition gl.h:3607
#define glBlendFunc
Definition gl.h:3325
Vec3d build_plate_tilt_up_direction()
Definition GUI_App.cpp:10519
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65
std::pair< GLVolume *, std::pair< unsigned int, double > > GLVolumeWithIdAndZ
Definition 3DScene.hpp:413
Eigen::Matrix< float, 3, 3, Eigen::DontAlign > Matrix3f
Definition Point.hpp:85
GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs &volumes, GLVolumeCollection::ERenderType type, const Transform3d &view_matrix, std::function< bool(const GLVolume &)> filter_func)
Definition 3DScene.cpp:1110
std::vector< GLVolumeWithIdAndZ > GLVolumeWithIdAndZList
Definition 3DScene.hpp:414
Eigen::Matrix< double, 3, 3, Eigen::DontAlign > Matrix3d
Definition Point.hpp:86

References Slic3r::GUI::build_plate_tilt_up_direction(), Slic3r::GUI::OpenGLManager::get_gl_info(), get_selection_support_normal_z(), Slic3r::GLShaderProgram::get_uniform_location(), GL_ALWAYS, GL_ARRAY_BUFFER, GL_BACK, GL_BLEND, GL_CULL_FACE, GL_ELEMENT_ARRAY_BUFFER, GL_LESS, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_POLYGON_OFFSET_FILL, GL_SRC_ALPHA, GL_TEXTURE_2D, glBindBuffer, glBindTexture, glBlendFunc, glcheck, glCullFace, glDepthFunc, glDisable, glEnable, glPolygonOffset, glsafe, Slic3r::GLVolume::HS_None, Slic3r::GUI::OpenGLManager::GLInfo::is_core_profile(), m_clipping_plane, m_color_clip_plane, m_color_clip_plane_colors, m_print_volume, m_show_sinking_contours, m_slope, m_use_color_clip_plane, m_z_range, OUTLINE_DEPTH_TEX_UNIT, Slic3r::GLShaderProgram::set_uniform(), Slic3r::GLShaderProgram::start_using(), Slic3r::GLShaderProgram::stop_using(), Transparent, volumes, and Slic3r::volumes_to_render().

Here is the call graph for this function:

◆ reset_outside_state()

void Slic3r::GLVolumeCollection::reset_outside_state ( )
1780{
1781 for (GLVolume* volume : this->volumes)
1782 {
1783 if (volume != nullptr) {
1784 volume->is_outside = false;
1785 volume->partly_inside = false;
1786 }
1787 }
1788}

◆ set_clipping_plane()

void Slic3r::GLVolumeCollection::set_clipping_plane ( const std::array< double, 4 > & coeffs)
inline
537{ m_clipping_plane = coeffs; }

References m_clipping_plane.

◆ set_color_clip_plane()

void Slic3r::GLVolumeCollection::set_color_clip_plane ( const Vec3d & cp_normal,
double offset )
inline
543 {
544 for (int i = 0; i < 3; ++i)
545 m_color_clip_plane[i] = -cp_normal[i];
547 }

References m_color_clip_plane, and Slic3r::offset().

Here is the call graph for this function:

◆ set_color_clip_plane_colors()

void Slic3r::GLVolumeCollection::set_color_clip_plane_colors ( const std::array< ColorRGBA, 2 > & colors)
inline

◆ set_default_slope_normal_z()

void Slic3r::GLVolumeCollection::set_default_slope_normal_z ( )
inline
557{ m_slope.normal_z = -::cos(Geometry::deg2rad(90.0f - 45.0f)); }

References Slic3r::Geometry::deg2rad(), and m_slope.

Referenced by GLVolumeCollection().

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

◆ set_print_volume()

void Slic3r::GLVolumeCollection::set_print_volume ( const PrintVolume & print_volume)
inline
534{ m_print_volume = print_volume; }

References m_print_volume.

◆ set_range()

void Slic3r::GLVolumeCollection::set_range ( double low,
double high )
inline
532{ for (GLVolume *vol : this->volumes) vol->set_range(low, high); }

◆ set_show_sinking_contours()

void Slic3r::GLVolumeCollection::set_show_sinking_contours ( bool show)
inline

◆ set_slope_active()

void Slic3r::GLVolumeCollection::set_slope_active ( bool active)
inline
552{ m_slope.active = active; }

References m_slope.

◆ set_slope_GlobalActive()

void Slic3r::GLVolumeCollection::set_slope_GlobalActive ( bool active)
inline
553{ m_slope.isGlobalActive = active; }

References m_slope.

◆ set_slope_normal_z()

void Slic3r::GLVolumeCollection::set_slope_normal_z ( float normal_z)
inline
556{ m_slope.normal_z = normal_z; }

References m_slope.

◆ set_transparency()

void Slic3r::GLVolumeCollection::set_transparency ( float alpha)
1847{
1848 for (GLVolume *volume : volumes) {
1849 if (volume == nullptr || volume->is_modifier || volume->is_wipe_tower || (volume->volume_idx() < 0))
1850 continue;
1851
1852 volume->color.a(alpha);
1853 }
1854}

References volumes.

◆ set_use_color_clip_plane()

void Slic3r::GLVolumeCollection::set_use_color_clip_plane ( bool use)
inline

◆ set_z_range()

void Slic3r::GLVolumeCollection::set_z_range ( float min_z,
float max_z )
inline
536{ m_z_range[0] = min_z; m_z_range[1] = max_z; }

References m_z_range.

◆ total_memory_used()

size_t Slic3r::GLVolumeCollection::total_memory_used ( ) const
inline
575{ return this->cpu_memory_used() + this->gpu_memory_used(); }

References cpu_memory_used(), and gpu_memory_used().

Here is the call graph for this function:

◆ update_colors_by_extruder()

void Slic3r::GLVolumeCollection::update_colors_by_extruder ( const DynamicPrintConfig * config,
bool is_update_alpha = true )
1791{
1792
1793 using ColorItem = std::pair<std::string, ColorRGBA>;
1794 std::vector<ColorItem> colors;
1795
1796 if (config->has("printer_technology") && static_cast<PrinterTechnology>(config->opt_int("printer_technology")) == ptSLA) {
1797 const std::string& txt_color = config->opt_string("material_colour").empty() ?
1798 print_config_def.get("material_colour")->get_default_value<ConfigOptionString>()->value :
1799 config->opt_string("material_colour");
1800 ColorRGBA rgba;
1801 if (decode_color(txt_color, rgba))
1802 colors.push_back({ txt_color, rgba });
1803 }
1804 else {
1805 if (!config->has("filament_colour")) {
1806 return;
1807 }
1808 const ConfigOptionStrings* filamemts_opt = dynamic_cast<const ConfigOptionStrings*>(config->option("filament_colour"));
1809 if (filamemts_opt == nullptr)
1810 return;
1811
1812 size_t colors_count = (size_t)filamemts_opt->values.size();
1813 if (colors_count == 0)
1814 return;
1815 colors.resize(colors_count);
1816
1817 for (unsigned int i = 0; i < colors_count; ++i) {
1818 ColorRGBA rgba;
1819 const std::string& fil_color = config->opt_string("filament_colour", i);
1820 if (decode_color(fil_color, rgba))
1821 colors[i] = { fil_color, rgba };
1822 }
1823 }
1824
1825 for (GLVolume* volume : volumes) {
1826 if (volume == nullptr || volume->is_modifier || volume->is_wipe_tower || volume->volume_idx() < 0)
1827 continue;
1828
1829 int extruder_id = volume->extruder_id - 1;
1830 if (extruder_id < 0 || (int)colors.size() <= extruder_id)
1831 extruder_id = 0;
1832
1833 const ColorItem& color = colors[extruder_id];
1834 if (!color.first.empty()) {
1835 if (!is_update_alpha) {
1836 float old_a = volume->color.a();
1837 volume->color = color.second;
1838 volume->color.a(old_a);
1839 } else {
1840 volume->color = color.second;
1841 }
1842 }
1843 }
1844}
const ConfigOptionDef * get(const t_config_option_key &opt_key) const
Definition Config.hpp:2662
const T * get_default_value() const
Definition Config.hpp:2350
bool decode_color(const std::string &color_in, ColorRGB &color_out)
Definition Color.cpp:330
PrinterTechnology
Definition Config.hpp:229
@ ptSLA
Definition Config.hpp:233
const PrintConfigDef print_config_def
Definition PrintConfig.cpp:10099
zaa_minimize_perimeter_height ConfigOptionString
Definition PrintConfig.hpp:1702

References Slic3r::decode_color(), Slic3r::ConfigOptionResolver::has(), Slic3r::DynamicConfig::opt_int(), Slic3r::DynamicConfig::opt_string(), Slic3r::ConfigBase::option(), Slic3r::print_config_def, Slic3r::ptSLA, Slic3r::ConfigOptionVector< T >::values, and volumes.

Here is the call graph for this function:

Member Data Documentation

◆ m_clipping_plane

std::array<double, 4> Slic3r::GLVolumeCollection::m_clipping_plane
private

◆ m_color_clip_plane

std::array<double, 4> Slic3r::GLVolumeCollection::m_color_clip_plane
private

Referenced by render(), and set_color_clip_plane().

◆ m_color_clip_plane_colors

std::array<ColorRGBA, 2> Slic3r::GLVolumeCollection::m_color_clip_plane_colors { ColorRGBA::RED(), ColorRGBA::BLUE() }
private
static const ColorRGBA RED()
Definition Color.hpp:139
static const ColorRGBA BLUE()
Definition Color.hpp:128

Referenced by render(), and set_color_clip_plane_colors().

◆ m_print_volume

PrintVolume Slic3r::GLVolumeCollection::m_print_volume
private

Referenced by render(), and set_print_volume().

◆ m_render_volume

PrintVolume Slic3r::GLVolumeCollection::m_render_volume
private

Referenced by GLVolumeCollection().

◆ m_show_sinking_contours

bool Slic3r::GLVolumeCollection::m_show_sinking_contours = false
private

◆ m_slope

◆ m_use_color_clip_plane

bool Slic3r::GLVolumeCollection::m_use_color_clip_plane { false }
private
453{ false };

Referenced by render(), and set_use_color_clip_plane().

◆ m_z_range

std::array<float, 2> Slic3r::GLVolumeCollection::m_z_range
private

Referenced by get_z_range(), render(), and set_z_range().

◆ volumes


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/3DScene.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/3DScene.cpp