src
Boundary

class sme::mesh::Boundary
Approximate boundary line with adjustable number of points.
Given an ordered set of pixels that form a line or a closed loop, constructs an approximation to the line. The number of points used can be chosen automatically or set by the user.
Public Functions

bool isLoop() const
Is the line a closed loop.

bool isValid() const
Is the line valid.

const std::vector<QPoint> &getPoints() const
The simplified line.

const std::vector<QPoint> &getAllPoints() const
The original unsimplified line.

std::size_t getMaxPoints() const
The maximum number of points used by the approximate line.

void setPoints(std::vector<QPoint> &&simplifiedPoints)
Set the simplified line points explicitly.

void setMaxPoints(std::size_t maxPoints)
Set the maximum number of points to use in the approximate line.

std::size_t setMaxPoints()
Automatically choose and return the maximum number of points to use in the approximate line.

explicit Boundary(const std::vector<QPoint> &boundaryPoints, bool isClosedLoop = false)
Construct a simplified line from on ordered set of points.
 Parameters
boundaryPoints – [in] the boundary as an ordered set of points
isClosedLoop – [in] true if the last point implicitly connects to the first point to form a closed loop

bool isLoop() const
ContourMap
getInteriorPoints
Line Simplifier

class sme::mesh::LineSimplifier
Simplify a line using VisvalingamWhyatt polyline simplification.
Given an ordered set of pixels that form a line or a closed loop, construct an npoint approximation to the line.
Note
Each point in the line is ranked according to the size of the triangle formed by itself and its two nearest neighbours, and points are removed in reverse order of importance. See 10.1179/000870493786962263 for more details.
Public Functions

void getSimplifiedLine(std::vector<QPoint> &line, const LineError &allowedError = {0.0, 0.4}) const
Construct a simplified line given a maximum allowed error.
 Parameters
line – [out] the simplified lines
allowedError – [in] the maximum allowed error

void getSimplifiedLine(std::vector<QPoint> &line, std::size_t nPoints) const
Construct a simplified line given a maximum number of points.
 Parameters
line – [out] the simplified lines
nPoints – [in] the maximum allowed number of points

const std::vector<QPoint> &getAllVertices() const
The original unsimplified line.

std::size_t maxPoints() const
The number of points in the original unsimplified line.

bool isValid() const
Is the line valid.

bool isLoop() const
Is the line a closed loop.

explicit LineSimplifier(const std::vector<QPoint> &points, bool isClosedLoop = false)
Construct a simplified version of the supplied line.
 Parameters
points – [in] the ordered points that define the line
isClosedLoop – [in] true if the line represents a closed loop, i.e. the last point implicitly connects to the first point

void getSimplifiedLine(std::vector<QPoint> &line, const LineError &allowedError = {0.0, 0.4}) const
PixelCornerIterator

class sme::mesh::PixelCornerIterator
Iterate around the edge vertices of a pixel contour.
Given a closed loop 8connected pixel contour generated by Suzuki contour tracing, this class iterates around the edge vertices of the pixels to to produce a 4connected contour of vertices.
Note
The OpenCV function cv::findContours() implements Suzuki contour tracing.
Note
Edge vertices are shifted by (1/2,1/2) relative to the pixel centre, e.g the (0,0) vertex corresponds to the topleft corner of the (0,0) pixel.
Public Functions

PixelCornerIterator(const std::vector<cv::Point> &points, bool outer)
Iterate around the edge vertices of a pixel contour.
Given a closed loop 8connected pixel contour generated by Suzuki contour tracing, this class iterates around the edge vertices of the pixels to to produce a 4connected contour of vertices.
 Parameters
points – [in] 8connected pixel contour as returned by cv::findContours()
outer – [in] true if the contour is an outer contour (has no parent)

cv::Point vertex() const
The current vertex.

bool done() const
Returns true if at the end of the contour.

PixelCornerIterator &operator++()
Progress to the next vertex in the contour.

PixelCornerIterator(const std::vector<cv::Point> &points, bool outer)
Triangulate

class sme::mesh::Triangulate
Triangulate a set of boundary lines.
Given a set of boundary lines, a set of interior points for each compartment, and a maximum allowed triangle area for each compartment, constructs a Constrained Delauney Triangulation of the geometry, with the triangles labelled according to the compartment they belong to.
Public Functions

explicit Triangulate(const std::vector<Boundary> &boundaries, const std::vector<std::vector<QPointF>> &interiorPoints, const std::vector<std::size_t> &maxTriangleAreas)
Triangulate a set of boundary lines.
Given a set of boundary lines, a set of interior points for each compartment,
 Parameters
boundaries – [in] the boundary lines separating the compartments
interiorPoints – [in] the interior point(s) for each compartment
maxTriangleAreas – [in] the maximum allowed triangle area for each compartment

const std::vector<QPointF> &getPoints() const
The vertices or points in the mesh.
 Returns
The vertices in the mesh

const std::vector<std::vector<TriangulateTriangleIndex>> &getTriangleIndices() const
The triangle vertex indices.
For each compartment, the vertices of the triangles that define this compartment in the mesh.
 Returns
The triangle vertex indices

explicit Triangulate(const std::vector<Boundary> &boundaries, const std::vector<std::vector<QPointF>> &interiorPoints, const std::vector<std::size_t> &maxTriangleAreas)