#ifndef CLIPPER_H
#define CLIPPER_H
#include <cstdlib>
#include <type_traits>
#include <vector>
#include "clipper2/clipper.core.h"
#include "clipper2/clipper.engine.h"
#include "clipper2/clipper.offset.h"
#include "clipper2/clipper.minkowski.h"
#include "clipper2/clipper.rectclip.h"
namespace Clipper2Lib {
inline Paths64 BooleanOp(ClipType cliptype, FillRule fillrule,
const Paths64& subjects, const Paths64& clips)
{ … }
inline void BooleanOp(ClipType cliptype, FillRule fillrule,
const Paths64& subjects, const Paths64& clips, PolyTree64& solution)
{ … }
inline PathsD BooleanOp(ClipType cliptype, FillRule fillrule,
const PathsD& subjects, const PathsD& clips, int precision = 2)
{ … }
inline void BooleanOp(ClipType cliptype, FillRule fillrule,
const PathsD& subjects, const PathsD& clips,
PolyTreeD& polytree, int precision = 2)
{ … }
inline Paths64 Intersect(const Paths64& subjects, const Paths64& clips, FillRule fillrule)
{ … }
inline PathsD Intersect(const PathsD& subjects, const PathsD& clips, FillRule fillrule, int decimal_prec = 2)
{ … }
inline Paths64 Union(const Paths64& subjects, const Paths64& clips, FillRule fillrule)
{ … }
inline PathsD Union(const PathsD& subjects, const PathsD& clips, FillRule fillrule, int decimal_prec = 2)
{ … }
inline Paths64 Union(const Paths64& subjects, FillRule fillrule)
{ … }
inline PathsD Union(const PathsD& subjects, FillRule fillrule, int precision = 2)
{ … }
inline Paths64 Difference(const Paths64& subjects, const Paths64& clips, FillRule fillrule)
{ … }
inline PathsD Difference(const PathsD& subjects, const PathsD& clips, FillRule fillrule, int decimal_prec = 2)
{ … }
inline Paths64 Xor(const Paths64& subjects, const Paths64& clips, FillRule fillrule)
{ … }
inline PathsD Xor(const PathsD& subjects, const PathsD& clips, FillRule fillrule, int decimal_prec = 2)
{ … }
inline Paths64 InflatePaths(const Paths64& paths, double delta,
JoinType jt, EndType et, double miter_limit = 2.0,
double arc_tolerance = 0.0)
{ … }
inline PathsD InflatePaths(const PathsD& paths, double delta,
JoinType jt, EndType et, double miter_limit = 2.0,
int precision = 2, double arc_tolerance = 0.0)
{ … }
template <typename T>
inline Path<T> TranslatePath(const Path<T>& path, T dx, T dy)
{ … }
inline Path64 TranslatePath(const Path64& path, int64_t dx, int64_t dy)
{ … }
inline PathD TranslatePath(const PathD& path, double dx, double dy)
{ … }
template <typename T>
inline Paths<T> TranslatePaths(const Paths<T>& paths, T dx, T dy)
{ … }
inline Paths64 TranslatePaths(const Paths64& paths, int64_t dx, int64_t dy)
{ … }
inline PathsD TranslatePaths(const PathsD& paths, double dx, double dy)
{ … }
inline Paths64 RectClip(const Rect64& rect, const Paths64& paths)
{ … }
inline Paths64 RectClip(const Rect64& rect, const Path64& path)
{ … }
inline PathsD RectClip(const RectD& rect, const PathsD& paths, int precision = 2)
{ … }
inline PathsD RectClip(const RectD& rect, const PathD& path, int precision = 2)
{ … }
inline Paths64 RectClipLines(const Rect64& rect, const Paths64& lines)
{ … }
inline Paths64 RectClipLines(const Rect64& rect, const Path64& line)
{ … }
inline PathsD RectClipLines(const RectD& rect, const PathsD& lines, int precision = 2)
{ … }
inline PathsD RectClipLines(const RectD& rect, const PathD& line, int precision = 2)
{ … }
namespace details
{
inline void PolyPathToPaths64(const PolyPath64& polypath, Paths64& paths)
{ … }
inline void PolyPathToPathsD(const PolyPathD& polypath, PathsD& paths)
{ … }
inline bool PolyPath64ContainsChildren(const PolyPath64& pp)
{ … }
static void OutlinePolyPath(std::ostream& os,
size_t idx, bool isHole, size_t count, const std::string& preamble)
{ … }
static void OutlinePolyPath64(std::ostream& os, const PolyPath64& pp,
size_t idx, std::string preamble)
{ … }
static void OutlinePolyPathD(std::ostream& os, const PolyPathD& pp,
size_t idx, std::string preamble)
{ … }
template<typename T, typename U>
inline constexpr void MakePathGeneric(const T an_array,
size_t array_size, std::vector<U>& result)
{ … }
}
inline std::ostream& operator<< (std::ostream& os, const PolyTree64& pp)
{ … }
inline std::ostream& operator<< (std::ostream& os, const PolyTreeD& pp)
{ … }
inline Paths64 PolyTreeToPaths64(const PolyTree64& polytree)
{ … }
inline PathsD PolyTreeToPathsD(const PolyTreeD& polytree)
{ … }
inline bool CheckPolytreeFullyContainsChildren(const PolyTree64& polytree)
{ … }
template<typename T,
typename std::enable_if<
std::is_integral<T>::value &&
!std::is_same<char, T>::value, bool
>::type = true>
inline Path64 MakePath(const std::vector<T>& list)
{ … }
template<typename T, std::size_t N,
typename std::enable_if<
std::is_integral<T>::value &&
!std::is_same<char, T>::value, bool
>::type = true>
inline Path64 MakePath(const T(&list)[N])
{ … }
template<typename T,
typename std::enable_if<
std::is_arithmetic<T>::value &&
!std::is_same<char, T>::value, bool
>::type = true>
inline PathD MakePathD(const std::vector<T>& list)
{ … }
template<typename T, std::size_t N,
typename std::enable_if<
std::is_arithmetic<T>::value &&
!std::is_same<char, T>::value, bool
>::type = true>
inline PathD MakePathD(const T(&list)[N])
{ … }
#ifdef USINGZ
template<typename T2, std::size_t N>
inline Path64 MakePathZ(const T2(&list)[N])
{
static_assert(N % 3 == 0 && std::numeric_limits<T2>::is_integer,
"MakePathZ requires integer values in multiples of 3");
std::size_t size = N / 3;
Path64 result(size);
for (size_t i = 0; i < size; ++i)
result[i] = Point64(list[i * 3],
list[i * 3 + 1], list[i * 3 + 2]);
return result;
}
template<typename T2, std::size_t N>
inline PathD MakePathZD(const T2(&list)[N])
{
static_assert(N % 3 == 0,
"MakePathZD requires values in multiples of 3");
std::size_t size = N / 3;
PathD result(size);
if constexpr (std::numeric_limits<T2>::is_integer)
for (size_t i = 0; i < size; ++i)
result[i] = PointD(list[i * 3],
list[i * 3 + 1], list[i * 3 + 2]);
else
for (size_t i = 0; i < size; ++i)
result[i] = PointD(list[i * 3], list[i * 3 + 1],
static_cast<int64_t>(list[i * 3 + 2]));
return result;
}
#endif
inline Path64 TrimCollinear(const Path64& p, bool is_open_path = false)
{ … }
inline PathD TrimCollinear(const PathD& path, int precision, bool is_open_path = false)
{ … }
template <typename T>
inline double Distance(const Point<T> pt1, const Point<T> pt2)
{ … }
template <typename T>
inline double Length(const Path<T>& path, bool is_closed_path = false)
{ … }
template <typename T>
inline bool NearCollinear(const Point<T>& pt1, const Point<T>& pt2, const Point<T>& pt3, double sin_sqrd_min_angle_rads)
{ … }
template <typename T>
inline Path<T> Ellipse(const Rect<T>& rect, size_t steps = 0)
{ … }
template <typename T>
inline Path<T> Ellipse(const Point<T>& center,
double radiusX, double radiusY = 0, size_t steps = 0)
{ … }
inline size_t GetNext(size_t current, size_t high,
const std::vector<bool>& flags)
{ … }
inline size_t GetPrior(size_t current, size_t high,
const std::vector<bool>& flags)
{ … }
template <typename T>
inline Path<T> SimplifyPath(const Path<T> &path,
double epsilon, bool isClosedPath = true)
{ … }
template <typename T>
inline Paths<T> SimplifyPaths(const Paths<T> &paths,
double epsilon, bool isClosedPath = true)
{ … }
template <typename T>
inline void RDP(const Path<T> path, std::size_t begin,
std::size_t end, double epsSqrd, std::vector<bool>& flags)
{ … }
template <typename T>
inline Path<T> RamerDouglasPeucker(const Path<T>& path, double epsilon)
{ … }
template <typename T>
inline Paths<T> RamerDouglasPeucker(const Paths<T>& paths, double epsilon)
{ … }
}
#endif