Change std::nan("") to proper nan constants

This commit is contained in:
tamasmeszaros 2022-05-09 13:11:01 +02:00
parent 12a54251c9
commit fed317f27b
10 changed files with 22 additions and 16 deletions

View File

@ -771,8 +771,8 @@ inline bool is_any_triangle_in_radius(
auto distancer = detail::IndexedTriangleSetDistancer<VertexType, IndexedFaceType, TreeType, VectorType>
{ vertices, faces, tree, point };
size_t hit_idx;
VectorType hit_point = VectorType::Ones() * (std::nan(""));
size_t hit_idx;
VectorType hit_point = VectorType::Ones() * (NaN<typename VectorType::Scalar>);
if(tree.empty())
{

View File

@ -15,7 +15,7 @@ class CircleBed {
double radius_;
public:
inline CircleBed(): center_(0, 0), radius_(std::nan("")) {}
inline CircleBed(): center_(0, 0), radius_(NaNd) {}
explicit inline CircleBed(const Point& c, double r): center_(c), radius_(r) {}
inline double radius() const { return radius_; }

View File

@ -41,13 +41,13 @@ template<size_t N> using Bounds = std::array<Bound, N>;
class StopCriteria {
// If the absolute value difference between two scores.
double m_abs_score_diff = std::nan("");
double m_abs_score_diff = NaNd;
// If the relative value difference between two scores.
double m_rel_score_diff = std::nan("");
double m_rel_score_diff = NaNd;
// Stop if this value or better is found.
double m_stop_score = std::nan("");
double m_stop_score = NaNd;
// A predicate that if evaluates to true, the optimization should terminate
// and the best result found prior to termination should be returned.

View File

@ -76,7 +76,7 @@ struct Facestats {
// Try to guess the number of support points needed to support a mesh
double get_misalginment_score(const TriangleMesh &mesh, const Transform3f &tr)
{
if (mesh.its.vertices.empty()) return std::nan("");
if (mesh.its.vertices.empty()) return NaNd;
auto accessfn = [&mesh, &tr](size_t fi) {
Facestats fc{get_transformed_triangle(mesh, tr, fi)};
@ -117,7 +117,7 @@ inline double get_supportedness_score(const Facestats &fc)
// Try to guess the number of support points needed to support a mesh
double get_supportedness_score(const TriangleMesh &mesh, const Transform3f &tr)
{
if (mesh.its.vertices.empty()) return std::nan("");
if (mesh.its.vertices.empty()) return NaNd;
auto accessfn = [&mesh, &tr](size_t fi) {
Facestats fc{get_transformed_triangle(mesh, tr, fi)};
@ -149,10 +149,10 @@ float find_ground_level(const TriangleMesh &mesh,
return execution::reduce(ex_tbb, size_t(0), vsize, zmin, minfn, accessfn, granularity);
}
float get_supportedness_onfloor_score(const TriangleMesh &mesh,
const Transform3f & tr)
double get_supportedness_onfloor_score(const TriangleMesh &mesh,
const Transform3f &tr)
{
if (mesh.its.vertices.empty()) return std::nan("");
if (mesh.its.vertices.empty()) return NaNd;
size_t Nthreads = std::thread::hardware_concurrency();

View File

@ -654,7 +654,7 @@ void SupportTreeBuildsteps::filter()
for (const SupportPoint &sp : m_support_pts) {
m_thr();
heads.emplace_back(
std::nan(""),
NaNd,
sp.head_front_radius,
0.,
m_cfg.head_penetration_mm,

View File

@ -1036,7 +1036,7 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() {
// Estimated printing time
// A layers count o the highest object
if (printer_input.size() == 0)
print_statistics.estimated_print_time = std::nan("");
print_statistics.estimated_print_time = NaNd;
else {
print_statistics.estimated_print_time = estim_time;
print_statistics.layers_times = layers_times;

View File

@ -331,6 +331,12 @@ public:
inline bool empty() const { return size() == 0; }
};
template<class T, class = FloatingOnly<T>>
constexpr T NaN = std::numeric_limits<T>::quiet_NaN();
constexpr float NaNf = NaN<float>;
constexpr double NaNd = NaN<double>;
} // namespace Slic3r
#endif

View File

@ -1163,7 +1163,7 @@ void Control::draw_ruler(wxDC& dc)
}
};
double short_tick = std::nan("");
double short_tick = NaNd;
int tick = 0;
double value = 0.0;
size_t sequence = 0;

View File

@ -822,7 +822,7 @@ public:
class WipeTowerInfo {
protected:
Vec2d m_pos = {std::nan(""), std::nan("")};
Vec2d m_pos = {NaNd, NaNd};
double m_rotation = 0.;
BoundingBoxf m_bb;
friend class GLCanvas3D;

View File

@ -386,7 +386,7 @@ long raster_pxsum(const sla::RasterGrayscaleAA &raster)
double raster_white_area(const sla::RasterGrayscaleAA &raster)
{
if (raster.resolution().pixels() == 0) return std::nan("");
if (raster.resolution().pixels() == 0) return NaNd;
auto res = raster.resolution();
double a = 0;