Commit d641f04c authored by Simon Spannagel's avatar Simon Spannagel
Browse files

MeshConverter: add check about NaN & inf interpolation results

parent 9846fa6c
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@

#include <Eigen/Eigen>
#include <array>
#include <cmath>
#include <utility>

#include "core/utils/log.h"
@@ -26,6 +27,8 @@ namespace mesh_converter {
        Point(double px, double py, double pz) noexcept : x(px), y(py), z(pz), dim(3){};
        Point(double py, double pz) noexcept : y(py), z(pz), dim(2){};

        bool isFinite() const { return std::isfinite(x) && std::isfinite(y) && std::isfinite(z); };

        double x{0}, y{0}, z{0};
        unsigned int dim{0};

@@ -154,6 +157,10 @@ namespace mesh_converter {
            if(valid_) {
                LOG(DEBUG) << element.print(reference_);
                result_ = element.getObservable(reference_);
                if(!result_.isFinite()) {
                    LOG(WARNING) << "Interpolated result not a finite number at " << reference_;
                    return false;
                }
            }

            return valid_;