11#ifndef CDT_HmXGv083vZCrT3OXASD9
12#define CDT_HmXGv083vZCrT3OXASD9
41 typename OutputVertIt,
46 OutputVertIt outVertsFirst,
47 OutputTriIt outTrisFirst,
48 const TXCoordIter xfirst,
49 const TXCoordIter xlast,
50 const TYCoordIter yfirst,
51 const TYCoordIter ylast)
53 typedef typename std::iterator_traits<TXCoordIter>::value_type T;
54 const std::size_t xres = std::distance(xfirst, xlast) - 1;
55 const std::size_t yres = std::distance(yfirst, ylast) - 1;
57 TXCoordIter yiter = yfirst;
58 for(std::size_t iy = 0; yiter != ylast; ++yiter, ++iy)
60 TXCoordIter xiter = xfirst;
61 for(std::size_t ix = 0; xiter != xlast; ++xiter, ++ix)
63 *outVertsFirst++ =
V2d<T>(*xiter, *yiter);
64 const std::size_t i = iy * xres + ix;
68 if(ix > 0 && iy < yres)
70 vTris.push_back(
static_cast<TriInd>(2 * (i - 1)));
71 vTris.push_back(
static_cast<TriInd>(2 * (i - 1) + 1));
74 if(ix < xres && iy < yres)
76 vTris.push_back(
static_cast<TriInd>(2 * i));
81 vTris.push_back(
static_cast<TriInd>(2 * (i - xres - 1) + 1));
84 if(ix < xres && iy > 0)
86 vTris.push_back(
static_cast<TriInd>(2 * (i - xres)));
87 vTris.push_back(
static_cast<TriInd>(2 * (i - xres) + 1));
90 *outTrisFirst++ = vTris.front();
103template <
typename OutputIt>
106 const IndexSizeType xres,
107 const IndexSizeType yres)
109 for(IndexSizeType iy = 0; iy < yres; ++iy)
111 for(IndexSizeType ix = 0; ix < xres; ++ix)
118 const IndexSizeType i = iy * xres + ix;
119 const IndexSizeType iv = iy * (xres + 1) + ix;
127 arr3(vv[0], vv[1], vv[2]),
129 TriInd(iy ? 2 * i - xres * 2 + 1 : noNeighbor),
131 TriInd(ix ? 2 * i - 1 : noNeighbor)));
136 arr3(vv[1], vv[3], vv[2]),
138 TriInd(ix < xres - 1 ? 2 * i + 2 : noNeighbor),
139 TriInd(iy < yres - 1 ? 2 * i + xres * 2 : noNeighbor),
164template <
typename T,
typename TNearPo
intLocator>
170 const std::size_t xres,
171 const std::size_t yres,
174 std::vector<T> xcoords;
175 std::vector<T> ycoords;
176 xcoords.reserve(xres + 1);
177 ycoords.reserve(yres + 1);
178 const T xstep = (xmax - xmin) / xres;
180 for(std::size_t ix = 0; ix <= xres; ++ix, x += xstep)
181 xcoords.push_back(x);
182 const T ystep = (ymax - ymin) / yres;
184 for(std::size_t iy = 0; iy <= yres; ++iy, y += ystep)
185 ycoords.push_back(y);
188 xcoords.begin(), xcoords.end(), ycoords.begin(), ycoords.end(), out);
208 typename TNearPointLocator,
209 typename TXCoordIter,
210 typename TYCoordIter>
212 const TXCoordIter xfirst,
213 const TXCoordIter xlast,
214 const TYCoordIter yfirst,
215 const TYCoordIter ylast,
218 const std::size_t xres = std::distance(xfirst, xlast) - 1;
219 const std::size_t yres = std::distance(yfirst, ylast) - 1;
221 out.
vertices.reserve((xres + 1) * (yres + 1));
232 static_cast<IndexSizeType
>(xres),
233 static_cast<IndexSizeType
>(yres));
void generateGridVertices(OutputVertIt outVertsFirst, OutputTriIt outTrisFirst, const TXCoordIter xfirst, const TXCoordIter xlast, const TYCoordIter yfirst, const TYCoordIter ylast)
Generate grid vertices given of X- and Y-ticks.
void generateGridTriangles(OutputIt outFirst, const IndexSizeType xres, const IndexSizeType yres)
Generate grid triangles.
Data structure representing a 2D constrained Delaunay triangulation.
V2dVec vertices
triangulation's vertices
TriangleVec triangles
triangulation's triangles
void initializedWithCustomSuperGeometry()
Call this method after directly setting custom super-geometry via vertices and triangles members.
TriIndVec & VertTrisInternal()
Access internal vertex adjacent triangles.
Namespace containing triangulation functionality.
std::vector< TriInd > TriIndVec
Vector of triangle indices.
IndexSizeType VertInd
Vertex index.
array< T, 3 > arr3(const T &v0, const T &v1, const T &v2)
Needed for c++03 compatibility (no uniform initialization available)
void initializeWithIrregularGrid(const TXCoordIter xfirst, const TXCoordIter xlast, const TYCoordIter yfirst, const TYCoordIter ylast, Triangulation< T, TNearPointLocator > &out)
Make a triangulation that uses irregular grid triangles instead of super-triangle.
IndexSizeType TriInd
Triangle index.
void initializeWithRegularGrid(const T xmin, const T xmax, const T ymin, const T ymax, const std::size_t xres, const std::size_t yres, Triangulation< T, TNearPointLocator > &out)
Make a triangulation that uses regular grid triangles instead of super-triangle.
Triangulation triangle (counter-clockwise winding)