49 static constexpr std::size_t
invalid_index = std::numeric_limits<std::size_t>::max();
72 using Segment = std::pair<std::size_t, std::size_t>;
86 void initialize(
const std::vector<Point2D> & points,
const std::vector<Segment> & segments);
155 const double *
xy(std::size_t v)
const {
return &
_vertices[v].x; }
164 std::size_t
toCaller(std::size_t v)
const;
184 std::size_t
locate(
const Point2D & p)
const;
196 void growCavity(std::size_t seed, std::size_t v_new, std::set<std::size_t> & cavity)
const;
205 std::vector<std::size_t>
retriangulate(
const std::vector<std::size_t> & removed,
206 const std::vector<std::array<std::size_t, 3>> & added);
222 const std::vector<std::size_t> & chain,
225 std::vector<std::array<std::size_t, 3>> & triangles)
const;
228 bool isStrictlyBetween(std::size_t v_first, std::size_t v_mid, std::size_t v_last)
const;
Constrained Delaunay triangulation of a set of points in the plane, built one point at a time.
std::size_t _last_triangle
A triangle the last insertion produced, which is where the next point walk starts.
static constexpr std::size_t _num_bounding
The number of bounding triangle vertices padding the front of the vertex list.
const std::set< Segment > & constrainedSegments() const
void initialize(const std::vector< Point2D > &points, const std::vector< Segment > &segments)
Triangulates points and recovers every entry of segments as an edge of the result.
std::size_t numPoints() const
std::size_t insertPoint(const Point2D &p)
Inserts a point, restoring the constrained Delaunay property around it.
bool isConstrainedSegment(std::size_t v0, std::size_t v1) const
void triangulatePseudopolygon(std::size_t v_start, std::size_t v_end, const std::vector< std::size_t > &chain, std::size_t first, std::size_t last, std::vector< std::array< std::size_t, 3 > > &triangles) const
Triangulates a polygon whose vertices are all visible from one of its edges, which is the shape a rec...
static Segment makeSegment(std::size_t v0, std::size_t v1)
unsigned int localVertexIndex(std::size_t t, std::size_t v) const
std::pair< std::size_t, std::size_t > Segment
A constrained segment, held as a vertex id pair with the smaller id first.
static constexpr double _bounding_reach
How far the bounding triangle reaches beyond the points, as a multiple of their extent.
std::set< Segment > _constraints
The constrained segments, in caller vertex ids with the smaller id first.
std::vector< std::string > checkInvariants() const
Checks everything this class promises: that every triangle is counter-clockwise, that the neighbor en...
bool isStrictlyBetween(std::size_t v_first, std::size_t v_mid, std::size_t v_last) const
std::vector< Triangle > _triangles
The triangles, every one of them live and counter-clockwise.
std::vector< std::string > checkEmptyCircumcircle() const
Tests every vertex against the circumcircle of every triangle.
static bool isBounding(std::size_t v)
std::size_t locate(const Point2D &p) const
Finds the triangle a point falls in by walking from the triangle the last insertion produced,...
void growCavity(std::size_t seed, std::size_t v_new, std::set< std::size_t > &cavity) const
Collects the triangles of the triangulation built so far that have to make way for a new vertex,...
std::string vertexName(std::size_t v) const
std::vector< Point2D > _vertices
The bounding triangle vertices followed by the caller's points.
unsigned int localEdgeIndex(std::size_t t, const Segment &edge) const
std::size_t toInternal(std::size_t id) const
void insertSegment(std::size_t v0, std::size_t v1)
Makes the segment between two vertices an edge of the triangulation and records it as constrained,...
bool isConstrainedEdge(std::size_t v0, std::size_t v1) const
const Point2D & point(std::size_t id) const
const double * xy(std::size_t v) const
bool containsPoint(std::size_t t, const Point2D &p) const
std::vector< std::size_t > retriangulate(const std::vector< std::size_t > &removed, const std::vector< std::array< std::size_t, 3 > > &added)
Swaps one triangulation of a region for another, reusing the slots of the triangles it removes and re...
std::size_t toCaller(std::size_t v) const
static constexpr std::size_t invalid_index
Sentinel for a vertex, triangle or neighbor that does not exist.
std::vector< std::size_t > _vertex_triangle
One triangle touching each vertex of _vertices, which is where a walk around it starts.
std::vector< Triangle > getTriangles() const
A point of the triangulation, held as plain coordinates.
A triangle of the triangulation.
std::array< std::size_t, 3 > neighbors
std::array< std::size_t, 3 > vertices