mirror of
https://git.mirrors.martin98.com/https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-01 08:41:59 +08:00

* Fix calls to depreciated wxPen constructor * Fix use of wxTimerEvent * Fix unrecognized character escape sequence * Fix signed/unsigned mismatch At least as much as possible without significantly altering parts of the application * Clean unreferenced variables * fix mistyped namespace selector * Update deprecated calls * Fix preprocessor statement * Remove empty switch statements * Change int vector used as bool to bool vector * Remove empty control statements and related unused code * Change multi character constant to string constant * Fix discarded return value json::parse was being called on the object, rather than statically like it should be. Also, the value was not being captured. * Rename ICON_SIZE def used by MultiMachine By having the definition in the header, it causes issues when other files define ICON_SIZE. By renaming it to MM_ICON_SIZE, this lessens the issue. It would probably be ideal to have the definitions in the respective .cpp that use them, but it would make it less convenient to update the values if needed in the future. * Remove unused includes * Fix linux/macOS compilation * Hide unused-function errors on non-Windows systems * Disable signed/unsigned comparison mismatch error * Remove/Disable more unused variables Still TODO: check double for loop in Print.cpp * Remove unused variable that was missed * Remove unused variables in libraries in the src folder * Apply temporary fix for subobject linkage error * Remove/Disable last set of unused variables reported by GCC * remove redundant for loop * fix misspelled ifdef check * Update message on dialog * Fix hard-coded platform specific modifier keys * Remove duplicate for loop * Disable -Wmisleading-indentation warning * disable -Wswitch warning * Remove unused local typedefs * Fix -Wunused-value * Fix pragma error on Windows from subobject linkage fix * Fix -Waddress * Fix null conversions (-Wconversion-null) --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
53 lines
2.1 KiB
C++
53 lines
2.1 KiB
C++
#include "../Layer.hpp"
|
|
|
|
#include "RetractWhenCrossingPerimeters.hpp"
|
|
|
|
namespace Slic3r {
|
|
|
|
bool RetractWhenCrossingPerimeters::travel_inside_internal_regions(const Layer &layer, const Polyline &travel)
|
|
{
|
|
if (m_layer != &layer) {
|
|
// Update cache.
|
|
m_layer = &layer;
|
|
m_internal_islands.clear();
|
|
m_aabbtree_internal_islands.clear();
|
|
// Collect expolygons of internal slices.
|
|
for (const LayerRegion *layerm : layer.regions())
|
|
for (const Surface &surface : layerm->get_slices().surfaces)
|
|
if (surface.is_internal())
|
|
m_internal_islands.emplace_back(&surface.expolygon);
|
|
// Calculate bounding boxes of internal slices.
|
|
std::vector<AABBTreeIndirect::BoundingBoxWrapper> bboxes;
|
|
bboxes.reserve(m_internal_islands.size());
|
|
for (size_t i = 0; i < m_internal_islands.size(); ++ i)
|
|
bboxes.emplace_back(i, get_extents(*m_internal_islands[i]));
|
|
// Build AABB tree over bounding boxes of internal slices.
|
|
m_aabbtree_internal_islands.build_modify_input(bboxes);
|
|
}
|
|
|
|
BoundingBox bbox_travel = get_extents(travel);
|
|
AABBTree::BoundingBox bbox_travel_eigen{ bbox_travel.min, bbox_travel.max };
|
|
int result = -1;
|
|
bbox_travel.offset(SCALED_EPSILON);
|
|
AABBTreeIndirect::traverse(m_aabbtree_internal_islands,
|
|
[&bbox_travel_eigen](const AABBTree::Node &node) {
|
|
return bbox_travel_eigen.intersects(node.bbox);
|
|
},
|
|
[&travel, &bbox_travel, &result, &islands = m_internal_islands](const AABBTree::Node &node) {
|
|
assert(node.is_leaf());
|
|
assert(node.is_valid());
|
|
Polygons clipped = ClipperUtils::clip_clipper_polygons_with_subject_bbox(*islands[node.idx], bbox_travel);
|
|
if (diff_pl(travel, clipped).empty()) {
|
|
// Travel path is completely inside an "internal" island. Don't retract.
|
|
result = int(node.idx);
|
|
// Stop traversal.
|
|
return false;
|
|
}
|
|
// Continue traversal.
|
|
return true;
|
|
});
|
|
return result != -1;
|
|
}
|
|
|
|
} // namespace Slic3r
|