1#pragma once23#include <vector>4#include "Contour.h"5#include "Scanline.h"67namespace msdfgen {89// Threshold of the dot product of adjacent edge directions to be considered convergent.10#define MSDFGEN_CORNER_DOT_EPSILON .0000011112/// Vector shape representation.13class Shape {1415public:16struct Bounds {17double l, b, r, t;18};1920/// The list of contours the shape consists of.21std::vector<Contour> contours;22/// Specifies whether the shape uses bottom-to-top (false) or top-to-bottom (true) Y coordinates.23bool inverseYAxis;2425Shape();26/// Adds a contour.27void addContour(const Contour &contour);28#ifdef MSDFGEN_USE_CPP1129void addContour(Contour &&contour);30#endif31/// Adds a blank contour and returns its reference.32Contour &addContour();33/// Normalizes the shape geometry for distance field generation.34void normalize();35/// Performs basic checks to determine if the object represents a valid shape.36bool validate() const;37/// Adjusts the bounding box to fit the shape.38void bound(double &l, double &b, double &r, double &t) const;39/// Adjusts the bounding box to fit the shape border's mitered corners.40void boundMiters(double &l, double &b, double &r, double &t, double border, double miterLimit, int polarity) const;41/// Computes the minimum bounding box that fits the shape, optionally with a (mitered) border.42Bounds getBounds(double border = 0, double miterLimit = 0, int polarity = 0) const;43/// Outputs the scanline that intersects the shape at y.44void scanline(Scanline &line, double y) const;45/// Returns the total number of edge segments46int edgeCount() const;47/// Assumes its contours are unoriented (even-odd fill rule). Attempts to orient them to conform to the non-zero winding rule.48void orientContours();4950};5152}535455