Visual Computing Library
|
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 |
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).
|
inline |
Performs an insertion into the BiMap, and associates:
[in] | triangleIndex | the triangle index that will be inserted in the BiMap. |
[in] | polygonIndex | the polygon index that will be inserted in the BiMap. |
|
inline |
Returns the index of the polygon mapped to the triangle having the index given as input argument.
[in] | triangleIndex | the triangle index for which we need to know its mapped polygon |
|
inline |
Returns the number of polygons stored in the BiMap.
|
inline |
Reserves enogh memory for the BiMap. Allows fast insertions.
[in] | nTriangles | number of triangles that will be inserted in the BiMap. |
[in] | nPolygons | number of polygons that will be inserted in the BiMap. |
|
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.
[in] | polygonIndex | the polygon index for which we need to know the first mapped triangleBegin |
|
inline |
Returns the number of triangles stored in the BiMap.
|
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":
[in] | polygonIndex | the polygon index for which we need to know the mapped triangles number |