Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] problem with read a txt file to cgal!

Subject: CGAL users discussion list

List archive

[cgal-discuss] problem with read a txt file to cgal!


Chronological Thread 
  • From: "Zheng,Guang" <>
  • To:
  • Subject: [cgal-discuss] problem with read a txt file to cgal!
  • Date: Tue, 20 Oct 2009 17:57:44 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=XFvgb0hPqRgZ/+Xhi8MLclrsv1ku8hxmEneFl0th65pqKWKtFUGXWvyHypcFexn1ma DEoL3ciG7f1hCWz0DEpzlWpyl8V8PNJJOtcdlBLCy3nwOe/PAZQiK/Sm0XATQm+hRePs 82BBGG5Gza8IPlqFHCB7jttX0fEQ+eTYtW3jg=

Hi, all:
 
I'm pretty new to cgal, and studying some example recently. I tried to modified a little bit of the example code in order to read a txt file to STL vector structure, but it doen't work.
 
Could someone help me ? here is the code:
 
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_2.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point_2;
typedef std::vector<Point_2> Points;
int main()
{
Points points, result;
ifstream file_to_read("1.txt");
double x,y;
while(!file_to_read.eof())
{
CGAL::set_ascii_mode( file_to_read );
file_to_read>>x;
file_to_read.ignore(1);
file_to_read>>y;
file_to_read.ignore(1);
points.push_back(Point_2(x,y));
};

  /*points.push_back(Point_2(0,0));
  points.push_back(Point_2(10,0));
  points.push_back(Point_2(10,10));
  points.push_back(Point_2(6,5));
  points.push_back(Point_2(4,1));
*/
  CGAL::convex_hull_2( points.begin(), points.end(), std::back_inserter(result) );
  std::cout << result.size() << " points on the convex hull" << std::endl;
  return 0;
}
 
 
Thanks very much!

--
Guang Zheng  





Archive powered by MHonArc 2.6.16.

Top of Page