aboutsummaryrefslogtreecommitdiff
path: root/src/o3d/obj3d.h
blob: 795b3374c8dd578446569b0670a41e2717cc7a96 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef O3D_OBJ3D_H
#define O3D_OBJ3D_H

#include <vector>
#include <array>
#include <iterator>
#include "o3d/vertex.h"
#include "o3d/tri_vertex.h"

namespace engine::o3d {

class Object3D {
    public:
        class TriangleVertex3Iterator {
            public:
                using iterator_category = std::input_iterator_tag;
                using value_type = TriangleVertex3;
                using difference_type = TriangleVertex3;
                using pointer = const TriangleVertex3*;
                using reference = TriangleVertex3;

                explicit TriangleVertex3Iterator(const Object3D* obj, int face_ind = 0);
                TriangleVertex3Iterator& operator++();
                TriangleVertex3Iterator operator++(int);
                bool operator==(TriangleVertex3Iterator other) const;
                bool operator!=(TriangleVertex3Iterator other) const;
                reference operator*() const;

            private:
                const Object3D* obj;
                int face_ind;

        };

        static Object3D cube(); // this function should not be in this file

        Object3D(std::vector<Vertex3> pts, std::vector<std::array<int, 3>> faces);
        TriangleVertex3Iterator begin();
        TriangleVertex3Iterator end();

    private:
        std::vector<Vertex3> pts;
        std::vector<std::array<int, 3>> faces;
};

}

#endif // O3D_OBJ3D_H