Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] error regarding file stream

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] error regarding file stream


Chronological Thread 
  • From: pratihast22089 <>
  • To:
  • Subject: Re: [cgal-discuss] error regarding file stream
  • Date: Wed, 4 Nov 2009 12:05:24 -0800 (PST)


Hi,
Thank you for you quick response and wonderfull suggestion.
It really help for the new developers like me.

I could not get your idea, could you please explain me why it is not
working.
here is my sort version code:


// simple file stream exaple


#include "stdafx.h"
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/double.h>

#include <utility> // defines std::pair
#include <vector>
#include <fstream>
#include<iostream>



// types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;

using namespace std;

int main(void)
{
// Reads a .xyz point set file in points[].

vector<Point> points;
ifstream in("D:/Cgalcode/file/data/tree.xyz");
if (!in ||
!CGAL::read_xyz_points(in,std::back_inserter(points)))
{
cerr << "Error: cannot read file data/oni.xyz" << std::endl;
return EXIT_FAILURE;
}
// displaying

for(unsigned int i = 0; i < points.size(); i++)
{
cout.precision(20);
cout << points[i]<< std::endl;
}


// Saves point set.

ofstream out("D:/Cgalcode/file/data/tree.xyz");
if (!out ||
!CGAL::write_xyz_points(out, points.begin(), points.end()))
{
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}

input:
257507.81 471326.84 44.99
257507.79 471326.90 44.70
257507.75 471326.93 44.51

output:
257508 471327 44.99
257508 471327 44.7
257508 471327 44.51


Sebastien Loriot wrote:
>
> pratihast22089 wrote:
>> hi,
>>
>> I am facing one simple problem regarding file stream.
>> I have the data file like this:
>>
>> 257507.75 471326.93 44.51
>> 257507.77 471326.90 44.49
>> 257507.89 471326.93 44.04
>> 257507.81 471326.81 44.51
>> 257507.89 471326.87 44.10
>>
>>
>> While Reading and writing file stream, it truncate the number behind
>> point
>> of first two columns but not for the third column.
>>
>> output:
>>
>> 257507 471326 44.51
>> 257507 471326 44.49
>> 257507 471326 44.04
>> 257507 471326 44.51
>> 257507 471326 44.10
>>
>>
>> I had included the #include <CGAL/double.h> header file.
>>
>> Could you please help me in this regrads.
>> Thank you in advance.
>>
>> Regards,
>> Arun K Pratihast
>>
>>
>>
>>
> Hello,
>
> Could you please post a minimal example so that we can reproduce the
> problem encountered.
>
>
> S.
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>
>
>

--
View this message in context:
http://old.nabble.com/error-regarding-file-stream-tp26195935p26203717.html
Sent from the cgal-discuss mailing list archive at Nabble.com.




Archive powered by MHonArc 2.6.16.

Top of Page