1#pragma once23#include <vector>4#include "Contour.h"5#include "YAxisOrientation.h"6#include "Scanline.h"78namespace msdfgen {910// Threshold of the dot product of adjacent edge directions to be considered convergent.11#define MSDFGEN_CORNER_DOT_EPSILON .0000011213/// Vector shape representation.14class Shape {1516public:17struct Bounds {18// NOTE: b is actually the lower Y-coordinate and t the higher Y-coordinate. For Y_DOWNWARD orientation, b is actually the top and t the bottom. May be renamed in a future version.19double l, b, r, t;20};2122/// The list of contours the shape consists of.23std::vector<Contour> contours;24/// Specifies whether the shape uses bottom-to-top (false) or top-to-bottom (true) Y coordinates.25/// DEPRECATED - use getYAxisOrientation / setYAxisOrientation instead.26bool inverseYAxis;2728Shape();29/// Adds a contour.30void addContour(const Contour &contour);31#ifdef MSDFGEN_USE_CPP1132void addContour(Contour &&contour);33#endif34/// Adds a blank contour and returns its reference.35Contour &addContour();36/// Normalizes the shape geometry for distance field generation.37void normalize();38/// Performs basic checks to determine if the object represents a valid shape.39bool validate() const;40/// Adjusts the bounding box to fit the shape.41void bound(double &xMin, double &yMin, double &xMax, double &yMax) const;42/// Adjusts the bounding box to fit the shape border's mitered corners.43void boundMiters(double &xMin, double &yMin, double &xMax, double &yMax, double border, double miterLimit, int polarity) const;44/// Computes the minimum bounding box that fits the shape, optionally with a (mitered) border.45Bounds getBounds(double border = 0, double miterLimit = 0, int polarity = 0) const;46/// Outputs the scanline that intersects the shape at y.47void scanline(Scanline &line, double y) const;48/// Returns the total number of edge segments49int edgeCount() const;50/// Assumes its contours are unoriented (even-odd fill rule). Attempts to orient them to conform to the non-zero winding rule.51void orientContours();52/// Returns the orientation of the axis of the shape's Y coordinates.53YAxisOrientation getYAxisOrientation() const;54/// Sets the orientation of the axis of the shape's Y coordinates.55void setYAxisOrientation(YAxisOrientation yAxisOrientation);5657};5859}606162