-
-
Notifications
You must be signed in to change notification settings - Fork 889
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/upstream/5.9' into fix-enc…
…ompassing-hole-alternative
- Loading branch information
Showing
15 changed files
with
440 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2024 Ultimaker B.V. | ||
// CuraEngine is released under the terms of the AGPLv3 or higher. | ||
|
||
#ifndef UTILS_CRITERION_SCORE_H | ||
#define UTILS_CRITERION_SCORE_H | ||
|
||
namespace cura | ||
{ | ||
|
||
/*! | ||
* This structure represents a score given by a single crtierion when calculating a global score to select a best | ||
* candidate among a list with multiple criteria. | ||
*/ | ||
struct CriterionScore | ||
{ | ||
/*! | ||
* The score given by the criterion. To ensure a proper selection, this value must be contained in [0.0, 1.0] and | ||
* the different given scores must be evenly distributed in this range. | ||
*/ | ||
double score{ 0.0 }; | ||
|
||
/*! | ||
* The weight to be given when taking this score into the global score. A score that contributes "normally" to the | ||
* global score should have a weight of 1.0, and others should be adjusted around this value, to give them more or | ||
* less influence. | ||
*/ | ||
double weight{ 0.0 }; | ||
}; | ||
|
||
} // namespace cura | ||
#endif // UTILS_CRITERION_SCORE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) 2024 Ultimaker B.V. | ||
// CuraEngine is released under the terms of the AGPLv3 or higher. | ||
|
||
#ifndef UTILS_SCORE_H | ||
#define UTILS_SCORE_H | ||
|
||
#include <fmt/format.h> | ||
|
||
#include "CriterionScore.h" | ||
|
||
namespace cura | ||
{ | ||
|
||
/*! | ||
* This class represents a score to be calculated over different criteria, to select the best candidate among a list. | ||
*/ | ||
class Score | ||
{ | ||
private: | ||
double value_{ 0.0 }; | ||
|
||
public: | ||
/*! | ||
* Get the actual score value, should be used for debug purposes only | ||
*/ | ||
double getValue() const | ||
{ | ||
return value_; | ||
} | ||
|
||
/*! | ||
* Add the calculated score of an inidividual criterion to the global score, taking care of its weight | ||
*/ | ||
void operator+=(const CriterionScore& criterion_score) | ||
{ | ||
value_ += criterion_score.score * criterion_score.weight; | ||
} | ||
|
||
/*! | ||
* Comparison operators to allow selecting the best global score | ||
*/ | ||
auto operator<=>(const Score&) const = default; | ||
}; | ||
|
||
} // namespace cura | ||
|
||
namespace fmt | ||
{ | ||
|
||
template<> | ||
struct formatter<cura::Score> : formatter<std::string> | ||
{ | ||
auto format(const cura::Score& score, format_context& ctx) | ||
{ | ||
return fmt::format_to(ctx.out(), "Score{{{}}}", score.getValue()); | ||
} | ||
}; | ||
|
||
} // namespace fmt | ||
|
||
#endif // UTILS_SCORE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.