本文整理汇总了C++中clipperlib::Path::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::clear方法的具体用法?C++ Path::clear怎么用?C++ Path::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clipperlib::Path
的用法示例。
在下文中一共展示了Path::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
Slic3rMultiPoint_to_ClipperPath(const Slic3r::MultiPoint &input, ClipperLib::Path &output)
{
output.clear();
for (Slic3r::Points::const_iterator pit = input.points.begin(); pit != input.points.end(); ++pit) {
output.push_back(ClipperLib::IntPoint( (*pit).x, (*pit).y ));
}
}
示例2:
geo::Polygon<geo::Ring<Vector>> Environment::subtract(geo::Polygon<geo::Ring<Vector>> const& poly, geo::Ring<Vector> const& ring) {
ClipperLib::Path subj;
ClipperLib::Paths solution;
ClipperLib::Clipper c;
for (Vector const& v : poly.ering)
subj.push_back(ClipperLib::IntPoint((int)v.x, (int)v.y));
c.AddPath(subj, ClipperLib::ptSubject, true);
for (Ring const& ring : poly.irings) {
subj.clear();
for (Vector const& v : ring)
subj.push_back(ClipperLib::IntPoint((int)v.x, (int)v.y));
std::reverse(subj.begin(), subj.end());
c.AddPath(subj, ClipperLib::ptSubject, true);
}
subj.clear();
for (Vector const& v : ring)
subj.push_back(ClipperLib::IntPoint((int)v.x, (int)v.y));
c.AddPath(subj, ClipperLib::ptClip, true);
c.Execute(ClipperLib::ctDifference, solution);
geo::Polygon<geo::Ring<Vector>> ans;
for (ClipperLib::IntPoint const& pt : solution[0]) {
ans.ering.push_back({pt.X, pt.Y});
}
for (int i = 1; i < solution.size(); ++i) {
ClipperLib::Path const& path = solution[i];
geo::Ring<Vector> ring;
for (ClipperLib::IntPoint const& pt : path)
ring.push_back({pt.X, pt.Y});
ans.irings.push_back(ring);
}
geo::correct(ans);
return ans;
}