mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
ENH: boost is_support_necessary's performance
1. Parallelize the majority of overhang detection, leaving only a small part of sharp tail detection as sequential. This strategy makes is_support_necessary 10 times faster. 2. Use the overlaps function to detect overlapping, instead of using intersection().empty() 3. Control the max recursion depth to prevent crashing due to too deep recursion. Jira: STUDIO-2445, STUDIO-2458 Change-Id: I35283da3e4a22d7afe251b804ce30b90a9d754df (cherry picked from commit 1a6fedd1a0c82906f1807234ea1b816247ca6fd7)
This commit is contained in:
parent
6f298ac6f1
commit
6c489808a7
5 changed files with 280 additions and 325 deletions
|
@ -83,7 +83,7 @@ public:
|
|||
* \param layer The layer of interest
|
||||
* \return Polygons object
|
||||
*/
|
||||
const ExPolygons& get_avoidance(coordf_t radius, size_t layer_idx) const;
|
||||
const ExPolygons& get_avoidance(coordf_t radius, size_t layer_idx, int recursions=0) const;
|
||||
|
||||
Polygons get_contours(size_t layer_nr) const;
|
||||
Polygons get_contours_with_holes(size_t layer_nr) const;
|
||||
|
@ -94,11 +94,20 @@ private:
|
|||
/*!
|
||||
* \brief Convenience typedef for the keys to the caches
|
||||
*/
|
||||
using RadiusLayerPair = std::pair<coordf_t, size_t>;
|
||||
|
||||
struct RadiusLayerPair {
|
||||
coordf_t radius;
|
||||
size_t layer_nr;
|
||||
int recursions;
|
||||
|
||||
};
|
||||
struct RadiusLayerPairEquality {
|
||||
constexpr bool operator()(const RadiusLayerPair& _Left, const RadiusLayerPair& _Right) const {
|
||||
return _Left.radius == _Right.radius && _Left.layer_nr == _Right.layer_nr;
|
||||
}
|
||||
};
|
||||
struct RadiusLayerPairHash {
|
||||
size_t operator()(const RadiusLayerPair& elem) const {
|
||||
return std::hash<coord_t>()(elem.first) ^ std::hash<coord_t>()(elem.second * 7919);
|
||||
return std::hash<coord_t>()(elem.radius) ^ std::hash<coord_t>()(elem.layer_nr * 7919);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -168,8 +177,8 @@ public:
|
|||
* coconut: previously stl::unordered_map is used which seems problematic with tbb::parallel_for.
|
||||
* So we change to tbb::concurrent_unordered_map
|
||||
*/
|
||||
mutable tbb::concurrent_unordered_map<RadiusLayerPair, ExPolygons, RadiusLayerPairHash> m_collision_cache;
|
||||
mutable tbb::concurrent_unordered_map<RadiusLayerPair, ExPolygons, RadiusLayerPairHash> m_avoidance_cache;
|
||||
mutable tbb::concurrent_unordered_map<RadiusLayerPair, ExPolygons, RadiusLayerPairHash, RadiusLayerPairEquality> m_collision_cache;
|
||||
mutable tbb::concurrent_unordered_map<RadiusLayerPair, ExPolygons, RadiusLayerPairHash, RadiusLayerPairEquality> m_avoidance_cache;
|
||||
|
||||
friend TreeSupport;
|
||||
};
|
||||
|
@ -203,7 +212,7 @@ public:
|
|||
*/
|
||||
void generate();
|
||||
|
||||
void detect_overhangs();
|
||||
void detect_overhangs(bool detect_first_sharp_tail_only=false);
|
||||
|
||||
enum NodeType {
|
||||
eCircle,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue