Radium Engine  1.5.0
Ra::Core::Geometry::TopologicalMesh Class Reference

#include <Core/Geometry/TopologicalMesh.hpp>

Inherits OpenMesh::PolyMesh_ArrayKernelT< TopologicalMeshTraits >.

+ Collaboration diagram for Ra::Core::Geometry::TopologicalMesh:

Classes

class  WedgeData
 

Public Types

using WedgeIndex = Ra::Core::Utils::Index
 
using WedgeAttribIndex = Ra::Core::Utils::Index
 

Public Member Functions

 TopologicalMesh ()
 
template<typename MeshIndex >
 TopologicalMesh ([[deprecated("Use MultiIndexedGeometry instead")]] const Ra::Core::Geometry::IndexedGeometry< MeshIndex > &mesh)
 Convenience constructor. More...
 
 TopologicalMesh (const Ra::Core::Geometry::MultiIndexedGeometry &mesh, const Ra::Core::Geometry::MultiIndexedGeometry::LayerKeyType &layerKey)
 Convenience constructor. More...
 
template<typename MeshIndex , typename NonManifoldFaceCommand >
 TopologicalMesh ([[deprecated("Use MultiIndexedGeometry instead")]] const Ra::Core::Geometry::IndexedGeometry< MeshIndex > &mesh, NonManifoldFaceCommand command)
 
template<typename NonManifoldFaceCommand >
 TopologicalMesh (const Ra::Core::Geometry::MultiIndexedGeometry &mesh, const Ra::Core::Geometry::MultiIndexedGeometry::LayerKeyType &layerKey, NonManifoldFaceCommand command)
 
void initWithWedge (const Ra::Core::Geometry::MultiIndexedGeometry &mesh, const Ra::Core::Geometry::MultiIndexedGeometry::LayerKeyType &layerKey)
 
template<typename NonManifoldFaceCommand >
void initWithWedge (const Ra::Core::Geometry::MultiIndexedGeometry &mesh, const Ra::Core::Geometry::MultiIndexedGeometry::LayerKeyType &layerKey, NonManifoldFaceCommand command)
 
TriangleMesh toTriangleMesh ()
 
PolyMesh toPolyMesh ()
 
LineMesh toLineMesh ()
 
void updateTriangleMesh (Ra::Core::Geometry::MultiIndexedGeometry &mesh)
 
void updateTriangleMeshNormals (Ra::Core::Geometry::MultiIndexedGeometry &mesh)
 
void updateTriangleMeshNormals (AttribArrayGeometry::NormalAttribHandle::Container &normals)
 
void update (const Ra::Core::Geometry::MultiIndexedGeometry &mesh)
 
void updateNormals (const Ra::Core::Geometry::MultiIndexedGeometry &mesh)
 
void updatePositions (const Ra::Core::Geometry::MultiIndexedGeometry &mesh)
 
void updatePositions (const AttribArrayGeometry::PointAttribHandle::Container &vertices)
 
HalfedgeHandle halfedge_handle (VertexHandle vh, FaceHandle fh) const
 
void propagate_normal_to_wedges (VertexHandle vh)
 
const OpenMesh::HPropHandleT< Index > & getInputTriangleMeshIndexPropHandle () const
 
const OpenMesh::HPropHandleT< Index > & getOutputTriangleMeshIndexPropHandle () const
 
void copyPointsPositionToWedges ()
 
std::set< WedgeIndex > getVertexWedges (OpenMesh::VertexHandle vh) const
 
WedgeIndex getWedgeIndex (OpenMesh::HalfedgeHandle heh) const
 
const WedgeDatagetWedgeData (const WedgeIndex &idx) const
 
template<typename T >
const T & getWedgeData (const WedgeIndex &idx, const std::string &name) const
 
template<typename T >
const T & getWedgeAttrib (const WedgeIndex &idx, const std::string &name) const
 
unsigned int getWedgeRefCount (const WedgeIndex &idx) const
 
void setWedgeData (WedgeIndex widx, const WedgeData &wd)
 
template<typename T >
bool setWedgeData (const WedgeIndex &idx, const std::string &name, const T &value)
 
template<typename T >
bool setWedgeAttrib (const WedgeIndex &idx, const std::string &name, const T &value)
 
WedgeData newWedgeData () const
 
WedgeData newWedgeData (HalfedgeHandle he) const
 
WedgeIndex replaceWedge (OpenMesh::HalfedgeHandle he, const WedgeData &wd)
 
template<typename T >
WedgeAttribIndex addWedgeAttrib (const std::string &name, T value={})
 
void replaceWedgeIndex (OpenMesh::HalfedgeHandle he, const WedgeIndex &widx)
 
void mergeEqualWedges ()
 
void mergeEqualWedges (OpenMesh::VertexHandle vh)
 
void garbage_collection ()
 Remove deleted element from the mesh, including wedges.
 
void clean ()
 
const std::vector< std::string > & getVec4AttribNames () const
 
const std::vector< std::string > & getVec3AttribNames () const
 
const std::vector< std::string > & getVec2AttribNames () const
 
const std::vector< std::string > & getFloatAttribNames () const
 
bool isFeatureVertex (const VertexHandle &vh) const
 true if more than one wedge arount vertex vh, false if only one wedge
 
bool isFeatureEdge (const EdgeHandle &eh) const
 
const OpenMesh::HPropHandleT< WedgeIndex > & getWedgeIndexPph () const
 
void delete_face (FaceHandle _fh, bool _delete_isolated_vertices=true)
 
bool isManifold (VertexHandle vh) const
 
bool checkIntegrity () const
 
void triangulate ()
 
template<typename MeshIndex , typename NonManifoldFaceCommand >
 TopologicalMesh (const IndexedGeometry< MeshIndex > &mesh, NonManifoldFaceCommand command)
 
Dealing with normals

Utils to deal with normals when modifying the mesh topology.

void updateWedgeNormals ()
 
Topological operations
bool splitEdge (TopologicalMesh::EdgeHandle eh, Scalar f)
 
void collapse (HalfedgeHandle, bool=false)
 
void collapseWedge (TopologicalMesh::HalfedgeHandle he, bool keepFromVertex=false)
 

Friends

class TMOperations
 

Detailed Description

This class represents a mesh with topological information on the vertex graph, using a half-edge representation.

This integration is inspired by: https://gist.github.com/Unril/03fa353d0461ed6bd41d

Todo:

rename methods to respect Radium guideline (get/set/is, camelCase)

private inheritance from OpenMesh, and import relevant methods.

Definition at line 55 of file TopologicalMesh.hpp.

Constructor & Destructor Documentation

◆ TopologicalMesh() [1/5]

Ra::Core::Geometry::TopologicalMesh::TopologicalMesh ( )
explicit

Construct an empty topological mesh, only initialize mandatory properties.

Definition at line 183 of file TopologicalMesh.cpp.

◆ TopologicalMesh() [2/5]

template<typename MeshIndex >
Ra::Core::Geometry::TopologicalMesh::TopologicalMesh ( [[deprecated("Use MultiIndexedGeometry instead")] ] const Ra::Core::Geometry::IndexedGeometry< MeshIndex > &  mesh)
explicit

Convenience constructor.

See also
TopologicalMesh( const Ra::Core::Geometry::TriangleMesh&, NonManifoldFaceCommand)

◆ TopologicalMesh() [3/5]

Ra::Core::Geometry::TopologicalMesh::TopologicalMesh ( const Ra::Core::Geometry::MultiIndexedGeometry mesh,
const Ra::Core::Geometry::MultiIndexedGeometry::LayerKeyType &  layerKey 
)
inlineexplicit

Convenience constructor.

See also
TopologicalMesh( const Ra::Core::Geometry::TriangleMesh&, NonManifoldFaceCommand)
Todo:
, when MultiIndexedGeometry will be operational, will this replace the above ?

Definition at line 1051 of file TopologicalMesh.hpp.

◆ TopologicalMesh() [4/5]

template<typename MeshIndex , typename NonManifoldFaceCommand >
Ra::Core::Geometry::TopologicalMesh::TopologicalMesh ( [[deprecated("Use MultiIndexedGeometry instead")] ] const Ra::Core::Geometry::IndexedGeometry< MeshIndex > &  mesh,
NonManifoldFaceCommand  command 
)
explicit

Construct a topological mesh from a triangle mesh. This operation merges vertex with same position, but keeps vertex attributes on halfedges, so that TriangleMesh vertices with the same 3D position are represented only once in the topological mesh.

Note
This is a costly operation.
Template Parameters
NonManifoldFaceCommandCommand executed when non-manifold faces are found. API and default implementation:
struct DefaultNonManifoldFaceCommand {
DefaultNonManifoldFaceCommand( const std::string& details = {} ) : m_details { details } {}
inline void initialize( const Ra::Core::Geometry::MultiIndexedGeometry& ) {}
inline void process( const std::vector<TopologicalMesh::VertexHandle>& /*face_vhandles*/ ) {
LOG( logWARNING ) << "Invalid face handle returned : face not added " + m_details;
}
inline void postProcess( TopologicalMesh& ) {}
private:
std::string m_details;
};
AbstractGeometry with per-vertex attributes and layers of indices. Each layer represents a different ...

◆ TopologicalMesh() [5/5]

template<typename NonManifoldFaceCommand >
Ra::Core::Geometry::TopologicalMesh::TopologicalMesh ( const Ra::Core::Geometry::MultiIndexedGeometry mesh,
const Ra::Core::Geometry::MultiIndexedGeometry::LayerKeyType &  layerKey,
NonManifoldFaceCommand  command 
)
explicit

Construct a topological mesh from a triangle mesh. This operation merges vertex with same position, but keeps vertex attributes on halfedges, so that TriangleMesh vertices with the same 3D position are represented only once in the topological mesh.

Note
This is a costly operation.
Template Parameters
NonManifoldFaceCommandCommand executed when non-manifold faces are found. API and default implementation:
struct DefaultNonManifoldFaceCommand {
DefaultNonManifoldFaceCommand( const std::string& details = {} ) : m_details { details } {}
inline void initialize( const Ra::Core::Geometry::MultiIndexedGeometry& ) {}
inline void process( const std::vector<TopologicalMesh::VertexHandle>& /*face_vhandles*/ ) {
LOG( logWARNING ) << "Invalid face handle returned : face not added " + m_details;
}
inline void postProcess( TopologicalMesh& ) {}
private:
std::string m_details;
};
Todo:
, when MultiIndexedGeometry will be operational, will this replace the above ?

Definition at line 1057 of file TopologicalMesh.hpp.

Member Function Documentation

◆ checkIntegrity()

bool Ra::Core::Geometry::TopologicalMesh::checkIntegrity ( ) const

Check if evrything looks right in the data structure

Returns
true if ok, false if ko.

Definition at line 68 of file TopologicalMesh.cpp.

◆ collapse()

void Ra::Core::Geometry::TopologicalMesh::collapse ( HalfedgeHandle  _hh,
bool  keepFrom = false 
)

Halfedge collapes he. vo=from_vertex_handle(he) is deleted. After collapse vo incoming halfedges points to vh = to_vertex_handle(he). Wedge indices are updated to reflect the change in topology. For detailed topological modifications see 3D objects (a.k.a. Meshes).

Parameters
hehalfedge's hangle to collapse.

Definition at line 783 of file TopologicalMesh.cpp.

◆ copyPointsPositionToWedges()

void Ra::Core::Geometry::TopologicalMesh::copyPointsPositionToWedges ( )

update wedge's position to correspond to current point position, which might not be the case if point(handle) = something; has been used.

Definition at line 497 of file TopologicalMesh.cpp.

◆ getInputTriangleMeshIndexPropHandle()

const OpenMesh::HPropHandleT< TopologicalMesh::Index > & Ra::Core::Geometry::TopologicalMesh::getInputTriangleMeshIndexPropHandle ( ) const
inline

Return a handle to the halfedge property storing vertices indices within the TriangleMesh *this has been built on.

Definition at line 1331 of file TopologicalMesh.hpp.

◆ getOutputTriangleMeshIndexPropHandle()

const OpenMesh::HPropHandleT< TopologicalMesh::Index > & Ra::Core::Geometry::TopologicalMesh::getOutputTriangleMeshIndexPropHandle ( ) const
inline

Return a handle to the halfedge property storing vertices indices within the TriangleMesh returned by toTriangleMesh().

Note
This property is valid only after toTriangleMesh() has been called.

Definition at line 1336 of file TopologicalMesh.hpp.

◆ getVertexWedges()

std::set< TopologicalMesh::WedgeIndex > Ra::Core::Geometry::TopologicalMesh::getVertexWedges ( OpenMesh::VertexHandle  vh) const
inline

Return the set of WedgeIndex incident to a given Vertex vh. only valid non deleted wedges are present in the set.

Definition at line 1341 of file TopologicalMesh.hpp.

◆ getWedgeData()

const TopologicalMesh::WedgeData & Ra::Core::Geometry::TopologicalMesh::getWedgeData ( const WedgeIndex &  idx) const
inline

Access to wedge data.

Parameters
idxmust be valid and correspond to a non delete wedge index.

Definition at line 1380 of file TopologicalMesh.hpp.

◆ getWedgeIndex()

TopologicalMesh::WedgeIndex Ra::Core::Geometry::TopologicalMesh::getWedgeIndex ( OpenMesh::HalfedgeHandle  heh) const
inline

get the wedge index associated with an halfedge

Definition at line 1352 of file TopologicalMesh.hpp.

◆ getWedgeRefCount()

unsigned int Ra::Core::Geometry::TopologicalMesh::getWedgeRefCount ( const WedgeIndex &  idx) const
inline

Return the wedge refcount, for debug purpose.

Definition at line 1356 of file TopologicalMesh.hpp.

◆ halfedge_handle()

TopologicalMesh::HalfedgeHandle Ra::Core::Geometry::TopologicalMesh::halfedge_handle ( VertexHandle  vh,
FaceHandle  fh 
) const
inline

Return the half-edge associated with a given vertex and face.

Note
Asserts if vh is not a member of fh.

Definition at line 1321 of file TopologicalMesh.hpp.

◆ initWithWedge()

template<typename NonManifoldFaceCommand >
void Ra::Core::Geometry::TopologicalMesh::initWithWedge ( const Ra::Core::Geometry::MultiIndexedGeometry mesh,
const Ra::Core::Geometry::MultiIndexedGeometry::LayerKeyType &  layerKey,
NonManifoldFaceCommand  command 
)
Todo:
and "cross face ?"

Definition at line 1074 of file TopologicalMesh.hpp.

+ Here is the call graph for this function:

◆ isFeatureEdge()

bool Ra::Core::Geometry::TopologicalMesh::isFeatureEdge ( const EdgeHandle &  eh) const
inline

true if at least one of edge's vertex as two different wedge arount the edge. false if the two vertices have the same wedge for both face aside the edge.

Definition at line 1441 of file TopologicalMesh.hpp.

+ Here is the call graph for this function:

◆ isManifold()

bool Ra::Core::Geometry::TopologicalMesh::isManifold ( VertexHandle  vh) const

is the vertex a "bow tie" vertex ?

Note
Alias for OpenMesh::is_manifold

Definition at line 64 of file TopologicalMesh.cpp.

◆ mergeEqualWedges() [1/2]

void Ra::Core::Geometry::TopologicalMesh::mergeEqualWedges ( )
inline

call mergeEquelWedges( vh ) for every vertices of the mesh.

See also
void mergeEqualWedges( OpenMesh::VertexHandle vh );

Definition at line 1410 of file TopologicalMesh.hpp.

◆ mergeEqualWedges() [2/2]

void Ra::Core::Geometry::TopologicalMesh::mergeEqualWedges ( OpenMesh::VertexHandle  vh)
inline

Merge (make same index) wegdes with the same data around vh

Parameters
vhvertex handle to process

Definition at line 1416 of file TopologicalMesh.hpp.

+ Here is the call graph for this function:

◆ newWedgeData() [1/2]

WedgeData Ra::Core::Geometry::TopologicalMesh::newWedgeData ( ) const
inline

return a WedgeData with all attrib initialized to default values

Definition at line 291 of file TopologicalMesh.hpp.

◆ newWedgeData() [2/2]

WedgeData Ra::Core::Geometry::TopologicalMesh::newWedgeData ( HalfedgeHandle  he) const
inline

return a WedgeData with position (and vertex handle) initialized from the value of he's to vertex.

Definition at line 294 of file TopologicalMesh.hpp.

◆ propagate_normal_to_wedges()

void Ra::Core::Geometry::TopologicalMesh::propagate_normal_to_wedges ( VertexHandle  vh)
inline

Set the normal n to all the wedges that share to vh. If you work with vertex normals, please call this function on all vertex handles before convertion with toTriangleMesh.

Definition at line 1307 of file TopologicalMesh.hpp.

+ Here is the call graph for this function:

◆ replaceWedge()

TopologicalMesh::WedgeIndex Ra::Core::Geometry::TopologicalMesh::replaceWedge ( OpenMesh::HalfedgeHandle  he,
const WedgeData wd 
)
inline

Replace the wedge data associated with an halfedge. The old wedge is "deleted". If wedge data correspond to an already present wedge, it's index is used.

Definition at line 1396 of file TopologicalMesh.hpp.

◆ replaceWedgeIndex()

void Ra::Core::Geometry::TopologicalMesh::replaceWedgeIndex ( OpenMesh::HalfedgeHandle  he,
const WedgeIndex &  widx 
)
inline

Replace the wedge index associated with an halfedge. The old wedge is "deleted". The new wedge reference count is incremented.

Definition at line 1404 of file TopologicalMesh.hpp.

◆ setWedgeData() [1/2]

template<typename T >
bool Ra::Core::Geometry::TopologicalMesh::setWedgeData ( const WedgeIndex &  idx,
const std::string &  name,
const T &  value 
)
inline

Change the WedgeData associated for idx, for attrib name to value. The data is changed for all halfedges referencing this wedge.

Returns
true if the wedge is set, false if nothing set, i.e. if name is not an attrib of type T.

Definition at line 1361 of file TopologicalMesh.hpp.

◆ setWedgeData() [2/2]

void Ra::Core::Geometry::TopologicalMesh::setWedgeData ( TopologicalMesh::WedgeIndex  widx,
const WedgeData wd 
)
inline

set WedgeData wd to the wedge with index widx. All halfedge that point to widx will get the new values.

Parameters
widxindex of the wedge
wddata to set to wedge that correspond to widx

Definition at line 1374 of file TopologicalMesh.hpp.

◆ splitEdge()

bool Ra::Core::Geometry::TopologicalMesh::splitEdge ( TopologicalMesh::EdgeHandle  eh,
Scalar  f 
)

Apply a 2-4 edge split.

Parameters
ehThe handle to the edge to split.
fThe interpolation factor to place the new point on the edge. Must be in [0,1].
Returns
True if the edge has been split, false otherwise.
Note
Only applies on edges between 2 triangles, and if f is in [0,1].
Mesh attributes are linearly interpolated on the newly created halfedge.
f=0 correspond to halfedge_handle( eh, 0 ) (i.e. first vertex of the edge)

Definition at line 647 of file TopologicalMesh.cpp.

◆ toLineMesh()

LineMesh Ra::Core::Geometry::TopologicalMesh::toLineMesh ( )

Wedges are output vertices !

Definition at line 258 of file TopologicalMesh.cpp.

◆ toPolyMesh()

PolyMesh Ra::Core::Geometry::TopologicalMesh::toPolyMesh ( )

Return a triangleMesh from the topological mesh.

Note
This is a costly operation.
Warning
It uses the attributes defined on wedges

add attribs to out

Wedges are output vertices !

Definition at line 316 of file TopologicalMesh.cpp.

◆ toTriangleMesh()

TriangleMesh Ra::Core::Geometry::TopologicalMesh::toTriangleMesh ( )

Return a triangleMesh from the topological mesh.

Note
This is a costly operation.

add attribs to out

Wedges are output vertices !

Definition at line 206 of file TopologicalMesh.cpp.

◆ updateTriangleMesh()

void Ra::Core::Geometry::TopologicalMesh::updateTriangleMesh ( Ra::Core::Geometry::MultiIndexedGeometry mesh)

Update triangle mesh data, assuming the mesh and this topo mesh has the same topology.

Wedges are output vertices !

Definition at line 373 of file TopologicalMesh.cpp.

+ Here is the call graph for this function:

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