OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::SeamPlacerImpl::SeamComparator Struct Reference

Public Member Functions

 SeamComparator (SeamPosition setup)
bool is_first_better (const SeamCandidate &a, const SeamCandidate &b, const Vec2f &preffered_location=Vec2f { 0.0f, 0.0f }) const
bool is_first_not_much_worse (const SeamCandidate &a, const SeamCandidate &b) const
bool are_similar (const SeamCandidate &a, const SeamCandidate &b) const

Public Attributes

SeamPosition setup
float angle_importance

Detailed Description

Constructor & Destructor Documentation

◆ SeamComparator()

Slic3r::SeamPlacerImpl::SeamComparator::SeamComparator ( SeamPosition setup)
inlineexplicit
1170 :
1171 setup(setup) {
1174 }
static constexpr float angle_importance_nearest
Definition SeamPlacer.hpp:147
static constexpr float angle_importance_aligned
Definition SeamPlacer.hpp:146
@ spNearest
Definition PrintConfig.hpp:395
SeamPosition setup
Definition SeamPlacer.cpp:1168
float angle_importance
Definition SeamPlacer.cpp:1169

References angle_importance, Slic3r::SeamPlacer::angle_importance_aligned, Slic3r::SeamPlacer::angle_importance_nearest, setup, and Slic3r::spNearest.

Member Function Documentation

◆ are_similar()

bool Slic3r::SeamPlacerImpl::SeamComparator::are_similar ( const SeamCandidate & a,
const SeamCandidate & b ) const
inline
1273 {
1275 }
bool is_first_not_much_worse(const SeamCandidate &a, const SeamCandidate &b) const
Definition SeamPlacer.cpp:1227

References is_first_not_much_worse().

Referenced by Slic3r::SeamPlacerImpl::pick_random_seam_point().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_first_better()

bool Slic3r::SeamPlacerImpl::SeamComparator::is_first_better ( const SeamCandidate & a,
const SeamCandidate & b,
const Vec2f & preffered_location = Vec2f { 0.0f, 0.0f } ) const
inline
1178 { 0.0f,
1179 0.0f }) const {
1180 if ((setup == SeamPosition::spAligned || setup == SeamPosition::spAlignedBack) && a.central_enforcer != b.central_enforcer) {
1181 return a.central_enforcer;
1182 }
1183
1184 // Blockers/Enforcers discrimination, top priority
1185 if (a.type != b.type) {
1186 return a.type > b.type;
1187 }
1188
1189 //avoid overhangs
1190 if (a.overhang > 0.0f || b.overhang > 0.0f) {
1191 return a.overhang < b.overhang;
1192 }
1193
1194 // prefer hidden points (more than 0.5 mm inside)
1195 if (a.embedded_distance < -0.5f && b.embedded_distance > -0.5f) {
1196 return true;
1197 }
1198 if (b.embedded_distance < -0.5f && a.embedded_distance > -0.5f) {
1199 return false;
1200 }
1201
1202 if (setup == SeamPosition::spRear && a.position.y() != b.position.y()) {
1203 return a.position.y() > b.position.y();
1204 }
1205
1206 float distance_penalty_a = 0.0f;
1207 float distance_penalty_b = 0.0f;
1208 if (setup == spNearest) {
1209 distance_penalty_a = 1.0f - gauss((a.position.head<2>() - preffered_location).norm(), 0.0f, 1.0f, 0.005f);
1210 distance_penalty_b = 1.0f - gauss((b.position.head<2>() - preffered_location).norm(), 0.0f, 1.0f, 0.005f);
1211 }
1212
1213 // the penalites are kept close to range [0-1.x] however, it should not be relied upon
1214 float penalty_a = a.overhang + a.visibility +
1215 angle_importance * compute_angle_penalty(a.local_ccw_angle)
1216 + distance_penalty_a;
1217 float penalty_b = b.overhang + b.visibility +
1218 angle_importance * compute_angle_penalty(b.local_ccw_angle)
1219 + distance_penalty_b;
1220
1221 return penalty_a < penalty_b;
1222 }
float compute_angle_penalty(float ccw_angle)
Definition SeamPlacer.cpp:82
float gauss(float value, float mean_x_coord, float mean_value, float falloff_speed)
Definition SeamPlacer.cpp:75
@ spAligned
Definition PrintConfig.hpp:395
@ spAlignedBack
Definition PrintConfig.hpp:395
@ spRear
Definition PrintConfig.hpp:395

Referenced by Slic3r::SeamPlacer::find_next_seam_in_layer(), Slic3r::SeamPlacerImpl::pick_nearest_seam_point_index(), and Slic3r::SeamPlacerImpl::pick_seam_point().

Here is the caller graph for this function:

◆ is_first_not_much_worse()

bool Slic3r::SeamPlacerImpl::SeamComparator::is_first_not_much_worse ( const SeamCandidate & a,
const SeamCandidate & b ) const
inline
1227 {
1228 // Blockers/Enforcers discrimination, top priority
1229 if ((setup == SeamPosition::spAligned || setup == SeamPosition::spAlignedBack) && a.central_enforcer != b.central_enforcer) {
1230 // Prefer centers of enforcers.
1231 return a.central_enforcer;
1232 }
1233
1234 if (a.type != b.type) {
1235 return a.type > b.type;
1236 }
1237
1238 // Two Blocked points fall through like Neutral ones, so a perimeter blocked all round still gets a proper seam.
1239 if (a.type == EnforcedBlockedSeamPoint::Enforced) {
1240 return true;
1241 }
1242
1243 //avoid overhangs
1244 if ((a.overhang > 0.0f || b.overhang > 0.0f)
1245 && abs(a.overhang - b.overhang) > (0.1f * a.perimeter.flow_width)) {
1246 return a.overhang < b.overhang;
1247 }
1248
1249 // prefer hidden points (more than 0.5 mm inside)
1250 if (a.embedded_distance < -0.5f && b.embedded_distance > -0.5f) {
1251 return true;
1252 }
1253 if (b.embedded_distance < -0.5f && a.embedded_distance > -0.5f) {
1254 return false;
1255 }
1256
1258 return true;
1259 }
1260
1261 if (setup == SeamPosition::spRear) {
1262 return a.position.y() + SeamPlacer::seam_align_score_tolerance * 5.0f > b.position.y();
1263 }
1264
1265 float penalty_a = a.overhang + a.visibility
1266 + angle_importance * compute_angle_penalty(a.local_ccw_angle);
1267 float penalty_b = b.overhang + b.visibility +
1268 angle_importance * compute_angle_penalty(b.local_ccw_angle);
1269
1270 return penalty_a <= penalty_b || penalty_a - penalty_b < SeamPlacer::seam_align_score_tolerance;
1271 }
static constexpr float seam_align_score_tolerance
Definition SeamPlacer.hpp:154
@ spRandom
Definition PrintConfig.hpp:395

References angle_importance, Slic3r::SeamPlacerImpl::SeamCandidate::central_enforcer, Slic3r::SeamPlacerImpl::compute_angle_penalty(), Slic3r::SeamPlacerImpl::SeamCandidate::embedded_distance, Slic3r::SeamPlacerImpl::Enforced, Slic3r::SeamPlacerImpl::Perimeter::flow_width, Slic3r::SeamPlacerImpl::SeamCandidate::local_ccw_angle, Slic3r::SeamPlacerImpl::SeamCandidate::overhang, Slic3r::SeamPlacerImpl::SeamCandidate::perimeter, Slic3r::SeamPlacerImpl::SeamCandidate::position, Slic3r::SeamPlacer::seam_align_score_tolerance, setup, Slic3r::spAligned, Slic3r::spAlignedBack, Slic3r::spRandom, Slic3r::spRear, Slic3r::SeamPlacerImpl::SeamCandidate::type, and Slic3r::SeamPlacerImpl::SeamCandidate::visibility.

Referenced by are_similar(), Slic3r::SeamPlacer::find_next_seam_in_layer(), and Slic3r::SeamPlacerImpl::pick_random_seam_point().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ angle_importance

float Slic3r::SeamPlacerImpl::SeamComparator::angle_importance

◆ setup

SeamPosition Slic3r::SeamPlacerImpl::SeamComparator::setup

The documentation for this struct was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode/SeamPlacer.cpp