本文整理汇总了C++中clipperlib::Polygon::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon::begin方法的具体用法?C++ Polygon::begin怎么用?C++ Polygon::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clipperlib::Polygon
的用法示例。
在下文中一共展示了Polygon::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: optimizePolygon
void optimizePolygon(ClipperLib::Polygon& poly)
{
Point p0 = poly[poly.size()-1];
for(unsigned int i=0;i<poly.size();i++)
{
Point p1 = poly[i];
if (shorterThen(p0 - p1, 10))
{
poly.erase(poly.begin() + i);
i --;
}else{
Point p2;
if (i < poly.size() - 1)
p2 = poly[i+1];
else
p2 = poly[0];
Point diff0 = normal(p1 - p0, 1000000);
Point diff2 = normal(p1 - p2, 1000000);
int64_t d = dot(diff0, diff2);
if (d < -999999000000LL)
{
poly.erase(poly.begin() + i);
i --;
}else{
p0 = p1;
}
}
}
}
示例2:
void
ClipperPolygon_to_Slic3rPolygon(const ClipperLib::Polygon &input, Slic3r::Polygon &output)
{
output.points.clear();
for (ClipperLib::Polygon::const_iterator pit = input.begin(); pit != input.end(); ++pit) {
output.points.push_back(Slic3r::Point( (*pit).X, (*pit).Y ));
}
}
示例3: polygon_to_ofPolyline
//--------------------------------------------------------------
ofPolyline ofxClipper::polygon_to_ofPolyline(ClipperLib::Polygon& polygon) {
vector<ClipperLib::IntPoint>::iterator iter;
ofPolyline polyline;
for(iter = polygon.begin(); iter != polygon.end(); iter++) {
ofPoint pnt((*iter).X / double(clipperGlobalScale), // bring back to our coords
(*iter).Y / double(clipperGlobalScale)); // bring back to our coords
polyline.addVertex(pnt);
}
polyline.close(); // close it
return polyline;
}
示例4: main
int main(int argc, char* argv[]) {
if (argc != 3) {
cout<<"Usage: offset.exe <input.poly> <output.poly>\n\n Input and output files should be different.\n Only one ring poly files are accepted now without inner rings.\n Default offset is 0.001 degree\n";
return 0;
}
ifstream f(argv[1], ifstream::in);
ofstream outfile(argv[2], ofstream::out);
outfile.precision(9);
string s;
for (int i=0;i<3;i++) {
getline(f, s);
outfile<<s<<"\n";
}
ClipperLib::Polygons polygons;
ClipperLib::Polygon polygon;
while(!f.eof()) {
f>>s;
if (s == "END") {
break;
}
double c1 = ::atof(s.c_str());
f>>s;
double c2 = ::atof(s.c_str());
ClipperLib::IntPoint point(c1 * MUL, c2 * MUL);
polygon.push_back(point);
}
polygons.push_back(polygon);
double distance = 0.001 * MUL;
ClipperLib::Polygons res_polygons;
ClipperLib::OffsetPolygons (polygons, res_polygons, distance, ClipperLib::jtMiter);
if (res_polygons.size() < 1) { cerr<<"Bad output of OffsetPolygons!\n";return 1;}
ClipperLib::Polygon result = res_polygons.front();
for (ClipperLib::Polygon::iterator it = result.begin(); it != result.end(); ++it) {
ClipperLib::IntPoint point = *it;
outfile << " " << (point.X/MUL) << " " << (point.Y/MUL) << " \n";
}
outfile<<s;
while (!f.eof()) {
getline(f, s);
outfile<<s<<"\n";
}
return 0;
}