Visual Computing Library
Loading...
Searching...
No Matches
vcl::MeshPos< FaceType > Class Template Reference

The MeshPos class describes a "Position in a Mesh" that can be identified with a triplet of Face-Vertex-Edge, where: More...

#include <vclib/space/complex/mesh_pos.h>

Public Types

using VertexType = FaceType::VertexType
 

Public Member Functions

 MeshPos ()=default
 Empty constructor that creates a null (invalid) MeshPos.
 
 MeshPos (const FaceType *f, short e)
 
 MeshPos (const FaceType *f, const VertexType *v)
 
 MeshPos (const FaceType *f, const VertexType *v, short e)
 Constructor that creates a MeshPos with the given facem vertex and edge. The given triplet must describe a valid MeshPos. The constructor asserts this condition.
 
const FaceType * face () const
 
const VertexType * vertex () const
 
short edge () const
 
const FaceType * adjFace () const
 
const VertexType * adjVertex () const
 
short adjEdge () const
 
bool isValid () const
 Returns true if this MeshPos is valid.
 
bool isNull () const
 Returns true if this is null, non initialized, MeshPos. The result of this function is different from calling !isValid().
 
bool isEdgeOnBorder () const
 Returns true if the current edge of this MeshPos is on a border. To check if is on border, this function checks wheter exists an adjacent face to the current face along the current edge of this MeshPos. It does not use border flags.
 
bool isCCWOriented () const
 Returns true if the current vertex of the MeshPos corresponts to the first vertex of the current edge. If this member function returns true, the next operations performed on the MeshPos will move in CounderClockWise order.
 
bool flipFace ()
 Moves this MeshPos to the face adjacent to the current face that shares the same vertex and the same edge of this MeshPos. The function returns true if the current face is changed. If the adjacent face does not exist because the edge of the current face is on border, the current face does not change, and the MeshPos remains valid. In this case, the function returns false.
 
void flipVertex ()
 Moves this MeshPos to the vertex adjacent to the current vertex that shares the same face and the same edge of this MeshPos.
 
void flipEdge ()
 Moves this MeshPos to the edge adjacent to the current edge that shares the same face and the same vertex of this MeshPos.
 
void nextEdgeAdjacentToV ()
 Moves this MeshPos to the next edge that is adjacent to the current vertex of the MeshPos. This Move corresponds to make a flipEdge() and then a flipFace() moves. Using this move, it is possible to visit the next face and the next edge adjacent to the current vertex, and can be used to navigate in the star of the current vertex.
 
bool nextEdgeOnBorderAdjacentToV ()
 Moves the MeshPos to the next edge on border that is adjacent to the current vertex of the MeshPos. Basically, cycles on the edges adjacent to the current vertex, and stops when finds a border edge.
 
uint numberOfAdjacentFacesToV () const
 Returns the number of adjacent faces to the current vertex of this MeshPos. This works also for vertices that are on a border, and the starting edge and face is ininfluent. The only requirement is that this MeshPos is valid.
 
bool operator== (const MeshPos &op) const
 
bool operator!= (const MeshPos &op) const
 
bool operator< (const MeshPos &op) const
 

Static Public Member Functions

static bool isValid (const FaceType *f, const VertexType *v, short e)
 Helper function to check if a MeshPos is valid, that is if:
 

Private Member Functions

uint countAdjacentFacesToV (bool &onBorder) const
 

Private Attributes

const FaceType * mFace = nullptr
 
const FaceType::VertexType * mVertex = nullptr
 
short mEdge = -1
 

Detailed Description

template<face::HasAdjacentFaces FaceType>
class vcl::MeshPos< FaceType >

The MeshPos class describes a "Position in a Mesh" that can be identified with a triplet of Face-Vertex-Edge, where:

  • the Vertex is part of the Face;
  • the edge is an index less than the number of vertices of the Face
  • The Vertex is part of the Edge in the Face.

Its utility is to navigate the topology of the Mesh trough a set of well-defined operations that allow to "move" the MeshPos object.

To be used, the MeshPos requires that the Mesh on which the given Face-Vertex-Edge triplet is defined, has per Face Adjacent Faces topology informtion.

Constructor & Destructor Documentation

◆ MeshPos()

template<face::HasAdjacentFaces FaceType>
vcl::MeshPos< FaceType >::MeshPos ( const FaceType *  f,
const VertexType *  v,
short  e 
)
inline

Constructor that creates a MeshPos with the given facem vertex and edge. The given triplet must describe a valid MeshPos. The constructor asserts this condition.

Parameters
[in]fthe Face pointer on which place the MeshPos.
[in]vthe Vertex pointer on which place the MeshPos.
[in]ethe Edge (an positive index < f.vertexNumber() on which place the MeshPos.

Member Function Documentation

◆ flipFace()

template<face::HasAdjacentFaces FaceType>
bool vcl::MeshPos< FaceType >::flipFace ( )
inline

Moves this MeshPos to the face adjacent to the current face that shares the same vertex and the same edge of this MeshPos. The function returns true if the current face is changed. If the adjacent face does not exist because the edge of the current face is on border, the current face does not change, and the MeshPos remains valid. In this case, the function returns false.

Returns
true if the current face is changed, false otherwise (because the current edge is on border).

◆ isCCWOriented()

template<face::HasAdjacentFaces FaceType>
bool vcl::MeshPos< FaceType >::isCCWOriented ( ) const
inline

Returns true if the current vertex of the MeshPos corresponts to the first vertex of the current edge. If this member function returns true, the next operations performed on the MeshPos will move in CounderClockWise order.

Returns

◆ isEdgeOnBorder()

template<face::HasAdjacentFaces FaceType>
bool vcl::MeshPos< FaceType >::isEdgeOnBorder ( ) const
inline

Returns true if the current edge of this MeshPos is on a border. To check if is on border, this function checks wheter exists an adjacent face to the current face along the current edge of this MeshPos. It does not use border flags.

Returns
true if the current edge in the current face is on a border.

◆ isNull()

template<face::HasAdjacentFaces FaceType>
bool vcl::MeshPos< FaceType >::isNull ( ) const
inline

Returns true if this is null, non initialized, MeshPos. The result of this function is different from calling !isValid().

Returns
true if this MeshPos is null.

◆ isValid() [1/2]

template<face::HasAdjacentFaces FaceType>
bool vcl::MeshPos< FaceType >::isValid ( ) const
inline

Returns true if this MeshPos is valid.

Returns
true if this MeshPos is valid.

◆ isValid() [2/2]

template<face::HasAdjacentFaces FaceType>
static bool vcl::MeshPos< FaceType >::isValid ( const FaceType *  f,
const VertexType *  v,
short  e 
)
inlinestatic

Helper function to check if a MeshPos is valid, that is if:

  • v and f are valid vertex/face pointers, and e >= 0
  • the type of f has AdjacentFaces
  • e is less than the number of vertices of f (that is the number of edges of f)
  • v is the vertex of f in position e or (e+1)f->numberVertices()
Parameters
fa face pointer
va vertex pointer
ean integer that represents the edge position in the face f
Returns
true if the triple (f,v,e) is a valid MeshPos.

◆ nextEdgeAdjacentToV()

template<face::HasAdjacentFaces FaceType>
void vcl::MeshPos< FaceType >::nextEdgeAdjacentToV ( )
inline

Moves this MeshPos to the next edge that is adjacent to the current vertex of the MeshPos. This Move corresponds to make a flipEdge() and then a flipFace() moves. Using this move, it is possible to visit the next face and the next edge adjacent to the current vertex, and can be used to navigate in the star of the current vertex.

Note that if a "next face" does not exists because we are on border, the MeshPos flips only the current edge, staying on the same face (see the flipFace() function for more details).

◆ nextEdgeOnBorderAdjacentToV()

template<face::HasAdjacentFaces FaceType>
bool vcl::MeshPos< FaceType >::nextEdgeOnBorderAdjacentToV ( )
inline

Moves the MeshPos to the next edge on border that is adjacent to the current vertex of the MeshPos. Basically, cycles on the edges adjacent to the current vertex, and stops when finds a border edge.

Returns
true if it finds a border edge that is different to the current one. Return false if no border edge was found.

◆ numberOfAdjacentFacesToV()

template<face::HasAdjacentFaces FaceType>
uint vcl::MeshPos< FaceType >::numberOfAdjacentFacesToV ( ) const
inline

Returns the number of adjacent faces to the current vertex of this MeshPos. This works also for vertices that are on a border, and the starting edge and face is ininfluent. The only requirement is that this MeshPos is valid.

Returns
The number of adjacent Faces to the current vertex of this MeshPos.

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