CDT  1.3.0
C++ library for constrained Delaunay triangulation
Helpers

Helpers for working with CDT::Triangulation. More...

Collaboration diagram for Helpers:

Classes

struct  CDT::DuplicatesInfo
 Information about removed duplicated vertices. More...
 

Functions

CDT_EXPORT VerticesTriangles CDT::calculateTrianglesByVertex (const TriangleVec &triangles, VertInd verticesSize)
 Calculate triangles adjacent to vertices (triangles by vertex index) More...
 
template<typename T , typename TVertexIter , typename TGetVertexCoordX , typename TGetVertexCoordY >
DuplicatesInfo CDT::FindDuplicates (TVertexIter first, TVertexIter last, TGetVertexCoordX getX, TGetVertexCoordY getY)
 Find duplicates in given custom point-type range. More...
 
template<typename TVertex , typename TAllocator >
void CDT::RemoveDuplicates (std::vector< TVertex, TAllocator > &vertices, const std::vector< std::size_t > &duplicates)
 Remove duplicates in-place from vector of custom points. More...
 
template<typename T >
CDT_EXPORT DuplicatesInfo CDT::RemoveDuplicates (std::vector< V2d< T > > &vertices)
 Remove duplicated points in-place. More...
 
template<typename TEdgeIter , typename TGetEdgeVertexStart , typename TGetEdgeVertexEnd , typename TMakeEdgeFromStartAndEnd >
CDT_EXPORT void CDT::RemapEdges (TEdgeIter first, TEdgeIter last, const std::vector< std::size_t > &mapping, TGetEdgeVertexStart getStart, TGetEdgeVertexEnd getEnd, TMakeEdgeFromStartAndEnd makeEdge)
 Remap vertex indices in edges (in-place) using given vertex-index mapping. More...
 
CDT_EXPORT void CDT::RemapEdges (std::vector< Edge > &edges, const std::vector< std::size_t > &mapping)
 Remap vertex indices in edges (in-place) using given vertex-index mapping. More...
 
template<typename T , typename TVertex , typename TGetVertexCoordX , typename TGetVertexCoordY , typename TVertexAllocator , typename TEdgeIter , typename TGetEdgeVertexStart , typename TGetEdgeVertexEnd , typename TMakeEdgeFromStartAndEnd >
DuplicatesInfo CDT::RemoveDuplicatesAndRemapEdges (std::vector< TVertex, TVertexAllocator > &vertices, TGetVertexCoordX getX, TGetVertexCoordY getY, TEdgeIter edgesFirst, TEdgeIter edgesLast, TGetEdgeVertexStart getStart, TGetEdgeVertexEnd getEnd, TMakeEdgeFromStartAndEnd makeEdge)
 Find point duplicates, remove them from vector (in-place) and remap edges (in-place) More...
 
template<typename T >
CDT_EXPORT DuplicatesInfo CDT::RemoveDuplicatesAndRemapEdges (std::vector< V2d< T > > &vertices, std::vector< Edge > &edges)
 Same as a chained call of CDT::RemoveDuplicates + CDT::RemapEdges. More...
 
CDT_EXPORT EdgeUSet CDT::extractEdgesFromTriangles (const TriangleVec &triangles)
 Extract all edges of triangles. More...
 
CDT_EXPORT unordered_map< Edge, EdgeVecCDT::EdgeToPiecesMapping (const unordered_map< Edge, EdgeVec > &pieceToOriginals)
 
template<typename T >
CDT_EXPORT unordered_map< Edge, std::vector< VertInd > > CDT::EdgeToSplitVertices (const unordered_map< Edge, EdgeVec > &edgeToPieces, const std::vector< V2d< T > > &vertices)
 

Detailed Description

Helpers for working with CDT::Triangulation.

Function Documentation

◆ calculateTrianglesByVertex()

CDT_INLINE_IF_HEADER_ONLY VerticesTriangles CDT::calculateTrianglesByVertex ( const TriangleVec triangles,
VertInd  verticesSize 
)

Calculate triangles adjacent to vertices (triangles by vertex index)

Parameters
trianglestriangulation
verticesSizetotal number of vertices to pre-allocate the output
Returns
triangles by vertex index

Definition at line 20 of file CDT.hpp.

◆ EdgeToPiecesMapping()

CDT_INLINE_IF_HEADER_ONLY unordered_map< Edge, EdgeVec > CDT::EdgeToPiecesMapping ( const unordered_map< Edge, EdgeVec > &  pieceToOriginals)

Converts piece->original_edges mapping to original_edge->pieces

Parameters
pieceToOriginalsmaps pieces to original edges
Returns
mapping of original edges to pieces

Definition at line 88 of file CDT.hpp.

◆ EdgeToSplitVertices()

template<typename T >
CDT_EXPORT unordered_map< Edge, std::vector< VertInd > > CDT::EdgeToSplitVertices ( const unordered_map< Edge, EdgeVec > &  edgeToPieces,
const std::vector< V2d< T > > &  vertices 
)

Convert edge-to-pieces mapping into edge-to-split-vertices mapping

Template Parameters
Ttype of vertex coordinates (e.g., float, double)
Parameters
edgeToPiecesedge-to-pieces mapping
verticesvertex buffer
Returns
mapping of edge-to-split-points. Split points are sorted from edge's start (v1) to end (v2)

Definition at line 384 of file CDT.h.

◆ extractEdgesFromTriangles()

CDT_INLINE_IF_HEADER_ONLY EdgeUSet CDT::extractEdgesFromTriangles ( const TriangleVec triangles)

Extract all edges of triangles.

Parameters
trianglestriangles used to extract edges
Returns
an unordered set of all edges of triangulation

Definition at line 74 of file CDT.hpp.

◆ FindDuplicates()

template<typename T , typename TVertexIter , typename TGetVertexCoordX , typename TGetVertexCoordY >
DuplicatesInfo CDT::FindDuplicates ( TVertexIter  first,
TVertexIter  last,
TGetVertexCoordX  getX,
TGetVertexCoordY  getY 
)

Find duplicates in given custom point-type range.

Note
duplicates are points with exactly same X and Y coordinates
Template Parameters
TVertexIteriterator that dereferences to custom point type
TGetVertexCoordXfunction object getting x coordinate from vertex. Getter signature: const TVertexIter::value_type& -> T
TGetVertexCoordYfunction object getting y coordinate from vertex. Getter signature: const TVertexIter::value_type& -> T
Parameters
firstbeginning of the range of vertices
lastend of the range of vertices
getXgetter of X-coordinate
getYgetter of Y-coordinate
Returns
information about vertex duplicates

Definition at line 293 of file CDT.h.

◆ RemapEdges() [1/2]

CDT_INLINE_IF_HEADER_ONLY void CDT::RemapEdges ( std::vector< Edge > &  edges,
const std::vector< std::size_t > &  mapping 
)

Remap vertex indices in edges (in-place) using given vertex-index mapping.

Note
Mapping can be a result of RemoveDuplicates function
Parameters
[in,out]edgescollection of edges to remap
mappingvertex-index mapping

Definition at line 46 of file CDT.hpp.

◆ RemapEdges() [2/2]

template<typename TEdgeIter , typename TGetEdgeVertexStart , typename TGetEdgeVertexEnd , typename TMakeEdgeFromStartAndEnd >
CDT_EXPORT void CDT::RemapEdges ( TEdgeIter  first,
TEdgeIter  last,
const std::vector< std::size_t > &  mapping,
TGetEdgeVertexStart  getStart,
TGetEdgeVertexEnd  getEnd,
TMakeEdgeFromStartAndEnd  makeEdge 
)

Remap vertex indices in edges (in-place) using given vertex-index mapping.

Template Parameters
TEdgeIteriterator that dereferences to custom edge type
TGetEdgeVertexStartfunction object getting start vertex index from an edge. Getter signature: const TEdgeIter::value_type& -> CDT::VertInd
TGetEdgeVertexEndfunction object getting end vertex index from an edge. Getter signature: const TEdgeIter::value_type& -> CDT::VertInd
TMakeEdgeFromStartAndEndfunction object that makes new edge from start and end vertices
Parameters
firstbeginning of the range of edges
lastend of the range of edges
mappingvertex-index mapping
getStartgetter of edge start vertex index
getEndgetter of edge end vertex index
makeEdgefactory for making edge from vetices

Definition at line 340 of file CDT.h.

◆ RemoveDuplicates() [1/2]

template<typename TVertex , typename TAllocator >
void CDT::RemoveDuplicates ( std::vector< TVertex, TAllocator > &  vertices,
const std::vector< std::size_t > &  duplicates 
)

Remove duplicates in-place from vector of custom points.

Template Parameters
TVertexvertex type
TAllocatorallocator used by input vector of vertices
Parameters
verticesvertices to remove duplicates from
duplicatesinformation about duplicates

Definition at line 322 of file CDT.h.

◆ RemoveDuplicates() [2/2]

template<typename T >
CDT_EXPORT DuplicatesInfo CDT::RemoveDuplicates ( std::vector< V2d< T > > &  vertices)

Remove duplicated points in-place.

Template Parameters
Ttype of vertex coordinates (e.g., float, double)
Parameters
[in,out]verticescollection of vertices to remove duplicates from
Returns
information about duplicated vertices that were removed.

Definition at line 37 of file CDT.hpp.

◆ RemoveDuplicatesAndRemapEdges() [1/2]

template<typename T , typename TVertex , typename TGetVertexCoordX , typename TGetVertexCoordY , typename TVertexAllocator , typename TEdgeIter , typename TGetEdgeVertexStart , typename TGetEdgeVertexEnd , typename TMakeEdgeFromStartAndEnd >
DuplicatesInfo CDT::RemoveDuplicatesAndRemapEdges ( std::vector< TVertex, TVertexAllocator > &  vertices,
TGetVertexCoordX  getX,
TGetVertexCoordY  getY,
TEdgeIter  edgesFirst,
TEdgeIter  edgesLast,
TGetEdgeVertexStart  getStart,
TGetEdgeVertexEnd  getEnd,
TMakeEdgeFromStartAndEnd  makeEdge 
)

Find point duplicates, remove them from vector (in-place) and remap edges (in-place)

Note
Same as a chained call of CDT::FindDuplicates, CDT::RemoveDuplicates, and CDT::RemapEdges
Template Parameters
Ttype of vertex coordinates (e.g., float, double)
TVertextype of vertex
TGetVertexCoordXfunction object getting x coordinate from vertex. Getter signature: const TVertexIter::value_type& -> T
TGetVertexCoordYfunction object getting y coordinate from vertex. Getter signature: const TVertexIter::value_type& -> T
TEdgeIteriterator that dereferences to custom edge type
TGetEdgeVertexStartfunction object getting start vertex index from an edge. Getter signature: const TEdgeIter::value_type& -> CDT::VertInd
TGetEdgeVertexEndfunction object getting end vertex index from an edge. Getter signature: const TEdgeIter::value_type& -> CDT::VertInd
TMakeEdgeFromStartAndEndfunction object that makes new edge from start and end vertices
Parameters
[in,out]verticesvertices to remove duplicates from
[in,out]edgescollection of edges connecting vertices
getXgetter of X-coordinate
getYgetter of Y-coordinate
edgesFirstbeginning of the range of edges
edgesLastend of the range of edges
getStartgetter of edge start vertex index
getEndgetter of edge end vertex index
makeEdgefactory for making edge from vetices
Returns
information about vertex duplicates

Definition at line 366 of file CDT.h.

◆ RemoveDuplicatesAndRemapEdges() [2/2]

template<typename T >
CDT_EXPORT DuplicatesInfo CDT::RemoveDuplicatesAndRemapEdges ( std::vector< V2d< T > > &  vertices,
std::vector< Edge > &  edges 
)

Same as a chained call of CDT::RemoveDuplicates + CDT::RemapEdges.

Template Parameters
Ttype of vertex coordinates (e.g., float, double)
Parameters
[in,out]verticescollection of vertices to remove duplicates from
[in,out]edgescollection of edges to remap

Definition at line 58 of file CDT.hpp.