mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
Simple implementation of spRandom
This commit is contained in:
parent
5d6bf3261e
commit
fffb79a085
2 changed files with 248 additions and 173 deletions
|
@ -15,11 +15,6 @@ class SeamPlacer {
|
|||
public:
|
||||
void init(const Print& print);
|
||||
|
||||
bool is_custom(size_t layer_id) const {
|
||||
return ! ((m_enforcers.empty() || m_enforcers[layer_id].empty())
|
||||
&& (m_blockers.empty() || m_blockers[layer_id].empty()));
|
||||
}
|
||||
|
||||
Point get_seam(const size_t layer_idx, const SeamPosition seam_position,
|
||||
const ExtrusionLoop& loop, Point last_pos,
|
||||
coordf_t nozzle_diameter, const PrintObject* po,
|
||||
|
@ -32,17 +27,27 @@ private:
|
|||
std::map<const PrintObject*, Point> m_last_seam_position;
|
||||
|
||||
// Get indices of points inside enforcers and blockers.
|
||||
void get_indices(size_t layer_id,
|
||||
const Polygon& polygon,
|
||||
std::vector<size_t>& enforcers_idxs,
|
||||
std::vector<size_t>& blockers_idxs) const;
|
||||
void get_enforcers_and_blockers(size_t layer_id,
|
||||
const Polygon& polygon,
|
||||
std::vector<size_t>& enforcers_idxs,
|
||||
std::vector<size_t>& blockers_idxs) const;
|
||||
|
||||
void penalize_polygon(const Polygon& polygon,
|
||||
std::vector<float>& penalties,
|
||||
const std::vector<float>& lengths,
|
||||
int layer_id) const;
|
||||
// Apply penalties to points inside enforcers/blockers.
|
||||
void apply_custom_seam(const Polygon& polygon,
|
||||
std::vector<float>& penalties,
|
||||
const std::vector<float>& lengths,
|
||||
int layer_id) const;
|
||||
|
||||
static constexpr float ENFORCER_BLOCKER_PENALTY = 1e6;
|
||||
// Return random point of a polygon. The distribution will be uniform
|
||||
// along the contour and account for enforcers and blockers.
|
||||
Point get_random_seam(size_t layer_idx, const Polygon& polygon,
|
||||
bool* saw_custom = nullptr) const;
|
||||
|
||||
// Is there any enforcer/blocker on this layer?
|
||||
bool is_custom_seam_on_layer(size_t layer_id) const {
|
||||
return ! ((m_enforcers.empty() || m_enforcers[layer_id].empty())
|
||||
&& (m_blockers.empty() || m_blockers[layer_id].empty()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue