Tensor meshing - mesh generation

This commit is contained in:
Jakub Melka
2019-09-20 18:19:21 +02:00
parent f3f0edffe5
commit 252203d6b9
4 changed files with 703 additions and 109 deletions

View File

@ -25,6 +25,7 @@
#include <QDataStream>
#include <vector>
#include <iterator>
namespace pdf
{
@ -136,6 +137,64 @@ private:
Value* m_value;
};
/// Implements range for range based for cycles
template<typename T>
class PDFIntegerRange
{
public:
explicit inline constexpr PDFIntegerRange(T begin, T end) : m_begin(begin), m_end(end) { }
struct Iterator : public std::iterator<std::random_access_iterator_tag, T, ptrdiff_t, T*, T&>
{
inline Iterator() : value(T(0)) { }
inline Iterator(T value) : value(value) { }
inline bool operator==(const Iterator& other) const { return value == other.value; }
inline bool operator!=(const Iterator& other) const { return value != other.value; }
inline T operator*() const { return value; }
inline Iterator& operator+=(ptrdiff_t movement) { value += T(movement); return *this; }
inline Iterator& operator-=(ptrdiff_t movement) { value -= T(movement); return *this; }
inline Iterator operator+(ptrdiff_t movement) const { return Iterator(value + T(movement)); }
inline ptrdiff_t operator-(const Iterator& other) const { return ptrdiff_t(value - other.value); }
inline Iterator& operator++()
{
++value;
return *this;
}
inline Iterator operator++(int)
{
Iterator copy(*this);
++value;
return copy;
}
inline Iterator& operator--()
{
--value;
return *this;
}
inline Iterator operator--(int)
{
Iterator copy(*this);
--value;
return copy;
}
T value = 0;
};
Iterator begin() const { return Iterator(m_begin); }
Iterator end() const { return Iterator(m_end); }
private:
T m_begin;
T m_end;
};
template<typename T>
bool contains(T value, std::initializer_list<T> list)
{