# HG changeset patch # User Teemu Piippo # Date 1576357201 -7200 # Node ID cef43609a374904f7c81a20b4fa4d9383ee0d883 # Parent ed9685f44ab36366590ad2c3e08e07a119d8e046 fixed build diff -r ed9685f44ab3 -r cef43609a374 CMakeLists.txt --- a/CMakeLists.txt Sat Dec 14 22:36:06 2019 +0200 +++ b/CMakeLists.txt Sat Dec 14 23:00:01 2019 +0200 @@ -55,7 +55,7 @@ src/libraries.h src/main.h src/mainwindow.h - src/math.h + src/maths.h src/matrix.h src/model.h src/modeleditcontext.h diff -r ed9685f44ab3 -r cef43609a374 src/main.h --- a/src/main.h Sat Dec 14 22:36:06 2019 +0200 +++ b/src/main.h Sat Dec 14 23:00:01 2019 +0200 @@ -5,7 +5,7 @@ #include #include "basics.h" #include "utility.h" -#include "main.h" +#include "maths.h" namespace settingGroups { diff -r ed9685f44ab3 -r cef43609a374 src/math.h --- a/src/math.h Sat Dec 14 22:36:06 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -#pragma once -#include - -namespace math -{ - using std::abs; - using std::sqrt; - using std::sin; - using std::cos; - using std::tan; - using std::atan; - using std::atan2; - using std::acos; - using std::asin; - using std::exp; - using std::log; - using std::log10; - using std::hypot; - using std::min; - using std::max; - using std::floor; - using std::ceil; - using std::trunc; - using std::round; - template - auto hypot(T&& x, Rest&&... rest) - { - return math::hypot(x, math::hypot(rest...)); - } - template - auto max(T&& x, Rest&&... rest) - { - return math::max(x, math::max(rest...)); - } - template - auto min(T&& x, Rest&&... rest) - { - return math::min(x, math::min(rest...)); - } - constexpr double infinity = std::numeric_limits::infinity(); - constexpr double pi = M_PIl; -} diff -r ed9685f44ab3 -r cef43609a374 src/maths.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/maths.h Sat Dec 14 23:00:01 2019 +0200 @@ -0,0 +1,56 @@ +#pragma once +#include + +namespace math +{ + using std::abs; + using std::sqrt; + using std::sin; + using std::cos; + using std::tan; + using std::atan; + using std::atan2; + using std::acos; + using std::asin; + using std::exp; + using std::log; + using std::log10; + using std::hypot; + using std::floor; + using std::ceil; + using std::trunc; + using std::round; + template + inline auto hypot(T&& x, Rest&&... rest) + { + return math::hypot(x, math::hypot(rest...)); + } + template + const T& max(const T& x, const T& y) + { + if (x > y) + return x; + else + return y; + } + template + const T& max(const T& x, const T& y, Rest&&... rest) + { + return math::max(x, math::max(y, rest...)); + } + template + const T& min(const T& x, const T& y) + { + if (x < y) + return x; + else + return y; + } + template + const T& min(const T& x, const T& y, Rest&&... rest) + { + return math::min(x, math::min(y, rest...)); + } + constexpr double infinity = std::numeric_limits::infinity(); + constexpr long double pi = M_PIl; +} diff -r ed9685f44ab3 -r cef43609a374 src/types/boundingbox.cpp --- a/src/types/boundingbox.cpp Sat Dec 14 22:36:06 2019 +0200 +++ b/src/types/boundingbox.cpp Sat Dec 14 23:00:01 2019 +0200 @@ -26,12 +26,12 @@ void BoundingBox::consider(const Point3D& vertex) { - this->minimum.x = std::min(vertex.x, this->minimum.x); - this->minimum.y = std::min(vertex.y, this->minimum.y); - this->minimum.z = std::min(vertex.z, this->minimum.z); - this->maximum.x = std::max(vertex.x, this->maximum.x); - this->maximum.y = std::max(vertex.y, this->maximum.y); - this->maximum.z = std::max(vertex.z, this->maximum.z); + this->minimum.x = math::min(vertex.x, this->minimum.x); + this->minimum.y = math::min(vertex.y, this->minimum.y); + this->minimum.z = math::min(vertex.z, this->minimum.z); + this->maximum.x = math::max(vertex.x, this->maximum.x); + this->maximum.y = math::max(vertex.y, this->maximum.y); + this->maximum.z = math::max(vertex.z, this->maximum.z); } /* @@ -64,5 +64,5 @@ */ double spaceDiagonal(const BoundingBox& box) { - return distance(box.minimum, box.maximum); + return math::distance(box.minimum, box.maximum); } diff -r ed9685f44ab3 -r cef43609a374 src/types/boundingbox.h --- a/src/types/boundingbox.h Sat Dec 14 22:36:06 2019 +0200 +++ b/src/types/boundingbox.h Sat Dec 14 23:00:01 2019 +0200 @@ -18,7 +18,6 @@ #pragma once #include "vertex.h" -#include "math.h" class BoundingBox { diff -r ed9685f44ab3 -r cef43609a374 src/vertex.cpp --- a/src/vertex.cpp Sat Dec 14 22:36:06 2019 +0200 +++ b/src/vertex.cpp Sat Dec 14 23:00:01 2019 +0200 @@ -61,6 +61,11 @@ } } +Point3D::operator QVariant() const +{ + return QVariant::fromValue(*this); +} + void Point3D::assign(Axis axis, CoordinateType value) { this->get(axis) = value; diff -r ed9685f44ab3 -r cef43609a374 src/vertex.h --- a/src/vertex.h Sat Dec 14 22:36:06 2019 +0200 +++ b/src/vertex.h Sat Dec 14 23:00:01 2019 +0200 @@ -20,6 +20,7 @@ #include #include #include "basics.h" +#include "maths.h" struct Point3D { @@ -28,6 +29,7 @@ void assign(Axis axis, CoordinateType value); CoordinateType& get(Axis ax); CoordinateType get(Axis ax) const; + operator QVariant() const; }; namespace math