Mesh/Geometry structures#

template<typename T>
struct Point2D#

Trivially copyable 2D Point implementation that provides basic arithmetic operators as well as bounds-checked template access to the arguments

Public Types

using value_type = T#

Public Functions

Point2D() = default#
inline constexpr Point2D(T x_val, T y_val)#
inline bool operator==(Point2D<T> other) const#
inline bool operator==(T other) const#
inline bool operator!=(Point2D<T> other) const#
inline Point2D<T> operator+(Point2D<T> other) const#
inline Point2D<T> operator+(T other) const#
inline Point2D<T> operator-(Point2D<T> other) const#
inline Point2D<T> operator-(T other) const#
inline Point2D<T> operator-() const#
inline Point2D<T> operator*(T factor) const#
inline Point2D<T> operator*(Point2D<T> other) const#
inline Point2D<T> &operator*=(Point2D<T> other)#
inline Point2D<T> operator/(T value) const#
inline Point2D<T> operator/(Point2D<T> other) const#
inline T distance(const Point2D<T> other) const#
template<typename U = T>
inline U x_checked()#

Bounds-checked access to the x coordinate of the point, throws error if value would exceed numeric limit.

template<typename U = T>
inline U y_checked()#

Bounds-checked access to the y coordinate of the point, throws error if value would exceed numeric limit.

inline size_t hash() const#

Hash function for Point2D, allowing Point2D objects to be used in hashed containers like std::unordered_map. Combines the hash of the x and y coordinates.

template<std::size_t I>
inline constexpr auto get(Point2D<T> &point)#
template<std::size_t I>
inline constexpr auto &get(Point2D<T> &point)#
template<std::size_t I>
inline constexpr const auto &get(const Point2D<T> &point)#
template<std::size_t I>
inline constexpr auto &&get(Point2D<T> &&point)#

Public Members

T x = static_cast<T>(0)#
T y = static_cast<T>(0)#

Public Static Functions

static inline bool equal(Point2D<T> pt1, Point2D<T> pt2, double epsilon = 1e-6)#
static inline Point2D lerp(const Point2D<T> a, const Point2D<T> b, double t)#

Static lerp function interpolating between a and b at position t where position t is between 0 and 1.

template<typename T>
struct Vertex#

Extension of a Point2D to additionally describe the UV coordinate of a given point.

Public Functions

Vertex() = default#
inline Vertex(Point2D<T> point)#
inline Vertex(Point2D<T> point, Point2D<double> uv)#
inline Point2D<T> point() const#
inline Point2D<T> &point()#
inline Point2D<double> uv() const#
template<typename T, size_t _Size>
struct Face#

Public Functions

inline Point2D<T> centroid(const QuadMesh<T> &mesh) const#
inline void bbox(BoundingBox<T> _bbox)#
inline const BoundingBox<T> &bbox() const#
inline size_t vertex_idx(size_t in_face_idx) const#
inline size_t num_vertices() const noexcept#
inline void vertex_indices(std::array<size_t, _Size> vertex_indices)#
inline std::array<size_t, _Size> vertex_indices() const#
template<typename T>
struct QuadMesh#

Mesh class for 2D Geometry representation, implemented with an Octree structure accelerating lookups and traversals. This currently only supports quadrilateral meshes and is very specific to the needs of the PhotoshopAPI. It is therefore recommended to use a more generic mesh library if further operations are wanted.

Public Functions

QuadMesh() = default#
inline QuadMesh(const std::vector<Point2D<T>> &points, size_t x_divisions, size_t y_divisions)#

Generate a QuadMesh from a flat vector of points. These points must be in scanline order.

inline QuadMesh(const std::vector<Vertex<T>> &vertices, size_t x_divisions, size_t y_divisions)#

Generate a QuadMesh from a flat vector of vertices. These points must be in scanline order.

inline void move(Point2D<T> offset)#
inline std::vector<Point2D<T>> points() const#
inline const Vertex<T> &vertex(size_t index) const#
inline const std::vector<Vertex<T>> &vertices() const#
inline void vertices(std::vector<Vertex<T>> &_vertices)#

Update the vertices of the mesh, the _vertices parameter must have the same amount of vertices as the mesh as this method is only supposed to represent transformations applied to the vertices not a complete rebuild of the structure.

If you wish to do that please re-initialize the mesh.

inline const Face<T, 4> &face(size_t index) const#
inline const std::vector<Face<T, 4>> &faces() const#
inline Point2D<double> uv_coordinate(Point2D<T> position) const#

Look up the mesh uv coordinate at the given point returning {-1, -1} if the point does not lie on the mesh.

inline BoundingBox<T> bbox() const noexcept#