Skip to Content.
Sympa Menu

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

Subject: CGAL users discussion list

List archive

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


Chronological Thread 
  • From: "Zheng,Guang" <>
  • To:
  • Subject: Re: [cgal-discuss] problem with read a txt file to cgal!
  • Date: Tue, 20 Oct 2009 20:06:41 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; b=owxYFRChQJZadhnnnO8vRjZ4EpnanxMGoC9kJu5PBE8L0x62IMUEhcObxle/MqDmJP 19L/4jHMn4/Ej4VOUhrjsHYaWYB5prVLSKEWDVVEITmYi2hl6607JEOxnJZSOf3F+w+M vqsq+uXcqAj1Fs9K/vm3V7hAPyGUdSV4ObQsQ=


HI, Rahul:
 
Thanks so much for your reply!
 
Acutally I did successfully build the project, when I run the code, what i thought it should ouput the result in a few seconds, but my CPU usage goes up to 100% and takes more than a couple minutes and get nothing.
 
the txt file I tried to read is:
 
0 ,0
10,0
10,10
6 ,5
4 ,1
 
but I can successfully run the corresponding example without modification.
 
Thanks again
 
Guang
On Tue, Oct 20, 2009 at 7:23 PM, Rahul Kavalapara <> wrote:
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  






--
Guang Zheng  





Archive powered by MHonArc 2.6.16.

Top of Page