diff options
Diffstat (limited to 'thirdparty/thekla_atlas/nvmesh/MeshTopology.h')
-rw-r--r-- | thirdparty/thekla_atlas/nvmesh/MeshTopology.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/thirdparty/thekla_atlas/nvmesh/MeshTopology.h b/thirdparty/thekla_atlas/nvmesh/MeshTopology.h new file mode 100644 index 0000000000..c3d7477b15 --- /dev/null +++ b/thirdparty/thekla_atlas/nvmesh/MeshTopology.h @@ -0,0 +1,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 |