Skip to content

Commit

Permalink
Make it compile on apple
Browse files Browse the repository at this point in the history
  • Loading branch information
casperlamboo committed Aug 8, 2023
1 parent 357f7c3 commit 6d89022
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
57 changes: 35 additions & 22 deletions include/infill/point_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,64 +26,74 @@ using Point = ClipperLib::IntPoint;
* @tparam Direction
* @tparam Container
*/
template<concepts::point P, bool IsClosed, direction Direction, template<class, class = std::allocator<P>> class Container>
requires concepts::point<typename Container<P>::value_type>
struct point_container : public Container<P>
template<concepts::point P, bool IsClosed, direction Direction>
struct point_container : public std::vector<P>
{
inline static constexpr bool is_closed = IsClosed;
inline static constexpr direction winding = Direction;

constexpr point_container() noexcept = default;
constexpr explicit point_container(std::initializer_list<P> points) noexcept
: std::vector<P>(points)
{
}
};

template<concepts::point P = Point, template<class, class = std::allocator<P>> class Container = std::vector>
struct polyline : public point_container<P, false, direction::NA, Container>
template<concepts::point P = Point>
struct polyline : public point_container<P, false, direction::NA>
{
constexpr polyline() noexcept = default;
constexpr explicit polyline(std::initializer_list<P> points) noexcept
: point_container<P, false, direction::NA, Container>(points)
: point_container<P, false, direction::NA>(points)
{
}
};

template<concepts::point P, direction Direction, template<class, class = std::allocator<P>> class Container>
struct polygon : public point_container<P, true, Direction, Container>
template<concepts::point P, direction Direction>
struct polygon : public point_container<P, true, Direction>
{
constexpr polygon() noexcept = default;
constexpr polygon(std::initializer_list<P> points) noexcept
: point_container<P, true, Direction, Container>(points)
: point_container<P, true, Direction>(points)
{
}
};

template<concepts::point P = Point, template<class, class = std::allocator<P>> class Container = std::vector>
polygon(std::initializer_list<P>) -> polygon<P, direction::NA, Container>;
template<concepts::point P = Point>
polygon(std::initializer_list<P>) -> polygon<P, direction::NA>;

template<concepts::point P = Point, template<class, class = std::allocator<P>> class Container = std::vector>
struct polygon_outer : public point_container<P, true, direction::CW, Container>
template<concepts::point P = Point>
struct polygon_outer : public point_container<P, true, direction::CW>
{
constexpr polygon_outer() noexcept = default;
constexpr explicit polygon_outer(std::initializer_list<P> points) noexcept
: point_container<P, true, direction::CW, Container>(points)
: point_container<P, true, direction::CW>(points)
{
}
};

template<concepts::point P = Point, template<class, class = std::allocator<P>> class Container = std::vector>
struct polygon_inner : public point_container<P, true, direction::CCW, Container>
template<concepts::point P = Point>
polygon_outer(std::initializer_list<P>) -> polygon_outer<P>;

template<concepts::point P = Point>
struct polygon_inner : public point_container<P, true, direction::CCW>
{
constexpr polygon_inner() noexcept = default;
constexpr explicit polygon_inner(std::initializer_list<P> points) noexcept
: point_container<P, true, direction::CCW, Container>(points)
: point_container<P, true, direction::CCW>(points)
{
}
};

template<concepts::point P = Point, template<class, class = std::allocator<P>> class Container = std::vector>
requires concepts::point<typename Container<P>::value_type>
struct polygons : public Container<polygon<P, direction::NA, Container>*>
template<concepts::point P = Point>
polygon_inner(std::initializer_list<P>) -> polygon_inner<P>;

template<concepts::point P = Point>
struct polygons : public std::vector<polygon<P, direction::NA>*>
{
constexpr polygons() noexcept = default;
constexpr explicit polygons(std::initializer_list<polygon<P, direction::NA, Container>*> polygons) noexcept
: Container<polygon<P, direction::NA, Container>*>(polygons)
constexpr explicit polygons(std::initializer_list<polygon<P, direction::NA>*> polygons) noexcept
: std::vector<polygon<P, direction::NA>*>(polygons)
{
}

Expand All @@ -103,6 +113,9 @@ struct polygons : public Container<polygon<P, direction::NA, Container>*>
}
};

template<concepts::point P = Point>
polygons(polygon_outer<P>, std::initializer_list<polygon_inner<P>>) -> polygons<P>;

} // namespace infill::geometry

static inline infill::geometry::Point operator-(const infill::geometry::Point& p0)
Expand Down
2 changes: 1 addition & 1 deletion include/infill/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Tile
}

private:
auto tileContour() const noexcept
geometry::polygon_outer<ClipperLib::IntPoint> tileContour() const noexcept
{
using coord_t = decltype(x);
switch (tile_type)
Expand Down

0 comments on commit 6d89022

Please sign in to comment.