This template class represents generic 3D object. All polygons in this object are independent, they do not share vertices as well as vertices are independent themselves. Even if object has two absolutely the same vertices they are represented as 2 different vertices in this kind of 3D object. If you need position, normal, texture coordinate sharing feature, you may use T3DObject instead.
You can find more information in comments below.
template<class TYPE>
class TMesh
{
public:
using Vertex = TVertex<TYPE>; // Vertex type
using Polygon = TPolygon<TYPE>; // Polygon type
using Polygons = std::vector<Polygon>; // Polygon list type
using reference = typename Polygons::reference;
using const_reference = typename Polygons::const_reference;
using iterator = typename Polygons::iterator;
using const_iterator = typename Polygons::const_iterator;
using reverse_iterator = typename Polygons::reverse_iterator;
using const_reverse_iterator = typename Polygons::const_reverse_iterator;
using pointer = typename Polygons::pointer;
using const_pointer = typename Polygons::const_pointer;
public:
TMesh() = default;
TMesh(const TMesh &other) = default;
TMesh(TMesh &&other) = default;
TMesh(const Polygons &polygons);
TMesh(const std::initializer_list<Polygon> &polygons); // Create with specified polygons
// Polygon iterators
reference front();
const_reference front() const;
iterator begin();
const_iterator begin() const;
const_iterator cbegin() const;
iterator end();
const_iterator end() const;
const_iterator cend() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
const_reverse_iterator crbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
const_reverse_iterator crend() const;
reference back();
const_reference back() const;
// Polygon data
reference at(const size_t index);
const_reference at(const size_t index) const;
pointer data();
const_pointer data() const;
void push_back(const TPolygon<TYPE> &polygon);
void push_back(TPolygon<TYPE> &&polygon);
void pop_back();
iterator insert(const_iterator where, const TPolygon<TYPE> &polygon);
iterator insert(const_iterator where, TPolygon<TYPE> &&polygon);
iterator erase(const_iterator where);
iterator erase(const_iterator first, const_iterator last);
// Polygon info & utils
size_t size() const;
size_t max_size() const;
size_t capacity() const;
void resize(const size_t size);
void resize(const size_t size, const TPolygon<TYPE> &polygon);
void shrink_to_fit();
void reserve(const size_t count);
bool empty() const;
void clear();
// Operators
TMesh &operator=(const TMesh &other) = default;
TMesh &operator=(TMesh &&other) = default;
reference operator[](const size_t index);
const_reference operator[](const size_t index) const;
// Helpers
void flip(); // Flip all polygons
size_t triangle_count() const; // Calculate triangle count in mesh
void update_planes(); // Update polygon planes
void update_normals(); // Set vertex normals equal to polygon normals
void relax_normals(const TYPE tolerance); // Set vertex normals to average value of the all nearest vertices(withing radius equal to the specified tolerance). Althor this method uses OctTree optimization it still could be slow with big meshes
};
Namespace: | nitisa::graphics3d |
Include: | Nitisa/Modules/Graphics3D/Core/Mesh.h |