CDT  1.4.1
C++ library for constrained Delaunay triangulation
Loading...
Searching...
No Matches
VerifyTopology.h
Go to the documentation of this file.
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
10#ifndef CDT_Zahj4kpHLwFgkKtcOI1i
11#define CDT_Zahj4kpHLwFgkKtcOI1i
12
13#include <CDT.h>
14
15#include <algorithm>
16
17namespace CDT
18{
19
31template <typename T, typename TNearPointLocator>
33{
34 // Check if vertices' adjacent triangles contain vertex
36 cdt.triangles, static_cast<VertInd>(cdt.vertices.size()));
37 for(VertInd iV(0); iV < VertInd(cdt.vertices.size()); ++iV)
38 {
39 const TriIndVec& vTris = vertTris[iV];
40 typedef TriIndVec::const_iterator TriIndCit;
41 for(TriIndCit it = vTris.begin(); it != vTris.end(); ++it)
42 {
43 const array<VertInd, 3>& vv = cdt.triangles[*it].vertices;
44 if(std::find(vv.begin(), vv.end(), iV) == vv.end())
45 return false;
46 }
47 }
48 // Check if triangle neighbor links are fine
49 for(TriInd iT(0); iT < TriInd(cdt.triangles.size()); ++iT)
50 {
51 const Triangle& t = cdt.triangles[iT];
52 typedef NeighborsArr3::const_iterator NCit;
53 for(NCit it = t.neighbors.begin(); it != t.neighbors.end(); ++it)
54 {
55 if(*it == noNeighbor)
56 continue;
57 const array<TriInd, 3>& nn = cdt.triangles[*it].neighbors;
58 if(std::find(nn.begin(), nn.end(), iT) == nn.end())
59 return false;
60 }
61 }
62 // Check if triangle's vertices have triangle as adjacent
63 for(TriInd iT(0); iT < TriInd(cdt.triangles.size()); ++iT)
64 {
65 const Triangle& t = cdt.triangles[iT];
66 typedef VerticesArr3::const_iterator VCit;
67 for(VCit it = t.vertices.begin(); it != t.vertices.end(); ++it)
68 {
69 const TriIndVec& tt = vertTris[*it];
70 if(std::find(tt.begin(), tt.end(), iT) == tt.end())
71 return false;
72 }
73 }
74 return true;
75}
76
78template <typename T, typename TNearPointLocator>
81{
82 for(const auto& vt : cdt.VertTrisInternal())
83 if(vt == noNeighbor)
84 return false;
85 return true;
86}
87
88} // namespace CDT
89
90#endif
Public API.
Data structure representing a 2D constrained Delaunay triangulation.
V2dVec vertices
triangulation's vertices
TriangleVec triangles
triangulation's triangles
std::vector< TriIndVec > VerticesTriangles
Triangles by vertex index.
Definition CDT.h:44
TriIndVec & VertTrisInternal()
Access internal vertex adjacent triangles.
CDT_EXPORT VerticesTriangles calculateTrianglesByVertex(const TriangleVec &triangles, VertInd verticesSize)
Calculate triangles adjacent to vertices (triangles by vertex index)
Definition CDT.hpp:20
Namespace containing triangulation functionality.
bool verifyTopology(const CDT::Triangulation< T, TNearPointLocator > &cdt)
Verify that triangulation topology is consistent.
std::vector< TriInd > TriIndVec
Vector of triangle indices.
Definition CDTUtils.h:155
IndexSizeType VertInd
Vertex index.
Definition CDTUtils.h:142
IndexSizeType TriInd
Triangle index.
Definition CDTUtils.h:144
bool eachVertexHasNeighborTriangle(const CDT::Triangulation< T, TNearPointLocator > &cdt)
Check that each vertex has a neighbor triangle.
Triangulation triangle (counter-clockwise winding)
Definition CDTUtils.h:259
VerticesArr3 vertices
triangle's three vertices
Definition CDTUtils.h:260
NeighborsArr3 neighbors
triangle's three neighbors
Definition CDTUtils.h:261