Antkeeper  0.0.1
Classes | Public Types | Public Member Functions | List of all members
geom::mesh Class Reference

Half-edge mesh. More...

#include <mesh.hpp>

Classes

struct  edge
 Half-edge mesh edge, containing its index and pointers to its starting vertex, parent face, and related edges. More...
 
struct  face
 Half-edge mesh face, containing its index and a pointer to its first edge. More...
 
struct  vertex
 Half-edge mesh vertex, containing its index, a pointer to its parent edge, and its position vector. More...
 

Public Types

typedef std::vector< edge * > loop
 List of edges which form a face. More...
 

Public Member Functions

constexpr mesh () noexcept=default
 Constructs a mesh. More...
 
 mesh (const mesh &other)
 Copy-constructs a mesh. More...
 
 ~mesh () noexcept
 Destructs a mesh. More...
 
meshoperator= (const mesh &other)
 Copies another mesh into this mesh. More...
 
void clear () noexcept
 Removes all vertices, edges, and faces from the mesh. More...
 
mesh::vertexadd_vertex (const float3 &position)
 Adds a vertex to the mesh. More...
 
mesh::edgeadd_edge (mesh::vertex *a, mesh::vertex *b)
 Adds two half edges to the mesh. More...
 
mesh::faceadd_face (const loop &loop)
 Adds a face to the mesh. More...
 
void remove_face (mesh::face *face)
 Removes a face from the mesh. More...
 
void remove_edge (mesh::edge *edge)
 Removes an edge and all dependent faces from the mesh. More...
 
void remove_vertex (mesh::vertex *vertex)
 Removes a vertex, all dependent edges, and all dependent faces from the mesh. More...
 
const std::vector< mesh::vertex * > & get_vertices () const
 Returns the mesh vertices. More...
 
const std::vector< mesh::edge * > & get_edges () const
 Returns the mesh edges. More...
 
const std::vector< mesh::face * > & get_faces () const
 Returns the mesh faces. More...
 

Detailed Description

Half-edge mesh.

See also
http://kaba.hilvi.org/homepage/blog/halfedge/halfedge.htm

Definition at line 33 of file mesh.hpp.

Member Typedef Documentation

◆ loop

typedef std::vector<edge*> geom::mesh::loop

List of edges which form a face.

Definition at line 94 of file mesh.hpp.

Constructor & Destructor Documentation

◆ mesh() [1/2]

constexpr geom::mesh::mesh ( )
constexprdefaultnoexcept

Constructs a mesh.

◆ mesh() [2/2]

geom::mesh::mesh ( const mesh other)

Copy-constructs a mesh.

Definition at line 25 of file mesh.cpp.

◆ ~mesh()

geom::mesh::~mesh ( )
noexcept

Destructs a mesh.

Definition at line 30 of file mesh.cpp.

Member Function Documentation

◆ add_edge()

mesh::edge * geom::mesh::add_edge ( mesh::vertex a,
mesh::vertex b 
)

Adds two half edges to the mesh.

Parameters
aVertex from which the edge originates.
bVertex at which the edge ends.
Returns
Pointer to the half edge ab. The symmetric half edge ba can be accessed through ab->symmetric.

Definition at line 159 of file mesh.cpp.

◆ add_face()

mesh::face * geom::mesh::add_face ( const loop loop)

Adds a face to the mesh.

Parameters
loopList of edges which form the face.
Returns
Pointer to the added face.
Exceptions
std::runtime_errorEmpty edge loop.
std::runtime_errorDisconnected edge loop.
std::runtime_errorNon-manifold mesh 1.
std::runtime_errorNon-manifold mesh 2.

Definition at line 212 of file mesh.cpp.

◆ add_vertex()

mesh::vertex * geom::mesh::add_vertex ( const float3 position)

Adds a vertex to the mesh.

Parameters
positionPosition of the vertex.
Returns
Pointer to the added vertex.
Warning
The added vertex will initially have a null edge.

Definition at line 145 of file mesh.cpp.

◆ clear()

void geom::mesh::clear ( )
noexcept

Removes all vertices, edges, and faces from the mesh.

Definition at line 123 of file mesh.cpp.

◆ get_edges()

const std::vector< mesh::edge * > & geom::mesh::get_edges ( ) const
inline

Returns the mesh edges.

Definition at line 204 of file mesh.hpp.

◆ get_faces()

const std::vector< mesh::face * > & geom::mesh::get_faces ( ) const
inline

Returns the mesh faces.

Definition at line 209 of file mesh.hpp.

◆ get_vertices()

const std::vector< mesh::vertex * > & geom::mesh::get_vertices ( ) const
inline

Returns the mesh vertices.

Definition at line 199 of file mesh.hpp.

◆ operator=()

mesh & geom::mesh::operator= ( const mesh other)

Copies another mesh into this mesh.

Parameters
otherMesh to copy.
Returns
Reference to this mesh.

Definition at line 35 of file mesh.cpp.

◆ remove_edge()

void geom::mesh::remove_edge ( mesh::edge edge)

Removes an edge and all dependent faces from the mesh.

Parameters
edgeEdge to be removed. This edge will be deallocated after removal.

Definition at line 288 of file mesh.cpp.

◆ remove_face()

void geom::mesh::remove_face ( mesh::face face)

Removes a face from the mesh.

Parameters
faceFace to be removed. This face will be deallocated after removal.

Definition at line 264 of file mesh.cpp.

◆ remove_vertex()

void geom::mesh::remove_vertex ( mesh::vertex vertex)

Removes a vertex, all dependent edges, and all dependent faces from the mesh.

Parameters
vertexVertex to be removed. This vertex will be deallocated after removal.

Definition at line 330 of file mesh.cpp.


The documentation for this class was generated from the following files: