本文整理汇总了C++中ConvexHull::getConVexHull方法的典型用法代码示例。如果您正苦于以下问题:C++ ConvexHull::getConVexHull方法的具体用法?C++ ConvexHull::getConVexHull怎么用?C++ ConvexHull::getConVexHull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConvexHull
的用法示例。
在下文中一共展示了ConvexHull::getConVexHull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
char *infile, *outfile;
if(argc == 5)
{
if(!strcmp(argv[1], "-in") && !strcmp(argv[3], "-out"))
{
infile = argv[2];
outfile = argv[4];
}
else if(!strcmp(argv[1], "-out") && !strcmp(argv[3], "-out"))
{
infile = argv[4];
outfile = argv[2];
}
}
else if((argc==2 && strcmp(argv[1], "-help")) || argc!=2)
{
cout << "help : -in [input file] -out [output file]" << endl;
return 0;
}
vector< Point2D<> > pointList;
clock_t start, end;
ifstream ifs;
ofstream ofs;
//input
ifs.open(infile, std::ios::in);
int numOfPoint;
ifs >> numOfPoint;
int tempX, tempY;
for(int i=0; i<numOfPoint; i++)
{
ifs >> tempX >> tempY;
pointList.push_back(Point2D<>(tempX, tempY));
}
//output
ofs.open(outfile, std::ios::out);
//convex hull
ConvexHull convexHull;
start = clock();
list<Point2D<>*> *ch = convexHull.getConVexHull(pointList);
end = clock();
ofs << "convex hull time" << endl;
ofs << (float)(end-start)/CLOCKS_PER_SEC << endl;
ofs << "convex hull set" << endl;
for(list<Point2D<>*>::iterator itr=ch->begin(); itr!=ch->end(); itr++)
ofs << (*itr)->X() << ' ' << (*itr)->Y() << endl;
ofs << -1 << endl;
//clesest pair
ClosestPair closestPair;
start = clock();
pair<Point2D<>, Point2D<> > cp = closestPair.getClosestPair(pointList);
end = clock();
ofs << "close pair time" << endl;
ofs << (float)(end-start)/CLOCKS_PER_SEC << endl;
ofs << "close pair" << endl;
ofs << cp.first.X() << ' ' << cp.first.Y() << endl;
ofs << cp.second.X() << ' ' << cp.second.Y();
return 0;
}