PrusaSlicer-NonPlainar/xs/src/ClipperUtils.hpp

113 lines
5.0 KiB
C++
Raw Normal View History

#ifndef slic3r_ClipperUtils_hpp_
#define slic3r_ClipperUtils_hpp_
#include <myinit.h>
#include "clipper.hpp"
#include "ExPolygon.hpp"
#include "Polygon.hpp"
2013-11-23 17:29:25 +00:00
#include "Surface.hpp"
2013-08-26 23:26:44 +00:00
// import these wherever we're included
using ClipperLib::jtMiter;
using ClipperLib::jtRound;
using ClipperLib::jtSquare;
namespace Slic3r {
2013-08-26 15:58:37 +00:00
#define CLIPPER_OFFSET_SCALE 100000.0
//-----------------------------------------------------------
// legacy code from Clipper documentation
void AddOuterPolyNodeToExPolygons(ClipperLib::PolyNode& polynode, Slic3r::ExPolygons& expolygons);
void PolyTreeToExPolygons(ClipperLib::PolyTree& polytree, Slic3r::ExPolygons& expolygons);
//-----------------------------------------------------------
2013-11-21 13:15:38 +00:00
void Slic3rMultiPoint_to_ClipperPath(const Slic3r::MultiPoint &input, ClipperLib::Path &output);
2013-11-20 10:35:58 +00:00
template <class T>
2013-11-21 13:15:38 +00:00
void Slic3rMultiPoints_to_ClipperPaths(const T &input, ClipperLib::Paths &output);
template <class T>
void ClipperPath_to_Slic3rMultiPoint(const ClipperLib::Path &input, T &output);
template <class T>
void ClipperPaths_to_Slic3rMultiPoints(const ClipperLib::Paths &input, T &output);
void ClipperPaths_to_Slic3rExPolygons(const ClipperLib::Paths &input, Slic3r::ExPolygons &output);
2013-11-20 14:59:19 +00:00
void scaleClipperPolygons(ClipperLib::Paths &polygons, const double scale);
2013-11-20 10:35:58 +00:00
// offset Polygons
2013-11-21 14:12:06 +00:00
void offset(const Slic3r::Polygons &polygons, ClipperLib::Paths &retval, const float delta,
2013-07-16 22:48:29 +00:00
double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtMiter,
double miterLimit = 3);
2013-11-21 14:12:06 +00:00
void offset(const Slic3r::Polygons &polygons, Slic3r::Polygons &retval, const float delta,
2013-07-16 22:48:29 +00:00
double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtMiter,
double miterLimit = 3);
2013-11-20 10:35:58 +00:00
// offset Polylines
2013-11-21 14:12:06 +00:00
void offset(const Slic3r::Polylines &polylines, ClipperLib::Paths &retval, const float delta,
2013-11-20 10:35:58 +00:00
double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtSquare,
double miterLimit = 3);
2013-11-21 14:12:06 +00:00
void offset(const Slic3r::Polylines &polylines, Slic3r::Polygons &retval, const float delta,
2013-11-20 10:35:58 +00:00
double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtSquare,
double miterLimit = 3);
2013-11-23 17:29:25 +00:00
void offset(const Slic3r::Surface &surface, Slic3r::Surfaces &retval, const float delta,
double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtSquare,
double miterLimit = 3);
2013-11-20 10:35:58 +00:00
2013-11-21 14:12:06 +00:00
void offset_ex(const Slic3r::Polygons &polygons, Slic3r::ExPolygons &retval, const float delta,
double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtMiter,
double miterLimit = 3);
2013-11-21 14:12:06 +00:00
void offset2(const Slic3r::Polygons &polygons, ClipperLib::Paths &retval, const float delta1,
2013-07-16 22:48:29 +00:00
const float delta2, double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtMiter,
double miterLimit = 3);
2013-11-21 14:12:06 +00:00
void offset2(const Slic3r::Polygons &polygons, Slic3r::Polygons &retval, const float delta1,
2013-07-16 22:48:29 +00:00
const float delta2, double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtMiter,
double miterLimit = 3);
2013-11-21 14:12:06 +00:00
void offset2_ex(const Slic3r::Polygons &polygons, Slic3r::ExPolygons &retval, const float delta1,
const float delta2, double scale = 100000, ClipperLib::JoinType joinType = ClipperLib::jtMiter,
double miterLimit = 3);
2013-07-16 23:21:30 +00:00
template <class T>
2013-11-21 14:12:06 +00:00
void _clipper_do(ClipperLib::ClipType clipType, const Slic3r::Polygons &subject,
const Slic3r::Polygons &clip, T &retval, bool safety_offset_);
void _clipper_do(ClipperLib::ClipType clipType, const Slic3r::Polylines &subject,
const Slic3r::Polygons &clip, ClipperLib::Paths &retval);
void _clipper(ClipperLib::ClipType clipType, const Slic3r::Polygons &subject,
const Slic3r::Polygons &clip, Slic3r::Polygons &retval, bool safety_offset_);
void _clipper(ClipperLib::ClipType clipType, const Slic3r::Polygons &subject,
const Slic3r::Polygons &clip, Slic3r::ExPolygons &retval, bool safety_offset_);
void _clipper(ClipperLib::ClipType clipType, const Slic3r::Polylines &subject,
const Slic3r::Polygons &clip, Slic3r::Polylines &retval);
2013-07-16 23:21:30 +00:00
template <class T>
2013-11-21 14:12:06 +00:00
void diff(const Slic3r::Polygons &subject, const Slic3r::Polygons &clip, T &retval, bool safety_offset_);
2013-07-16 23:21:30 +00:00
2013-11-21 14:12:06 +00:00
void diff(const Slic3r::Polylines &subject, const Slic3r::Polygons &clip, Slic3r::Polylines &retval);
2013-11-21 13:15:38 +00:00
2013-07-16 23:21:30 +00:00
template <class T>
2013-11-21 14:12:06 +00:00
void intersection(const Slic3r::Polygons &subject, const Slic3r::Polygons &clip, T &retval, bool safety_offset_);
2013-07-16 23:21:30 +00:00
2013-11-21 14:12:06 +00:00
void intersection(const Slic3r::Polylines &subject, const Slic3r::Polygons &clip, Slic3r::Polylines &retval);
2013-11-21 13:15:38 +00:00
2013-11-21 14:12:06 +00:00
void xor_ex(const Slic3r::Polygons &subject, const Slic3r::Polygons &clip, Slic3r::ExPolygons &retval,
2013-08-26 15:58:37 +00:00
bool safety_offset_ = false);
2013-07-16 23:21:30 +00:00
2013-08-17 10:24:04 +00:00
template <class T>
2013-11-21 14:12:06 +00:00
void union_(const Slic3r::Polygons &subject, T &retval, bool safety_offset_ = false);
2013-11-21 14:12:06 +00:00
void union_pt(const Slic3r::Polygons &subject, ClipperLib::PolyTree &retval, bool safety_offset_ = false);
2013-08-26 16:37:19 +00:00
2013-11-21 14:12:06 +00:00
void simplify_polygons(const Slic3r::Polygons &subject, Slic3r::Polygons &retval);
2013-11-20 14:59:19 +00:00
void safety_offset(ClipperLib::Paths* &subject);
2013-08-26 15:58:37 +00:00
2013-08-26 16:37:19 +00:00
/////////////////
#ifdef SLIC3RXS
2013-08-26 16:37:19 +00:00
SV* polynode_children_2_perl(const ClipperLib::PolyNode& node);
SV* polynode2perl(const ClipperLib::PolyNode& node);
#endif
2013-08-26 16:37:19 +00:00
}
#endif