Subject: CGAL users discussion list
List archive
- From: Rahul Kavalapara <>
- To:
- Subject: Re: [cgal-discuss] problem with read a txt file to cgal!
- Date: Tue, 20 Oct 2009 20:23:30 -0600
Hi Guang,
I tried to execute your code, and it works fine. I replaced 1.txt with another text file.
I am not sure where exactly your having trouble with ?
--
Rahul Kavalapara
On Tue, Oct 20, 2009 at 6:57 PM, Zheng,Guang <> wrote:
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
- [cgal-discuss] problem with read a txt file to cgal!, Zheng,Guang, 10/21/2009
- Re: [cgal-discuss] problem with read a txt file to cgal!, Rahul Kavalapara, 10/21/2009
- Re: [cgal-discuss] problem with read a txt file to cgal!, Zheng,Guang, 10/21/2009
- Re: [cgal-discuss] problem with read a txt file to cgal!, Rahul Kavalapara, 10/21/2009
- Re: [cgal-discuss] problem with read a txt file to cgal!, Zheng,Guang, 10/21/2009
- Re: [cgal-discuss] problem with read a txt file to cgal!, Rahul Kavalapara, 10/21/2009
- Re: [cgal-discuss] problem with read a txt file to cgal!, Zheng,Guang, 10/21/2009
- Re: [cgal-discuss] problem with read a txt file to cgal!, Rahul Kavalapara, 10/21/2009
- Re: [cgal-discuss] problem with read a txt file to cgal!, Zheng,Guang, 10/21/2009
- Re: [cgal-discuss] problem with read a txt file to cgal!, Rahul Kavalapara, 10/21/2009
Archive powered by MHonArc 2.6.16.