mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-01-30 15:38:43 +03:00
Optimized exclusion region
This commit is contained in:
@@ -31,7 +31,29 @@ public:
|
|||||||
: BoundingBoxBase(points.begin(), points.end())
|
: BoundingBoxBase(points.begin(), points.end())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void reset() { this->defined = false; this->min = PointType::Zero(); this->max = PointType::Zero(); }
|
void reset()
|
||||||
|
{
|
||||||
|
this->defined = false;
|
||||||
|
this->min = PointType::Zero();
|
||||||
|
this->max = PointType::Zero();
|
||||||
|
}
|
||||||
|
// B66
|
||||||
|
Polygon polygon(bool is_scaled = false) const
|
||||||
|
{
|
||||||
|
Polygon polygon;
|
||||||
|
polygon.points.clear();
|
||||||
|
polygon.points.resize(4);
|
||||||
|
double scale_factor = 1 / (is_scaled ? SCALING_FACTOR : 1);
|
||||||
|
polygon.points[0](0) = this->min(0) * scale_factor;
|
||||||
|
polygon.points[0](1) = this->min(1) * scale_factor;
|
||||||
|
polygon.points[1](0) = this->max(0) * scale_factor;
|
||||||
|
polygon.points[1](1) = this->min(1) * scale_factor;
|
||||||
|
polygon.points[2](0) = this->max(0) * scale_factor;
|
||||||
|
polygon.points[2](1) = this->max(1) * scale_factor;
|
||||||
|
polygon.points[3](0) = this->min(0) * scale_factor;
|
||||||
|
polygon.points[3](1) = this->max(1) * scale_factor;
|
||||||
|
return polygon;
|
||||||
|
};
|
||||||
void merge(const PointType &point);
|
void merge(const PointType &point);
|
||||||
void merge(const PointsType &points);
|
void merge(const PointsType &points);
|
||||||
void merge(const BoundingBoxBase<PointType, PointsType> &bb);
|
void merge(const BoundingBoxBase<PointType, PointsType> &bb);
|
||||||
|
|||||||
@@ -339,6 +339,7 @@ BuildVolume::ObjectState BuildVolume::volume_state_bbox(const BoundingBoxf3& vol
|
|||||||
else if (tem_build_volume.intersects(volume_bbox)) {
|
else if (tem_build_volume.intersects(volume_bbox)) {
|
||||||
is_contain = false;
|
is_contain = false;
|
||||||
is_intersect = true;
|
is_intersect = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_max_print_height == 0.0)
|
if (m_max_print_height == 0.0)
|
||||||
@@ -369,32 +370,33 @@ bool BuildVolume::all_paths_inside(const GCodeProcessorResult& paths, const Boun
|
|||||||
build_volume.max.z() = std::numeric_limits<double>::max();
|
build_volume.max.z() = std::numeric_limits<double>::max();
|
||||||
if (ignore_bottom)
|
if (ignore_bottom)
|
||||||
build_volume.min.z() = -std::numeric_limits<double>::max();
|
build_volume.min.z() = -std::numeric_limits<double>::max();
|
||||||
std::vector<BoundingBox3Base<Vec3d>> exclude_build_volume;
|
// B66
|
||||||
|
Points pts;
|
||||||
|
for (const GCodeProcessorResult::MoveVertex &move : paths.moves) {
|
||||||
|
if (move.type == EMoveType::Extrude && move.extrusion_role != GCodeExtrusionRole::Custom && move.width != 0.0f &&
|
||||||
|
move.height != 0.0f)
|
||||||
|
pts.emplace_back(Point(scale_(move.position.x()), scale_(move.position.y())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((build_volume.contains(paths_bbox))) {
|
||||||
|
if (m_exclude_bed_shape.size() > 0) {
|
||||||
|
Slic3r::Polygon convex_hull_2d = Slic3r::Geometry::convex_hull(std::move(pts));
|
||||||
for (int i = 1; i < m_exclude_bed_shape.size(); i += 7) {
|
for (int i = 1; i < m_exclude_bed_shape.size(); i += 7) {
|
||||||
std::vector<Vec2d> tem_exclude_bed_shap;
|
std::vector<Vec2d> tem_exclude_bed_shap;
|
||||||
for (int j = 1; j < 5; j++)
|
for (int j = 1; j < 6; j++)
|
||||||
tem_exclude_bed_shap.push_back(m_exclude_bed_shape[i + j]);
|
tem_exclude_bed_shap.push_back(m_exclude_bed_shape[i + j]);
|
||||||
BoundingBoxf tem_bboxf = get_extents(tem_exclude_bed_shap);
|
BoundingBoxf tem_bboxf = get_extents(tem_exclude_bed_shap);
|
||||||
auto tem_exclude_bboxf = BoundingBoxf3{to_3d(tem_bboxf.min, 0.), to_3d(tem_bboxf.max, m_max_print_height)};
|
auto tem_exclude_bboxf = BoundingBoxf3{to_3d(tem_bboxf.min, 0.), to_3d(tem_bboxf.max, m_max_print_height)};
|
||||||
BoundingBox3Base<Vec3d> tem_build_volume = tem_exclude_bboxf.inflated(SceneEpsilon);
|
Slic3r::Polygon p = tem_exclude_bboxf.polygon(true); // instance convex hull is scaled, so we need to scale here
|
||||||
exclude_build_volume.push_back(tem_build_volume);
|
if (intersection({p}, {convex_hull_2d}).empty() == false) {
|
||||||
}
|
return false;
|
||||||
|
|
||||||
bool is_contain = false;
|
|
||||||
bool is_intersect = false;
|
|
||||||
|
|
||||||
for (const auto &tem_build_volume : exclude_build_volume) {
|
|
||||||
if (tem_build_volume.contains(paths_bbox)) {
|
|
||||||
is_contain = true;
|
|
||||||
is_intersect = false;
|
|
||||||
break;
|
break;
|
||||||
} else if (tem_build_volume.intersects(paths_bbox)) {
|
}
|
||||||
is_contain = false;
|
}
|
||||||
is_intersect = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (build_volume.contains(paths_bbox) && !is_contain && !is_intersect);
|
return build_volume.contains(paths_bbox);
|
||||||
}
|
}
|
||||||
case Type::Circle:
|
case Type::Circle:
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user