summaryrefslogtreecommitdiff
path: root/thirdparty/thekla_atlas/nvmesh/MeshTopology.h
blob: c3d7477b1548abec34170ae8cd695d5cc3f79e17 (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
61
62
63
64
65
66
// This code is in the public domain -- castanyo@yahoo.es

#pragma once
#ifndef NV_MESH_MESHTOPOLOGY_H
#define NV_MESH_MESHTOPOLOGY_H

#include <nvmesh/nvmesh.h>

namespace nv
{
    namespace HalfEdge { class Mesh; }
    class MeshAdjacency;

    /// Mesh topology information.
    class MeshTopology
    {
    public:
        MeshTopology(const HalfEdge::Mesh * mesh) { buildTopologyInfo(mesh); }

        /// Determine if the mesh is connected.
        bool isConnected() const { return m_connectedCount == 1; }

        /// Determine if the mesh is closed. (Each edge is shared by two faces)
        bool isClosed() const { return m_boundaryCount == 0; }

        /// Return true if the mesh has the topology of a disk.
        bool isDisk() const { return isConnected() && m_boundaryCount == 1/* && m_eulerNumber == 1*/; }

        /// Return the number of connected components.
        int connectedCount() const { return m_connectedCount; }

        /// Return the number of open holes.
        int holeCount() const { return m_boundaryCount; }

        /// Return the genus of the mesh.
        int genus() const { return m_genus; }

        /// Return the euler number of the mesh.
        int euler() const { return m_eulerNumber; }


        static bool isQuadOnly(const HalfEdge::Mesh * mesh);


    private:

        NVMESH_API void buildTopologyInfo(const HalfEdge::Mesh * mesh);

    private:

        ///< Number of boundary loops.
        int m_boundaryCount;		

        ///< Number of connected components.
        int m_connectedCount;		

        ///< Euler number.
        int m_eulerNumber;

        /// Mesh genus.
        int m_genus;
    };

} // nv namespace

#endif // NV_MESH_MESHTOPOLOGY_H