Visual Computing Library
Loading...
Searching...
No Matches
vcl::TriPolyIndexBiMap Class Reference

The TriPolyIndexBiMap class allows to store a bidirectional mapping between a Polygon Mesh and a Triangle Mesh generated by the polygon mesh. More...

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

Public Member Functions

 TriPolyIndexBiMap ()=default
 Creates an empty BiMap.
 
uint polygon (uint triangleIndex) const
 Returns the index of the polygon mapped to the triangle having the index given as input argument.
 
uint triangleBegin (uint polygonIndex) const
 Returns the smallest index of set of triangles mapped to the polygon having the index given as input argument. To know how many (consecutive index) triangles are associated to the given polygon, you can use the triangleNumber() member function.
 
uint triangleNumber (uint polygonIndex) const
 Returns the number of (consecutive index) triangles mapped to a polygon.
 
void clear ()
 Clears the BiMap.
 
void reserve (uint nTriangles, uint nPolygons)
 Reserves enogh memory for the BiMap. Allows fast insertions.
 
void insert (uint triangleIndex, uint polygonIndex)
 Performs an insertion into the BiMap, and associates:
 
uint triangleNumber () const
 Returns the number of triangles stored in the BiMap.
 
uint polygonNumber () const
 Returns the number of polygons stored in the BiMap.
 

Private Attributes

std::vector< uint > mTriToPoly
 
std::vector< uint > mPolyToTri
 

Detailed Description

The TriPolyIndexBiMap class allows to store a bidirectional mapping between a Polygon Mesh and a Triangle Mesh generated by the polygon mesh.

The class stores, for each triangle index, the index of the polygon that generated the triangle, and for each polygon, the first triangle index generated by that polygon. Therefore, keep in mind that the mapping assumes that, for each polygon that generates N triangles, the N triangles are contiguous in the Triangle Mesh.

Queries have O(1) complexity. Insertion may have O(1) or O(n), depending on the size of the containers used to store indices (same way of std::vector push_back() memeber function). You can also reserve before, in order to be sure that the insertion will be O(1).

Member Function Documentation

◆ insert()

void vcl::TriPolyIndexBiMap::insert ( uint  triangleIndex,
uint  polygonIndex 
)
inline

Performs an insertion into the BiMap, and associates:

  • the given polygon index to the given triangle
  • the given triangle index to the given polygon, only if there was no a smaller triangle index already associated to the given polygon. In this way, there will always be the smallest triangle index associated to every polygon.
Parameters
[in]triangleIndexthe triangle index that will be inserted in the BiMap.
[in]polygonIndexthe polygon index that will be inserted in the BiMap.

◆ polygon()

uint vcl::TriPolyIndexBiMap::polygon ( uint  triangleIndex) const
inline

Returns the index of the polygon mapped to the triangle having the index given as input argument.

Parameters
[in]triangleIndexthe triangle index for which we need to know its mapped polygon
Returns
the index of the polygon mapped to the given triangle

◆ polygonNumber()

uint vcl::TriPolyIndexBiMap::polygonNumber ( ) const
inline

Returns the number of polygons stored in the BiMap.

Returns
the number of polygons stored in the BiMap.

◆ reserve()

void vcl::TriPolyIndexBiMap::reserve ( uint  nTriangles,
uint  nPolygons 
)
inline

Reserves enogh memory for the BiMap. Allows fast insertions.

Parameters
[in]nTrianglesnumber of triangles that will be inserted in the BiMap.
[in]nPolygonsnumber of polygons that will be inserted in the BiMap.

◆ triangleBegin()

uint vcl::TriPolyIndexBiMap::triangleBegin ( uint  polygonIndex) const
inline

Returns the smallest index of set of triangles mapped to the polygon having the index given as input argument. To know how many (consecutive index) triangles are associated to the given polygon, you can use the triangleNumber() member function.

Parameters
[in]polygonIndexthe polygon index for which we need to know the first mapped triangleBegin
Returns
the smallest index of the set of triangles mapped to the given polygon

◆ triangleNumber() [1/2]

uint vcl::TriPolyIndexBiMap::triangleNumber ( ) const
inline

Returns the number of triangles stored in the BiMap.

Returns
the number of triangles stored in the BiMap.

◆ triangleNumber() [2/2]

uint vcl::TriPolyIndexBiMap::triangleNumber ( uint  polygonIndex) const
inline

Returns the number of (consecutive index) triangles mapped to a polygon.

You can use this function to know how many triangles are mapped to a polygon.

Assuming that you have a list of triangles "list_t", and a polygon "p":

firstTri = map.triangleBegin(p);
nTris = map.triangleNumber(p);
// loop into the triangles generated by p
for (uint t = firstTri; t < firstTri + nTris; ++t) {
// use list_t[t];
}
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
Parameters
[in]polygonIndexthe polygon index for which we need to know the mapped triangles number
Returns
the number of triangles mapped to the given polygon

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