ENH: 3dbed: support rendering extruder area with different color

JIRA: STUDIO-7494
Change-Id: I717999e8b7ab1d7d350299b412a3a270c6ba7a9e
(cherry picked from commit 62b1d00d1fd6675fd067b76778d6a577dfae0c24)
This commit is contained in:
lane.wei
2024-09-02 19:51:02 +08:00
committed by Noisyfox
parent f702ad9fd2
commit 6e063bdc8d
7 changed files with 157 additions and 6 deletions

View File

@@ -12,9 +12,9 @@
namespace Slic3r {
struct GCodeProcessorResult;
enum class BuildVolume_Type : unsigned char {
enum class BuildVolume_Type : char {
// Not set yet or undefined.
Invalid,
Invalid = -1,
// Rectangular print bed. Most common, cheap to work with.
Rectangle,
// Circular print bed. Common on detals, cheap to work with.
@@ -24,6 +24,7 @@ enum class BuildVolume_Type : unsigned char {
// Some non convex shape.
Custom
};
// For collision detection of objects and G-code (extrusion paths) against the build volume.
class BuildVolume
{
@@ -31,12 +32,26 @@ public:
struct BuildExtruderVolume {
bool same_with_bed{false};
Type type{Type::Invalid};
BuildVolume_Type type{BuildVolume_Type::Invalid};
BoundingBox bbox;
BoundingBoxf3 bboxf;
Geometry::Circled circle;
};
struct BuildSharedVolume
{
// see: Bed3D::EShapeType
int type{ 0 };
// data contains:
// Rectangle:
// [0] = min.x, [1] = min.y, [2] = max.x, [3] = max.y
// Circle:
// [0] = center.x, [1] = center.y, [3] = radius
std::array<float, 4> data;
// [0] = min z, [1] = max z
std::array<float, 2> zs;
};
// Initialized to empty, all zeros, Invalid.
BuildVolume() {}
// Initialize from PrintConfig::printable_area and PrintConfig::printable_height
@@ -46,6 +61,7 @@ public:
const std::vector<Vec2d>& printable_area() const { return m_bed_shape; }
double printable_height() const { return m_max_print_height; }
const std::vector<std::vector<Vec2d>>& extruder_areas() const { return m_extruder_shapes; }
const BuildSharedVolume& get_shared_volume() const { return m_shared_volume; }
// Derived data
BuildVolume_Type type() const { return m_type; }
@@ -118,8 +134,9 @@ private:
// Source definition of the print bed geometry (PrintConfig::printable_area)
std::vector<Vec2d> m_bed_shape;
//BBS: extruder shapes
std::vector<std::vector<Vec2d>> m_extruder_shapes;
std::vector<std::vector<Vec2d>> m_extruder_shapes; //original data from config
std::vector<BuildExtruderVolume> m_extruder_volumes;
BuildSharedVolume m_shared_volume; //used for rendering
// Source definition of the print volume height (PrintConfig::printable_height)
double m_max_print_height { 0.f };