11#ifndef CDT_HmXGv083vZCrT3OXASD9
12#define CDT_HmXGv083vZCrT3OXASD9
17#ifdef CDT_CXX11_IS_SUPPORTED
43 typename OutputVertIt,
48 OutputVertIt outVertsFirst,
49 OutputTriIt outTrisFirst,
50 const TXCoordIter xfirst,
51 const TXCoordIter xlast,
52 const TYCoordIter yfirst,
53 const TYCoordIter ylast)
55 typedef typename std::iterator_traits<TXCoordIter>::value_type T;
56 const std::size_t xres = std::distance(xfirst, xlast) - 1;
57 const std::size_t yres = std::distance(yfirst, ylast) - 1;
59 TXCoordIter yiter = yfirst;
60 for(std::size_t iy = 0; yiter != ylast; ++yiter, ++iy)
62 TXCoordIter xiter = xfirst;
63 for(std::size_t ix = 0; xiter != xlast; ++xiter, ++ix)
66 const std::size_t i = iy * xres + ix;
70 if(ix > 0 && iy < yres)
72 vTris.push_back(
static_cast<TriInd>(2 * (i - 1)));
73 vTris.push_back(
static_cast<TriInd>(2 * (i - 1) + 1));
76 if(ix < xres && iy < yres)
78 vTris.push_back(
static_cast<TriInd>(2 * i));
83 vTris.push_back(
static_cast<TriInd>(2 * (i - xres - 1) + 1));
86 if(ix < xres && iy > 0)
88 vTris.push_back(
static_cast<TriInd>(2 * (i - xres)));
89 vTris.push_back(
static_cast<TriInd>(2 * (i - xres) + 1));
91#ifdef CDT_CXX11_IS_SUPPORTED
92 *outTrisFirst++ = std::move(vTris.front());
94 *outTrisFirst++ = vTris;
108template <
typename OutputIt>
111 const IndexSizeType xres,
112 const IndexSizeType yres)
114 for(IndexSizeType iy = 0; iy < yres; ++iy)
116 for(IndexSizeType ix = 0; ix < xres; ++ix)
123 const IndexSizeType i = iy * xres + ix;
124 const IndexSizeType iv = iy * (xres + 1) + ix;
132 {vv[0], vv[1], vv[2]},
133 {
TriInd(iy ? 2 * i - xres * 2 + 1 : noNeighbor),
135 TriInd(ix ? 2 * i - 1 : noNeighbor)}};
140 {vv[1], vv[3], vv[2]},
141 {
TriInd(ix < xres - 1 ? 2 * i + 2 : noNeighbor),
142 TriInd(iy < yres - 1 ? 2 * i + xres * 2 : noNeighbor),
167template <
typename T,
typename TNearPo
intLocator>
173 const std::size_t xres,
174 const std::size_t yres,
177 std::vector<T> xcoords;
178 std::vector<T> ycoords;
179 xcoords.reserve(xres + 1);
180 ycoords.reserve(yres + 1);
181 const T xstep = (xmax - xmin) / xres;
183 for(std::size_t ix = 0; ix <= xres; ++ix, x += xstep)
184 xcoords.push_back(x);
185 const T ystep = (ymax - ymin) / yres;
187 for(std::size_t iy = 0; iy <= yres; ++iy, y += ystep)
188 ycoords.push_back(y);
191 xcoords.begin(), xcoords.end(), ycoords.begin(), ycoords.end(), out);
211 typename TNearPointLocator,
212 typename TXCoordIter,
213 typename TYCoordIter>
215 const TXCoordIter xfirst,
216 const TXCoordIter xlast,
217 const TYCoordIter yfirst,
218 const TYCoordIter ylast,
221 const std::size_t xres = std::distance(xfirst, xlast) - 1;
222 const std::size_t yres = std::distance(yfirst, ylast) - 1;
224 out.
vertices.reserve((xres + 1) * (yres + 1));
226 detail::generateGridVertices(
233 detail::generateGridTriangles(
235 static_cast<IndexSizeType
>(xres),
236 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.
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)
static V2d make(T x, T y)
Create vector from X and Y coordinates.