summaryrefslogtreecommitdiff
path: root/thirdparty/thekla_atlas/nvmesh/QuadTriMesh.h
blob: b8465f2db01967b7e916a80588e651f4d26c6ebe (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
// This code is in the public domain -- Ignacio Castaño <castano@gmail.com>

#pragma once
#ifndef NV_MESH_QUADTRIMESH_H
#define NV_MESH_QUADTRIMESH_H

#include "nvcore/Array.h"
#include "nvmath/Vector.h"
#include "nvmesh/nvmesh.h"
#include "nvmesh/BaseMesh.h"

namespace nv
{
    class Stream;

    /// Mixed quad/triangle mesh.
    class QuadTriMesh : public BaseMesh
    {
    public:
        struct Face;
        typedef BaseMesh::Vertex Vertex;

        QuadTriMesh() {};
        QuadTriMesh(uint faceCount, uint vertexCount) : BaseMesh(vertexCount), m_faceArray(faceCount) {}

        // Face methods.
        uint faceCount() const { return m_faceArray.count(); }

        const Face & faceAt(uint i) const { return m_faceArray[i]; }
        Face & faceAt(uint i) { return m_faceArray[i]; }

        const Array<Face> & faces() const { return m_faceArray; }
        Array<Face> & faces() { return m_faceArray; }

        bool isQuadFace(uint i) const;

        const Vertex & faceVertex(uint f, uint v) const;

        friend Stream & operator<< (Stream & s, QuadTriMesh & obj);

    private:

        Array<Face> m_faceArray;

    };


    /// QuadTriMesh face.
    struct QuadTriMesh::Face
    {
        uint id;
        uint v[4];

        bool isQuadFace() const { return v[3] != NIL; }
    };

} // nv namespace


#endif // NV_MESH_QUADTRIMESH_H