Had troubles with the template instantiation on OSX, so I reverted
them to overloaded functions. This is certainly easier to read and work with anyway.
This commit is contained in:
parent
ddea33d93a
commit
852b542913
2 changed files with 40 additions and 26 deletions
|
@ -133,13 +133,21 @@ ClipperPath_to_Slic3rMultiPoint(const ClipperLib::Path &input)
|
|||
return retval;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T
|
||||
ClipperPaths_to_Slic3rMultiPoints(const ClipperLib::Paths &input)
|
||||
Slic3r::Polygons ClipperPaths_to_Slic3rPolygons(const ClipperLib::Paths &input)
|
||||
{
|
||||
T retval;
|
||||
Slic3r::Polygons retval;
|
||||
retval.reserve(input.size());
|
||||
for (ClipperLib::Paths::const_iterator it = input.begin(); it != input.end(); ++it)
|
||||
retval.push_back(ClipperPath_to_Slic3rMultiPoint<typename T::value_type>(*it));
|
||||
retval.push_back(ClipperPath_to_Slic3rMultiPoint<Slic3r::Polygon>(*it));
|
||||
return retval;
|
||||
}
|
||||
|
||||
Slic3r::Polylines ClipperPaths_to_Slic3rPolylines(const ClipperLib::Paths &input)
|
||||
{
|
||||
Slic3r::Polylines retval;
|
||||
retval.reserve(input.size());
|
||||
for (ClipperLib::Paths::const_iterator it = input.begin(); it != input.end(); ++it)
|
||||
retval.push_back(ClipperPath_to_Slic3rMultiPoint<Slic3r::Polyline>(*it));
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -178,12 +186,18 @@ Slic3rMultiPoint_to_ClipperPath_reversed(const Slic3r::MultiPoint &input)
|
|||
return output;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
ClipperLib::Paths
|
||||
Slic3rMultiPoints_to_ClipperPaths(const T &input)
|
||||
ClipperLib::Paths Slic3rMultiPoints_to_ClipperPaths(const Polygons &input)
|
||||
{
|
||||
ClipperLib::Paths retval;
|
||||
for (typename T::const_iterator it = input.begin(); it != input.end(); ++it)
|
||||
for (Polygons::const_iterator it = input.begin(); it != input.end(); ++it)
|
||||
retval.push_back(Slic3rMultiPoint_to_ClipperPath(*it));
|
||||
return retval;
|
||||
}
|
||||
|
||||
ClipperLib::Paths Slic3rMultiPoints_to_ClipperPaths(const Polylines &input)
|
||||
{
|
||||
ClipperLib::Paths retval;
|
||||
for (Polylines::const_iterator it = input.begin(); it != input.end(); ++it)
|
||||
retval.push_back(Slic3rMultiPoint_to_ClipperPath(*it));
|
||||
return retval;
|
||||
}
|
||||
|
@ -380,7 +394,7 @@ offset2(const Polygons &polygons, const float delta1, const float delta2,
|
|||
ClipperLib::Paths output = _offset2(polygons, delta1, delta2, joinType, miterLimit);
|
||||
|
||||
// convert into ExPolygons
|
||||
return ClipperPaths_to_Slic3rMultiPoints<Polygons>(output);
|
||||
return ClipperPaths_to_Slic3rPolygons(output);
|
||||
}
|
||||
|
||||
ExPolygons
|
||||
|
@ -456,7 +470,7 @@ Polygons
|
|||
_clipper(ClipperLib::ClipType clipType, const Polygons &subject,
|
||||
const Polygons &clip, bool safety_offset_)
|
||||
{
|
||||
return ClipperPaths_to_Slic3rMultiPoints<Polygons>(_clipper_do<ClipperLib::Paths>(clipType, subject, clip, ClipperLib::pftNonZero, safety_offset_));
|
||||
return ClipperPaths_to_Slic3rPolygons(_clipper_do<ClipperLib::Paths>(clipType, subject, clip, ClipperLib::pftNonZero, safety_offset_));
|
||||
}
|
||||
|
||||
ExPolygons
|
||||
|
@ -473,7 +487,7 @@ _clipper_pl(ClipperLib::ClipType clipType, const Polylines &subject,
|
|||
{
|
||||
ClipperLib::Paths output;
|
||||
ClipperLib::PolyTreeToPaths(_clipper_do(clipType, subject, clip, ClipperLib::pftNonZero, safety_offset_), output);
|
||||
return ClipperPaths_to_Slic3rMultiPoints<Polylines>(output);
|
||||
return ClipperPaths_to_Slic3rPolylines(output);
|
||||
}
|
||||
|
||||
Polylines
|
||||
|
@ -609,7 +623,7 @@ simplify_polygons(const Polygons &subject, bool preserve_collinear)
|
|||
}
|
||||
|
||||
// convert into Slic3r polygons
|
||||
return ClipperPaths_to_Slic3rMultiPoints<Polygons>(output);
|
||||
return ClipperPaths_to_Slic3rPolygons(output);
|
||||
}
|
||||
|
||||
ExPolygons
|
||||
|
|
|
@ -20,36 +20,36 @@ void AddOuterPolyNodeToExPolygons(ClipperLib::PolyNode& polynode, Slic3r::ExPoly
|
|||
void PolyTreeToExPolygons(ClipperLib::PolyTree& polytree, Slic3r::ExPolygons& expolygons);
|
||||
//-----------------------------------------------------------
|
||||
|
||||
ClipperLib::Path Slic3rMultiPoint_to_ClipperPath(const Slic3r::MultiPoint &input);
|
||||
template <class T>
|
||||
ClipperLib::Paths Slic3rMultiPoints_to_ClipperPaths(const T &input);
|
||||
template <class T>
|
||||
T ClipperPath_to_Slic3rMultiPoint(const ClipperLib::Path &input);
|
||||
template <class T>
|
||||
T ClipperPaths_to_Slic3rMultiPoints(const ClipperLib::Paths &input);
|
||||
template <class T> T ClipperPath_to_Slic3rMultiPoint(const ClipperLib::Path &input);
|
||||
ClipperLib::Path Slic3rMultiPoint_to_ClipperPath(const Slic3r::MultiPoint &input);
|
||||
ClipperLib::Paths Slic3rMultiPoints_to_ClipperPaths(const Polygons &input);
|
||||
ClipperLib::Paths Slic3rMultiPoints_to_ClipperPaths(const Polylines &input);
|
||||
Slic3r::Polygon ClipperPaths_to_Slic3rMultiPoints(const ClipperLib::Paths &input);
|
||||
Slic3r::Polygons ClipperPaths_to_Slic3rPolygons(const ClipperLib::Paths &input);
|
||||
Slic3r::Polylines ClipperPaths_to_Slic3rPolylines(const ClipperLib::Paths &input);
|
||||
Slic3r::ExPolygons ClipperPaths_to_Slic3rExPolygons(const ClipperLib::Paths &input);
|
||||
|
||||
// offset Polygons
|
||||
ClipperLib::Paths _offset(ClipperLib::Path &&input, ClipperLib::EndType endType, const float delta, ClipperLib::JoinType joinType, double miterLimit);
|
||||
ClipperLib::Paths _offset(ClipperLib::Paths &&input, ClipperLib::EndType endType, const float delta, ClipperLib::JoinType joinType, double miterLimit);
|
||||
inline Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3)
|
||||
{ return ClipperPaths_to_Slic3rMultiPoints<Polygons>(_offset(Slic3rMultiPoint_to_ClipperPath(polygon), ClipperLib::etClosedPolygon, delta, joinType, miterLimit)); }
|
||||
{ return ClipperPaths_to_Slic3rPolygons(_offset(Slic3rMultiPoint_to_ClipperPath(polygon), ClipperLib::etClosedPolygon, delta, joinType, miterLimit)); }
|
||||
inline Slic3r::Polygons offset(const Slic3r::Polygons &polygons, const float delta, ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3)
|
||||
{ return ClipperPaths_to_Slic3rMultiPoints<Polygons>(_offset(Slic3rMultiPoints_to_ClipperPaths(polygons), ClipperLib::etClosedPolygon, delta, joinType, miterLimit)); }
|
||||
{ return ClipperPaths_to_Slic3rPolygons(_offset(Slic3rMultiPoints_to_ClipperPaths(polygons), ClipperLib::etClosedPolygon, delta, joinType, miterLimit)); }
|
||||
|
||||
// offset Polylines
|
||||
inline Slic3r::Polygons offset(const Slic3r::Polyline &polyline, const float delta, ClipperLib::JoinType joinType = ClipperLib::jtSquare, double miterLimit = 3)
|
||||
{ return ClipperPaths_to_Slic3rMultiPoints<Polygons>(_offset(Slic3rMultiPoint_to_ClipperPath(polyline), ClipperLib::etOpenButt, delta, joinType, miterLimit)); }
|
||||
{ return ClipperPaths_to_Slic3rPolygons(_offset(Slic3rMultiPoint_to_ClipperPath(polyline), ClipperLib::etOpenButt, delta, joinType, miterLimit)); }
|
||||
inline Slic3r::Polygons offset(const Slic3r::Polylines &polylines, const float delta, ClipperLib::JoinType joinType = ClipperLib::jtSquare, double miterLimit = 3)
|
||||
{ return ClipperPaths_to_Slic3rMultiPoints<Polygons>(_offset(Slic3rMultiPoints_to_ClipperPaths(polylines), ClipperLib::etOpenButt, delta, joinType, miterLimit)); }
|
||||
{ return ClipperPaths_to_Slic3rPolygons(_offset(Slic3rMultiPoints_to_ClipperPaths(polylines), ClipperLib::etOpenButt, delta, joinType, miterLimit)); }
|
||||
|
||||
// offset expolygons and surfaces
|
||||
ClipperLib::Paths _offset(const Slic3r::ExPolygon &expolygon, const float delta, ClipperLib::JoinType joinType, double miterLimit);
|
||||
ClipperLib::Paths _offset(const Slic3r::ExPolygons &expolygons, const float delta, ClipperLib::JoinType joinType, double miterLimit);
|
||||
inline Slic3r::Polygons offset(const Slic3r::ExPolygon &expolygon, const float delta, ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3)
|
||||
{ return ClipperPaths_to_Slic3rMultiPoints<Polygons>(_offset(expolygon, delta, joinType, miterLimit)); }
|
||||
{ return ClipperPaths_to_Slic3rPolygons(_offset(expolygon, delta, joinType, miterLimit)); }
|
||||
inline Slic3r::Polygons offset(const Slic3r::ExPolygons &expolygons, const float delta, ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3)
|
||||
{ return ClipperPaths_to_Slic3rMultiPoints<Polygons>(_offset(expolygons, delta, joinType, miterLimit)); }
|
||||
{ return ClipperPaths_to_Slic3rPolygons(_offset(expolygons, delta, joinType, miterLimit)); }
|
||||
inline Slic3r::ExPolygons offset_ex(const Slic3r::Polygon &polygon, const float delta, ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3)
|
||||
{ return ClipperPaths_to_Slic3rExPolygons(_offset(Slic3rMultiPoint_to_ClipperPath(polygon), ClipperLib::etClosedPolygon, delta, joinType, miterLimit)); }
|
||||
inline Slic3r::ExPolygons offset_ex(const Slic3r::Polygons &polygons, const float delta, ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3)
|
||||
|
|
Loading…
Reference in a new issue