mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
Tech ENABLE_SEQUENTIAL_LIMITS -> 1st installment of visualization of objects clearance for sequential prints
This commit is contained in:
parent
9537c4e8d0
commit
75677ba810
14 changed files with 889 additions and 87 deletions
|
@ -1194,9 +1194,18 @@ bool Print::has_brim() const
|
|||
return std::any_of(m_objects.begin(), m_objects.end(), [](PrintObject *object) { return object->has_brim(); });
|
||||
}
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
bool Print::sequential_print_horizontal_clearance_valid(const Print& print, Polygons* polygons)
|
||||
#else
|
||||
static inline bool sequential_print_horizontal_clearance_valid(const Print &print)
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
{
|
||||
Polygons convex_hulls_other;
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
std::vector<size_t> intersecting_idxs;
|
||||
bool intersection_detected = false;
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
std::map<ObjectID, Polygon> map_model_object_to_convex_hull;
|
||||
for (const PrintObject *print_object : print.objects()) {
|
||||
assert(! print_object->model_object()->instances.empty());
|
||||
|
@ -1221,21 +1230,49 @@ static inline bool sequential_print_horizontal_clearance_valid(const Print &prin
|
|||
}
|
||||
// Make a copy, so it may be rotated for instances.
|
||||
Polygon convex_hull0 = it_convex_hull->second;
|
||||
double z_diff = Geometry::rotation_diff_z(model_instance0->get_rotation(), print_object->instances().front().model_instance->get_rotation());
|
||||
const double z_diff = Geometry::rotation_diff_z(model_instance0->get_rotation(), print_object->instances().front().model_instance->get_rotation());
|
||||
if (std::abs(z_diff) > EPSILON)
|
||||
convex_hull0.rotate(z_diff);
|
||||
// Now we check that no instance of convex_hull intersects any of the previously checked object instances.
|
||||
for (const PrintInstance &instance : print_object->instances()) {
|
||||
Polygon convex_hull = convex_hull0;
|
||||
// instance.shift is a position of a centered object, while model object may not be centered.
|
||||
// Conver the shift from the PrintObject's coordinates into ModelObject's coordinates by removing the centering offset.
|
||||
// Convert the shift from the PrintObject's coordinates into ModelObject's coordinates by removing the centering offset.
|
||||
convex_hull.translate(instance.shift - print_object->center_offset());
|
||||
if (! intersection(convex_hulls_other, (Polygons)convex_hull).empty())
|
||||
return false;
|
||||
convex_hulls_other.emplace_back(std::move(convex_hull));
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
for (size_t i = 0; i < convex_hulls_other.size(); ++i) {
|
||||
if (!intersection((Polygons)convex_hulls_other[i], (Polygons)convex_hull).empty()) {
|
||||
if (polygons == nullptr)
|
||||
return false;
|
||||
else {
|
||||
intersection_detected = true;
|
||||
intersecting_idxs.push_back(i);
|
||||
intersecting_idxs.push_back(convex_hulls_other.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!intersection(convex_hulls_other, (Polygons)convex_hull).empty())
|
||||
return false;
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
convex_hulls_other.emplace_back(std::move(convex_hull));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
if (intersection_detected) {
|
||||
assert(polygons != nullptr);
|
||||
|
||||
std::sort(intersecting_idxs.begin(), intersecting_idxs.end());
|
||||
intersecting_idxs.erase(std::unique(intersecting_idxs.begin(), intersecting_idxs.end()), intersecting_idxs.end());
|
||||
for (size_t i : intersecting_idxs) {
|
||||
polygons->emplace_back(std::move(convex_hulls_other[i]));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool sequential_print_vertical_clearance_valid(const Print &print)
|
||||
|
|
|
@ -502,6 +502,10 @@ public:
|
|||
const PrintRegion* get_region(size_t idx) const { return m_regions[idx]; }
|
||||
const ToolOrdering& get_tool_ordering() const { return m_wipe_tower_data.tool_ordering; } // #ys_FIXME just for testing
|
||||
|
||||
#if ENABLE_SEQUENTIAL_LIMITS
|
||||
static bool sequential_print_horizontal_clearance_valid(const Print& print, Polygons* polygons = nullptr);
|
||||
#endif // ENABLE_SEQUENTIAL_LIMITS
|
||||
|
||||
protected:
|
||||
// methods for handling regions
|
||||
PrintRegion* get_region(size_t idx) { return m_regions[idx]; }
|
||||
|
|
|
@ -63,6 +63,8 @@
|
|||
#define ENABLE_START_GCODE_VISUALIZATION (1 && ENABLE_2_4_0_ALPHA0)
|
||||
// Enable visualization of seams in preview
|
||||
#define ENABLE_SEAMS_VISUALIZATION (1 && ENABLE_2_4_0_ALPHA0)
|
||||
// Enable visualization of objects clearance for sequential prints
|
||||
#define ENABLE_SEQUENTIAL_LIMITS (1 && ENABLE_2_4_0_ALPHA0)
|
||||
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue